Debian Codegraph @

patches/autofs4-2.6.28-v5-update-20090903.patch

raw
1 --- linux-2.6.28.orig/fs/autofs4/autofs_i.h
2 +++ linux-2.6.28/fs/autofs4/autofs_i.h
3 @@ -25,8 +25,6 @@
4 #define AUTOFS_DEV_IOCTL_IOC_FIRST (AUTOFS_DEV_IOCTL_VERSION)
5 #define AUTOFS_DEV_IOCTL_IOC_COUNT (AUTOFS_IOC_COUNT - 11)
6
7 -#define AUTOFS_TYPE_TRIGGER (AUTOFS_TYPE_DIRECT|AUTOFS_TYPE_OFFSET)
8 -
9 #include <linux/kernel.h>
10 #include <linux/slab.h>
11 #include <linux/time.h>
12 @@ -188,6 +186,8 @@ int autofs4_expire_wait(struct dentry *d
13 int autofs4_expire_run(struct super_block *, struct vfsmount *,
14 struct autofs_sb_info *,
15 struct autofs_packet_expire __user *);
16 +int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt,
17 + struct autofs_sb_info *sbi, int when);
18 int autofs4_expire_multi(struct super_block *, struct vfsmount *,
19 struct autofs_sb_info *, int __user *);
20 struct dentry *autofs4_expire_direct(struct super_block *sb,
21 --- linux-2.6.28.orig/fs/autofs4/dev-ioctl.c
22 +++ linux-2.6.28/fs/autofs4/dev-ioctl.c
23 @@ -124,7 +124,7 @@ static inline void free_dev_ioctl(struct
24
25 /*
26 * Check sanity of parameter control fields and if a path is present
27 - * check that it has a "/" and is terminated.
28 + * check that it is terminated and contains at least one "/".
29 */
30 static int validate_dev_ioctl(int cmd, struct autofs_dev_ioctl *param)
31 {
32 @@ -138,15 +138,16 @@ static int validate_dev_ioctl(int cmd, s
33 }
34
35 if (param->size > sizeof(*param)) {
36 - err = check_name(param->path);
37 + err = invalid_str(param->path,
38 + (void *) ((size_t) param + param->size));
39 if (err) {
40 - AUTOFS_WARN("invalid path supplied for cmd(0x%08x)",
41 - cmd);
42 + AUTOFS_WARN(
43 + "path string terminator missing for cmd(0x%08x)",
44 + cmd);
45 goto out;
46 }
47
48 - err = invalid_str(param->path,
49 - (void *) ((size_t) param + param->size));
50 + err = check_name(param->path);
51 if (err) {
52 AUTOFS_WARN("invalid path supplied for cmd(0x%08x)",
53 cmd);
54 @@ -180,7 +181,7 @@ static int autofs_dev_ioctl_protover(str
55 struct autofs_sb_info *sbi,
56 struct autofs_dev_ioctl *param)
57 {
58 - param->arg1 = sbi->version;
59 + param->protover.version = sbi->version;
60 return 0;
61 }
62
63 @@ -189,7 +190,7 @@ static int autofs_dev_ioctl_protosubver(
64 struct autofs_sb_info *sbi,
65 struct autofs_dev_ioctl *param)
66 {
67 - param->arg1 = sbi->sub_version;
68 + param->protosubver.sub_version = sbi->sub_version;
69 return 0;
70 }
71
72 @@ -334,13 +335,13 @@ static int autofs_dev_ioctl_openmount(st
73 int err, fd;
74
75 /* param->path has already been checked */
76 - if (!param->arg1)
77 + if (!param->openmount.devid)
78 return -EINVAL;
79
80 param->ioctlfd = -1;
81
82 path = param->path;
83 - devid = param->arg1;
84 + devid = param->openmount.devid;
85
86 err = 0;
87 fd = autofs_dev_ioctl_open_mountpoint(path, devid);
88 @@ -372,7 +373,7 @@ static int autofs_dev_ioctl_ready(struct
89 {
90 autofs_wqt_t token;
91
92 - token = (autofs_wqt_t) param->arg1;
93 + token = (autofs_wqt_t) param->ready.token;
94 return autofs4_wait_release(sbi, token, 0);
95 }
96
97 @@ -387,8 +388,8 @@ static int autofs_dev_ioctl_fail(struct
98 autofs_wqt_t token;
99 int status;
100
101 - token = (autofs_wqt_t) param->arg1;
102 - status = param->arg2 ? param->arg2 : -ENOENT;
103 + token = (autofs_wqt_t) param->fail.token;
104 + status = param->fail.status ? param->fail.status : -ENOENT;
105 return autofs4_wait_release(sbi, token, status);
106 }
107
108 @@ -411,10 +412,10 @@ static int autofs_dev_ioctl_setpipefd(st
109 int pipefd;
110 int err = 0;
111
112 - if (param->arg1 == -1)
113 + if (param->setpipefd.pipefd == -1)
114 return -EINVAL;
115
116 - pipefd = param->arg1;
117 + pipefd = param->setpipefd.pipefd;
118
119 mutex_lock(&sbi->wq_mutex);
120 if (!sbi->catatonic) {
121 @@ -456,8 +457,8 @@ static int autofs_dev_ioctl_timeout(stru
122 {
123 unsigned long timeout;
124
125 - timeout = param->arg1;
126 - param->arg1 = sbi->exp_timeout / HZ;
127 + timeout = param->timeout.timeout;
128 + param->timeout.timeout = sbi->exp_timeout / HZ;
129 sbi->exp_timeout = timeout * HZ;
130 return 0;
131 }
132 @@ -488,7 +489,7 @@ static int autofs_dev_ioctl_requester(st
133 path = param->path;
134 devid = sbi->sb->s_dev;
135
136 - param->arg1 = param->arg2 = -1;
137 + param->requester.uid = param->requester.gid = -1;
138
139 /* Get nameidata of the parent directory */
140 err = path_lookup(path, LOOKUP_PARENT, &nd);
141 @@ -504,8 +505,8 @@ static int autofs_dev_ioctl_requester(st
142 err = 0;
143 autofs4_expire_wait(nd.path.dentry);
144 spin_lock(&sbi->fs_lock);
145 - param->arg1 = ino->uid;
146 - param->arg2 = ino->gid;
147 + param->requester.uid = ino->uid;
148 + param->requester.gid = ino->gid;
149 spin_unlock(&sbi->fs_lock);
150 }
151
152 @@ -523,40 +524,13 @@ static int autofs_dev_ioctl_expire(struc
153 struct autofs_sb_info *sbi,
154 struct autofs_dev_ioctl *param)
155 {
156 - struct dentry *dentry;
157 struct vfsmount *mnt;
158 - int err = -EAGAIN;
159 int how;
160
161 - how = param->arg1;
162 + how = param->expire.how;
163 mnt = fp->f_path.mnt;
164
165 - if (sbi->type & AUTOFS_TYPE_TRIGGER)
166 - dentry = autofs4_expire_direct(sbi->sb, mnt, sbi, how);
167 - else
168 - dentry = autofs4_expire_indirect(sbi->sb, mnt, sbi, how);
169 -
170 - if (dentry) {
171 - struct autofs_info *ino = autofs4_dentry_ino(dentry);
172 -
173 - /*
174 - * This is synchronous because it makes the daemon a
175 - * little easier
176 - */
177 - err = autofs4_wait(sbi, dentry, NFY_EXPIRE);
178 -
179 - spin_lock(&sbi->fs_lock);
180 - if (ino->flags & AUTOFS_INF_MOUNTPOINT) {
181 - ino->flags &= ~AUTOFS_INF_MOUNTPOINT;
182 - sbi->sb->s_root->d_mounted++;
183 - }
184 - ino->flags &= ~AUTOFS_INF_EXPIRING;
185 - complete_all(&ino->expire_complete);
186 - spin_unlock(&sbi->fs_lock);
187 - dput(dentry);
188 - }
189 -
190 - return err;
191 + return autofs4_do_expire_multi(sbi->sb, mnt, sbi, how);
192 }
193
194 /* Check if autofs mount point is in use */
195 @@ -564,9 +538,9 @@ static int autofs_dev_ioctl_askumount(st
196 struct autofs_sb_info *sbi,
197 struct autofs_dev_ioctl *param)
198 {
199 - param->arg1 = 0;
200 + param->askumount.may_umount = 0;
201 if (may_umount(fp->f_path.mnt))
202 - param->arg1 = 1;
203 + param->askumount.may_umount = 1;
204 return 0;
205 }
206
207 @@ -599,6 +573,7 @@ static int autofs_dev_ioctl_ismountpoint
208 struct nameidata nd;
209 const char *path;
210 unsigned int type;
211 + unsigned int devid, magic;
212 int err = -ENOENT;
213
214 if (param->size <= sizeof(*param)) {
215 @@ -607,13 +582,13 @@ static int autofs_dev_ioctl_ismountpoint
216 }
217
218 path = param->path;
219 - type = param->arg1;
220 + type = param->ismountpoint.in.type;
221
222 - param->arg1 = 0;
223 - param->arg2 = 0;
224 + param->ismountpoint.out.devid = devid = 0;
225 + param->ismountpoint.out.magic = magic = 0;
226
227 if (!fp || param->ioctlfd == -1) {
228 - if (type == AUTOFS_TYPE_ANY) {
229 + if (autofs_type_any(type)) {
230 struct super_block *sb;
231
232 err = path_lookup(path, LOOKUP_FOLLOW, &nd);
233 @@ -621,7 +596,7 @@ static int autofs_dev_ioctl_ismountpoint
234 goto out;
235
236 sb = nd.path.dentry->d_sb;
237 - param->arg1 = new_encode_dev(sb->s_dev);
238 + devid = new_encode_dev(sb->s_dev);
239 } else {
240 struct autofs_info *ino;
241
242 @@ -634,38 +609,41 @@ static int autofs_dev_ioctl_ismountpoint
243 goto out_release;
244
245 ino = autofs4_dentry_ino(nd.path.dentry);
246 - param->arg1 = autofs4_get_dev(ino->sbi);
247 + devid = autofs4_get_dev(ino->sbi);
248 }
249
250 err = 0;
251 if (nd.path.dentry->d_inode &&
252 nd.path.mnt->mnt_root == nd.path.dentry) {
253 err = 1;
254 - param->arg2 = nd.path.dentry->d_inode->i_sb->s_magic;
255 + magic = nd.path.dentry->d_inode->i_sb->s_magic;
256 }
257 } else {
258 - dev_t devid = new_encode_dev(sbi->sb->s_dev);
259 + dev_t dev = autofs4_get_dev(sbi);
260
261 err = path_lookup(path, LOOKUP_PARENT, &nd);
262 if (err)
263 goto out;
264
265 - err = autofs_dev_ioctl_find_super(&nd, devid);
266 + err = autofs_dev_ioctl_find_super(&nd, dev);
267 if (err)
268 goto out_release;
269
270 - param->arg1 = autofs4_get_dev(sbi);
271 + devid = dev;
272
273 err = have_submounts(nd.path.dentry);
274
275 if (nd.path.mnt->mnt_mountpoint != nd.path.mnt->mnt_root) {
276 if (follow_down(&nd.path.mnt, &nd.path.dentry)) {
277 struct inode *inode = nd.path.dentry->d_inode;
278 - param->arg2 = inode->i_sb->s_magic;
279 + magic = inode->i_sb->s_magic;
280 }
281 }
282 }
283
284 + param->ismountpoint.out.devid = devid;
285 + param->ismountpoint.out.magic = magic;
286 +
287 out_release:
288 path_put(&nd.path);
289 out:
290 --- linux-2.6.28.orig/fs/autofs4/expire.c
291 +++ linux-2.6.28/fs/autofs4/expire.c
292 @@ -63,15 +63,17 @@ static int autofs4_mount_busy(struct vfs
293 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
294
295 /* This is an autofs submount, we can't expire it */
296 - if (sbi->type == AUTOFS_TYPE_INDIRECT)
297 + if (autofs_type_indirect(sbi->type))
298 goto done;
299
300 /*
301 * Otherwise it's an offset mount and we need to check
302 * if we can umount its mount, if there is one.
303 */
304 - if (!d_mountpoint(dentry))
305 + if (!d_mountpoint(dentry)) {
306 + status = 0;
307 goto done;
308 + }
309 }
310
311 /* Update the expiry counter if fs is busy */
312 @@ -478,22 +480,16 @@ int autofs4_expire_run(struct super_bloc
313 return ret;
314 }
315
316 -/* Call repeatedly until it returns -EAGAIN, meaning there's nothing
317 - more to be done */
318 -int autofs4_expire_multi(struct super_block *sb, struct vfsmount *mnt,
319 - struct autofs_sb_info *sbi, int __user *arg)
320 +int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt,
321 + struct autofs_sb_info *sbi, int when)
322 {
323 struct dentry *dentry;
324 int ret = -EAGAIN;
325 - int do_now = 0;
326
327 - if (arg && get_user(do_now, arg))
328 - return -EFAULT;
329 -
330 - if (sbi->type & AUTOFS_TYPE_TRIGGER)
331 - dentry = autofs4_expire_direct(sb, mnt, sbi, do_now);
332 + if (autofs_type_trigger(sbi->type))
333 + dentry = autofs4_expire_direct(sb, mnt, sbi, when);
334 else
335 - dentry = autofs4_expire_indirect(sb, mnt, sbi, do_now);
336 + dentry = autofs4_expire_indirect(sb, mnt, sbi, when);
337
338 if (dentry) {
339 struct autofs_info *ino = autofs4_dentry_ino(dentry);
340 @@ -516,3 +512,16 @@ int autofs4_expire_multi(struct super_bl
341 return ret;
342 }
343
344 +/* Call repeatedly until it returns -EAGAIN, meaning there's nothing
345 + more to be done */
346 +int autofs4_expire_multi(struct super_block *sb, struct vfsmount *mnt,
347 + struct autofs_sb_info *sbi, int __user *arg)
348 +{
349 + int do_now = 0;
350 +
351 + if (arg && get_user(do_now, arg))
352 + return -EFAULT;
353 +
354 + return autofs4_do_expire_multi(sb, mnt, sbi, do_now);
355 +}
356 +
357 --- linux-2.6.28.orig/fs/autofs4/inode.c
358 +++ linux-2.6.28/fs/autofs4/inode.c
359 @@ -197,9 +197,9 @@ static int autofs4_show_options(struct s
360 seq_printf(m, ",minproto=%d", sbi->min_proto);
361 seq_printf(m, ",maxproto=%d", sbi->max_proto);
362
363 - if (sbi->type & AUTOFS_TYPE_OFFSET)
364 + if (autofs_type_offset(sbi->type))
365 seq_printf(m, ",offset");
366 - else if (sbi->type & AUTOFS_TYPE_DIRECT)
367 + else if (autofs_type_direct(sbi->type))
368 seq_printf(m, ",direct");
369 else
370 seq_printf(m, ",indirect");
371 @@ -284,13 +284,13 @@ static int parse_options(char *options,
372 *maxproto = option;
373 break;
374 case Opt_indirect:
375 - *type = AUTOFS_TYPE_INDIRECT;
376 + set_autofs_type_indirect(type);
377 break;
378 case Opt_direct:
379 - *type = AUTOFS_TYPE_DIRECT;
380 + set_autofs_type_direct(type);
381 break;
382 case Opt_offset:
383 - *type = AUTOFS_TYPE_OFFSET;
384 + set_autofs_type_offset(type);
385 break;
386 default:
387 return 1;
388 @@ -338,7 +338,7 @@ int autofs4_fill_super(struct super_bloc
389 sbi->sb = s;
390 sbi->version = 0;
391 sbi->sub_version = 0;
392 - sbi->type = AUTOFS_TYPE_INDIRECT;
393 + set_autofs_type_indirect(&sbi->type);
394 sbi->min_proto = 0;
395 sbi->max_proto = 0;
396 mutex_init(&sbi->wq_mutex);
397 @@ -380,7 +380,7 @@ int autofs4_fill_super(struct super_bloc
398 }
399
400 root_inode->i_fop = &autofs4_root_operations;
401 - root_inode->i_op = sbi->type & AUTOFS_TYPE_TRIGGER ?
402 + root_inode->i_op = autofs_type_trigger(sbi->type) ?
403 &autofs4_direct_root_inode_operations :
404 &autofs4_indirect_root_inode_operations;
405
406 --- linux-2.6.28.orig/fs/autofs4/waitq.c
407 +++ linux-2.6.28/fs/autofs4/waitq.c
408 @@ -297,20 +297,14 @@ static int validate_request(struct autof
409 */
410 if (notify == NFY_MOUNT) {
411 /*
412 - * If the dentry isn't hashed just go ahead and try the
413 - * mount again with a new wait (not much else we can do).
414 - */
415 - if (!d_unhashed(dentry)) {
416 - /*
417 - * But if the dentry is hashed, that means that we
418 - * got here through the revalidate path. Thus, we
419 - * need to check if the dentry has been mounted
420 - * while we waited on the wq_mutex. If it has,
421 - * simply return success.
422 - */
423 - if (d_mountpoint(dentry))
424 - return 0;
425 - }
426 + * If the dentry was successfully mounted while we slept
427 + * on the wait queue mutex we can return success. If it
428 + * isn't mounted (doesn't have submounts for the case of
429 + * a multi-mount with no mount at it's base) we can
430 + * continue on and create a new request.
431 + */
432 + if (have_submounts(dentry))
433 + return 0;
434 }
435
436 return 1;
437 @@ -337,7 +331,7 @@ int autofs4_wait(struct autofs_sb_info *
438 * is very similar for indirect mounts except only dentrys
439 * in the root of the autofs file system may be negative.
440 */
441 - if (sbi->type & AUTOFS_TYPE_TRIGGER)
442 + if (autofs_type_trigger(sbi->type))
443 return -ENOENT;
444 else if (!IS_ROOT(dentry->d_parent))
445 return -ENOENT;
446 @@ -348,7 +342,7 @@ int autofs4_wait(struct autofs_sb_info *
447 return -ENOMEM;
448
449 /* If this is a direct mount request create a dummy name */
450 - if (IS_ROOT(dentry) && sbi->type & AUTOFS_TYPE_TRIGGER)
451 + if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
452 qstr.len = sprintf(name, "%p", dentry);
453 else {
454 qstr.len = autofs4_getpath(sbi, dentry, &name);
455 @@ -406,11 +400,11 @@ int autofs4_wait(struct autofs_sb_info *
456 type = autofs_ptype_expire_multi;
457 } else {
458 if (notify == NFY_MOUNT)
459 - type = (sbi->type & AUTOFS_TYPE_TRIGGER) ?
460 + type = autofs_type_trigger(sbi->type) ?
461 autofs_ptype_missing_direct :
462 autofs_ptype_missing_indirect;
463 else
464 - type = (sbi->type & AUTOFS_TYPE_TRIGGER) ?
465 + type = autofs_type_trigger(sbi->type) ?
466 autofs_ptype_expire_direct :
467 autofs_ptype_expire_indirect;
468 }
469 --- linux-2.6.28.orig/include/linux/auto_fs4.h
470 +++ linux-2.6.28/include/linux/auto_fs4.h
471 @@ -29,10 +29,64 @@
472 #define AUTOFS_EXP_IMMEDIATE 1
473 #define AUTOFS_EXP_LEAVES 2
474
475 -#define AUTOFS_TYPE_ANY 0x0000
476 -#define AUTOFS_TYPE_INDIRECT 0x0001
477 -#define AUTOFS_TYPE_DIRECT 0x0002
478 -#define AUTOFS_TYPE_OFFSET 0x0004
479 +#define AUTOFS_TYPE_ANY 0U
480 +#define AUTOFS_TYPE_INDIRECT 1U
481 +#define AUTOFS_TYPE_DIRECT 2U
482 +#define AUTOFS_TYPE_OFFSET 4U
483 +
484 +static inline void set_autofs_type_indirect(unsigned int *type)
485 +{
486 + *type = AUTOFS_TYPE_INDIRECT;
487 + return;
488 +}
489 +
490 +static inline unsigned int autofs_type_indirect(unsigned int type)
491 +{
492 + return (type == AUTOFS_TYPE_INDIRECT);
493 +}
494 +
495 +static inline void set_autofs_type_direct(unsigned int *type)
496 +{
497 + *type = AUTOFS_TYPE_DIRECT;
498 + return;
499 +}
500 +
501 +static inline unsigned int autofs_type_direct(unsigned int type)
502 +{
503 + return (type == AUTOFS_TYPE_DIRECT);
504 +}
505 +
506 +static inline void set_autofs_type_offset(unsigned int *type)
507 +{
508 + *type = AUTOFS_TYPE_OFFSET;
509 + return;
510 +}
511 +
512 +static inline unsigned int autofs_type_offset(unsigned int type)
513 +{
514 + return (type == AUTOFS_TYPE_OFFSET);
515 +}
516 +
517 +static inline unsigned int autofs_type_trigger(unsigned int type)
518 +{
519 + return (type == AUTOFS_TYPE_DIRECT || type == AUTOFS_TYPE_OFFSET);
520 +}
521 +
522 +/*
523 + * This isn't really a type as we use it to say "no type set" to
524 + * indicate we want to search for "any" mount in the
525 + * autofs_dev_ioctl_ismountpoint() device ioctl function.
526 + */
527 +static inline void set_autofs_type_any(unsigned int *type)
528 +{
529 + *type = AUTOFS_TYPE_ANY;
530 + return;
531 +}
532 +
533 +static inline unsigned int autofs_type_any(unsigned int type)
534 +{
535 + return (type == AUTOFS_TYPE_ANY);
536 +}
537
538 /* Daemon notification packet types */
539 enum autofs_notify {
540 --- linux-2.6.28.orig/Documentation/filesystems/autofs4-mount-control.txt
541 +++ linux-2.6.28/Documentation/filesystems/autofs4-mount-control.txt
542 @@ -179,8 +179,21 @@ struct autofs_dev_ioctl {
543 * including this struct */
544 __s32 ioctlfd; /* automount command fd */
545
546 - __u32 arg1; /* Command parameters */
547 - __u32 arg2;
548 + /* Command parameters */
549 +
550 + union {
551 + struct args_protover protover;
552 + struct args_protosubver protosubver;
553 + struct args_openmount openmount;
554 + struct args_ready ready;
555 + struct args_fail fail;
556 + struct args_setpipefd setpipefd;
557 + struct args_timeout timeout;
558 + struct args_requester requester;
559 + struct args_expire expire;
560 + struct args_askumount askumount;
561 + struct args_ismountpoint ismountpoint;
562 + };
563
564 char path[0];
565 };
566 @@ -192,8 +205,8 @@ optionally be used to check a specific m
567 mount point file descriptor, and when requesting the uid and gid of the
568 last successful mount on a directory within the autofs file system.
569
570 -The fields arg1 and arg2 are used to communicate parameters and results of
571 -calls made as described below.
572 +The anonymous union is used to communicate parameters and results of calls
573 +made as described below.
574
575 The path field is used to pass a path where it is needed and the size field
576 is used account for the increased structure length when translating the
577 @@ -245,25 +258,27 @@ AUTOFS_DEV_IOCTL_PROTOVER_CMD and AUTOFS
578 Get the major and minor version of the autofs4 protocol version understood
579 by loaded module. This call requires an initialized struct autofs_dev_ioctl
580 with the ioctlfd field set to a valid autofs mount point descriptor
581 -and sets the requested version number in structure field arg1. These
582 -commands return 0 on success or one of the negative error codes if
583 -validation fails.
584 +and sets the requested version number in structure field protover.version
585 +and ptotosubver.sub_version respectively. These commands return 0 on
586 +success or one of the negative error codes if validation fails.
587
588
589 -AUTOFS_DEV_IOCTL_OPENMOUNT and AUTOFS_DEV_IOCTL_CLOSEMOUNT
590 -----------------------------------------------------------
591 +AUTOFS_DEV_IOCTL_OPENMOUNT_CMD and AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD
592 +------------------------------------------------------------------
593
594 Obtain and release a file descriptor for an autofs managed mount point
595 path. The open call requires an initialized struct autofs_dev_ioctl with
596 the the path field set and the size field adjusted appropriately as well
597 -as the arg1 field set to the device number of the autofs mount. The
598 -device number can be obtained from the mount options shown in
599 -/proc/mounts. The close call requires an initialized struct
600 -autofs_dev_ioct with the ioctlfd field set to the descriptor obtained
601 -from the open call. The release of the file descriptor can also be done
602 -with close(2) so any open descriptors will also be closed at process exit.
603 -The close call is included in the implemented operations largely for
604 -completeness and to provide for a consistent user space implementation.
605 +as the openmount.devid field set to the device number of the autofs mount.
606 +The device number of an autofs mounted filesystem can be obtained by using
607 +the AUTOFS_DEV_IOCTL_ISMOUNTPOINT ioctl function by providing the path
608 +and autofs mount type, as described below. The close call requires an
609 +initialized struct autofs_dev_ioct with the ioctlfd field set to the
610 +descriptor obtained from the open call. The release of the file descriptor
611 +can also be done with close(2) so any open descriptors will also be
612 +closed at process exit. The close call is included in the implemented
613 +operations largely for completeness and to provide for a consistent
614 +user space implementation.
615
616
617 AUTOFS_DEV_IOCTL_READY_CMD and AUTOFS_DEV_IOCTL_FAIL_CMD
618 @@ -272,10 +287,10 @@ AUTOFS_DEV_IOCTL_READY_CMD and AUTOFS_DE
619 Return mount and expire result status from user space to the kernel.
620 Both of these calls require an initialized struct autofs_dev_ioctl
621 with the ioctlfd field set to the descriptor obtained from the open
622 -call and the arg1 field set to the wait queue token number, received
623 -by user space in the foregoing mount or expire request. The arg2 field
624 -is set to the status to be returned. For the ready call this is always
625 -0 and for the fail call it is set to the errno of the operation.
626 +call and the ready.token or fail.token field set to the wait queue
627 +token number, received by user space in the foregoing mount or expire
628 +request. The fail.status field is set to the status to be returned when
629 +sending a failure notification with AUTOFS_DEV_IOCTL_FAIL_CMD.
630
631
632 AUTOFS_DEV_IOCTL_SETPIPEFD_CMD
633 @@ -290,9 +305,10 @@ mount be catatonic (see next call).
634
635 The call requires an initialized struct autofs_dev_ioctl with the
636 ioctlfd field set to the descriptor obtained from the open call and
637 -the arg1 field set to descriptor of the pipe. On success the call
638 -also sets the process group id used to identify the controlling process
639 -(eg. the owning automount(8) daemon) to the process group of the caller.
640 +the setpipefd.pipefd field set to descriptor of the pipe. On success
641 +the call also sets the process group id used to identify the controlling
642 +process (eg. the owning automount(8) daemon) to the process group of
643 +the caller.
644
645
646 AUTOFS_DEV_IOCTL_CATATONIC_CMD
647 @@ -313,6 +329,9 @@ Set the expire timeout for mounts within
648
649 The call requires an initialized struct autofs_dev_ioctl with the
650 ioctlfd field set to the descriptor obtained from the open call.
651 +The timeout.timeout field is set to the desired timeout and this
652 +field is set to the value of the value of the current timeout of
653 +the mount upon successful completion.
654
655
656 AUTOFS_DEV_IOCTL_REQUESTER_CMD
657 @@ -323,9 +342,9 @@ mount on the given path dentry.
658
659 The call requires an initialized struct autofs_dev_ioctl with the path
660 field set to the mount point in question and the size field adjusted
661 -appropriately as well as the arg1 field set to the device number of the
662 -containing autofs mount. Upon return the struct field arg1 contains the
663 -uid and arg2 the gid.
664 +appropriately as well as the ioctlfd field set to the descriptor obtained
665 +from the open call. Upon return the struct fields requester.uid and
666 +requester.gid contain the uid and gid respectively.
667
668 When reconstructing an autofs mount tree with active mounts we need to
669 re-connect to mounts that may have used the original process uid and
670 @@ -343,8 +362,8 @@ this ioctl is called until no further ex
671 The call requires an initialized struct autofs_dev_ioctl with the
672 ioctlfd field set to the descriptor obtained from the open call. In
673 addition an immediate expire, independent of the mount timeout, can be
674 -requested by setting the arg1 field to 1. If no expire candidates can
675 -be found the ioctl returns -1 with errno set to EAGAIN.
676 +requested by setting the expire.how field to 1. If no expire candidates
677 +can be found the ioctl returns -1 with errno set to EAGAIN.
678
679 This call causes the kernel module to check the mount corresponding
680 to the given ioctlfd for mounts that can be expired, issues an expire
681 @@ -357,7 +376,8 @@ Checks if an autofs mount point is in us
682
683 The call requires an initialized struct autofs_dev_ioctl with the
684 ioctlfd field set to the descriptor obtained from the open call and
685 -it returns the result in the arg1 field, 1 for busy and 0 otherwise.
686 +it returns the result in the askumount.may_umount field, 1 for busy
687 +and 0 otherwise.
688
689
690 AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD
691 @@ -367,14 +387,15 @@ Check if the given path is a mountpoint.
692
693 The call requires an initialized struct autofs_dev_ioctl. There are two
694 possible variations. Both use the path field set to the path of the mount
695 -point to check and the size field adjusted appropriately. One uses the
696 -ioctlfd field to identify a specific mount point to check while the other
697 -variation uses the path and optionaly arg1 set to an autofs mount type.
698 -The call returns 1 if this is a mount point and sets arg1 to the device
699 -number of the mount and field arg2 to the relevant super block magic
700 -number (described below) or 0 if it isn't a mountpoint. In both cases
701 -the the device number (as returned by new_encode_dev()) is returned
702 -in field arg1.
703 +point to check and the size field must be adjusted appropriately. One uses
704 +the ioctlfd field to identify a specific mount point to check while the
705 +other variation uses the path and optionaly the ismountpoint.in.type
706 +field set to an autofs mount type. The call returns 1 if this is a mount
707 +point and sets the ismountpoint.out.devid field to the device number of
708 +the mount and the ismountpoint.out.magic field to the relevant super
709 +block magic number (described below) or 0 if it isn't a mountpoint. In
710 +both cases the the device number (as returned by new_encode_dev()) is
711 +returned in the ismountpoint.out.devid field.
712
713 If supplied with a file descriptor we're looking for a specific mount,
714 not necessarily at the top of the mounted stack. In this case the path
715 --- linux-2.6.28.orig/include/linux/auto_dev-ioctl.h
716 +++ linux-2.6.28/include/linux/auto_dev-ioctl.h
717 @@ -10,7 +10,13 @@
718 #ifndef _LINUX_AUTO_DEV_IOCTL_H
719 #define _LINUX_AUTO_DEV_IOCTL_H
720
721 -#include <linux/types.h>
722 +#include <linux/auto_fs.h>
723 +
724 +#ifdef __KERNEL__
725 +#include <linux/string.h>
726 +#else
727 +#include <string.h>
728 +#endif /* __KERNEL__ */
729
730 #define AUTOFS_DEVICE_NAME "autofs"
731
732 @@ -25,6 +31,60 @@
733 * An ioctl interface for autofs mount point control.
734 */
735
736 +struct args_protover {
737 + __u32 version;
738 +};
739 +
740 +struct args_protosubver {
741 + __u32 sub_version;
742 +};
743 +
744 +struct args_openmount {
745 + __u32 devid;
746 +};
747 +
748 +struct args_ready {
749 + __u32 token;
750 +};
751 +
752 +struct args_fail {
753 + __u32 token;
754 + __s32 status;
755 +};
756 +
757 +struct args_setpipefd {
758 + __s32 pipefd;
759 +};
760 +
761 +struct args_timeout {
762 + __u64 timeout;
763 +};
764 +
765 +struct args_requester {
766 + __u32 uid;
767 + __u32 gid;
768 +};
769 +
770 +struct args_expire {
771 + __u32 how;
772 +};
773 +
774 +struct args_askumount {
775 + __u32 may_umount;
776 +};
777 +
778 +struct args_ismountpoint {
779 + union {
780 + struct args_in {
781 + __u32 type;
782 + } in;
783 + struct args_out {
784 + __u32 devid;
785 + __u32 magic;
786 + } out;
787 + };
788 +};
789 +
790 /*
791 * All the ioctls use this structure.
792 * When sending a path size must account for the total length
793 @@ -39,20 +99,32 @@ struct autofs_dev_ioctl {
794 * including this struct */
795 __s32 ioctlfd; /* automount command fd */
796
797 - __u32 arg1; /* Command parameters */
798 - __u32 arg2;
799 + /* Command parameters */
800 +
801 + union {
802 + struct args_protover protover;
803 + struct args_protosubver protosubver;
804 + struct args_openmount openmount;
805 + struct args_ready ready;
806 + struct args_fail fail;
807 + struct args_setpipefd setpipefd;
808 + struct args_timeout timeout;
809 + struct args_requester requester;
810 + struct args_expire expire;
811 + struct args_askumount askumount;
812 + struct args_ismountpoint ismountpoint;
813 + };
814
815 char path[0];
816 };
817
818 static inline void init_autofs_dev_ioctl(struct autofs_dev_ioctl *in)
819 {
820 + memset(in, 0, sizeof(struct autofs_dev_ioctl));
821 in->ver_major = AUTOFS_DEV_IOCTL_VERSION_MAJOR;
822 in->ver_minor = AUTOFS_DEV_IOCTL_VERSION_MINOR;
823 in->size = sizeof(struct autofs_dev_ioctl);
824 in->ioctlfd = -1;
825 - in->arg1 = 0;
826 - in->arg2 = 0;
827 return;
828 }
829
830 --- linux-2.6.28.orig/fs/autofs4/root.c
831 +++ linux-2.6.28/fs/autofs4/root.c
832 @@ -485,22 +485,6 @@ static struct dentry *autofs4_lookup(str
833 DPRINTK("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d",
834 current->pid, task_pgrp_nr(current), sbi->catatonic, oz_mode);
835
836 - expiring = autofs4_lookup_expiring(sbi, dentry->d_parent, &dentry->d_name);
837 - if (expiring) {
838 - /*
839 - * If we are racing with expire the request might not
840 - * be quite complete but the directory has been removed
841 - * so it must have been successful, so just wait for it.
842 - */
843 - ino = autofs4_dentry_ino(expiring);
844 - autofs4_expire_wait(expiring);
845 - spin_lock(&sbi->lookup_lock);
846 - if (!list_empty(&ino->expiring))
847 - list_del_init(&ino->expiring);
848 - spin_unlock(&sbi->lookup_lock);
849 - dput(expiring);
850 - }
851 -
852 unhashed = autofs4_lookup_active(sbi, dentry->d_parent, &dentry->d_name);
853 if (unhashed)
854 dentry = unhashed;
855 @@ -538,14 +522,31 @@ static struct dentry *autofs4_lookup(str
856 }
857
858 if (!oz_mode) {
859 + mutex_unlock(&dir->i_mutex);
860 + expiring = autofs4_lookup_expiring(sbi,
861 + dentry->d_parent,
862 + &dentry->d_name);
863 + if (expiring) {
864 + /*
865 + * If we are racing with expire the request might not
866 + * be quite complete but the directory has been removed
867 + * so it must have been successful, so just wait for it.
868 + */
869 + ino = autofs4_dentry_ino(expiring);
870 + autofs4_expire_wait(expiring);
871 + spin_lock(&sbi->lookup_lock);
872 + if (!list_empty(&ino->expiring))
873 + list_del_init(&ino->expiring);
874 + spin_unlock(&sbi->lookup_lock);
875 + dput(expiring);
876 + }
877 +
878 spin_lock(&dentry->d_lock);
879 dentry->d_flags |= DCACHE_AUTOFS_PENDING;
880 spin_unlock(&dentry->d_lock);
881 - if (dentry->d_op && dentry->d_op->d_revalidate) {
882 - mutex_unlock(&dir->i_mutex);
883 + if (dentry->d_op && dentry->d_op->d_revalidate)
884 (dentry->d_op->d_revalidate)(dentry, nd);
885 - mutex_lock(&dir->i_mutex);
886 - }
887 + mutex_lock(&dir->i_mutex);
888 }
889
890 /*
891 --- linux-2.6.28.orig/include/linux/auto_fs.h
892 +++ linux-2.6.28/include/linux/auto_fs.h
893 @@ -17,11 +17,13 @@
894 #ifdef __KERNEL__
895 #include <linux/fs.h>
896 #include <linux/limits.h>
897 +#include <linux/types.h>
898 +#include <linux/ioctl.h>
899 +#else
900 #include <asm/types.h>
901 +#include <sys/ioctl.h>
902 #endif /* __KERNEL__ */
903
904 -#include <linux/ioctl.h>
905 -
906 /* This file describes autofs v3 */
907 #define AUTOFS_PROTO_VERSION 3
908