On Mon, 2022-11-28 at 16:41 +0100, Bean Huo wrote: > On Mon, 2022-11-28 at 10:24 -0500, Steven Rostedt wrote: > > On Mon, 28 Nov 2022 14:21:06 +0100 > > > > Bean Huo <beanhuo@xxxxxxxx> wrote: > > > > > > > > > From: Bean Huo <beanhuo@xxxxxxxxxx> > > > If it eventually mounts successfully, it should return 1 instead > > > of > > > 0, otherwise it will make the caller's verification logic more > > > complicated > > > > The man page shows: > > > > > > > > The tracefs_tracing_dir_is_mounted() returns 1 if the tracing > > directory is > > > > already mounted, 0 if it is not, and -1 on error. > > > > > > > > If you only want to mount it and not care if it was already mounted > > then > > > > use tracefs_tracing_dir(), as it will return the path of the mount > > point > > > > and try to mount it if it is not already, or NULL if it could not > > mount it. > > > > > > > > Hi Steve, > > I used to reply on tracefs_tracing_dir(). But after updated the > libtracefs yesterday, I found my app doesn't work as before, then > checked the changelog, and switch to use > tracefs_tracing_dir_is_mounted. > > in your latest libtracefs: > > > const char *tracefs_tracing_dir(void) { > > ... > tracing_dir = trace_find_tracing_dir(false);//shold be changed to > true? > ... > > } > > > __hidden char *trace_find_tracing_dir(bool debugfs) > { > return find_tracing_dir(debugfs, false); > } > > > > static char *find_tracing_dir(bool debugfs, bool mount) { > > ... > if (!mount || mount_debugfs() < 0) > return NULL; > > > ... > > > } > > instead of changing tracefs_tracing_dir_is_mounted(), or we could change trace_find_tracing_dir(), let it mount the tracefs in case of it is not mounted when we call tracefs_tracing_dir(): --- a/src/tracefs-utils.c +++ b/src/tracefs-utils.c @@ -200,7 +200,7 @@ int tracefs_tracing_dir_is_mounted(bool mount, const char **path) */ __hidden char *trace_find_tracing_dir(bool debugfs) { - return find_tracing_dir(debugfs, false); + return find_tracing_dir(debugfs, true); } Kind regard, Bean