fs.h 1.8 KB

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