]> git.hungrycats.org Git - linux/commitdiff
[PATCH] autofs4: add ioctl to query unmountability
authorAndrew Morton <akpm@osdl.org>
Sat, 15 May 2004 03:14:54 +0000 (20:14 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sat, 15 May 2004 03:14:54 +0000 (20:14 -0700)
From: Ian Kent <raven@themaw.net>

Add ioctl to find out if autofs mount can be umounted.  When the daemon
discovers this it's past the point of no return.

fs/autofs4/root.c
include/linux/auto_fs4.h

index 245f88b66affe7c46e4cc8d52372f7e5f7f01b0f..a5afb3104e79af8d74765359dbc8dce70cffd198 100644 (file)
@@ -673,6 +673,23 @@ static inline int autofs4_get_protosubver(struct autofs_sb_info *sbi, int *p)
        return put_user(sbi->sub_version, p);
 }
 
+/*
+* Tells the daemon whether it can umount the autofs mount.
+*/
+static inline int autofs4_ask_umount(struct vfsmount *mnt, int *p)
+{
+       int status = 0;
+
+       if (may_umount(mnt) == 0)
+               status = 1;
+
+       DPRINTK(("autofs_ask_umount: returning %d\n", status));
+
+       status = put_user(status, p);
+
+       return status;
+}
+
 /* Identify autofs4_dentries - this is so we can tell if there's
    an extra dentry refcount or not.  We only hold a refcount on the
    dentry if its non-negative (ie, d_inode != NULL)
@@ -719,6 +736,9 @@ static int autofs4_root_ioctl(struct inode *inode, struct file *filp,
        case AUTOFS_IOC_SETTIMEOUT:
                return autofs4_get_set_timeout(sbi,(unsigned long *)arg);
 
+       case AUTOFS_IOC_ASKUMOUNT:
+               return autofs4_ask_umount(filp->f_vfsmnt, (int *) arg);
+
        /* return a single thing to expire */
        case AUTOFS_IOC_EXPIRE:
                return autofs4_expire_run(inode->i_sb,filp->f_vfsmnt,sbi,
index 1494546329e5d552b99e67cb899c4d9470573c98..b7ca600efa99d78fd5d4934851feed5eb19d12c8 100644 (file)
@@ -49,6 +49,7 @@ union autofs_packet_union {
 
 #define AUTOFS_IOC_EXPIRE_MULTI _IOW(0x93,0x66,int)
 #define AUTOFS_IOC_PROTOSUBVER  _IOR(0x93,0x67,int)
+#define AUTOFS_IOC_ASKUMOUNT   _IOR(0x93,0x70,int)
 
 
 #endif /* _LINUX_AUTO_FS4_H */