auto_fs4.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
  2. /*
  3. * Copyright 1999-2000 Jeremy Fitzhardinge <jeremy@goop.org>
  4. *
  5. * This file is part of the Linux kernel and is made available under
  6. * the terms of the GNU General Public License, version 2, or at your
  7. * option, any later version, incorporated herein by reference.
  8. */
  9. #ifndef _LINUX_AUTO_FS4_H
  10. #define _LINUX_AUTO_FS4_H
  11. /* Include common v3 definitions */
  12. #include <linux/types.h>
  13. #include <linux/auto_fs.h>
  14. /* autofs v4 definitions */
  15. #undef AUTOFS_PROTO_VERSION
  16. #undef AUTOFS_MIN_PROTO_VERSION
  17. #undef AUTOFS_MAX_PROTO_VERSION
  18. #define AUTOFS_PROTO_VERSION 5
  19. #define AUTOFS_MIN_PROTO_VERSION 3
  20. #define AUTOFS_MAX_PROTO_VERSION 5
  21. #define AUTOFS_PROTO_SUBVERSION 2
  22. /* Mask for expire behaviour */
  23. #define AUTOFS_EXP_IMMEDIATE 1
  24. #define AUTOFS_EXP_LEAVES 2
  25. #define AUTOFS_TYPE_ANY 0U
  26. #define AUTOFS_TYPE_INDIRECT 1U
  27. #define AUTOFS_TYPE_DIRECT 2U
  28. #define AUTOFS_TYPE_OFFSET 4U
  29. static inline void set_autofs_type_indirect(unsigned int *type)
  30. {
  31. *type = AUTOFS_TYPE_INDIRECT;
  32. }
  33. static inline unsigned int autofs_type_indirect(unsigned int type)
  34. {
  35. return (type == AUTOFS_TYPE_INDIRECT);
  36. }
  37. static inline void set_autofs_type_direct(unsigned int *type)
  38. {
  39. *type = AUTOFS_TYPE_DIRECT;
  40. }
  41. static inline unsigned int autofs_type_direct(unsigned int type)
  42. {
  43. return (type == AUTOFS_TYPE_DIRECT);
  44. }
  45. static inline void set_autofs_type_offset(unsigned int *type)
  46. {
  47. *type = AUTOFS_TYPE_OFFSET;
  48. }
  49. static inline unsigned int autofs_type_offset(unsigned int type)
  50. {
  51. return (type == AUTOFS_TYPE_OFFSET);
  52. }
  53. static inline unsigned int autofs_type_trigger(unsigned int type)
  54. {
  55. return (type == AUTOFS_TYPE_DIRECT || type == AUTOFS_TYPE_OFFSET);
  56. }
  57. /*
  58. * This isn't really a type as we use it to say "no type set" to
  59. * indicate we want to search for "any" mount in the
  60. * autofs_dev_ioctl_ismountpoint() device ioctl function.
  61. */
  62. static inline void set_autofs_type_any(unsigned int *type)
  63. {
  64. *type = AUTOFS_TYPE_ANY;
  65. }
  66. static inline unsigned int autofs_type_any(unsigned int type)
  67. {
  68. return (type == AUTOFS_TYPE_ANY);
  69. }
  70. /* Daemon notification packet types */
  71. enum autofs_notify {
  72. NFY_NONE,
  73. NFY_MOUNT,
  74. NFY_EXPIRE
  75. };
  76. /* Kernel protocol version 4 packet types */
  77. /* Expire entry (umount request) */
  78. #define autofs_ptype_expire_multi 2
  79. /* Kernel protocol version 5 packet types */
  80. /* Indirect mount missing and expire requests. */
  81. #define autofs_ptype_missing_indirect 3
  82. #define autofs_ptype_expire_indirect 4
  83. /* Direct mount missing and expire requests */
  84. #define autofs_ptype_missing_direct 5
  85. #define autofs_ptype_expire_direct 6
  86. /* v4 multi expire (via pipe) */
  87. struct autofs_packet_expire_multi {
  88. struct autofs_packet_hdr hdr;
  89. autofs_wqt_t wait_queue_token;
  90. int len;
  91. char name[NAME_MAX+1];
  92. };
  93. union autofs_packet_union {
  94. struct autofs_packet_hdr hdr;
  95. struct autofs_packet_missing missing;
  96. struct autofs_packet_expire expire;
  97. struct autofs_packet_expire_multi expire_multi;
  98. };
  99. /* autofs v5 common packet struct */
  100. struct autofs_v5_packet {
  101. struct autofs_packet_hdr hdr;
  102. autofs_wqt_t wait_queue_token;
  103. __u32 dev;
  104. __u64 ino;
  105. __u32 uid;
  106. __u32 gid;
  107. __u32 pid;
  108. __u32 tgid;
  109. __u32 len;
  110. char name[NAME_MAX+1];
  111. };
  112. typedef struct autofs_v5_packet autofs_packet_missing_indirect_t;
  113. typedef struct autofs_v5_packet autofs_packet_expire_indirect_t;
  114. typedef struct autofs_v5_packet autofs_packet_missing_direct_t;
  115. typedef struct autofs_v5_packet autofs_packet_expire_direct_t;
  116. union autofs_v5_packet_union {
  117. struct autofs_packet_hdr hdr;
  118. struct autofs_v5_packet v5_packet;
  119. autofs_packet_missing_indirect_t missing_indirect;
  120. autofs_packet_expire_indirect_t expire_indirect;
  121. autofs_packet_missing_direct_t missing_direct;
  122. autofs_packet_expire_direct_t expire_direct;
  123. };
  124. enum {
  125. AUTOFS_IOC_EXPIRE_MULTI_CMD = 0x66, /* AUTOFS_IOC_EXPIRE_CMD + 1 */
  126. AUTOFS_IOC_PROTOSUBVER_CMD,
  127. AUTOFS_IOC_ASKUMOUNT_CMD = 0x70, /* AUTOFS_DEV_IOCTL_VERSION_CMD - 1 */
  128. };
  129. #define AUTOFS_IOC_EXPIRE_MULTI _IOW(AUTOFS_IOCTL, AUTOFS_IOC_EXPIRE_MULTI_CMD, int)
  130. #define AUTOFS_IOC_PROTOSUBVER _IOR(AUTOFS_IOCTL, AUTOFS_IOC_PROTOSUBVER_CMD, int)
  131. #define AUTOFS_IOC_ASKUMOUNT _IOR(AUTOFS_IOCTL, AUTOFS_IOC_ASKUMOUNT_CMD, int)
  132. #endif /* _LINUX_AUTO_FS4_H */