xref: /openbmc/linux/tools/lib/api/fs/fs.h (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2cd0cfad7SBorislav Petkov #ifndef __API_FS__
3cd0cfad7SBorislav Petkov #define __API_FS__
4cd0cfad7SBorislav Petkov 
5709adcb3SJiri Olsa #include <stdbool.h>
6607bfbd7SJiri Olsa #include <unistd.h>
7709adcb3SJiri Olsa 
8b86b0d35SJiri Olsa /*
9b86b0d35SJiri Olsa  * On most systems <limits.h> would have given us this, but  not on some systems
10b86b0d35SJiri Olsa  * (e.g. GNU/Hurd).
11b86b0d35SJiri Olsa  */
12b86b0d35SJiri Olsa #ifndef PATH_MAX
13b86b0d35SJiri Olsa #define PATH_MAX 4096
14b86b0d35SJiri Olsa #endif
15b86b0d35SJiri Olsa 
1673ca85adSJiri Olsa #define FS(name)				\
1773ca85adSJiri Olsa 	const char *name##__mountpoint(void);	\
18709adcb3SJiri Olsa 	const char *name##__mount(void);	\
19709adcb3SJiri Olsa 	bool name##__configured(void);		\
2073ca85adSJiri Olsa 
21*c6fddb28SStephane Eranian /*
22*c6fddb28SStephane Eranian  * The xxxx__mountpoint() entry points find the first match mount point for each
23*c6fddb28SStephane Eranian  * filesystems listed below, where xxxx is the filesystem type.
24*c6fddb28SStephane Eranian  *
25*c6fddb28SStephane Eranian  * The interface is as follows:
26*c6fddb28SStephane Eranian  *
27*c6fddb28SStephane Eranian  * - If a mount point is found on first call, it is cached and used for all
28*c6fddb28SStephane Eranian  *   subsequent calls.
29*c6fddb28SStephane Eranian  *
30*c6fddb28SStephane Eranian  * - If a mount point is not found, NULL is returned on first call and all
31*c6fddb28SStephane Eranian  *   subsequent calls.
32*c6fddb28SStephane Eranian  */
3373ca85adSJiri Olsa FS(sysfs)
3473ca85adSJiri Olsa FS(procfs)
3573ca85adSJiri Olsa FS(debugfs)
3673ca85adSJiri Olsa FS(tracefs)
375e7be3e1SWang Nan FS(hugetlbfs)
3871dc4c30SJoe Stringer FS(bpf_fs)
3973ca85adSJiri Olsa 
4073ca85adSJiri Olsa #undef FS
4173ca85adSJiri Olsa 
423a351127SArnaldo Carvalho de Melo 
437982a898SNamhyung Kim int cgroupfs_find_mountpoint(char *buf, size_t maxlen, const char *subsys);
447982a898SNamhyung Kim 
453a351127SArnaldo Carvalho de Melo int filename__read_int(const char *filename, int *value);
462d729f6aSArnaldo Carvalho de Melo int filename__read_ull(const char *filename, unsigned long long *value);
476baddfc6SJiri Olsa int filename__read_xll(const char *filename, unsigned long long *value);
48607bfbd7SJiri Olsa int filename__read_str(const char *filename, char **buf, size_t *sizep);
492d729f6aSArnaldo Carvalho de Melo 
503b00ea93SKan Liang int filename__write_int(const char *filename, int value);
513b00ea93SKan Liang 
524bd112dfSArnaldo Carvalho de Melo int procfs__read_str(const char *entry, char **buf, size_t *sizep);
534bd112dfSArnaldo Carvalho de Melo 
5442e3c4a1SArnaldo Carvalho de Melo int sysctl__read_int(const char *sysctl, int *value);
552d729f6aSArnaldo Carvalho de Melo int sysfs__read_int(const char *entry, int *value);
562d729f6aSArnaldo Carvalho de Melo int sysfs__read_ull(const char *entry, unsigned long long *value);
57d9c5f322SJiri Olsa int sysfs__read_xll(const char *entry, unsigned long long *value);
5851c0396cSJiri Olsa int sysfs__read_str(const char *entry, char **buf, size_t *sizep);
59b9835a90SAlexander Shishkin int sysfs__read_bool(const char *entry, bool *value);
603b00ea93SKan Liang 
613b00ea93SKan Liang int sysfs__write_int(const char *entry, int value);
62cd0cfad7SBorislav Petkov #endif /* __API_FS__ */
63