diff options
-rw-r--r-- | packaging/sys-kernel-tracing.service | 15 | ||||
-rw-r--r-- | packaging/ttrace-marker.service | 4 | ||||
-rw-r--r-- | packaging/ttrace.spec | 12 | ||||
-rwxr-xr-x | src/atrace/atrace.cpp | 38 |
4 files changed, 25 insertions, 44 deletions
diff --git a/packaging/sys-kernel-tracing.service b/packaging/sys-kernel-tracing.service new file mode 100644 index 0000000..08b4335 --- /dev/null +++ b/packaging/sys-kernel-tracing.service @@ -0,0 +1,15 @@ +[Unit] +Description=TraceFs mount +DefaultDependencies=no +After=sys-kernel-debug.mount +Before=tmp.mount systemd-tmpfiles-setup.service + +[Service] +SmackProcessLabel=System +Type=oneshot +RemainAfterExit=yes +ExecStart=/bin/touch -f /sys/kernel/debug/tracing + +[Install] +WantedBy=sysinit.target + diff --git a/packaging/ttrace-marker.service b/packaging/ttrace-marker.service index e3f2d47..d5eafad 100644 --- a/packaging/ttrace-marker.service +++ b/packaging/ttrace-marker.service @@ -1,11 +1,11 @@ [Unit] Description=T-trace marker DefaultDependencies=no -After=sys-kernel-debug.mount +After=tmp.mount sys-kernel-tracing.service [Service] Type=simple ExecStart=/usr/bin/atrace --init_exec [Install] -WantedBy=sys-kernel-debug.mount +WantedBy=sysinit.target diff --git a/packaging/ttrace.spec b/packaging/ttrace.spec index e3b4b8d..08f271d 100644 --- a/packaging/ttrace.spec +++ b/packaging/ttrace.spec @@ -6,6 +6,7 @@ Group: System/Libraries License: Apache-2.0 Source0: %{name}-%{version}.tar.gz SOURCE100: packaging/ttrace.conf +SOURCE101: packaging/sys-kernel-tracing.service SOURCE102: packaging/ttrace-marker.service SOURCE103: packaging/atrace-bootup.sh @@ -60,13 +61,15 @@ make %{?jobs:-j%jobs} %install rm -rf %{buildroot} %make_install +mkdir -p %{buildroot}%{_unitdir} mkdir -p %{buildroot}/usr/lib/tmpfiles.d -install -d %{buildroot}%{_unitdir}/ttrace-marker.service.wants install -m 0644 %{SOURCE100} %{buildroot}/usr/lib/tmpfiles.d/ttrace.conf +install -m 0644 %{SOURCE101} %{buildroot}%{_unitdir} install -m 0644 %{SOURCE102} %{buildroot}%{_unitdir} mkdir -p %{buildroot}%{_bindir} cp %{SOURCE103} %{buildroot}%{_bindir} -%install_service sys-kernel-debug.mount.wants ttrace-marker.service +%install_service sysinit.target.wants ttrace-marker.service +%install_service sysinit.target.wants sys-kernel-tracing.service %post -p /sbin/ldconfig @@ -77,10 +80,11 @@ cp %{SOURCE103} %{buildroot}%{_bindir} %defattr(-,root,root,-) %{_libdir}/libttrace.so.* %{_unitdir}/ttrace-marker.service -%{_unitdir}/ttrace-marker.service.wants/ +%{_unitdir}/sys-kernel-tracing.service %attr(755,root,users) %{_bindir}/atrace %attr(755,root,users) %{_bindir}/atrace-1.1 -%{_unitdir}/sys-kernel-debug.mount.wants/ttrace-marker.service +%{_unitdir}/sysinit.target.wants/ttrace-marker.service +%{_unitdir}/sysinit.target.wants/sys-kernel-tracing.service %attr(755,root,root) %{_bindir}/atrace-bootup.sh /usr/lib/tmpfiles.d/ttrace.conf %license LICENSE diff --git a/src/atrace/atrace.cpp b/src/atrace/atrace.cpp index 2639795..b372c60 100755 --- a/src/atrace/atrace.cpp +++ b/src/atrace/atrace.cpp @@ -150,13 +150,6 @@ static bool g_categoryEnables[NELEM(k_categories)] = {}; static bool g_init_exec = false; static bool g_append_trace = false; static bool g_backup_trace = false; -static struct group group_dev; -#if TTRACE_TIZEN_VERSION_MAJOR < 3 -#define TTRACE_GROUP_NAME "developer" -#else -#define TTRACE_GROUP_NAME "users" -#endif -static struct group* group_ptr; /* Save excluded tags list */ uint64_t excludedTags; @@ -382,38 +375,7 @@ static bool setTagsProperty(uint64_t tags) fprintf(stderr, "[Info] T-trace has been already initailized\n"); return false; //atrace has been already initailized. } - ret = getgrnam_r(TTRACE_GROUP_NAME, &group_dev, buf, bufSize, &group_ptr); - - if (ret != 0 && ret != ERANGE) - { - fprintf(stderr, "Fail to group[%s] info: %s(%d)\n", TTRACE_GROUP_NAME, strerror_r(errno, str_error, sizeof(str_error)), errno); - return false; - } - - bool isInvalid = false; - while(ret == ERANGE) - { - long int tmpSize = -1; - - if(!isInvalid) - tmpSize = sysconf(_SC_GETGR_R_SIZE_MAX); - - if (tmpSize == -1) - { - bufSize *= 2; - } - else bufSize = (size_t) tmpSize; - char *dynbuf = (char *) malloc(bufSize); - if(dynbuf == NULL) - { - fprintf(stderr, "Fail to allocate buffer for group[%s]: %s(%d)\n", TTRACE_GROUP_NAME, strerror_r(errno, str_error, sizeof(str_error)), errno); - return false; - } - ret = getgrnam_r(TTRACE_GROUP_NAME, &group_dev, dynbuf, bufSize, &group_ptr); - if(ret == ERANGE) isInvalid = true; - free(dynbuf); - } fd = open("/tmp/tmp_tag", O_CREAT | O_RDWR | O_CLOEXEC, 0666); if(fd < 0){ fprintf(stderr, "Fail to open enabled_tag file: %s(%d)\n", strerror_r(errno, str_error, sizeof(str_error)), errno); |