xref: /linux/include/uapi/linux/auto_fs.h (revision 597473720f4dc69749542bfcfed4a927a43d935e)
1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2e9a7c2f1SIan Kent /*
3607ca46eSDavid Howells  * Copyright 1997 Transmeta Corporation - All Rights Reserved
4ef8b42f7SIan Kent  * Copyright 1999-2000 Jeremy Fitzhardinge <jeremy@goop.org>
5ef8b42f7SIan Kent  * Copyright 2005-2006,2013,2017-2018 Ian Kent <raven@themaw.net>
6607ca46eSDavid Howells  *
7607ca46eSDavid Howells  * This file is part of the Linux kernel and is made available under
8607ca46eSDavid Howells  * the terms of the GNU General Public License, version 2, or at your
9607ca46eSDavid Howells  * option, any later version, incorporated herein by reference.
10607ca46eSDavid Howells  *
11607ca46eSDavid Howells  * ----------------------------------------------------------------------- */
12607ca46eSDavid Howells 
13607ca46eSDavid Howells #ifndef _UAPI_LINUX_AUTO_FS_H
14607ca46eSDavid Howells #define _UAPI_LINUX_AUTO_FS_H
15607ca46eSDavid Howells 
16607ca46eSDavid Howells #include <linux/types.h>
17f58b3c91STomohiro Kusumi #include <linux/limits.h>
18607ca46eSDavid Howells #ifndef __KERNEL__
19607ca46eSDavid Howells #include <sys/ioctl.h>
20607ca46eSDavid Howells #endif /* __KERNEL__ */
21607ca46eSDavid Howells 
22ef8b42f7SIan Kent #define AUTOFS_PROTO_VERSION		5
23ef8b42f7SIan Kent #define AUTOFS_MIN_PROTO_VERSION	3
24ef8b42f7SIan Kent #define AUTOFS_MAX_PROTO_VERSION	5
25607ca46eSDavid Howells 
26*60d6d04cSIan Kent #define AUTOFS_PROTO_SUBVERSION		5
27607ca46eSDavid Howells 
28607ca46eSDavid Howells /*
297cee9384SLinus Torvalds  * The wait_queue_token (autofs_wqt_t) is part of a structure which is passed
304f4ffc3aSHelge Deller  * back to the kernel via ioctl from userspace. On architectures where 32- and
314f4ffc3aSHelge Deller  * 64-bit userspace binaries can be executed it's important that the size of
324f4ffc3aSHelge Deller  * autofs_wqt_t stays constant between 32- and 64-bit Linux kernels so that we
334f4ffc3aSHelge Deller  * do not break the binary ABI interface by changing the structure size.
34607ca46eSDavid Howells  */
354f4ffc3aSHelge Deller #if defined(__ia64__) || defined(__alpha__) /* pure 64bit architectures */
36607ca46eSDavid Howells typedef unsigned long autofs_wqt_t;
374f4ffc3aSHelge Deller #else
384f4ffc3aSHelge Deller typedef unsigned int autofs_wqt_t;
39607ca46eSDavid Howells #endif
40607ca46eSDavid Howells 
41607ca46eSDavid Howells /* Packet types */
42607ca46eSDavid Howells #define autofs_ptype_missing	0	/* Missing entry (mount request) */
43607ca46eSDavid Howells #define autofs_ptype_expire	1	/* Expire entry (umount request) */
44607ca46eSDavid Howells 
45607ca46eSDavid Howells struct autofs_packet_hdr {
46607ca46eSDavid Howells 	int proto_version;		/* Protocol version */
47607ca46eSDavid Howells 	int type;			/* Type of packet */
48607ca46eSDavid Howells };
49607ca46eSDavid Howells 
50607ca46eSDavid Howells struct autofs_packet_missing {
51607ca46eSDavid Howells 	struct autofs_packet_hdr hdr;
527cee9384SLinus Torvalds 	autofs_wqt_t wait_queue_token;
53607ca46eSDavid Howells 	int len;
54607ca46eSDavid Howells 	char name[NAME_MAX+1];
55607ca46eSDavid Howells };
56607ca46eSDavid Howells 
57607ca46eSDavid Howells /* v3 expire (via ioctl) */
58607ca46eSDavid Howells struct autofs_packet_expire {
59607ca46eSDavid Howells 	struct autofs_packet_hdr hdr;
60607ca46eSDavid Howells 	int len;
61607ca46eSDavid Howells 	char name[NAME_MAX+1];
62607ca46eSDavid Howells };
63607ca46eSDavid Howells 
640fae77feSTomohiro Kusumi #define AUTOFS_IOCTL 0x93
650fae77feSTomohiro Kusumi 
660fae77feSTomohiro Kusumi enum {
670fae77feSTomohiro Kusumi 	AUTOFS_IOC_READY_CMD = 0x60,
680fae77feSTomohiro Kusumi 	AUTOFS_IOC_FAIL_CMD,
690fae77feSTomohiro Kusumi 	AUTOFS_IOC_CATATONIC_CMD,
700fae77feSTomohiro Kusumi 	AUTOFS_IOC_PROTOVER_CMD,
710fae77feSTomohiro Kusumi 	AUTOFS_IOC_SETTIMEOUT_CMD,
720fae77feSTomohiro Kusumi 	AUTOFS_IOC_EXPIRE_CMD,
730fae77feSTomohiro Kusumi };
740fae77feSTomohiro Kusumi 
750fae77feSTomohiro Kusumi #define AUTOFS_IOC_READY        _IO(AUTOFS_IOCTL, AUTOFS_IOC_READY_CMD)
760fae77feSTomohiro Kusumi #define AUTOFS_IOC_FAIL         _IO(AUTOFS_IOCTL, AUTOFS_IOC_FAIL_CMD)
770fae77feSTomohiro Kusumi #define AUTOFS_IOC_CATATONIC    _IO(AUTOFS_IOCTL, AUTOFS_IOC_CATATONIC_CMD)
78ef8b42f7SIan Kent #define AUTOFS_IOC_PROTOVER     _IOR(AUTOFS_IOCTL, \
79ef8b42f7SIan Kent 				     AUTOFS_IOC_PROTOVER_CMD, int)
80ef8b42f7SIan Kent #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(AUTOFS_IOCTL, \
81ef8b42f7SIan Kent 				      AUTOFS_IOC_SETTIMEOUT_CMD, \
82ef8b42f7SIan Kent 				      compat_ulong_t)
83ef8b42f7SIan Kent #define AUTOFS_IOC_SETTIMEOUT   _IOWR(AUTOFS_IOCTL, \
84ef8b42f7SIan Kent 				      AUTOFS_IOC_SETTIMEOUT_CMD, \
85ef8b42f7SIan Kent 				      unsigned long)
86ef8b42f7SIan Kent #define AUTOFS_IOC_EXPIRE       _IOR(AUTOFS_IOCTL, \
87ef8b42f7SIan Kent 				     AUTOFS_IOC_EXPIRE_CMD, \
88ef8b42f7SIan Kent 				     struct autofs_packet_expire)
89ef8b42f7SIan Kent 
90ef8b42f7SIan Kent /* autofs version 4 and later definitions */
91ef8b42f7SIan Kent 
92ef8b42f7SIan Kent /* Mask for expire behaviour */
93cbf6898fSIan Kent #define AUTOFS_EXP_NORMAL		0x00
94cbf6898fSIan Kent #define AUTOFS_EXP_IMMEDIATE		0x01
95cbf6898fSIan Kent #define AUTOFS_EXP_LEAVES		0x02
96cbf6898fSIan Kent #define AUTOFS_EXP_FORCED		0x04
97ef8b42f7SIan Kent 
98ef8b42f7SIan Kent #define AUTOFS_TYPE_ANY			0U
99ef8b42f7SIan Kent #define AUTOFS_TYPE_INDIRECT		1U
100ef8b42f7SIan Kent #define AUTOFS_TYPE_DIRECT		2U
101ef8b42f7SIan Kent #define AUTOFS_TYPE_OFFSET		4U
102ef8b42f7SIan Kent 
set_autofs_type_indirect(unsigned int * type)103ef8b42f7SIan Kent static inline void set_autofs_type_indirect(unsigned int *type)
104ef8b42f7SIan Kent {
105ef8b42f7SIan Kent 	*type = AUTOFS_TYPE_INDIRECT;
106ef8b42f7SIan Kent }
107ef8b42f7SIan Kent 
autofs_type_indirect(unsigned int type)108ef8b42f7SIan Kent static inline unsigned int autofs_type_indirect(unsigned int type)
109ef8b42f7SIan Kent {
110ef8b42f7SIan Kent 	return (type == AUTOFS_TYPE_INDIRECT);
111ef8b42f7SIan Kent }
112ef8b42f7SIan Kent 
set_autofs_type_direct(unsigned int * type)113ef8b42f7SIan Kent static inline void set_autofs_type_direct(unsigned int *type)
114ef8b42f7SIan Kent {
115ef8b42f7SIan Kent 	*type = AUTOFS_TYPE_DIRECT;
116ef8b42f7SIan Kent }
117ef8b42f7SIan Kent 
autofs_type_direct(unsigned int type)118ef8b42f7SIan Kent static inline unsigned int autofs_type_direct(unsigned int type)
119ef8b42f7SIan Kent {
120ef8b42f7SIan Kent 	return (type == AUTOFS_TYPE_DIRECT);
121ef8b42f7SIan Kent }
122ef8b42f7SIan Kent 
set_autofs_type_offset(unsigned int * type)123ef8b42f7SIan Kent static inline void set_autofs_type_offset(unsigned int *type)
124ef8b42f7SIan Kent {
125ef8b42f7SIan Kent 	*type = AUTOFS_TYPE_OFFSET;
126ef8b42f7SIan Kent }
127ef8b42f7SIan Kent 
autofs_type_offset(unsigned int type)128ef8b42f7SIan Kent static inline unsigned int autofs_type_offset(unsigned int type)
129ef8b42f7SIan Kent {
130ef8b42f7SIan Kent 	return (type == AUTOFS_TYPE_OFFSET);
131ef8b42f7SIan Kent }
132ef8b42f7SIan Kent 
autofs_type_trigger(unsigned int type)133ef8b42f7SIan Kent static inline unsigned int autofs_type_trigger(unsigned int type)
134ef8b42f7SIan Kent {
135ef8b42f7SIan Kent 	return (type == AUTOFS_TYPE_DIRECT || type == AUTOFS_TYPE_OFFSET);
136ef8b42f7SIan Kent }
137ef8b42f7SIan Kent 
138ef8b42f7SIan Kent /*
139ef8b42f7SIan Kent  * This isn't really a type as we use it to say "no type set" to
140ef8b42f7SIan Kent  * indicate we want to search for "any" mount in the
141ef8b42f7SIan Kent  * autofs_dev_ioctl_ismountpoint() device ioctl function.
142ef8b42f7SIan Kent  */
set_autofs_type_any(unsigned int * type)143ef8b42f7SIan Kent static inline void set_autofs_type_any(unsigned int *type)
144ef8b42f7SIan Kent {
145ef8b42f7SIan Kent 	*type = AUTOFS_TYPE_ANY;
146ef8b42f7SIan Kent }
147ef8b42f7SIan Kent 
autofs_type_any(unsigned int type)148ef8b42f7SIan Kent static inline unsigned int autofs_type_any(unsigned int type)
149ef8b42f7SIan Kent {
150ef8b42f7SIan Kent 	return (type == AUTOFS_TYPE_ANY);
151ef8b42f7SIan Kent }
152ef8b42f7SIan Kent 
153ef8b42f7SIan Kent /* Daemon notification packet types */
154ef8b42f7SIan Kent enum autofs_notify {
155ef8b42f7SIan Kent 	NFY_NONE,
156ef8b42f7SIan Kent 	NFY_MOUNT,
157ef8b42f7SIan Kent 	NFY_EXPIRE
158ef8b42f7SIan Kent };
159ef8b42f7SIan Kent 
160ef8b42f7SIan Kent /* Kernel protocol version 4 packet types */
161ef8b42f7SIan Kent 
162ef8b42f7SIan Kent /* Expire entry (umount request) */
163ef8b42f7SIan Kent #define autofs_ptype_expire_multi	2
164ef8b42f7SIan Kent 
165ef8b42f7SIan Kent /* Kernel protocol version 5 packet types */
166ef8b42f7SIan Kent 
167ef8b42f7SIan Kent /* Indirect mount missing and expire requests. */
168ef8b42f7SIan Kent #define autofs_ptype_missing_indirect	3
169ef8b42f7SIan Kent #define autofs_ptype_expire_indirect	4
170ef8b42f7SIan Kent 
171ef8b42f7SIan Kent /* Direct mount missing and expire requests */
172ef8b42f7SIan Kent #define autofs_ptype_missing_direct	5
173ef8b42f7SIan Kent #define autofs_ptype_expire_direct	6
174ef8b42f7SIan Kent 
175ef8b42f7SIan Kent /* v4 multi expire (via pipe) */
176ef8b42f7SIan Kent struct autofs_packet_expire_multi {
177ef8b42f7SIan Kent 	struct autofs_packet_hdr hdr;
178ef8b42f7SIan Kent 	autofs_wqt_t wait_queue_token;
179ef8b42f7SIan Kent 	int len;
180ef8b42f7SIan Kent 	char name[NAME_MAX+1];
181ef8b42f7SIan Kent };
182ef8b42f7SIan Kent 
183ef8b42f7SIan Kent union autofs_packet_union {
184ef8b42f7SIan Kent 	struct autofs_packet_hdr hdr;
185ef8b42f7SIan Kent 	struct autofs_packet_missing missing;
186ef8b42f7SIan Kent 	struct autofs_packet_expire expire;
187ef8b42f7SIan Kent 	struct autofs_packet_expire_multi expire_multi;
188ef8b42f7SIan Kent };
189ef8b42f7SIan Kent 
190ef8b42f7SIan Kent /* autofs v5 common packet struct */
191ef8b42f7SIan Kent struct autofs_v5_packet {
192ef8b42f7SIan Kent 	struct autofs_packet_hdr hdr;
193ef8b42f7SIan Kent 	autofs_wqt_t wait_queue_token;
194ef8b42f7SIan Kent 	__u32 dev;
195ef8b42f7SIan Kent 	__u64 ino;
196ef8b42f7SIan Kent 	__u32 uid;
197ef8b42f7SIan Kent 	__u32 gid;
198ef8b42f7SIan Kent 	__u32 pid;
199ef8b42f7SIan Kent 	__u32 tgid;
200ef8b42f7SIan Kent 	__u32 len;
201ef8b42f7SIan Kent 	char name[NAME_MAX+1];
202ef8b42f7SIan Kent };
203ef8b42f7SIan Kent 
204ef8b42f7SIan Kent typedef struct autofs_v5_packet autofs_packet_missing_indirect_t;
205ef8b42f7SIan Kent typedef struct autofs_v5_packet autofs_packet_expire_indirect_t;
206ef8b42f7SIan Kent typedef struct autofs_v5_packet autofs_packet_missing_direct_t;
207ef8b42f7SIan Kent typedef struct autofs_v5_packet autofs_packet_expire_direct_t;
208ef8b42f7SIan Kent 
209ef8b42f7SIan Kent union autofs_v5_packet_union {
210ef8b42f7SIan Kent 	struct autofs_packet_hdr hdr;
211ef8b42f7SIan Kent 	struct autofs_v5_packet v5_packet;
212ef8b42f7SIan Kent 	autofs_packet_missing_indirect_t missing_indirect;
213ef8b42f7SIan Kent 	autofs_packet_expire_indirect_t expire_indirect;
214ef8b42f7SIan Kent 	autofs_packet_missing_direct_t missing_direct;
215ef8b42f7SIan Kent 	autofs_packet_expire_direct_t expire_direct;
216ef8b42f7SIan Kent };
217ef8b42f7SIan Kent 
218ef8b42f7SIan Kent enum {
219ef8b42f7SIan Kent 	AUTOFS_IOC_EXPIRE_MULTI_CMD = 0x66, /* AUTOFS_IOC_EXPIRE_CMD + 1 */
220ef8b42f7SIan Kent 	AUTOFS_IOC_PROTOSUBVER_CMD,
221ef8b42f7SIan Kent 	AUTOFS_IOC_ASKUMOUNT_CMD = 0x70, /* AUTOFS_DEV_IOCTL_VERSION_CMD - 1 */
222ef8b42f7SIan Kent };
223ef8b42f7SIan Kent 
224ef8b42f7SIan Kent #define AUTOFS_IOC_EXPIRE_MULTI		_IOW(AUTOFS_IOCTL, \
225ef8b42f7SIan Kent 					     AUTOFS_IOC_EXPIRE_MULTI_CMD, int)
226ef8b42f7SIan Kent #define AUTOFS_IOC_PROTOSUBVER		_IOR(AUTOFS_IOCTL, \
227ef8b42f7SIan Kent 					     AUTOFS_IOC_PROTOSUBVER_CMD, int)
228ef8b42f7SIan Kent #define AUTOFS_IOC_ASKUMOUNT		_IOR(AUTOFS_IOCTL, \
229ef8b42f7SIan Kent 					     AUTOFS_IOC_ASKUMOUNT_CMD, int)
230607ca46eSDavid Howells 
231607ca46eSDavid Howells #endif /* _UAPI_LINUX_AUTO_FS_H */
232