Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __API_FS__
0003 #define __API_FS__
0004 
0005 #include <stdbool.h>
0006 #include <unistd.h>
0007 
0008 /*
0009  * On most systems <limits.h> would have given us this, but  not on some systems
0010  * (e.g. GNU/Hurd).
0011  */
0012 #ifndef PATH_MAX
0013 #define PATH_MAX 4096
0014 #endif
0015 
0016 #define FS(name)                \
0017     const char *name##__mountpoint(void);   \
0018     const char *name##__mount(void);    \
0019     bool name##__configured(void);      \
0020 
0021 /*
0022  * The xxxx__mountpoint() entry points find the first match mount point for each
0023  * filesystems listed below, where xxxx is the filesystem type.
0024  *
0025  * The interface is as follows:
0026  *
0027  * - If a mount point is found on first call, it is cached and used for all
0028  *   subsequent calls.
0029  *
0030  * - If a mount point is not found, NULL is returned on first call and all
0031  *   subsequent calls.
0032  */
0033 FS(sysfs)
0034 FS(procfs)
0035 FS(debugfs)
0036 FS(tracefs)
0037 FS(hugetlbfs)
0038 FS(bpf_fs)
0039 
0040 #undef FS
0041 
0042 
0043 int cgroupfs_find_mountpoint(char *buf, size_t maxlen, const char *subsys);
0044 
0045 int filename__read_int(const char *filename, int *value);
0046 int filename__read_ull(const char *filename, unsigned long long *value);
0047 int filename__read_xll(const char *filename, unsigned long long *value);
0048 int filename__read_str(const char *filename, char **buf, size_t *sizep);
0049 
0050 int filename__write_int(const char *filename, int value);
0051 
0052 int procfs__read_str(const char *entry, char **buf, size_t *sizep);
0053 
0054 int sysctl__read_int(const char *sysctl, int *value);
0055 int sysfs__read_int(const char *entry, int *value);
0056 int sysfs__read_ull(const char *entry, unsigned long long *value);
0057 int sysfs__read_xll(const char *entry, unsigned long long *value);
0058 int sysfs__read_str(const char *entry, char **buf, size_t *sizep);
0059 int sysfs__read_bool(const char *entry, bool *value);
0060 
0061 int sysfs__write_int(const char *entry, int value);
0062 #endif /* __API_FS__ */