^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef __API_FS__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define __API_FS__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <stdbool.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <unistd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * On most systems <limits.h> would have given us this, but not on some systems
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * (e.g. GNU/Hurd).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #ifndef PATH_MAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #define PATH_MAX 4096
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define FS(name) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) const char *name##__mountpoint(void); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) const char *name##__mount(void); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) bool name##__configured(void); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * The xxxx__mountpoint() entry points find the first match mount point for each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * filesystems listed below, where xxxx is the filesystem type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * The interface is as follows:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * - If a mount point is found on first call, it is cached and used for all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * subsequent calls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * - If a mount point is not found, NULL is returned on first call and all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * subsequent calls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) FS(sysfs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) FS(procfs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) FS(debugfs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) FS(tracefs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) FS(hugetlbfs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) FS(bpf_fs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #undef FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) int cgroupfs_find_mountpoint(char *buf, size_t maxlen, const char *subsys);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) int filename__read_int(const char *filename, int *value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) int filename__read_ull(const char *filename, unsigned long long *value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) int filename__read_xll(const char *filename, unsigned long long *value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) int filename__read_str(const char *filename, char **buf, size_t *sizep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) int filename__write_int(const char *filename, int value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) int procfs__read_str(const char *entry, char **buf, size_t *sizep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) int sysctl__read_int(const char *sysctl, int *value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) int sysfs__read_int(const char *entry, int *value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) int sysfs__read_ull(const char *entry, unsigned long long *value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) int sysfs__read_xll(const char *entry, unsigned long long *value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) int sysfs__read_str(const char *entry, char **buf, size_t *sizep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) int sysfs__read_bool(const char *entry, bool *value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) int sysfs__write_int(const char *entry, int value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #endif /* __API_FS__ */