[PATCH] autofs4: can't mount due to mount point dir not empty
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / fs / autofs4 / root.c
blobc7ff35774344e1dc805fd40e62b06ddd5ca1d11d
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-2003 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/param.h>
19 #include <linux/time.h>
20 #include <linux/smp_lock.h>
21 #include "autofs_i.h"
23 static int autofs4_dir_symlink(struct inode *,struct dentry *,const char *);
24 static int autofs4_dir_unlink(struct inode *,struct dentry *);
25 static int autofs4_dir_rmdir(struct inode *,struct dentry *);
26 static int autofs4_dir_mkdir(struct inode *,struct dentry *,int);
27 static int autofs4_root_ioctl(struct inode *, struct file *,unsigned int,unsigned long);
28 static int autofs4_dir_open(struct inode *inode, struct file *file);
29 static int autofs4_dir_close(struct inode *inode, struct file *file);
30 static int autofs4_dir_readdir(struct file * filp, void * dirent, filldir_t filldir);
31 static int autofs4_root_readdir(struct file * filp, void * dirent, filldir_t filldir);
32 static struct dentry *autofs4_lookup(struct inode *,struct dentry *, struct nameidata *);
34 struct file_operations autofs4_root_operations = {
35 .open = dcache_dir_open,
36 .release = dcache_dir_close,
37 .read = generic_read_dir,
38 .readdir = autofs4_root_readdir,
39 .ioctl = autofs4_root_ioctl,
42 struct file_operations autofs4_dir_operations = {
43 .open = autofs4_dir_open,
44 .release = autofs4_dir_close,
45 .read = generic_read_dir,
46 .readdir = autofs4_dir_readdir,
49 struct inode_operations autofs4_root_inode_operations = {
50 .lookup = autofs4_lookup,
51 .unlink = autofs4_dir_unlink,
52 .symlink = autofs4_dir_symlink,
53 .mkdir = autofs4_dir_mkdir,
54 .rmdir = autofs4_dir_rmdir,
57 struct inode_operations autofs4_dir_inode_operations = {
58 .lookup = autofs4_lookup,
59 .unlink = autofs4_dir_unlink,
60 .symlink = autofs4_dir_symlink,
61 .mkdir = autofs4_dir_mkdir,
62 .rmdir = autofs4_dir_rmdir,
65 static int autofs4_root_readdir(struct file *file, void *dirent,
66 filldir_t filldir)
68 struct autofs_sb_info *sbi = autofs4_sbi(file->f_dentry->d_sb);
69 int oz_mode = autofs4_oz_mode(sbi);
71 DPRINTK("called, filp->f_pos = %lld", file->f_pos);
74 * Don't set reghost flag if:
75 * 1) f_pos is larger than zero -- we've already been here.
76 * 2) we haven't even enabled reghosting in the 1st place.
77 * 3) this is the daemon doing a readdir
79 if (oz_mode && file->f_pos == 0 && sbi->reghost_enabled)
80 sbi->needs_reghost = 1;
82 DPRINTK("needs_reghost = %d", sbi->needs_reghost);
84 return dcache_readdir(file, dirent, filldir);
87 /* Update usage from here to top of tree, so that scan of
88 top-level directories will give a useful result */
89 static void autofs4_update_usage(struct vfsmount *mnt, struct dentry *dentry)
91 struct dentry *top = dentry->d_sb->s_root;
93 spin_lock(&dcache_lock);
94 for(; dentry != top; dentry = dentry->d_parent) {
95 struct autofs_info *ino = autofs4_dentry_ino(dentry);
97 if (ino) {
98 touch_atime(mnt, dentry);
99 ino->last_used = jiffies;
102 spin_unlock(&dcache_lock);
105 static int autofs4_dir_open(struct inode *inode, struct file *file)
107 struct dentry *dentry = file->f_dentry;
108 struct vfsmount *mnt = file->f_vfsmnt;
109 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
110 struct dentry *cursor;
111 int status;
113 status = dcache_dir_open(inode, file);
114 if (status)
115 goto out;
117 cursor = file->private_data;
118 cursor->d_fsdata = NULL;
120 DPRINTK("file=%p dentry=%p %.*s",
121 file, dentry, dentry->d_name.len, dentry->d_name.name);
123 if (autofs4_oz_mode(sbi))
124 goto out;
126 if (autofs4_ispending(dentry)) {
127 DPRINTK("dentry busy");
128 dcache_dir_close(inode, file);
129 status = -EBUSY;
130 goto out;
133 status = -ENOENT;
134 if (!d_mountpoint(dentry) && dentry->d_op && dentry->d_op->d_revalidate) {
135 struct nameidata nd;
136 int empty, ret;
138 /* In case there are stale directory dentrys from a failed mount */
139 spin_lock(&dcache_lock);
140 empty = list_empty(&dentry->d_subdirs);
141 spin_unlock(&dcache_lock);
143 if (!empty)
144 d_invalidate(dentry);
146 nd.flags = LOOKUP_DIRECTORY;
147 ret = (dentry->d_op->d_revalidate)(dentry, &nd);
149 if (!ret) {
150 dcache_dir_close(inode, file);
151 goto out;
155 if (d_mountpoint(dentry)) {
156 struct file *fp = NULL;
157 struct vfsmount *fp_mnt = mntget(mnt);
158 struct dentry *fp_dentry = dget(dentry);
160 if (!autofs4_follow_mount(&fp_mnt, &fp_dentry)) {
161 dput(fp_dentry);
162 mntput(fp_mnt);
163 dcache_dir_close(inode, file);
164 goto out;
167 fp = dentry_open(fp_dentry, fp_mnt, file->f_flags);
168 status = PTR_ERR(fp);
169 if (IS_ERR(fp)) {
170 dcache_dir_close(inode, file);
171 goto out;
173 cursor->d_fsdata = fp;
175 return 0;
176 out:
177 return status;
180 static int autofs4_dir_close(struct inode *inode, struct file *file)
182 struct dentry *dentry = file->f_dentry;
183 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
184 struct dentry *cursor = file->private_data;
185 int status = 0;
187 DPRINTK("file=%p dentry=%p %.*s",
188 file, dentry, dentry->d_name.len, dentry->d_name.name);
190 if (autofs4_oz_mode(sbi))
191 goto out;
193 if (autofs4_ispending(dentry)) {
194 DPRINTK("dentry busy");
195 status = -EBUSY;
196 goto out;
199 if (d_mountpoint(dentry)) {
200 struct file *fp = cursor->d_fsdata;
201 if (!fp) {
202 status = -ENOENT;
203 goto out;
205 filp_close(fp, current->files);
207 out:
208 dcache_dir_close(inode, file);
209 return status;
212 static int autofs4_dir_readdir(struct file *file, void *dirent, filldir_t filldir)
214 struct dentry *dentry = file->f_dentry;
215 struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
216 struct dentry *cursor = file->private_data;
217 int status;
219 DPRINTK("file=%p dentry=%p %.*s",
220 file, dentry, dentry->d_name.len, dentry->d_name.name);
222 if (autofs4_oz_mode(sbi))
223 goto out;
225 if (autofs4_ispending(dentry)) {
226 DPRINTK("dentry busy");
227 return -EBUSY;
230 if (d_mountpoint(dentry)) {
231 struct file *fp = cursor->d_fsdata;
233 if (!fp)
234 return -ENOENT;
236 if (!fp->f_op || !fp->f_op->readdir)
237 goto out;
239 status = vfs_readdir(fp, filldir, dirent);
240 file->f_pos = fp->f_pos;
241 if (status)
242 autofs4_copy_atime(file, fp);
243 return status;
245 out:
246 return dcache_readdir(file, dirent, filldir);
249 static int try_to_fill_dentry(struct vfsmount *mnt, struct dentry *dentry, int flags)
251 struct super_block *sb = mnt->mnt_sb;
252 struct autofs_sb_info *sbi = autofs4_sbi(sb);
253 struct autofs_info *ino = autofs4_dentry_ino(dentry);
254 int status = 0;
256 /* Block on any pending expiry here; invalidate the dentry
257 when expiration is done to trigger mount request with a new
258 dentry */
259 if (ino && (ino->flags & AUTOFS_INF_EXPIRING)) {
260 DPRINTK("waiting for expire %p name=%.*s",
261 dentry, dentry->d_name.len, dentry->d_name.name);
263 status = autofs4_wait(sbi, dentry, NFY_NONE);
265 DPRINTK("expire done status=%d", status);
268 * If the directory still exists the mount request must
269 * continue otherwise it can't be followed at the right
270 * time during the walk.
272 status = d_invalidate(dentry);
273 if (status != -EBUSY)
274 return 0;
277 DPRINTK("dentry=%p %.*s ino=%p",
278 dentry, dentry->d_name.len, dentry->d_name.name, dentry->d_inode);
281 * Wait for a pending mount, triggering one if there
282 * isn't one already
284 if (dentry->d_inode == NULL) {
285 DPRINTK("waiting for mount name=%.*s",
286 dentry->d_name.len, dentry->d_name.name);
288 status = autofs4_wait(sbi, dentry, NFY_MOUNT);
290 DPRINTK("mount done status=%d", status);
292 if (status && dentry->d_inode)
293 return 0; /* Try to get the kernel to invalidate this dentry */
295 /* Turn this into a real negative dentry? */
296 if (status == -ENOENT) {
297 spin_lock(&dentry->d_lock);
298 dentry->d_flags &= ~DCACHE_AUTOFS_PENDING;
299 spin_unlock(&dentry->d_lock);
300 return 0;
301 } else if (status) {
302 /* Return a negative dentry, but leave it "pending" */
303 return 0;
305 /* Trigger mount for path component or follow link */
306 } else if (flags & (LOOKUP_CONTINUE | LOOKUP_DIRECTORY) ||
307 current->link_count) {
308 DPRINTK("waiting for mount name=%.*s",
309 dentry->d_name.len, dentry->d_name.name);
311 spin_lock(&dentry->d_lock);
312 dentry->d_flags |= DCACHE_AUTOFS_PENDING;
313 spin_unlock(&dentry->d_lock);
314 status = autofs4_wait(sbi, dentry, NFY_MOUNT);
316 DPRINTK("mount done status=%d", status);
318 if (status) {
319 spin_lock(&dentry->d_lock);
320 dentry->d_flags &= ~DCACHE_AUTOFS_PENDING;
321 spin_unlock(&dentry->d_lock);
322 return 0;
327 * We don't update the usages for the autofs daemon itself, this
328 * is necessary for recursive autofs mounts
330 if (!autofs4_oz_mode(sbi))
331 autofs4_update_usage(mnt, dentry);
333 spin_lock(&dentry->d_lock);
334 dentry->d_flags &= ~DCACHE_AUTOFS_PENDING;
335 spin_unlock(&dentry->d_lock);
336 return 1;
340 * Revalidate is called on every cache lookup. Some of those
341 * cache lookups may actually happen while the dentry is not
342 * yet completely filled in, and revalidate has to delay such
343 * lookups..
345 static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd)
347 struct inode *dir = dentry->d_parent->d_inode;
348 struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
349 int oz_mode = autofs4_oz_mode(sbi);
350 int flags = nd ? nd->flags : 0;
351 int status = 1;
353 /* Pending dentry */
354 if (autofs4_ispending(dentry)) {
355 if (!oz_mode)
356 status = try_to_fill_dentry(nd->mnt, dentry, flags);
357 return status;
360 /* Negative dentry.. invalidate if "old" */
361 if (dentry->d_inode == NULL)
362 return 0;
364 /* Check for a non-mountpoint directory with no contents */
365 spin_lock(&dcache_lock);
366 if (S_ISDIR(dentry->d_inode->i_mode) &&
367 !d_mountpoint(dentry) &&
368 simple_empty_nolock(dentry)) {
369 DPRINTK("dentry=%p %.*s, emptydir",
370 dentry, dentry->d_name.len, dentry->d_name.name);
371 spin_unlock(&dcache_lock);
372 if (!oz_mode)
373 status = try_to_fill_dentry(nd->mnt, dentry, flags);
374 return status;
376 spin_unlock(&dcache_lock);
378 /* Update the usage list */
379 if (!oz_mode)
380 autofs4_update_usage(nd->mnt, dentry);
382 return 1;
385 static void autofs4_dentry_release(struct dentry *de)
387 struct autofs_info *inf;
389 DPRINTK("releasing %p", de);
391 inf = autofs4_dentry_ino(de);
392 de->d_fsdata = NULL;
394 if (inf) {
395 inf->dentry = NULL;
396 inf->inode = NULL;
398 autofs4_free_ino(inf);
402 /* For dentries of directories in the root dir */
403 static struct dentry_operations autofs4_root_dentry_operations = {
404 .d_revalidate = autofs4_revalidate,
405 .d_release = autofs4_dentry_release,
408 /* For other dentries */
409 static struct dentry_operations autofs4_dentry_operations = {
410 .d_revalidate = autofs4_revalidate,
411 .d_release = autofs4_dentry_release,
414 /* Lookups in the root directory */
415 static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
417 struct autofs_sb_info *sbi;
418 int oz_mode;
420 DPRINTK("name = %.*s",
421 dentry->d_name.len, dentry->d_name.name);
423 /* File name too long to exist */
424 if (dentry->d_name.len > NAME_MAX)
425 return ERR_PTR(-ENAMETOOLONG);
427 sbi = autofs4_sbi(dir->i_sb);
428 oz_mode = autofs4_oz_mode(sbi);
430 DPRINTK("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d",
431 current->pid, process_group(current), sbi->catatonic, oz_mode);
434 * Mark the dentry incomplete, but add it. This is needed so
435 * that the VFS layer knows about the dentry, and we can count
436 * on catching any lookups through the revalidate.
438 * Let all the hard work be done by the revalidate function that
439 * needs to be able to do this anyway..
441 * We need to do this before we release the directory semaphore.
443 dentry->d_op = &autofs4_root_dentry_operations;
445 if (!oz_mode) {
446 spin_lock(&dentry->d_lock);
447 dentry->d_flags |= DCACHE_AUTOFS_PENDING;
448 spin_unlock(&dentry->d_lock);
450 dentry->d_fsdata = NULL;
451 d_add(dentry, NULL);
453 if (dentry->d_op && dentry->d_op->d_revalidate) {
454 mutex_unlock(&dir->i_mutex);
455 (dentry->d_op->d_revalidate)(dentry, nd);
456 mutex_lock(&dir->i_mutex);
460 * If we are still pending, check if we had to handle
461 * a signal. If so we can force a restart..
463 if (dentry->d_flags & DCACHE_AUTOFS_PENDING) {
464 /* See if we were interrupted */
465 if (signal_pending(current)) {
466 sigset_t *sigset = &current->pending.signal;
467 if (sigismember (sigset, SIGKILL) ||
468 sigismember (sigset, SIGQUIT) ||
469 sigismember (sigset, SIGINT)) {
470 return ERR_PTR(-ERESTARTNOINTR);
476 * If this dentry is unhashed, then we shouldn't honour this
477 * lookup even if the dentry is positive. Returning ENOENT here
478 * doesn't do the right thing for all system calls, but it should
479 * be OK for the operations we permit from an autofs.
481 if (dentry->d_inode && d_unhashed(dentry))
482 return ERR_PTR(-ENOENT);
484 return NULL;
487 static int autofs4_dir_symlink(struct inode *dir,
488 struct dentry *dentry,
489 const char *symname)
491 struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
492 struct autofs_info *ino = autofs4_dentry_ino(dentry);
493 struct inode *inode;
494 char *cp;
496 DPRINTK("%s <- %.*s", symname,
497 dentry->d_name.len, dentry->d_name.name);
499 if (!autofs4_oz_mode(sbi))
500 return -EACCES;
502 ino = autofs4_init_ino(ino, sbi, S_IFLNK | 0555);
503 if (ino == NULL)
504 return -ENOSPC;
506 ino->size = strlen(symname);
507 ino->u.symlink = cp = kmalloc(ino->size + 1, GFP_KERNEL);
509 if (cp == NULL) {
510 kfree(ino);
511 return -ENOSPC;
514 strcpy(cp, symname);
516 inode = autofs4_get_inode(dir->i_sb, ino);
517 d_instantiate(dentry, inode);
519 if (dir == dir->i_sb->s_root->d_inode)
520 dentry->d_op = &autofs4_root_dentry_operations;
521 else
522 dentry->d_op = &autofs4_dentry_operations;
524 dentry->d_fsdata = ino;
525 ino->dentry = dget(dentry);
526 ino->inode = inode;
528 dir->i_mtime = CURRENT_TIME;
530 return 0;
534 * NOTE!
536 * Normal filesystems would do a "d_delete()" to tell the VFS dcache
537 * that the file no longer exists. However, doing that means that the
538 * VFS layer can turn the dentry into a negative dentry. We don't want
539 * this, because since the unlink is probably the result of an expire.
540 * We simply d_drop it, which allows the dentry lookup to remount it
541 * if necessary.
543 * If a process is blocked on the dentry waiting for the expire to finish,
544 * it will invalidate the dentry and try to mount with a new one.
546 * Also see autofs4_dir_rmdir()..
548 static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry)
550 struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
551 struct autofs_info *ino = autofs4_dentry_ino(dentry);
553 /* This allows root to remove symlinks */
554 if ( !autofs4_oz_mode(sbi) && !capable(CAP_SYS_ADMIN) )
555 return -EACCES;
557 dput(ino->dentry);
559 dentry->d_inode->i_size = 0;
560 dentry->d_inode->i_nlink = 0;
562 dir->i_mtime = CURRENT_TIME;
564 d_drop(dentry);
566 return 0;
569 static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry)
571 struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
572 struct autofs_info *ino = autofs4_dentry_ino(dentry);
574 if (!autofs4_oz_mode(sbi))
575 return -EACCES;
577 spin_lock(&dcache_lock);
578 if (!list_empty(&dentry->d_subdirs)) {
579 spin_unlock(&dcache_lock);
580 return -ENOTEMPTY;
582 spin_lock(&dentry->d_lock);
583 __d_drop(dentry);
584 spin_unlock(&dentry->d_lock);
585 spin_unlock(&dcache_lock);
587 dput(ino->dentry);
589 dentry->d_inode->i_size = 0;
590 dentry->d_inode->i_nlink = 0;
592 if (dir->i_nlink)
593 dir->i_nlink--;
595 return 0;
598 static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode)
600 struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
601 struct autofs_info *ino = autofs4_dentry_ino(dentry);
602 struct inode *inode;
604 if ( !autofs4_oz_mode(sbi) )
605 return -EACCES;
607 DPRINTK("dentry %p, creating %.*s",
608 dentry, dentry->d_name.len, dentry->d_name.name);
610 ino = autofs4_init_ino(ino, sbi, S_IFDIR | 0555);
611 if (ino == NULL)
612 return -ENOSPC;
614 inode = autofs4_get_inode(dir->i_sb, ino);
615 d_instantiate(dentry, inode);
617 if (dir == dir->i_sb->s_root->d_inode)
618 dentry->d_op = &autofs4_root_dentry_operations;
619 else
620 dentry->d_op = &autofs4_dentry_operations;
622 dentry->d_fsdata = ino;
623 ino->dentry = dget(dentry);
624 ino->inode = inode;
625 dir->i_nlink++;
626 dir->i_mtime = CURRENT_TIME;
628 return 0;
631 /* Get/set timeout ioctl() operation */
632 static inline int autofs4_get_set_timeout(struct autofs_sb_info *sbi,
633 unsigned long __user *p)
635 int rv;
636 unsigned long ntimeout;
638 if ( (rv = get_user(ntimeout, p)) ||
639 (rv = put_user(sbi->exp_timeout/HZ, p)) )
640 return rv;
642 if ( ntimeout > ULONG_MAX/HZ )
643 sbi->exp_timeout = 0;
644 else
645 sbi->exp_timeout = ntimeout * HZ;
647 return 0;
650 /* Return protocol version */
651 static inline int autofs4_get_protover(struct autofs_sb_info *sbi, int __user *p)
653 return put_user(sbi->version, p);
656 /* Return protocol sub version */
657 static inline int autofs4_get_protosubver(struct autofs_sb_info *sbi, int __user *p)
659 return put_user(sbi->sub_version, p);
663 * Tells the daemon whether we need to reghost or not. Also, clears
664 * the reghost_needed flag.
666 static inline int autofs4_ask_reghost(struct autofs_sb_info *sbi, int __user *p)
668 int status;
670 DPRINTK("returning %d", sbi->needs_reghost);
672 status = put_user(sbi->needs_reghost, p);
673 if ( status )
674 return status;
676 sbi->needs_reghost = 0;
677 return 0;
681 * Enable / Disable reghosting ioctl() operation
683 static inline int autofs4_toggle_reghost(struct autofs_sb_info *sbi, int __user *p)
685 int status;
686 int val;
688 status = get_user(val, p);
690 DPRINTK("reghost = %d", val);
692 if (status)
693 return status;
695 /* turn on/off reghosting, with the val */
696 sbi->reghost_enabled = val;
697 return 0;
701 * Tells the daemon whether it can umount the autofs mount.
703 static inline int autofs4_ask_umount(struct vfsmount *mnt, int __user *p)
705 int status = 0;
707 if (may_umount(mnt) == 0)
708 status = 1;
710 DPRINTK("returning %d", status);
712 status = put_user(status, p);
714 return status;
717 /* Identify autofs4_dentries - this is so we can tell if there's
718 an extra dentry refcount or not. We only hold a refcount on the
719 dentry if its non-negative (ie, d_inode != NULL)
721 int is_autofs4_dentry(struct dentry *dentry)
723 return dentry && dentry->d_inode &&
724 (dentry->d_op == &autofs4_root_dentry_operations ||
725 dentry->d_op == &autofs4_dentry_operations) &&
726 dentry->d_fsdata != NULL;
730 * ioctl()'s on the root directory is the chief method for the daemon to
731 * generate kernel reactions
733 static int autofs4_root_ioctl(struct inode *inode, struct file *filp,
734 unsigned int cmd, unsigned long arg)
736 struct autofs_sb_info *sbi = autofs4_sbi(inode->i_sb);
737 void __user *p = (void __user *)arg;
739 DPRINTK("cmd = 0x%08x, arg = 0x%08lx, sbi = %p, pgrp = %u",
740 cmd,arg,sbi,process_group(current));
742 if ( _IOC_TYPE(cmd) != _IOC_TYPE(AUTOFS_IOC_FIRST) ||
743 _IOC_NR(cmd) - _IOC_NR(AUTOFS_IOC_FIRST) >= AUTOFS_IOC_COUNT )
744 return -ENOTTY;
746 if ( !autofs4_oz_mode(sbi) && !capable(CAP_SYS_ADMIN) )
747 return -EPERM;
749 switch(cmd) {
750 case AUTOFS_IOC_READY: /* Wait queue: go ahead and retry */
751 return autofs4_wait_release(sbi,(autofs_wqt_t)arg,0);
752 case AUTOFS_IOC_FAIL: /* Wait queue: fail with ENOENT */
753 return autofs4_wait_release(sbi,(autofs_wqt_t)arg,-ENOENT);
754 case AUTOFS_IOC_CATATONIC: /* Enter catatonic mode (daemon shutdown) */
755 autofs4_catatonic_mode(sbi);
756 return 0;
757 case AUTOFS_IOC_PROTOVER: /* Get protocol version */
758 return autofs4_get_protover(sbi, p);
759 case AUTOFS_IOC_PROTOSUBVER: /* Get protocol sub version */
760 return autofs4_get_protosubver(sbi, p);
761 case AUTOFS_IOC_SETTIMEOUT:
762 return autofs4_get_set_timeout(sbi, p);
764 case AUTOFS_IOC_TOGGLEREGHOST:
765 return autofs4_toggle_reghost(sbi, p);
766 case AUTOFS_IOC_ASKREGHOST:
767 return autofs4_ask_reghost(sbi, p);
769 case AUTOFS_IOC_ASKUMOUNT:
770 return autofs4_ask_umount(filp->f_vfsmnt, p);
772 /* return a single thing to expire */
773 case AUTOFS_IOC_EXPIRE:
774 return autofs4_expire_run(inode->i_sb,filp->f_vfsmnt,sbi, p);
775 /* same as above, but can send multiple expires through pipe */
776 case AUTOFS_IOC_EXPIRE_MULTI:
777 return autofs4_expire_multi(inode->i_sb,filp->f_vfsmnt,sbi, p);
779 default:
780 return -ENOSYS;