From: Ian Kent Add ioctl to find out if autofs mount can be umounted. When the daemon discovers this it's past the point of no return. --- 25-akpm/fs/autofs4/root.c | 20 ++++++++++++++++++++ 25-akpm/include/linux/auto_fs4.h | 1 + 2 files changed, 21 insertions(+) diff -puN fs/autofs4/root.c~6-autofs4-2.6.0-may_umount-20040405 fs/autofs4/root.c --- 25/fs/autofs4/root.c~6-autofs4-2.6.0-may_umount-20040405 Tue Apr 6 15:50:44 2004 +++ 25-akpm/fs/autofs4/root.c Tue Apr 6 15:50:44 2004 @@ -705,6 +705,23 @@ static inline int autofs4_get_protosubve 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) @@ -751,6 +768,9 @@ static int autofs4_root_ioctl(struct ino 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, diff -puN include/linux/auto_fs4.h~6-autofs4-2.6.0-may_umount-20040405 include/linux/auto_fs4.h --- 25/include/linux/auto_fs4.h~6-autofs4-2.6.0-may_umount-20040405 Tue Apr 6 15:50:44 2004 +++ 25-akpm/include/linux/auto_fs4.h Tue Apr 6 15:50:44 2004 @@ -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 */ _