1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
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>
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.
11 * ----------------------------------------------------------------------- */
13 #ifndef _LINUX_AUTO_FS_H
14 #define _LINUX_AUTO_FS_H
16 #include <linux/types.h>
17 #include <linux/limits.h>
18 #include <sys/ioctl.h>
20 #define AUTOFS_PROTO_VERSION 5
21 #define AUTOFS_MIN_PROTO_VERSION 3
22 #define AUTOFS_MAX_PROTO_VERSION 5
24 #define AUTOFS_PROTO_SUBVERSION 3
27 * The wait_queue_token (autofs_wqt_t) is part of a structure which is passed
28 * back to the kernel via ioctl from userspace. On architectures where 32- and
29 * 64-bit userspace binaries can be executed it's important that the size of
30 * autofs_wqt_t stays constant between 32- and 64-bit Linux kernels so that we
31 * do not break the binary ABI interface by changing the structure size.
33 #if defined(__ia64__) || defined(__alpha__) /* pure 64bit architectures */
34 typedef unsigned long autofs_wqt_t;
36 typedef unsigned int autofs_wqt_t;
40 #define autofs_ptype_missing 0 /* Missing entry (mount request) */
41 #define autofs_ptype_expire 1 /* Expire entry (umount request) */
43 struct autofs_packet_hdr {
44 int proto_version; /* Protocol version */
45 int type; /* Type of packet */
48 struct autofs_packet_missing {
49 struct autofs_packet_hdr hdr;
50 autofs_wqt_t wait_queue_token;
52 char name[NAME_MAX+1];
55 /* v3 expire (via ioctl) */
56 struct autofs_packet_expire {
57 struct autofs_packet_hdr hdr;
59 char name[NAME_MAX+1];
62 #define AUTOFS_IOCTL 0x93
65 AUTOFS_IOC_READY_CMD = 0x60,
67 AUTOFS_IOC_CATATONIC_CMD,
68 AUTOFS_IOC_PROTOVER_CMD,
69 AUTOFS_IOC_SETTIMEOUT_CMD,
70 AUTOFS_IOC_EXPIRE_CMD,
73 #define AUTOFS_IOC_READY _IO(AUTOFS_IOCTL, AUTOFS_IOC_READY_CMD)
74 #define AUTOFS_IOC_FAIL _IO(AUTOFS_IOCTL, AUTOFS_IOC_FAIL_CMD)
75 #define AUTOFS_IOC_CATATONIC _IO(AUTOFS_IOCTL, AUTOFS_IOC_CATATONIC_CMD)
76 #define AUTOFS_IOC_PROTOVER _IOR(AUTOFS_IOCTL, \
77 AUTOFS_IOC_PROTOVER_CMD, int)
78 #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(AUTOFS_IOCTL, \
79 AUTOFS_IOC_SETTIMEOUT_CMD, \
81 #define AUTOFS_IOC_SETTIMEOUT _IOWR(AUTOFS_IOCTL, \
82 AUTOFS_IOC_SETTIMEOUT_CMD, \
84 #define AUTOFS_IOC_EXPIRE _IOR(AUTOFS_IOCTL, \
85 AUTOFS_IOC_EXPIRE_CMD, \
86 struct autofs_packet_expire)
88 /* autofs version 4 and later definitions */
90 /* Mask for expire behaviour */
91 #define AUTOFS_EXP_NORMAL 0x00
92 #define AUTOFS_EXP_IMMEDIATE 0x01
93 #define AUTOFS_EXP_LEAVES 0x02
94 #define AUTOFS_EXP_FORCED 0x04
96 #define AUTOFS_TYPE_ANY 0U
97 #define AUTOFS_TYPE_INDIRECT 1U
98 #define AUTOFS_TYPE_DIRECT 2U
99 #define AUTOFS_TYPE_OFFSET 4U
101 static __inline__ void set_autofs_type_indirect(unsigned int *type)
103 *type = AUTOFS_TYPE_INDIRECT;
106 static __inline__ unsigned int autofs_type_indirect(unsigned int type)
108 return (type == AUTOFS_TYPE_INDIRECT);
111 static __inline__ void set_autofs_type_direct(unsigned int *type)
113 *type = AUTOFS_TYPE_DIRECT;
116 static __inline__ unsigned int autofs_type_direct(unsigned int type)
118 return (type == AUTOFS_TYPE_DIRECT);
121 static __inline__ void set_autofs_type_offset(unsigned int *type)
123 *type = AUTOFS_TYPE_OFFSET;
126 static __inline__ unsigned int autofs_type_offset(unsigned int type)
128 return (type == AUTOFS_TYPE_OFFSET);
131 static __inline__ unsigned int autofs_type_trigger(unsigned int type)
133 return (type == AUTOFS_TYPE_DIRECT || type == AUTOFS_TYPE_OFFSET);
137 * This isn't really a type as we use it to say "no type set" to
138 * indicate we want to search for "any" mount in the
139 * autofs_dev_ioctl_ismountpoint() device ioctl function.
141 static __inline__ void set_autofs_type_any(unsigned int *type)
143 *type = AUTOFS_TYPE_ANY;
146 static __inline__ unsigned int autofs_type_any(unsigned int type)
148 return (type == AUTOFS_TYPE_ANY);
151 /* Daemon notification packet types */
158 /* Kernel protocol version 4 packet types */
160 /* Expire entry (umount request) */
161 #define autofs_ptype_expire_multi 2
163 /* Kernel protocol version 5 packet types */
165 /* Indirect mount missing and expire requests. */
166 #define autofs_ptype_missing_indirect 3
167 #define autofs_ptype_expire_indirect 4
169 /* Direct mount missing and expire requests */
170 #define autofs_ptype_missing_direct 5
171 #define autofs_ptype_expire_direct 6
173 /* v4 multi expire (via pipe) */
174 struct autofs_packet_expire_multi {
175 struct autofs_packet_hdr hdr;
176 autofs_wqt_t wait_queue_token;
178 char name[NAME_MAX+1];
181 union autofs_packet_union {
182 struct autofs_packet_hdr hdr;
183 struct autofs_packet_missing missing;
184 struct autofs_packet_expire expire;
185 struct autofs_packet_expire_multi expire_multi;
188 /* autofs v5 common packet struct */
189 struct autofs_v5_packet {
190 struct autofs_packet_hdr hdr;
191 autofs_wqt_t wait_queue_token;
199 char name[NAME_MAX+1];
202 typedef struct autofs_v5_packet autofs_packet_missing_indirect_t;
203 typedef struct autofs_v5_packet autofs_packet_expire_indirect_t;
204 typedef struct autofs_v5_packet autofs_packet_missing_direct_t;
205 typedef struct autofs_v5_packet autofs_packet_expire_direct_t;
207 union autofs_v5_packet_union {
208 struct autofs_packet_hdr hdr;
209 struct autofs_v5_packet v5_packet;
210 autofs_packet_missing_indirect_t missing_indirect;
211 autofs_packet_expire_indirect_t expire_indirect;
212 autofs_packet_missing_direct_t missing_direct;
213 autofs_packet_expire_direct_t expire_direct;
217 AUTOFS_IOC_EXPIRE_MULTI_CMD = 0x66, /* AUTOFS_IOC_EXPIRE_CMD + 1 */
218 AUTOFS_IOC_PROTOSUBVER_CMD,
219 AUTOFS_IOC_ASKUMOUNT_CMD = 0x70, /* AUTOFS_DEV_IOCTL_VERSION_CMD - 1 */
222 #define AUTOFS_IOC_EXPIRE_MULTI _IOW(AUTOFS_IOCTL, \
223 AUTOFS_IOC_EXPIRE_MULTI_CMD, int)
224 #define AUTOFS_IOC_PROTOSUBVER _IOR(AUTOFS_IOCTL, \
225 AUTOFS_IOC_PROTOSUBVER_CMD, int)
226 #define AUTOFS_IOC_ASKUMOUNT _IOR(AUTOFS_IOCTL, \
227 AUTOFS_IOC_ASKUMOUNT_CMD, int)
229 #endif /* _LINUX_AUTO_FS_H */