1 #include <linux/limits.h>
2 #include <linux/auto_fs4.h>
11 /* include/linux/auto_dev-ioctl.h */
13 * Copyright 2008 Red Hat, Inc. All rights reserved.
14 * Copyright 2008 Ian Kent <raven@themaw.net>
16 * This file is part of the Linux kernel and is made available under
17 * the terms of the GNU General Public License, version 2, or at your
18 * option, any later version, incorporated herein by reference.
23 #define AUTOFS_DEVICE_NAME "autofs"
25 #define AUTOFS_DEV_IOCTL_VERSION_MAJOR 1
26 #define AUTOFS_DEV_IOCTL_VERSION_MINOR 0
28 #define AUTOFS_DEVID_LEN 16
30 #define AUTOFS_DEV_IOCTL_SIZE sizeof(struct autofs_dev_ioctl)
33 * An ioctl interface for autofs mount point control.
36 struct args_protover
{
40 struct args_protosubver
{
44 struct args_openmount
{
57 struct args_setpipefd
{
65 struct args_requester
{
74 struct args_askumount
{
78 struct args_ismountpoint
{
91 * All the ioctls use this structure.
92 * When sending a path size must account for the total length
93 * of the chunk of memory otherwise is is the size of the
97 struct autofs_dev_ioctl
{
100 __u32 size
; /* total size of data passed in
101 * including this struct */
102 __s32 ioctlfd
; /* automount command fd */
104 /* Command parameters */
107 struct args_protover protover
;
108 struct args_protosubver protosubver
;
109 struct args_openmount openmount
;
110 struct args_ready ready
;
111 struct args_fail fail
;
112 struct args_setpipefd setpipefd
;
113 struct args_timeout timeout
;
114 struct args_requester requester
;
115 struct args_expire expire
;
116 struct args_askumount askumount
;
117 struct args_ismountpoint ismountpoint
;
123 static inline void init_autofs_dev_ioctl(struct autofs_dev_ioctl
*in
)
125 memset(in
, 0, sizeof(struct autofs_dev_ioctl
));
126 in
->ver_major
= AUTOFS_DEV_IOCTL_VERSION_MAJOR
;
127 in
->ver_minor
= AUTOFS_DEV_IOCTL_VERSION_MINOR
;
128 in
->size
= sizeof(struct autofs_dev_ioctl
);
134 * If you change this make sure you make the corresponding change
135 * to autofs-dev-ioctl.c:lookup_ioctl()
138 /* Get various version info */
139 AUTOFS_DEV_IOCTL_VERSION_CMD
= 0x71,
140 AUTOFS_DEV_IOCTL_PROTOVER_CMD
,
141 AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD
,
143 /* Open mount ioctl fd */
144 AUTOFS_DEV_IOCTL_OPENMOUNT_CMD
,
146 /* Close mount ioctl fd */
147 AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD
,
149 /* Mount/expire status returns */
150 AUTOFS_DEV_IOCTL_READY_CMD
,
151 AUTOFS_DEV_IOCTL_FAIL_CMD
,
153 /* Activate/deactivate autofs mount */
154 AUTOFS_DEV_IOCTL_SETPIPEFD_CMD
,
155 AUTOFS_DEV_IOCTL_CATATONIC_CMD
,
158 AUTOFS_DEV_IOCTL_TIMEOUT_CMD
,
160 /* Get mount last requesting uid and gid */
161 AUTOFS_DEV_IOCTL_REQUESTER_CMD
,
163 /* Check for eligible expire candidates */
164 AUTOFS_DEV_IOCTL_EXPIRE_CMD
,
166 /* Request busy status */
167 AUTOFS_DEV_IOCTL_ASKUMOUNT_CMD
,
169 /* Check if path is a mountpoint */
170 AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD
,
173 #define AUTOFS_IOCTL 0x93
175 #define AUTOFS_DEV_IOCTL_VERSION \
176 _IOWR(AUTOFS_IOCTL, \
177 AUTOFS_DEV_IOCTL_VERSION_CMD, struct autofs_dev_ioctl)
179 #define AUTOFS_DEV_IOCTL_PROTOVER \
180 _IOWR(AUTOFS_IOCTL, \
181 AUTOFS_DEV_IOCTL_PROTOVER_CMD, struct autofs_dev_ioctl)
183 #define AUTOFS_DEV_IOCTL_PROTOSUBVER \
184 _IOWR(AUTOFS_IOCTL, \
185 AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD, struct autofs_dev_ioctl)
187 #define AUTOFS_DEV_IOCTL_OPENMOUNT \
188 _IOWR(AUTOFS_IOCTL, \
189 AUTOFS_DEV_IOCTL_OPENMOUNT_CMD, struct autofs_dev_ioctl)
191 #define AUTOFS_DEV_IOCTL_CLOSEMOUNT \
192 _IOWR(AUTOFS_IOCTL, \
193 AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD, struct autofs_dev_ioctl)
195 #define AUTOFS_DEV_IOCTL_READY \
196 _IOWR(AUTOFS_IOCTL, \
197 AUTOFS_DEV_IOCTL_READY_CMD, struct autofs_dev_ioctl)
199 #define AUTOFS_DEV_IOCTL_FAIL \
200 _IOWR(AUTOFS_IOCTL, \
201 AUTOFS_DEV_IOCTL_FAIL_CMD, struct autofs_dev_ioctl)
203 #define AUTOFS_DEV_IOCTL_SETPIPEFD \
204 _IOWR(AUTOFS_IOCTL, \
205 AUTOFS_DEV_IOCTL_SETPIPEFD_CMD, struct autofs_dev_ioctl)
207 #define AUTOFS_DEV_IOCTL_CATATONIC \
208 _IOWR(AUTOFS_IOCTL, \
209 AUTOFS_DEV_IOCTL_CATATONIC_CMD, struct autofs_dev_ioctl)
211 #define AUTOFS_DEV_IOCTL_TIMEOUT \
212 _IOWR(AUTOFS_IOCTL, \
213 AUTOFS_DEV_IOCTL_TIMEOUT_CMD, struct autofs_dev_ioctl)
215 #define AUTOFS_DEV_IOCTL_REQUESTER \
216 _IOWR(AUTOFS_IOCTL, \
217 AUTOFS_DEV_IOCTL_REQUESTER_CMD, struct autofs_dev_ioctl)
219 #define AUTOFS_DEV_IOCTL_EXPIRE \
220 _IOWR(AUTOFS_IOCTL, \
221 AUTOFS_DEV_IOCTL_EXPIRE_CMD, struct autofs_dev_ioctl)
223 #define AUTOFS_DEV_IOCTL_ASKUMOUNT \
224 _IOWR(AUTOFS_IOCTL, \
225 AUTOFS_DEV_IOCTL_ASKUMOUNT_CMD, struct autofs_dev_ioctl)
227 #define AUTOFS_DEV_IOCTL_ISMOUNTPOINT \
228 _IOWR(AUTOFS_IOCTL, \
229 AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD, struct autofs_dev_ioctl)
231 static const struct ioctl autofs_ioctls
[] = {
232 IOCTL(AUTOFS_IOC_READY
),
233 IOCTL(AUTOFS_IOC_FAIL
),
234 IOCTL(AUTOFS_IOC_CATATONIC
),
235 IOCTL(AUTOFS_IOC_PROTOVER
),
236 /* IOCTL(AUTOFS_IOC_SETTIMEOUT32), */
237 IOCTL(AUTOFS_IOC_SETTIMEOUT
),
238 IOCTL(AUTOFS_IOC_EXPIRE
),
239 IOCTL(AUTOFS_IOC_EXPIRE_MULTI
),
240 IOCTL(AUTOFS_IOC_EXPIRE_INDIRECT
),
241 IOCTL(AUTOFS_IOC_EXPIRE_DIRECT
),
242 IOCTL(AUTOFS_IOC_PROTOSUBVER
),
243 IOCTL(AUTOFS_IOC_ASKUMOUNT
),
245 IOCTL(AUTOFS_DEV_IOCTL_VERSION
),
246 IOCTL(AUTOFS_DEV_IOCTL_PROTOVER
),
247 IOCTL(AUTOFS_DEV_IOCTL_PROTOSUBVER
),
248 IOCTL(AUTOFS_DEV_IOCTL_OPENMOUNT
),
249 IOCTL(AUTOFS_DEV_IOCTL_CLOSEMOUNT
),
250 IOCTL(AUTOFS_DEV_IOCTL_READY
),
251 IOCTL(AUTOFS_DEV_IOCTL_FAIL
),
252 IOCTL(AUTOFS_DEV_IOCTL_SETPIPEFD
),
253 IOCTL(AUTOFS_DEV_IOCTL_CATATONIC
),
254 IOCTL(AUTOFS_DEV_IOCTL_TIMEOUT
),
255 IOCTL(AUTOFS_DEV_IOCTL_REQUESTER
),
256 IOCTL(AUTOFS_DEV_IOCTL_EXPIRE
),
257 IOCTL(AUTOFS_DEV_IOCTL_ASKUMOUNT
),
258 IOCTL(AUTOFS_DEV_IOCTL_ISMOUNTPOINT
),
261 static const char *const autofs_devs
[] = {
265 static void autofs_sanitise(const struct ioctl_group
*grp
, int childno
)
268 struct autofs_dev_ioctl
*arg
;
270 pick_random_ioctl(grp
, childno
);
272 shm
->a3
[childno
] = (unsigned long) page_rand
;
274 switch (shm
->a2
[childno
]) {
275 case AUTOFS_DEV_IOCTL_VERSION
:
276 case AUTOFS_DEV_IOCTL_PROTOVER
:
277 case AUTOFS_DEV_IOCTL_PROTOSUBVER
:
278 case AUTOFS_DEV_IOCTL_OPENMOUNT
:
279 case AUTOFS_DEV_IOCTL_CLOSEMOUNT
:
280 case AUTOFS_DEV_IOCTL_READY
:
281 case AUTOFS_DEV_IOCTL_FAIL
:
282 case AUTOFS_DEV_IOCTL_SETPIPEFD
:
283 case AUTOFS_DEV_IOCTL_CATATONIC
:
284 case AUTOFS_DEV_IOCTL_TIMEOUT
:
285 case AUTOFS_DEV_IOCTL_REQUESTER
:
286 case AUTOFS_DEV_IOCTL_EXPIRE
:
287 case AUTOFS_DEV_IOCTL_ASKUMOUNT
:
288 case AUTOFS_DEV_IOCTL_ISMOUNTPOINT
:
289 arg
= (struct autofs_dev_ioctl
*)shm
->a3
[childno
];
290 init_autofs_dev_ioctl(arg
);
291 arg
->ioctlfd
= get_random_fd();
292 arg
->fail
.token
= rand();
293 arg
->fail
.status
= rand();
297 arg
->path
[1] = rand();
298 arg
->path
[2] = rand();
299 arg
->path
[3] = rand();
303 for (i
=0; i
< 10; ++i
)
304 arg
->path
[i
] = rand();
312 static const struct ioctl_group autofs_grp
= {
315 .devs_cnt
= ARRAY_SIZE(autofs_devs
),
316 .sanitise
= autofs_sanitise
,
317 .ioctls
= autofs_ioctls
,
318 .ioctls_cnt
= ARRAY_SIZE(autofs_ioctls
),
321 REG_IOCTL_GROUP(autofs_grp
)