auto_fs.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
  2. /*
  3. * Copyright 1997 Transmeta Corporation - All Rights Reserved
  4. * Copyright 1999-2000 Jeremy Fitzhardinge <jeremy@goop.org>
  5. * Copyright 2005-2006,2013,2017-2018 Ian Kent <raven@themaw.net>
  6. *
  7. * This file is part of the Linux kernel and is made available under
  8. * the terms of the GNU General Public License, version 2, or at your
  9. * option, any later version, incorporated herein by reference.
  10. *
  11. * ----------------------------------------------------------------------- */
  12. #ifndef _UAPI_LINUX_AUTO_FS_H
  13. #define _UAPI_LINUX_AUTO_FS_H
  14. #include <linux/types.h>
  15. #include <linux/limits.h>
  16. #ifndef __KERNEL__
  17. #include <sys/ioctl.h>
  18. #endif /* __KERNEL__ */
  19. #define AUTOFS_PROTO_VERSION 5
  20. #define AUTOFS_MIN_PROTO_VERSION 3
  21. #define AUTOFS_MAX_PROTO_VERSION 5
  22. #define AUTOFS_PROTO_SUBVERSION 3
  23. /*
  24. * The wait_queue_token (autofs_wqt_t) is part of a structure which is passed
  25. * back to the kernel via ioctl from userspace. On architectures where 32- and
  26. * 64-bit userspace binaries can be executed it's important that the size of
  27. * autofs_wqt_t stays constant between 32- and 64-bit Linux kernels so that we
  28. * do not break the binary ABI interface by changing the structure size.
  29. */
  30. #if defined(__ia64__) || defined(__alpha__) /* pure 64bit architectures */
  31. typedef unsigned long autofs_wqt_t;
  32. #else
  33. typedef unsigned int autofs_wqt_t;
  34. #endif
  35. /* Packet types */
  36. #define autofs_ptype_missing 0 /* Missing entry (mount request) */
  37. #define autofs_ptype_expire 1 /* Expire entry (umount request) */
  38. struct autofs_packet_hdr {
  39. int proto_version; /* Protocol version */
  40. int type; /* Type of packet */
  41. };
  42. struct autofs_packet_missing {
  43. struct autofs_packet_hdr hdr;
  44. autofs_wqt_t wait_queue_token;
  45. int len;
  46. char name[NAME_MAX+1];
  47. };
  48. /* v3 expire (via ioctl) */
  49. struct autofs_packet_expire {
  50. struct autofs_packet_hdr hdr;
  51. int len;
  52. char name[NAME_MAX+1];
  53. };
  54. #define AUTOFS_IOCTL 0x93
  55. enum {
  56. AUTOFS_IOC_READY_CMD = 0x60,
  57. AUTOFS_IOC_FAIL_CMD,
  58. AUTOFS_IOC_CATATONIC_CMD,
  59. AUTOFS_IOC_PROTOVER_CMD,
  60. AUTOFS_IOC_SETTIMEOUT_CMD,
  61. AUTOFS_IOC_EXPIRE_CMD,
  62. };
  63. #define AUTOFS_IOC_READY _IO(AUTOFS_IOCTL, AUTOFS_IOC_READY_CMD)
  64. #define AUTOFS_IOC_FAIL _IO(AUTOFS_IOCTL, AUTOFS_IOC_FAIL_CMD)
  65. #define AUTOFS_IOC_CATATONIC _IO(AUTOFS_IOCTL, AUTOFS_IOC_CATATONIC_CMD)
  66. #define AUTOFS_IOC_PROTOVER _IOR(AUTOFS_IOCTL, \
  67. AUTOFS_IOC_PROTOVER_CMD, int)
  68. #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(AUTOFS_IOCTL, \
  69. AUTOFS_IOC_SETTIMEOUT_CMD, \
  70. compat_ulong_t)
  71. #define AUTOFS_IOC_SETTIMEOUT _IOWR(AUTOFS_IOCTL, \
  72. AUTOFS_IOC_SETTIMEOUT_CMD, \
  73. unsigned long)
  74. #define AUTOFS_IOC_EXPIRE _IOR(AUTOFS_IOCTL, \
  75. AUTOFS_IOC_EXPIRE_CMD, \
  76. struct autofs_packet_expire)
  77. /* autofs version 4 and later definitions */
  78. /* Mask for expire behaviour */
  79. #define AUTOFS_EXP_NORMAL 0x00
  80. #define AUTOFS_EXP_IMMEDIATE 0x01
  81. #define AUTOFS_EXP_LEAVES 0x02
  82. #define AUTOFS_EXP_FORCED 0x04
  83. #define AUTOFS_TYPE_ANY 0U
  84. #define AUTOFS_TYPE_INDIRECT 1U
  85. #define AUTOFS_TYPE_DIRECT 2U
  86. #define AUTOFS_TYPE_OFFSET 4U
  87. static inline void set_autofs_type_indirect(unsigned int *type)
  88. {
  89. *type = AUTOFS_TYPE_INDIRECT;
  90. }
  91. static inline unsigned int autofs_type_indirect(unsigned int type)
  92. {
  93. return (type == AUTOFS_TYPE_INDIRECT);
  94. }
  95. static inline void set_autofs_type_direct(unsigned int *type)
  96. {
  97. *type = AUTOFS_TYPE_DIRECT;
  98. }
  99. static inline unsigned int autofs_type_direct(unsigned int type)
  100. {
  101. return (type == AUTOFS_TYPE_DIRECT);
  102. }
  103. static inline void set_autofs_type_offset(unsigned int *type)
  104. {
  105. *type = AUTOFS_TYPE_OFFSET;
  106. }
  107. static inline unsigned int autofs_type_offset(unsigned int type)
  108. {
  109. return (type == AUTOFS_TYPE_OFFSET);
  110. }
  111. static inline unsigned int autofs_type_trigger(unsigned int type)
  112. {
  113. return (type == AUTOFS_TYPE_DIRECT || type == AUTOFS_TYPE_OFFSET);
  114. }
  115. /*
  116. * This isn't really a type as we use it to say "no type set" to
  117. * indicate we want to search for "any" mount in the
  118. * autofs_dev_ioctl_ismountpoint() device ioctl function.
  119. */
  120. static inline void set_autofs_type_any(unsigned int *type)
  121. {
  122. *type = AUTOFS_TYPE_ANY;
  123. }
  124. static inline unsigned int autofs_type_any(unsigned int type)
  125. {
  126. return (type == AUTOFS_TYPE_ANY);
  127. }
  128. /* Daemon notification packet types */
  129. enum autofs_notify {
  130. NFY_NONE,
  131. NFY_MOUNT,
  132. NFY_EXPIRE
  133. };
  134. /* Kernel protocol version 4 packet types */
  135. /* Expire entry (umount request) */
  136. #define autofs_ptype_expire_multi 2
  137. /* Kernel protocol version 5 packet types */
  138. /* Indirect mount missing and expire requests. */
  139. #define autofs_ptype_missing_indirect 3
  140. #define autofs_ptype_expire_indirect 4
  141. /* Direct mount missing and expire requests */
  142. #define autofs_ptype_missing_direct 5
  143. #define autofs_ptype_expire_direct 6
  144. /* v4 multi expire (via pipe) */
  145. struct autofs_packet_expire_multi {
  146. struct autofs_packet_hdr hdr;
  147. autofs_wqt_t wait_queue_token;
  148. int len;
  149. char name[NAME_MAX+1];
  150. };
  151. union autofs_packet_union {
  152. struct autofs_packet_hdr hdr;
  153. struct autofs_packet_missing missing;
  154. struct autofs_packet_expire expire;
  155. struct autofs_packet_expire_multi expire_multi;
  156. };
  157. /* autofs v5 common packet struct */
  158. struct autofs_v5_packet {
  159. struct autofs_packet_hdr hdr;
  160. autofs_wqt_t wait_queue_token;
  161. __u32 dev;
  162. __u64 ino;
  163. __u32 uid;
  164. __u32 gid;
  165. __u32 pid;
  166. __u32 tgid;
  167. __u32 len;
  168. char name[NAME_MAX+1];
  169. };
  170. typedef struct autofs_v5_packet autofs_packet_missing_indirect_t;
  171. typedef struct autofs_v5_packet autofs_packet_expire_indirect_t;
  172. typedef struct autofs_v5_packet autofs_packet_missing_direct_t;
  173. typedef struct autofs_v5_packet autofs_packet_expire_direct_t;
  174. union autofs_v5_packet_union {
  175. struct autofs_packet_hdr hdr;
  176. struct autofs_v5_packet v5_packet;
  177. autofs_packet_missing_indirect_t missing_indirect;
  178. autofs_packet_expire_indirect_t expire_indirect;
  179. autofs_packet_missing_direct_t missing_direct;
  180. autofs_packet_expire_direct_t expire_direct;
  181. };
  182. enum {
  183. AUTOFS_IOC_EXPIRE_MULTI_CMD = 0x66, /* AUTOFS_IOC_EXPIRE_CMD + 1 */
  184. AUTOFS_IOC_PROTOSUBVER_CMD,
  185. AUTOFS_IOC_ASKUMOUNT_CMD = 0x70, /* AUTOFS_DEV_IOCTL_VERSION_CMD - 1 */
  186. };
  187. #define AUTOFS_IOC_EXPIRE_MULTI _IOW(AUTOFS_IOCTL, \
  188. AUTOFS_IOC_EXPIRE_MULTI_CMD, int)
  189. #define AUTOFS_IOC_PROTOSUBVER _IOR(AUTOFS_IOCTL, \
  190. AUTOFS_IOC_PROTOSUBVER_CMD, int)
  191. #define AUTOFS_IOC_ASKUMOUNT _IOR(AUTOFS_IOCTL, \
  192. AUTOFS_IOC_ASKUMOUNT_CMD, int)
  193. #endif /* _UAPI_LINUX_AUTO_FS_H */