@@ -10,8 +10,10 @@
/* Can be overridden */
void warning(const char *fmt, ...);
+
int str_read_file(const char *file, char **buffer);
char *trace_append_file(const char *dir, const char *name);
+char *trace_find_tracing_dir(void);
#ifndef ACCESSPERMS
#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
@@ -15,9 +15,6 @@ void tracefs_put_tracing_file(char *name);
/* tracefs_get_tracing_dir must *not* be freed */
const char *tracefs_get_tracing_dir(void);
-/* tracefs_find_tracing_dir must be freed */
-char *tracefs_find_tracing_dir(void);
-
/* ftrace instances */
struct tracefs_instance;
@@ -210,7 +210,7 @@ char *tracefs_instance_get_dir(struct tracefs_instance *instance)
path = tracefs_get_tracing_file(buf);
free(buf);
} else
- path = tracefs_find_tracing_dir();
+ path = trace_find_tracing_dir();
return path;
}
@@ -60,12 +60,12 @@ static int mount_debugfs(void)
}
/**
- * tracefs_find_tracing_dir - Find tracing directory
+ * trace_find_tracing_dir - Find tracing directory
*
* Returns string containing the full path to the system's tracing directory.
* The string must be freed by free()
*/
-char *tracefs_find_tracing_dir(void)
+char *trace_find_tracing_dir(void)
{
char *debug_str = NULL;
char fspath[PATH_MAX+1];
@@ -143,7 +143,7 @@ const char *tracefs_get_tracing_dir(void)
if (tracing_dir)
return tracing_dir;
- tracing_dir = tracefs_find_tracing_dir();
+ tracing_dir = trace_find_tracing_dir();
return tracing_dir;
}
@@ -166,7 +166,7 @@ char *tracefs_get_tracing_file(const char *name)
return NULL;
if (!tracing) {
- tracing = tracefs_find_tracing_dir();
+ tracing = trace_find_tracing_dir();
if (!tracing)
return NULL;
}
@@ -162,21 +162,12 @@ static void test_trace_file(void)
const char *tdir;
struct stat st;
char *file;
- char *dir;
-
- dir = tracefs_find_tracing_dir();
- CU_TEST(dir != NULL);
- CU_TEST(stat(dir, &st) == 0);
- CU_TEST(S_ISDIR(st.st_mode));
tdir = tracefs_get_tracing_dir();
CU_TEST(tdir != NULL);
CU_TEST(stat(tdir, &st) == 0);
CU_TEST(S_ISDIR(st.st_mode));
- CU_TEST(strcmp(dir, tdir) == 0);
- free(dir);
-
file = tracefs_get_tracing_file(NULL);
CU_TEST(file == NULL);
file = tracefs_get_tracing_file(tmp);
There are two APIs to get the tracefs mount point: tracefs_get_tracing_dir() and tracefs_find_tracing_dir(). The only difference between them is that the first returns a static cashed string and the second a newly allocated string. In order not to confused the users with too many APIs that do the same, the tracefs_find_tracing_dir() is removed as an API, renamed to trace_find_tracing_dir() and is used only as library internal function. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> --- include/tracefs-local.h | 2 ++ include/tracefs.h | 3 --- src/tracefs-instance.c | 2 +- src/tracefs-utils.c | 8 ++++---- utest/tracefs-utest.c | 9 --------- 5 files changed, 7 insertions(+), 17 deletions(-)