tools lib api fs: Add FSTYPE__configured() method
authorJiri Olsa <jolsa@kernel.org>
Wed, 2 Sep 2015 07:56:42 +0000 (09:56 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 4 Sep 2015 15:01:01 +0000 (12:01 -0300)
Add FSTYPE__configured() (where FSTYPE is one of sysfs, procfs, debugfs,
tracefs) interface that returns bool state of the filesystem mount:

  true - mounted, false - not mounted

It will not try to mount the filesystem.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1441180605-24737-13-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/lib/api/fs/fs.c
tools/lib/api/fs/fs.h

index bc93baf33fffca625f0585e966595ae6ceac9b9d..8afe08a99bc66fe3a53a0767ff99de0c56a34072 100644 (file)
@@ -244,15 +244,20 @@ static const char *fs__mount(int idx)
        return fs__check_mounts(fs) ? fs->path : NULL;
 }
 
-#define FS(name, idx)                  \
-const char *name##__mountpoint(void)   \
-{                                      \
-       return fs__mountpoint(idx);     \
-}                                      \
-                                       \
-const char *name##__mount(void)                \
-{                                      \
-       return fs__mount(idx);          \
+#define FS(name, idx)                          \
+const char *name##__mountpoint(void)           \
+{                                              \
+       return fs__mountpoint(idx);             \
+}                                              \
+                                               \
+const char *name##__mount(void)                        \
+{                                              \
+       return fs__mount(idx);                  \
+}                                              \
+                                               \
+bool name##__configured(void)                  \
+{                                              \
+       return name##__mountpoint() != NULL;    \
 }
 
 FS(sysfs,   FS__SYSFS);
index a9627ea5e6ae73753bdc41f9ec84bb331e99c2d9..f654bcb99d1e9b7a7823279135d97420b45b7861 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __API_FS__
 #define __API_FS__
 
+#include <stdbool.h>
+
 /*
  * On most systems <limits.h> would have given us this, but  not on some systems
  * (e.g. GNU/Hurd).
@@ -11,7 +13,8 @@
 
 #define FS(name)                               \
        const char *name##__mountpoint(void);   \
-       const char *name##__mount(void);
+       const char *name##__mount(void);        \
+       bool name##__configured(void);          \
 
 FS(sysfs)
 FS(procfs)