Skip to content

Commit 8d7b48e

Browse files
raven-autorvalds
authored andcommitted
autofs4: add miscellaneous device for ioctls
Add a miscellaneous device to the autofs4 module for routing ioctls. This provides the ability to obtain an ioctl file handle for an autofs mount point that is possibly covered by another mount. The actual problem with autofs is that it can't reconnect to existing mounts. Immediately one things of just adding the ability to remount autofs file systems would solve it, but alas, that can't work. This is because autofs direct mounts and the implementation of "on demand mount and expire" of nested mount trees have the file system mounted on top of the mount trigger dentry. To resolve this a miscellaneous device node for routing ioctl commands to these mount points has been implemented in the autofs4 kernel module and a library added to autofs. This provides the ability to open a file descriptor for these over mounted autofs mount points. Please refer to Documentation/filesystems/autofs4-mount-control.txt for a discussion of the problem, implementation alternatives considered and a description of the interface. [akpm@linux-foundation.org: coding-style fixes] [akpm@linux-foundation.org: build fix] Signed-off-by: Ian Kent <raven@themaw.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 4b22ff1 commit 8d7b48e

7 files changed

Lines changed: 1073 additions & 13 deletions

File tree

‎fs/autofs4/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
obj-$(CONFIG_AUTOFS4_FS) += autofs4.o
66

7-
autofs4-objs := init.o inode.o root.o symlink.o waitq.o expire.o
7+
autofs4-objs := init.o inode.o root.o symlink.o waitq.o expire.o dev-ioctl.o

‎fs/autofs4/autofs_i.h‎

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@
1414
/* Internal header file for autofs */
1515

1616
#include <linux/auto_fs4.h>
17+
#include <linux/auto_dev-ioctl.h>
1718
#include <linux/mutex.h>
1819
#include <linux/list.h>
1920

2021
/* This is the range of ioctl() numbers we claim as ours */
2122
#define AUTOFS_IOC_FIRST AUTOFS_IOC_READY
2223
#define AUTOFS_IOC_COUNT 32
2324

25+
#define AUTOFS_DEV_IOCTL_IOC_FIRST (AUTOFS_DEV_IOCTL_VERSION)
26+
#define AUTOFS_DEV_IOCTL_IOC_COUNT (AUTOFS_IOC_COUNT - 11)
27+
2428
#define AUTOFS_TYPE_TRIGGER (AUTOFS_TYPE_DIRECT|AUTOFS_TYPE_OFFSET)
2529

2630
#include <linux/kernel.h>
@@ -37,11 +41,27 @@
3741
/* #define DEBUG */
3842

3943
#ifdef DEBUG
40-
#define DPRINTK(fmt,args...) do { printk(KERN_DEBUG "pid %d: %s: " fmt "\n" , current->pid , __func__ , ##args); } while(0)
44+
#define DPRINTK(fmt, args...) \
45+
do { \
46+
printk(KERN_DEBUG "pid %d: %s: " fmt "\n", \
47+
current->pid, __func__, ##args); \
48+
} while (0)
4149
#else
42-
#define DPRINTK(fmt,args...) do {} while(0)
50+
#define DPRINTK(fmt, args...) do {} while (0)
4351
#endif
4452

53+
#define AUTOFS_WARN(fmt, args...) \
54+
do { \
55+
printk(KERN_WARNING "pid %d: %s: " fmt "\n", \
56+
current->pid, __func__, ##args); \
57+
} while (0)
58+
59+
#define AUTOFS_ERROR(fmt, args...) \
60+
do { \
61+
printk(KERN_ERR "pid %d: %s: " fmt "\n", \
62+
current->pid, __func__, ##args); \
63+
} while (0)
64+
4565
/* Unified info structure. This is pointed to by both the dentry and
4666
inode structures. Each file in the filesystem has an instance of this
4767
structure. It holds a reference to the dentry, so dentries are never
@@ -170,6 +190,17 @@ int autofs4_expire_run(struct super_block *, struct vfsmount *,
170190
struct autofs_packet_expire __user *);
171191
int autofs4_expire_multi(struct super_block *, struct vfsmount *,
172192
struct autofs_sb_info *, int __user *);
193+
struct dentry *autofs4_expire_direct(struct super_block *sb,
194+
struct vfsmount *mnt,
195+
struct autofs_sb_info *sbi, int how);
196+
struct dentry *autofs4_expire_indirect(struct super_block *sb,
197+
struct vfsmount *mnt,
198+
struct autofs_sb_info *sbi, int how);
199+
200+
/* Device node initialization */
201+
202+
int autofs_dev_ioctl_init(void);
203+
void autofs_dev_ioctl_exit(void);
173204

174205
/* Operations structures */
175206

0 commit comments

Comments
 (0)