summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEunji, Lee <eunjieji.lee@samsung.com>2016-04-15 18:07:38 +0900
committerEunji, Lee <eunjieji.lee@samsung.com>2016-04-15 18:07:38 +0900
commitc4008bc7cde52ba326d3efaf7d4b7d49515af1fa (patch)
treeadf424e64393a680dad05812b134a900d85287af
parentdfb608375a5feba9f5d1c0d35bd0e705a923787c (diff)
parent754738f63dc8f638ca67964c669fd517a943acec (diff)
downloadttrace-c4008bc7cde52ba326d3efaf7d4b7d49515af1fa.tar.gz
ttrace-c4008bc7cde52ba326d3efaf7d4b7d49515af1fa.tar.bz2
ttrace-c4008bc7cde52ba326d3efaf7d4b7d49515af1fa.zip
-rwxr-xr-xCMakeLists.txt7
-rwxr-xr-xpackaging/ttrace.spec7
-rwxr-xr-xsrc/atrace/atrace.cpp22
-rwxr-xr-xttrace.h.in2
4 files changed, 35 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f0fd51e..1a1abf6 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,6 +26,13 @@ ELSEIF("${TTRACE_PROFILE}" STREQUAL "wearable")
ELSE()
SET(TTRACE_PROFILE_MOBILE ON)
ENDIF()
+
+IF("${TTRACE_TIZEN_VERSION_MAJOR}" STREQUAL "3")
+ SET(TTRACE_TIZEN_VERSION_MAJOR "3")
+ELSE()
+ SET(TTRACE_TIZEN_VERSION_MAJOR "2")
+ENDIF()
+
configure_file(${TTRACE_H_IN} "include/ttrace.h")
#################################################################
diff --git a/packaging/ttrace.spec b/packaging/ttrace.spec
index 1dc0259..b401717 100755
--- a/packaging/ttrace.spec
+++ b/packaging/ttrace.spec
@@ -29,6 +29,11 @@ BuildRequires: cmake
%endif
%endif
+%define TTRACE_TIZEN_VERSION_MAJOR 2
+%if "%{?tizen_version_major}" == "3"
+%define TTRACE_TIZEN_VERSION_MAJOR 3
+%endif
+
%description
T-trace library
@@ -47,7 +52,7 @@ T-trace library devel
export CFLAGS="$CFLAGS -g -Wall -std=gnu99"
export CXXFLAGS="$CXXFLAGS -std=c++0x -fPIE -pie"
%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DLIBDIR=%{_libdir} -DINCLUDEDIR=%{_includedir} \
- -DTTRACE_PROFILE=%{TTRACE_PROFILE}
+ -DTTRACE_PROFILE=%{TTRACE_PROFILE} -DTTRACE_TIZEN_VERSION_MAJOR=%{TTRACE_TIZEN_VERSION_MAJOR}
make %{?jobs:-j%jobs}
%install
diff --git a/src/atrace/atrace.cpp b/src/atrace/atrace.cpp
index 06de03f..c1b1b1e 100755
--- a/src/atrace/atrace.cpp
+++ b/src/atrace/atrace.cpp
@@ -221,8 +221,14 @@ static bool g_init_exec = false;
static bool g_append_trace = false;
static bool g_backup_trace = false;
+#if TTRACE_TIZEN_VERSION_MAJOR < 3
static struct group group_dev;
+#define TTRACE_GROUP_NAME "developer"
+#else
+#define TTRACE_GROUP_NAME "users"
+#endif
static struct group* group_ptr;
+
#endif
/* Sys file paths */
@@ -277,7 +283,11 @@ static bool fileIsWritable(const char* filename) {
static bool setFilePermission (const char *path, const mode_t perms) {
//fprintf(stderr, "path: %s, perms: %d, gid: %d\n", path,perms, group_dev.gr_gid);
+#if TTRACE_TIZEN_VERSION_MAJOR < 3
if (0 > chown(path, 0, group_dev.gr_gid)) return false;
+#else
+ if (0 > chown(path, 0, group_ptr->gr_gid)) return false;
+#endif
if (0 > chmod(path, perms)) return false;
if (0 > smack_setlabel(path, "*", SMACK_LABEL_ACCESS)) return false;
@@ -503,8 +513,16 @@ static bool setTagsProperty(uint64_t tags)
//atrace "--init_exec" mode
if(g_init_exec) {
- if(0 != getgrnam_r("developer", &group_dev, buf, sizeof(buf), &group_ptr))
- return false;
+#if TTRACE_TIZEN_VERSION_MAJOR < 3
+ if(0 != getgrnam_r(TTRACE_GROUP_NAME, &group_dev, buf, sizeof(buf), &group_ptr))
+#else
+ group_ptr = getgrnam(TTRACE_GROUP_NAME);
+ if(group_ptr == NULL)
+#endif
+ {
+ fprintf(stderr, "Fail to group[%s] info: %s(%d)\n", TTRACE_GROUP_NAME, strerror_r(errno, str_error, sizeof(str_error)), errno);
+ return false;
+ }
fd = open("/tmp/tmp_tag", O_CREAT | O_RDWR | O_CLOEXEC, 0666);
if(fd < 0){
diff --git a/ttrace.h.in b/ttrace.h.in
index 8cf061b..057a2df 100755
--- a/ttrace.h.in
+++ b/ttrace.h.in
@@ -22,6 +22,8 @@
#cmakedefine TTRACE_PROFILE_TV
#cmakedefine TTRACE_PROFILE_WEARABLE
+#cmakedefine TTRACE_TIZEN_VERSION_MAJOR @TTRACE_TIZEN_VERSION_MAJOR@
+
#include "stdint.h"