1 /* -*- c -*- --------------------------------------------------------------- *
3 * linux/fs/autofs/root.c
5 * Copyright 1997-1998 Transmeta Corporation -- All Rights Reserved
6 * Copyright 1999-2000 Jeremy Fitzhardinge <jeremy@goop.org>
7 * Copyright 2001-2006 Ian Kent <raven@themaw.net>
9 * This file is part of the Linux kernel and is made available under
10 * the terms of the GNU General Public License, version 2, or at your
11 * option, any later version, incorporated herein by reference.
13 * ------------------------------------------------------------------------- */
15 #include <linux/capability.h>
16 #include <linux/errno.h>
17 #include <linux/stat.h>
18 #include <linux/slab.h>
19 #include <linux/param.h>
20 #include <linux/time.h>
21 #include <linux/compat.h>
22 #include <linux/mutex.h>
26 DEFINE_SPINLOCK(autofs4_lock);
28 static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *);
29 static int autofs4_dir_unlink(struct inode *,struct dentry *);
30 static int autofs4_dir_rmdir(struct inode *,struct dentry *);
31 static int autofs4_dir_mkdir(struct inode *,struct dentry *,int);
32 static long autofs4_root_ioctl(struct file *,unsigned int,unsigned long);
34 static long autofs4_root_compat_ioctl(struct file *,unsigned int,unsigned long);
36 static int autofs4_dir_open(struct inode *inode, struct file *file);
37 static struct dentry *autofs4_lookup(struct inode *,struct dentry *, struct nameidata *);
39 const struct file_operations autofs4_root_operations = {
40 .open = dcache_dir_open,
41 .release = dcache_dir_close,
42 .read = generic_read_dir,
43 .readdir = dcache_readdir,
44 .llseek = dcache_dir_lseek,
45 .unlocked_ioctl = autofs4_root_ioctl,
47 .compat_ioctl = autofs4_root_compat_ioctl,
51 const struct file_operations autofs4_dir_operations = {
52 .open = autofs4_dir_open,
53 .release = dcache_dir_close,
54 .read = generic_read_dir,
55 .readdir = dcache_readdir,
56 .llseek = dcache_dir_lseek,
59 const struct inode_operations autofs4_indirect_root_inode_operations = {
60 .lookup = autofs4_lookup,
61 .unlink = autofs4_dir_unlink,
62 .symlink = autofs4_dir_symlink,
63 .mkdir = autofs4_dir_mkdir,
64 .rmdir = autofs4_dir_rmdir,
67 const struct inode_operations autofs4_direct_root_inode_operations = {
68 .lookup = autofs4_lookup,
69 .unlink = autofs4_dir_unlink,
70 .mkdir = autofs4_dir_mkdir,
71 .rmdir = autofs4_dir_rmdir,
74 const struct inode_operations autofs4_dir_inode_operations = {
75 .lookup = autofs4_lookup,
76 .unlink = autofs4_dir_unlink,
77 .symlink = autofs4_dir_symlink,
78 .mkdir = autofs4_dir_mkdir,
79 .rmdir = autofs4_dir_rmdir,
82 static void autofs4_add_active(struct dentry *dentry)
84 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
85 struct autofs_info *ino = autofs4_dentry_ino(dentry);
87 spin_lock(&sbi->lookup_lock);
88 if (!ino->active_count) {
89 if (list_empty(&ino->active))
90 list_add(&ino->active, &sbi->active_list);
93 spin_unlock(&sbi->lookup_lock);
98 static void autofs4_del_active(struct dentry *dentry)
100 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
101 struct autofs_info *ino = autofs4_dentry_ino(dentry);
103 spin_lock(&sbi->lookup_lock);
105 if (!ino->active_count) {
106 if (!list_empty(&ino->active))
107 list_del_init(&ino->active);
109 spin_unlock(&sbi->lookup_lock);
114 static int autofs4_dir_open(struct inode *inode, struct file *file)
116 struct dentry *dentry = file->f_path.dentry;
117 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
119 DPRINTK("file=%p dentry=%p %.*s",
120 file, dentry, dentry->d_name.len, dentry->d_name.name);
122 if (autofs4_oz_mode(sbi))
126 * An empty directory in an autofs file system is always a
127 * mount point. The daemon must have failed to mount this
128 * during lookup so it doesn't exist. This can happen, for
129 * example, if user space returns an incorrect status for a
130 * mount request. Otherwise we're doing a readdir on the
131 * autofs file system so just let the libfs routines handle
134 spin_lock(&autofs4_lock);
135 spin_lock(&dentry->d_lock);
136 if (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) {
137 spin_unlock(&dentry->d_lock);
138 spin_unlock(&autofs4_lock);
141 spin_unlock(&dentry->d_lock);
142 spin_unlock(&autofs4_lock);
145 return dcache_dir_open(inode, file);
148 void autofs4_dentry_release(struct dentry *de)
150 struct autofs_info *inf;
152 DPRINTK("releasing %p", de);
154 inf = autofs4_dentry_ino(de);
158 struct autofs_sb_info *sbi = autofs4_sbi(de->d_sb);
161 spin_lock(&sbi->lookup_lock);
162 if (!list_empty(&inf->active))
163 list_del(&inf->active);
164 if (!list_empty(&inf->expiring))
165 list_del(&inf->expiring);
166 spin_unlock(&sbi->lookup_lock);
172 autofs4_free_ino(inf);
176 /* For dentries of directories in the root dir */
177 static const struct dentry_operations autofs4_root_dentry_operations = {
178 .d_release = autofs4_dentry_release,
181 /* For other dentries */
182 static const struct dentry_operations autofs4_dentry_operations = {
183 .d_automount = autofs4_d_automount,
184 .d_manage = autofs4_d_manage,
185 .d_release = autofs4_dentry_release,
188 static struct dentry *autofs4_lookup_active(struct dentry *dentry)
190 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
191 struct dentry *parent = dentry->d_parent;
192 struct qstr *name = &dentry->d_name;
193 unsigned int len = name->len;
194 unsigned int hash = name->hash;
195 const unsigned char *str = name->name;
196 struct list_head *p, *head;
198 spin_lock(&autofs4_lock);
199 spin_lock(&sbi->lookup_lock);
200 head = &sbi->active_list;
201 list_for_each(p, head) {
202 struct autofs_info *ino;
203 struct dentry *active;
206 ino = list_entry(p, struct autofs_info, active);
207 active = ino->dentry;
209 spin_lock(&active->d_lock);
212 if (active->d_count == 0)
215 qstr = &active->d_name;
217 if (active->d_name.hash != hash)
219 if (active->d_parent != parent)
222 if (qstr->len != len)
224 if (memcmp(qstr->name, str, len))
227 if (d_unhashed(active)) {
229 spin_unlock(&active->d_lock);
230 spin_unlock(&sbi->lookup_lock);
231 spin_unlock(&autofs4_lock);
235 spin_unlock(&active->d_lock);
237 spin_unlock(&sbi->lookup_lock);
238 spin_unlock(&autofs4_lock);
243 static struct dentry *autofs4_lookup_expiring(struct dentry *dentry)
245 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
246 struct dentry *parent = dentry->d_parent;
247 struct qstr *name = &dentry->d_name;
248 unsigned int len = name->len;
249 unsigned int hash = name->hash;
250 const unsigned char *str = name->name;
251 struct list_head *p, *head;
253 spin_lock(&autofs4_lock);
254 spin_lock(&sbi->lookup_lock);
255 head = &sbi->expiring_list;
256 list_for_each(p, head) {
257 struct autofs_info *ino;
258 struct dentry *expiring;
261 ino = list_entry(p, struct autofs_info, expiring);
262 expiring = ino->dentry;
264 spin_lock(&expiring->d_lock);
266 /* Bad luck, we've already been dentry_iput */
267 if (!expiring->d_inode)
270 qstr = &expiring->d_name;
272 if (expiring->d_name.hash != hash)
274 if (expiring->d_parent != parent)
277 if (qstr->len != len)
279 if (memcmp(qstr->name, str, len))
282 if (d_unhashed(expiring)) {
283 dget_dlock(expiring);
284 spin_unlock(&expiring->d_lock);
285 spin_unlock(&sbi->lookup_lock);
286 spin_unlock(&autofs4_lock);
290 spin_unlock(&expiring->d_lock);
292 spin_unlock(&sbi->lookup_lock);
293 spin_unlock(&autofs4_lock);
298 static int autofs4_mount_wait(struct dentry *dentry)
300 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
301 struct autofs_info *ino = autofs4_dentry_ino(dentry);
304 if (ino->flags & AUTOFS_INF_PENDING) {
305 DPRINTK("waiting for mount name=%.*s",
306 dentry->d_name.len, dentry->d_name.name);
307 status = autofs4_wait(sbi, dentry, NFY_MOUNT);
308 DPRINTK("mount wait done status=%d", status);
309 ino->last_used = jiffies;
315 static int do_expire_wait(struct dentry *dentry)
317 struct dentry *expiring;
319 expiring = autofs4_lookup_expiring(dentry);
321 return autofs4_expire_wait(dentry);
324 * If we are racing with expire the request might not
325 * be quite complete, but the directory has been removed
326 * so it must have been successful, just wait for it.
328 autofs4_expire_wait(expiring);
329 autofs4_del_expiring(expiring);
335 static struct dentry *autofs4_mountpoint_changed(struct path *path)
337 struct dentry *dentry = path->dentry;
338 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
341 * If this is an indirect mount the dentry could have gone away
342 * as a result of an expire and a new one created.
344 if (autofs_type_indirect(sbi->type) && d_unhashed(dentry)) {
345 struct dentry *parent = dentry->d_parent;
346 struct dentry *new = d_lookup(parent, &dentry->d_name);
355 struct vfsmount *autofs4_d_automount(struct path *path)
357 struct dentry *dentry = path->dentry;
358 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
359 struct autofs_info *ino = autofs4_dentry_ino(dentry);
362 DPRINTK("dentry=%p %.*s",
363 dentry, dentry->d_name.len, dentry->d_name.name);
366 * Someone may have manually umounted this or it was a submount
367 * that has gone away.
369 spin_lock(&dentry->d_lock);
370 if (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) {
371 if (!(dentry->d_flags & DCACHE_MANAGE_TRANSIT) &&
372 (dentry->d_flags & DCACHE_NEED_AUTOMOUNT))
373 __managed_dentry_set_transit(path->dentry);
375 spin_unlock(&dentry->d_lock);
377 /* The daemon never triggers a mount. */
378 if (autofs4_oz_mode(sbi))
382 * If an expire request is pending everyone must wait.
383 * If the expire fails we're still mounted so continue
384 * the follow and return. A return of -EAGAIN (which only
385 * happens with indirect mounts) means the expire completed
386 * and the directory was removed, so just go ahead and try
389 status = do_expire_wait(dentry);
390 if (status && status != -EAGAIN)
393 /* Callback to the daemon to perform the mount or wait */
394 spin_lock(&sbi->fs_lock);
395 if (ino->flags & AUTOFS_INF_PENDING) {
396 spin_unlock(&sbi->fs_lock);
397 status = autofs4_mount_wait(dentry);
399 return ERR_PTR(status);
400 spin_lock(&sbi->fs_lock);
405 * If the dentry is a symlink it's equivalent to a directory
406 * having d_mountpoint() true, so there's no need to call back
409 if (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode))
411 if (!d_mountpoint(dentry)) {
413 * It's possible that user space hasn't removed directories
414 * after umounting a rootless multi-mount, although it
415 * should. For v5 have_submounts() is sufficient to handle
416 * this because the leaves of the directory tree under the
417 * mount never trigger mounts themselves (they have an autofs
418 * trigger mount mounted on them). But v4 pseudo direct mounts
419 * do need the leaves to to trigger mounts. In this case we
420 * have no choice but to use the list_empty() check and
421 * require user space behave.
423 if (sbi->version > 4) {
424 if (have_submounts(dentry))
427 spin_lock(&dentry->d_lock);
428 if (!list_empty(&dentry->d_subdirs)) {
429 spin_unlock(&dentry->d_lock);
432 spin_unlock(&dentry->d_lock);
434 ino->flags |= AUTOFS_INF_PENDING;
435 spin_unlock(&sbi->fs_lock);
436 status = autofs4_mount_wait(dentry);
438 return ERR_PTR(status);
439 spin_lock(&sbi->fs_lock);
440 ino->flags &= ~AUTOFS_INF_PENDING;
443 if (!(ino->flags & AUTOFS_INF_EXPIRING)) {
445 * Any needed mounting has been completed and the path updated
446 * so turn this into a normal dentry so we don't continually
447 * call ->d_automount() and ->d_manage().
449 spin_lock(&dentry->d_lock);
450 __managed_dentry_clear_transit(dentry);
452 * Only clear DMANAGED_AUTOMOUNT for rootless multi-mounts and
453 * symlinks as in all other cases the dentry will be covered by
454 * an actual mount so ->d_automount() won't be called during
457 if ((!d_mountpoint(dentry) &&
458 !list_empty(&dentry->d_subdirs)) ||
459 (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode)))
460 __managed_dentry_clear_automount(dentry);
461 spin_unlock(&dentry->d_lock);
463 spin_unlock(&sbi->fs_lock);
465 /* Mount succeeded, check if we ended up with a new dentry */
466 dentry = autofs4_mountpoint_changed(path);
468 return ERR_PTR(-ENOENT);
473 int autofs4_d_manage(struct dentry *dentry, bool mounting_here)
475 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
477 DPRINTK("dentry=%p %.*s",
478 dentry, dentry->d_name.len, dentry->d_name.name);
480 /* The daemon never waits. */
481 if (autofs4_oz_mode(sbi) || mounting_here) {
482 if (!d_mountpoint(dentry))
487 /* Wait for pending expires */
488 do_expire_wait(dentry);
491 * This dentry may be under construction so wait on mount
494 return autofs4_mount_wait(dentry);
497 /* Lookups in the root directory */
498 static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
500 struct autofs_sb_info *sbi;
501 struct autofs_info *ino;
502 struct dentry *active;
504 DPRINTK("name = %.*s", dentry->d_name.len, dentry->d_name.name);
506 /* File name too long to exist */
507 if (dentry->d_name.len > NAME_MAX)
508 return ERR_PTR(-ENAMETOOLONG);
510 sbi = autofs4_sbi(dir->i_sb);
512 DPRINTK("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d",
513 current->pid, task_pgrp_nr(current), sbi->catatonic, oz_mode);
515 active = autofs4_lookup_active(dentry);
519 d_set_d_op(dentry, &autofs4_root_dentry_operations);
522 * A dentry that is not within the root can never trigger a
523 * mount operation, unless the directory already exists, so we
524 * can return fail immediately. The daemon however does need
525 * to create directories within the file system.
527 if (!autofs4_oz_mode(sbi) && !IS_ROOT(dentry->d_parent))
528 return ERR_PTR(-ENOENT);
530 /* Mark entries in the root as mount triggers */
531 if (autofs_type_indirect(sbi->type) && IS_ROOT(dentry->d_parent)) {
532 d_set_d_op(dentry, &autofs4_dentry_operations);
533 __managed_dentry_set_managed(dentry);
536 ino = autofs4_init_ino(NULL, sbi, 0555);
538 return ERR_PTR(-ENOMEM);
540 dentry->d_fsdata = ino;
541 ino->dentry = dentry;
543 autofs4_add_active(dentry);
545 d_instantiate(dentry, NULL);
550 static int autofs4_dir_symlink(struct inode *dir,
551 struct dentry *dentry,
554 struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
555 struct autofs_info *ino = autofs4_dentry_ino(dentry);
556 struct autofs_info *p_ino;
560 DPRINTK("%s <- %.*s", symname,
561 dentry->d_name.len, dentry->d_name.name);
563 if (!autofs4_oz_mode(sbi))
566 ino = autofs4_init_ino(ino, sbi, S_IFLNK | 0555);
570 autofs4_del_active(dentry);
572 ino->size = strlen(symname);
573 cp = kmalloc(ino->size + 1, GFP_KERNEL);
575 if (!dentry->d_fsdata)
582 inode = autofs4_get_inode(dir->i_sb, ino);
585 if (!dentry->d_fsdata)
589 d_add(dentry, inode);
591 dentry->d_fsdata = ino;
592 ino->dentry = dget(dentry);
593 atomic_inc(&ino->count);
594 p_ino = autofs4_dentry_ino(dentry->d_parent);
595 if (p_ino && dentry->d_parent != dentry)
596 atomic_inc(&p_ino->count);
600 dir->i_mtime = CURRENT_TIME;
608 * Normal filesystems would do a "d_delete()" to tell the VFS dcache
609 * that the file no longer exists. However, doing that means that the
610 * VFS layer can turn the dentry into a negative dentry. We don't want
611 * this, because the unlink is probably the result of an expire.
612 * We simply d_drop it and add it to a expiring list in the super block,
613 * which allows the dentry lookup to check for an incomplete expire.
615 * If a process is blocked on the dentry waiting for the expire to finish,
616 * it will invalidate the dentry and try to mount with a new one.
618 * Also see autofs4_dir_rmdir()..
620 static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry)
622 struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
623 struct autofs_info *ino = autofs4_dentry_ino(dentry);
624 struct autofs_info *p_ino;
626 /* This allows root to remove symlinks */
627 if (!autofs4_oz_mode(sbi) && !capable(CAP_SYS_ADMIN))
630 if (atomic_dec_and_test(&ino->count)) {
631 p_ino = autofs4_dentry_ino(dentry->d_parent);
632 if (p_ino && dentry->d_parent != dentry)
633 atomic_dec(&p_ino->count);
637 dentry->d_inode->i_size = 0;
638 clear_nlink(dentry->d_inode);
640 dir->i_mtime = CURRENT_TIME;
642 spin_lock(&autofs4_lock);
643 autofs4_add_expiring(dentry);
644 spin_lock(&dentry->d_lock);
646 spin_unlock(&dentry->d_lock);
647 spin_unlock(&autofs4_lock);
652 static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry)
654 struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
655 struct autofs_info *ino = autofs4_dentry_ino(dentry);
656 struct autofs_info *p_ino;
658 DPRINTK("dentry %p, removing %.*s",
659 dentry, dentry->d_name.len, dentry->d_name.name);
661 if (!autofs4_oz_mode(sbi))
664 spin_lock(&autofs4_lock);
665 spin_lock(&sbi->lookup_lock);
666 spin_lock(&dentry->d_lock);
667 if (!list_empty(&dentry->d_subdirs)) {
668 spin_unlock(&dentry->d_lock);
669 spin_unlock(&sbi->lookup_lock);
670 spin_unlock(&autofs4_lock);
673 __autofs4_add_expiring(dentry);
674 spin_unlock(&sbi->lookup_lock);
676 spin_unlock(&dentry->d_lock);
677 spin_unlock(&autofs4_lock);
679 if (atomic_dec_and_test(&ino->count)) {
680 p_ino = autofs4_dentry_ino(dentry->d_parent);
681 if (p_ino && dentry->d_parent != dentry)
682 atomic_dec(&p_ino->count);
685 dentry->d_inode->i_size = 0;
686 clear_nlink(dentry->d_inode);
694 static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode)
696 struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
697 struct autofs_info *ino = autofs4_dentry_ino(dentry);
698 struct autofs_info *p_ino;
701 if (!autofs4_oz_mode(sbi))
704 DPRINTK("dentry %p, creating %.*s",
705 dentry, dentry->d_name.len, dentry->d_name.name);
707 ino = autofs4_init_ino(ino, sbi, S_IFDIR | 0555);
711 autofs4_del_active(dentry);
713 inode = autofs4_get_inode(dir->i_sb, ino);
715 if (!dentry->d_fsdata)
719 d_add(dentry, inode);
721 dentry->d_fsdata = ino;
722 ino->dentry = dget(dentry);
723 atomic_inc(&ino->count);
724 p_ino = autofs4_dentry_ino(dentry->d_parent);
725 if (p_ino && dentry->d_parent != dentry)
726 atomic_inc(&p_ino->count);
729 dir->i_mtime = CURRENT_TIME;
734 /* Get/set timeout ioctl() operation */
736 static inline int autofs4_compat_get_set_timeout(struct autofs_sb_info *sbi,
737 compat_ulong_t __user *p)
740 unsigned long ntimeout;
742 if ((rv = get_user(ntimeout, p)) ||
743 (rv = put_user(sbi->exp_timeout/HZ, p)))
746 if (ntimeout > UINT_MAX/HZ)
747 sbi->exp_timeout = 0;
749 sbi->exp_timeout = ntimeout * HZ;
755 static inline int autofs4_get_set_timeout(struct autofs_sb_info *sbi,
756 unsigned long __user *p)
759 unsigned long ntimeout;
761 if ((rv = get_user(ntimeout, p)) ||
762 (rv = put_user(sbi->exp_timeout/HZ, p)))
765 if (ntimeout > ULONG_MAX/HZ)
766 sbi->exp_timeout = 0;
768 sbi->exp_timeout = ntimeout * HZ;
773 /* Return protocol version */
774 static inline int autofs4_get_protover(struct autofs_sb_info *sbi, int __user *p)
776 return put_user(sbi->version, p);
779 /* Return protocol sub version */
780 static inline int autofs4_get_protosubver(struct autofs_sb_info *sbi, int __user *p)
782 return put_user(sbi->sub_version, p);
786 * Tells the daemon whether it can umount the autofs mount.
788 static inline int autofs4_ask_umount(struct vfsmount *mnt, int __user *p)
795 DPRINTK("returning %d", status);
797 status = put_user(status, p);
802 /* Identify autofs4_dentries - this is so we can tell if there's
803 an extra dentry refcount or not. We only hold a refcount on the
804 dentry if its non-negative (ie, d_inode != NULL)
806 int is_autofs4_dentry(struct dentry *dentry)
808 return dentry && dentry->d_inode &&
809 (dentry->d_op == &autofs4_root_dentry_operations ||
810 dentry->d_op == &autofs4_dentry_operations) &&
811 dentry->d_fsdata != NULL;
815 * ioctl()'s on the root directory is the chief method for the daemon to
816 * generate kernel reactions
818 static int autofs4_root_ioctl_unlocked(struct inode *inode, struct file *filp,
819 unsigned int cmd, unsigned long arg)
821 struct autofs_sb_info *sbi = autofs4_sbi(inode->i_sb);
822 void __user *p = (void __user *)arg;
824 DPRINTK("cmd = 0x%08x, arg = 0x%08lx, sbi = %p, pgrp = %u",
825 cmd,arg,sbi,task_pgrp_nr(current));
827 if (_IOC_TYPE(cmd) != _IOC_TYPE(AUTOFS_IOC_FIRST) ||
828 _IOC_NR(cmd) - _IOC_NR(AUTOFS_IOC_FIRST) >= AUTOFS_IOC_COUNT)
831 if (!autofs4_oz_mode(sbi) && !capable(CAP_SYS_ADMIN))
835 case AUTOFS_IOC_READY: /* Wait queue: go ahead and retry */
836 return autofs4_wait_release(sbi,(autofs_wqt_t)arg,0);
837 case AUTOFS_IOC_FAIL: /* Wait queue: fail with ENOENT */
838 return autofs4_wait_release(sbi,(autofs_wqt_t)arg,-ENOENT);
839 case AUTOFS_IOC_CATATONIC: /* Enter catatonic mode (daemon shutdown) */
840 autofs4_catatonic_mode(sbi);
842 case AUTOFS_IOC_PROTOVER: /* Get protocol version */
843 return autofs4_get_protover(sbi, p);
844 case AUTOFS_IOC_PROTOSUBVER: /* Get protocol sub version */
845 return autofs4_get_protosubver(sbi, p);
846 case AUTOFS_IOC_SETTIMEOUT:
847 return autofs4_get_set_timeout(sbi, p);
849 case AUTOFS_IOC_SETTIMEOUT32:
850 return autofs4_compat_get_set_timeout(sbi, p);
853 case AUTOFS_IOC_ASKUMOUNT:
854 return autofs4_ask_umount(filp->f_path.mnt, p);
856 /* return a single thing to expire */
857 case AUTOFS_IOC_EXPIRE:
858 return autofs4_expire_run(inode->i_sb,filp->f_path.mnt,sbi, p);
859 /* same as above, but can send multiple expires through pipe */
860 case AUTOFS_IOC_EXPIRE_MULTI:
861 return autofs4_expire_multi(inode->i_sb,filp->f_path.mnt,sbi, p);
868 static long autofs4_root_ioctl(struct file *filp,
869 unsigned int cmd, unsigned long arg)
871 struct inode *inode = filp->f_dentry->d_inode;
872 return autofs4_root_ioctl_unlocked(inode, filp, cmd, arg);
876 static long autofs4_root_compat_ioctl(struct file *filp,
877 unsigned int cmd, unsigned long arg)
879 struct inode *inode = filp->f_path.dentry->d_inode;
882 if (cmd == AUTOFS_IOC_READY || cmd == AUTOFS_IOC_FAIL)
883 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg);
885 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd,
886 (unsigned long)compat_ptr(arg));