xref: /linux-6.15/include/linux/auto_dev-ioctl.h (revision e9a7c2f1)
1 /*
2  * Copyright 2008 Red Hat, Inc. All rights reserved.
3  * Copyright 2008 Ian Kent <[email protected]>
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 
10 #ifndef _LINUX_AUTO_DEV_IOCTL_H
11 #define _LINUX_AUTO_DEV_IOCTL_H
12 
13 #include <linux/auto_fs.h>
14 
15 #ifdef __KERNEL__
16 #include <linux/string.h>
17 #else
18 #include <string.h>
19 #endif /* __KERNEL__ */
20 
21 #define AUTOFS_DEVICE_NAME		"autofs"
22 
23 #define AUTOFS_DEV_IOCTL_VERSION_MAJOR	1
24 #define AUTOFS_DEV_IOCTL_VERSION_MINOR	0
25 
26 #define AUTOFS_DEVID_LEN		16
27 
28 #define AUTOFS_DEV_IOCTL_SIZE		sizeof(struct autofs_dev_ioctl)
29 
30 /*
31  * An ioctl interface for autofs mount point control.
32  */
33 
34 struct args_protover {
35 	__u32	version;
36 };
37 
38 struct args_protosubver {
39 	__u32	sub_version;
40 };
41 
42 struct args_openmount {
43 	__u32	devid;
44 };
45 
46 struct args_ready {
47 	__u32	token;
48 };
49 
50 struct args_fail {
51 	__u32	token;
52 	__s32	status;
53 };
54 
55 struct args_setpipefd {
56 	__s32	pipefd;
57 };
58 
59 struct args_timeout {
60 	__u64	timeout;
61 };
62 
63 struct args_requester {
64 	__u32	uid;
65 	__u32	gid;
66 };
67 
68 struct args_expire {
69 	__u32	how;
70 };
71 
72 struct args_askumount {
73 	__u32	may_umount;
74 };
75 
76 struct args_ismountpoint {
77 	union {
78 		struct args_in {
79 			__u32	type;
80 		} in;
81 		struct args_out {
82 			__u32	devid;
83 			__u32	magic;
84 		} out;
85 	};
86 };
87 
88 /*
89  * All the ioctls use this structure.
90  * When sending a path size must account for the total length
91  * of the chunk of memory otherwise is is the size of the
92  * structure.
93  */
94 
95 struct autofs_dev_ioctl {
96 	__u32 ver_major;
97 	__u32 ver_minor;
98 	__u32 size;		/* total size of data passed in
99 				 * including this struct */
100 	__s32 ioctlfd;		/* automount command fd */
101 
102 	/* Command parameters */
103 
104 	union {
105 		struct args_protover		protover;
106 		struct args_protosubver		protosubver;
107 		struct args_openmount		openmount;
108 		struct args_ready		ready;
109 		struct args_fail		fail;
110 		struct args_setpipefd		setpipefd;
111 		struct args_timeout		timeout;
112 		struct args_requester		requester;
113 		struct args_expire		expire;
114 		struct args_askumount		askumount;
115 		struct args_ismountpoint	ismountpoint;
116 	};
117 
118 	char path[0];
119 };
120 
121 static inline void init_autofs_dev_ioctl(struct autofs_dev_ioctl *in)
122 {
123 	memset(in, 0, sizeof(struct autofs_dev_ioctl));
124 	in->ver_major = AUTOFS_DEV_IOCTL_VERSION_MAJOR;
125 	in->ver_minor = AUTOFS_DEV_IOCTL_VERSION_MINOR;
126 	in->size = sizeof(struct autofs_dev_ioctl);
127 	in->ioctlfd = -1;
128 }
129 
130 /*
131  * If you change this make sure you make the corresponding change
132  * to autofs-dev-ioctl.c:lookup_ioctl()
133  */
134 enum {
135 	/* Get various version info */
136 	AUTOFS_DEV_IOCTL_VERSION_CMD = 0x71,
137 	AUTOFS_DEV_IOCTL_PROTOVER_CMD,
138 	AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD,
139 
140 	/* Open mount ioctl fd */
141 	AUTOFS_DEV_IOCTL_OPENMOUNT_CMD,
142 
143 	/* Close mount ioctl fd */
144 	AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD,
145 
146 	/* Mount/expire status returns */
147 	AUTOFS_DEV_IOCTL_READY_CMD,
148 	AUTOFS_DEV_IOCTL_FAIL_CMD,
149 
150 	/* Activate/deactivate autofs mount */
151 	AUTOFS_DEV_IOCTL_SETPIPEFD_CMD,
152 	AUTOFS_DEV_IOCTL_CATATONIC_CMD,
153 
154 	/* Expiry timeout */
155 	AUTOFS_DEV_IOCTL_TIMEOUT_CMD,
156 
157 	/* Get mount last requesting uid and gid */
158 	AUTOFS_DEV_IOCTL_REQUESTER_CMD,
159 
160 	/* Check for eligible expire candidates */
161 	AUTOFS_DEV_IOCTL_EXPIRE_CMD,
162 
163 	/* Request busy status */
164 	AUTOFS_DEV_IOCTL_ASKUMOUNT_CMD,
165 
166 	/* Check if path is a mountpoint */
167 	AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD,
168 };
169 
170 #define AUTOFS_IOCTL 0x93
171 
172 #define AUTOFS_DEV_IOCTL_VERSION \
173 	_IOWR(AUTOFS_IOCTL, \
174 	      AUTOFS_DEV_IOCTL_VERSION_CMD, struct autofs_dev_ioctl)
175 
176 #define AUTOFS_DEV_IOCTL_PROTOVER \
177 	_IOWR(AUTOFS_IOCTL, \
178 	      AUTOFS_DEV_IOCTL_PROTOVER_CMD, struct autofs_dev_ioctl)
179 
180 #define AUTOFS_DEV_IOCTL_PROTOSUBVER \
181 	_IOWR(AUTOFS_IOCTL, \
182 	      AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD, struct autofs_dev_ioctl)
183 
184 #define AUTOFS_DEV_IOCTL_OPENMOUNT \
185 	_IOWR(AUTOFS_IOCTL, \
186 	      AUTOFS_DEV_IOCTL_OPENMOUNT_CMD, struct autofs_dev_ioctl)
187 
188 #define AUTOFS_DEV_IOCTL_CLOSEMOUNT \
189 	_IOWR(AUTOFS_IOCTL, \
190 	      AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD, struct autofs_dev_ioctl)
191 
192 #define AUTOFS_DEV_IOCTL_READY \
193 	_IOWR(AUTOFS_IOCTL, \
194 	      AUTOFS_DEV_IOCTL_READY_CMD, struct autofs_dev_ioctl)
195 
196 #define AUTOFS_DEV_IOCTL_FAIL \
197 	_IOWR(AUTOFS_IOCTL, \
198 	      AUTOFS_DEV_IOCTL_FAIL_CMD, struct autofs_dev_ioctl)
199 
200 #define AUTOFS_DEV_IOCTL_SETPIPEFD \
201 	_IOWR(AUTOFS_IOCTL, \
202 	      AUTOFS_DEV_IOCTL_SETPIPEFD_CMD, struct autofs_dev_ioctl)
203 
204 #define AUTOFS_DEV_IOCTL_CATATONIC \
205 	_IOWR(AUTOFS_IOCTL, \
206 	      AUTOFS_DEV_IOCTL_CATATONIC_CMD, struct autofs_dev_ioctl)
207 
208 #define AUTOFS_DEV_IOCTL_TIMEOUT \
209 	_IOWR(AUTOFS_IOCTL, \
210 	      AUTOFS_DEV_IOCTL_TIMEOUT_CMD, struct autofs_dev_ioctl)
211 
212 #define AUTOFS_DEV_IOCTL_REQUESTER \
213 	_IOWR(AUTOFS_IOCTL, \
214 	      AUTOFS_DEV_IOCTL_REQUESTER_CMD, struct autofs_dev_ioctl)
215 
216 #define AUTOFS_DEV_IOCTL_EXPIRE \
217 	_IOWR(AUTOFS_IOCTL, \
218 	      AUTOFS_DEV_IOCTL_EXPIRE_CMD, struct autofs_dev_ioctl)
219 
220 #define AUTOFS_DEV_IOCTL_ASKUMOUNT \
221 	_IOWR(AUTOFS_IOCTL, \
222 	      AUTOFS_DEV_IOCTL_ASKUMOUNT_CMD, struct autofs_dev_ioctl)
223 
224 #define AUTOFS_DEV_IOCTL_ISMOUNTPOINT \
225 	_IOWR(AUTOFS_IOCTL, \
226 	      AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD, struct autofs_dev_ioctl)
227 
228 #endif	/* _LINUX_AUTO_DEV_IOCTL_H */
229