libtracefs: Have tracefs_{tracing,debug}_dir() make sure it's still mounted

The test to test tracefs_tracing_dir() actually did not mount the
tracing_dir but only returned where it was mounted. This was because the
setup of the tests already called tracefs_tracing_dir() and set the static
variable to it. As the tracefs_tracing_dir() function already found the
mounted tracefs file system, it cached the location. The test unmounted
it, and then called tracefs_tracing_dir(), and since that returned a path,
the test assumed (incorrectly) that it was mounted.

Have tracefs_tracing_dir() and tracefs_debug_dir() check to make sure each
time that the cached directory is still mounted by checking for a
file/directory in it.

For tracefs, it checks to see if "trace" exists.

For debugfs, it checks to see if "tracing" exists.

Link: https://lore.kernel.org/linux-trace-devel/20221210191112.749f045c@gandalf.local.home

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 file changed