Skip to content

Commit 709adcb

Browse files
olsajiriacmel
authored andcommitted
tools lib api fs: Add FSTYPE__configured() method
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>
1 parent 73ca85a commit 709adcb

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

tools/lib/api/fs/fs.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,20 @@ static const char *fs__mount(int idx)
244244
return fs__check_mounts(fs) ? fs->path : NULL;
245245
}
246246

247-
#define FS(name, idx) \
248-
const char *name##__mountpoint(void) \
249-
{ \
250-
return fs__mountpoint(idx); \
251-
} \
252-
\
253-
const char *name##__mount(void) \
254-
{ \
255-
return fs__mount(idx); \
247+
#define FS(name, idx) \
248+
const char *name##__mountpoint(void) \
249+
{ \
250+
return fs__mountpoint(idx); \
251+
} \
252+
\
253+
const char *name##__mount(void) \
254+
{ \
255+
return fs__mount(idx); \
256+
} \
257+
\
258+
bool name##__configured(void) \
259+
{ \
260+
return name##__mountpoint() != NULL; \
256261
}
257262

258263
FS(sysfs, FS__SYSFS);

tools/lib/api/fs/fs.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef __API_FS__
22
#define __API_FS__
33

4+
#include <stdbool.h>
5+
46
/*
57
* On most systems <limits.h> would have given us this, but not on some systems
68
* (e.g. GNU/Hurd).
@@ -11,7 +13,8 @@
1113

1214
#define FS(name) \
1315
const char *name##__mountpoint(void); \
14-
const char *name##__mount(void);
16+
const char *name##__mount(void); \
17+
bool name##__configured(void); \
1518

1619
FS(sysfs)
1720
FS(procfs)

0 commit comments

Comments
 (0)