wrappers.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. #ifndef __SELFTEST_OVERLAYFS_WRAPPERS_H__
  4. #define __SELFTEST_OVERLAYFS_WRAPPERS_H__
  5. #define _GNU_SOURCE
  6. #include <linux/types.h>
  7. #include <linux/mount.h>
  8. #include <sys/syscall.h>
  9. #ifndef STATX_MNT_ID_UNIQUE
  10. #define STATX_MNT_ID_UNIQUE 0x00004000U /* Want/got extended stx_mount_id */
  11. #endif
  12. static inline int sys_fsopen(const char *fsname, unsigned int flags)
  13. {
  14. return syscall(__NR_fsopen, fsname, flags);
  15. }
  16. static inline int sys_fsconfig(int fd, unsigned int cmd, const char *key,
  17. const char *value, int aux)
  18. {
  19. return syscall(__NR_fsconfig, fd, cmd, key, value, aux);
  20. }
  21. static inline int sys_fsmount(int fd, unsigned int flags,
  22. unsigned int attr_flags)
  23. {
  24. return syscall(__NR_fsmount, fd, flags, attr_flags);
  25. }
  26. static inline int sys_mount(const char *src, const char *tgt, const char *fst,
  27. unsigned long flags, const void *data)
  28. {
  29. return syscall(__NR_mount, src, tgt, fst, flags, data);
  30. }
  31. #ifndef MOVE_MOUNT_F_EMPTY_PATH
  32. #define MOVE_MOUNT_F_EMPTY_PATH 0x00000004 /* Empty from path permitted */
  33. #endif
  34. #ifndef MOVE_MOUNT_T_EMPTY_PATH
  35. #define MOVE_MOUNT_T_EMPTY_PATH 0x00000040 /* Empty to path permitted */
  36. #endif
  37. #ifndef __NR_move_mount
  38. #if defined __alpha__
  39. #define __NR_move_mount 539
  40. #elif defined _MIPS_SIM
  41. #if _MIPS_SIM == _MIPS_SIM_ABI32 /* o32 */
  42. #define __NR_move_mount 4429
  43. #endif
  44. #if _MIPS_SIM == _MIPS_SIM_NABI32 /* n32 */
  45. #define __NR_move_mount 6429
  46. #endif
  47. #if _MIPS_SIM == _MIPS_SIM_ABI64 /* n64 */
  48. #define __NR_move_mount 5429
  49. #endif
  50. #else
  51. #define __NR_move_mount 429
  52. #endif
  53. #endif
  54. static inline int sys_move_mount(int from_dfd, const char *from_pathname,
  55. int to_dfd, const char *to_pathname,
  56. unsigned int flags)
  57. {
  58. return syscall(__NR_move_mount, from_dfd, from_pathname, to_dfd,
  59. to_pathname, flags);
  60. }
  61. #ifndef OPEN_TREE_CLONE
  62. #define OPEN_TREE_CLONE 1
  63. #endif
  64. #ifndef OPEN_TREE_CLOEXEC
  65. #define OPEN_TREE_CLOEXEC O_CLOEXEC
  66. #endif
  67. #ifndef AT_RECURSIVE
  68. #define AT_RECURSIVE 0x8000 /* Apply to the entire subtree */
  69. #endif
  70. #ifndef __NR_open_tree
  71. #if defined __alpha__
  72. #define __NR_open_tree 538
  73. #elif defined _MIPS_SIM
  74. #if _MIPS_SIM == _MIPS_SIM_ABI32 /* o32 */
  75. #define __NR_open_tree 4428
  76. #endif
  77. #if _MIPS_SIM == _MIPS_SIM_NABI32 /* n32 */
  78. #define __NR_open_tree 6428
  79. #endif
  80. #if _MIPS_SIM == _MIPS_SIM_ABI64 /* n64 */
  81. #define __NR_open_tree 5428
  82. #endif
  83. #else
  84. #define __NR_open_tree 428
  85. #endif
  86. #endif
  87. static inline int sys_open_tree(int dfd, const char *filename, unsigned int flags)
  88. {
  89. return syscall(__NR_open_tree, dfd, filename, flags);
  90. }
  91. #endif