aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2011-01-25 17:17:20 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-01-31 16:38:15 -0500
commit561c5cf9236a7eb5a52971b6e7e02c5bd094c6d5 (patch)
tree29a92308cd7415dc1b703e9d362ccaafb3ade213
parent8aea5882c54feb246ef20399cc55ae4672697ac0 (diff)
staging: Remove autofs3
autofs3 was moved to staging in 2.6.37, so we can remove it in the 2.6.39 merge window. If we have a reason to bring it back after that, this patch can get reverted. Signed-off-by: Arnd Bergmann <arnd@arndb.de> About-fscking-timed-by: H. Peter Anvin <hpa@zytor.com> Cc: Ian Kent <raven@themaw.net> Cc: autofs@linux.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--MAINTAINERS6
-rw-r--r--drivers/staging/Kconfig2
-rw-r--r--drivers/staging/Makefile1
-rw-r--r--drivers/staging/autofs/Kconfig22
-rw-r--r--drivers/staging/autofs/Makefile7
-rw-r--r--drivers/staging/autofs/TODO8
-rw-r--r--drivers/staging/autofs/autofs_i.h165
-rw-r--r--drivers/staging/autofs/dirhash.c260
-rw-r--r--drivers/staging/autofs/init.c52
-rw-r--r--drivers/staging/autofs/inode.c288
-rw-r--r--drivers/staging/autofs/root.c648
-rw-r--r--drivers/staging/autofs/symlink.c26
-rw-r--r--drivers/staging/autofs/waitq.c205
13 files changed, 0 insertions, 1690 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 1af022e63668..dd6ca456cde3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3559,12 +3559,6 @@ W: http://lse.sourceforge.net/kdump/
3559S: Maintained 3559S: Maintained
3560F: Documentation/kdump/ 3560F: Documentation/kdump/
3561 3561
3562KERNEL AUTOMOUNTER (AUTOFS)
3563M: "H. Peter Anvin" <hpa@zytor.com>
3564L: autofs@linux.kernel.org
3565S: Obsolete
3566F: drivers/staging/autofs/
3567
3568KERNEL AUTOMOUNTER v4 (AUTOFS4) 3562KERNEL AUTOMOUNTER v4 (AUTOFS4)
3569M: Ian Kent <raven@themaw.net> 3563M: Ian Kent <raven@themaw.net>
3570L: autofs@linux.kernel.org 3564L: autofs@linux.kernel.org
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index 9a5b7a6a97e4..8bcc153310c9 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -93,8 +93,6 @@ source "drivers/staging/frontier/Kconfig"
93 93
94source "drivers/staging/pohmelfs/Kconfig" 94source "drivers/staging/pohmelfs/Kconfig"
95 95
96source "drivers/staging/autofs/Kconfig"
97
98source "drivers/staging/phison/Kconfig" 96source "drivers/staging/phison/Kconfig"
99 97
100source "drivers/staging/line6/Kconfig" 98source "drivers/staging/line6/Kconfig"
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 2057b89d4d05..0919a423398c 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -31,7 +31,6 @@ obj-$(CONFIG_RTS_PSTOR) += rts_pstor/
31obj-$(CONFIG_SPECTRA) += spectra/ 31obj-$(CONFIG_SPECTRA) += spectra/
32obj-$(CONFIG_TRANZPORT) += frontier/ 32obj-$(CONFIG_TRANZPORT) += frontier/
33obj-$(CONFIG_POHMELFS) += pohmelfs/ 33obj-$(CONFIG_POHMELFS) += pohmelfs/
34obj-$(CONFIG_AUTOFS_FS) += autofs/
35obj-$(CONFIG_IDE_PHISON) += phison/ 34obj-$(CONFIG_IDE_PHISON) += phison/
36obj-$(CONFIG_LINE6_USB) += line6/ 35obj-$(CONFIG_LINE6_USB) += line6/
37obj-$(CONFIG_USB_SERIAL_QUATECH2) += serqt_usb2/ 36obj-$(CONFIG_USB_SERIAL_QUATECH2) += serqt_usb2/
diff --git a/drivers/staging/autofs/Kconfig b/drivers/staging/autofs/Kconfig
deleted file mode 100644
index 480e210c83ab..000000000000
--- a/drivers/staging/autofs/Kconfig
+++ /dev/null
@@ -1,22 +0,0 @@
1config AUTOFS_FS
2 tristate "Kernel automounter support"
3 depends on BKL # unfixable, just use autofs4
4 help
5 The automounter is a tool to automatically mount remote file systems
6 on demand. This implementation is partially kernel-based to reduce
7 overhead in the already-mounted case; this is unlike the BSD
8 automounter (amd), which is a pure user space daemon.
9
10 To use the automounter you need the user-space tools from the autofs
11 package; you can find the location in <file:Documentation/Changes>.
12 You also want to answer Y to "NFS file system support", below.
13
14 If you want to use the newer version of the automounter with more
15 features, say N here and say Y to "Kernel automounter v4 support",
16 below.
17
18 To compile this support as a module, choose M here: the module will be
19 called autofs.
20
21 If you are not a part of a fairly large, distributed network, you
22 probably do not need an automounter, and can say N here.
diff --git a/drivers/staging/autofs/Makefile b/drivers/staging/autofs/Makefile
deleted file mode 100644
index f48781c34df1..000000000000
--- a/drivers/staging/autofs/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
1#
2# Makefile for the linux autofs-filesystem routines.
3#
4
5obj-$(CONFIG_AUTOFS_FS) += autofs.o
6
7autofs-y := dirhash.o init.o inode.o root.o symlink.o waitq.o
diff --git a/drivers/staging/autofs/TODO b/drivers/staging/autofs/TODO
deleted file mode 100644
index 543803d03993..000000000000
--- a/drivers/staging/autofs/TODO
+++ /dev/null
@@ -1,8 +0,0 @@
1autofs version 3 is on its way out of the kernel,
2It has been replaced by autofs4 several years ago.
3
4The autofs3 code uses the big kernel lock which
5is getting deprecated.
6
7Users that find autofs3 to work but not autofs4
8should talk to Ian Kent <raven@themaw.net>.
diff --git a/drivers/staging/autofs/autofs_i.h b/drivers/staging/autofs/autofs_i.h
deleted file mode 100644
index 647a14356e39..000000000000
--- a/drivers/staging/autofs/autofs_i.h
+++ /dev/null
@@ -1,165 +0,0 @@
1/* -*- linux-c -*- ------------------------------------------------------- *
2 *
3 * drivers/staging/autofs/autofs_i.h
4 *
5 * Copyright 1997-1998 Transmeta Corporation - All Rights Reserved
6 *
7 * This file is part of the Linux kernel and is made available under
8 * the terms of the GNU General Public License, version 2, or at your
9 * option, any later version, incorporated herein by reference.
10 *
11 * ----------------------------------------------------------------------- */
12
13/* Internal header file for autofs */
14
15#include <linux/auto_fs.h>
16
17/* This is the range of ioctl() numbers we claim as ours */
18#define AUTOFS_IOC_FIRST AUTOFS_IOC_READY
19#define AUTOFS_IOC_COUNT 32
20
21#include <linux/kernel.h>
22#include <linux/slab.h>
23#include <linux/time.h>
24#include <linux/string.h>
25#include <linux/wait.h>
26#include <linux/dcache.h>
27#include <linux/namei.h>
28#include <linux/mount.h>
29#include <linux/sched.h>
30
31#include <asm/current.h>
32#include <asm/uaccess.h>
33
34#ifdef DEBUG
35#define DPRINTK(D) (printk D)
36#else
37#define DPRINTK(D) ((void)0)
38#endif
39
40/*
41 * If the daemon returns a negative response (AUTOFS_IOC_FAIL) then the
42 * kernel will keep the negative response cached for up to the time given
43 * here, although the time can be shorter if the kernel throws the dcache
44 * entry away. This probably should be settable from user space.
45 */
46#define AUTOFS_NEGATIVE_TIMEOUT (60*HZ) /* 1 minute */
47
48/* Structures associated with the root directory hash table */
49
50#define AUTOFS_HASH_SIZE 67
51
52struct autofs_dir_ent {
53 int hash;
54 char *name;
55 int len;
56 ino_t ino;
57 struct dentry *dentry;
58 /* Linked list of entries */
59 struct autofs_dir_ent *next;
60 struct autofs_dir_ent **back;
61 /* The following entries are for the expiry system */
62 unsigned long last_usage;
63 struct list_head exp;
64};
65
66struct autofs_dirhash {
67 struct autofs_dir_ent *h[AUTOFS_HASH_SIZE];
68 struct list_head expiry_head;
69};
70
71struct autofs_wait_queue {
72 wait_queue_head_t queue;
73 struct autofs_wait_queue *next;
74 autofs_wqt_t wait_queue_token;
75 /* We use the following to see what we are waiting for */
76 int hash;
77 int len;
78 char *name;
79 /* This is for status reporting upon return */
80 int status;
81 int wait_ctr;
82};
83
84struct autofs_symlink {
85 char *data;
86 int len;
87 time_t mtime;
88};
89
90#define AUTOFS_MAX_SYMLINKS 256
91
92#define AUTOFS_ROOT_INO 1
93#define AUTOFS_FIRST_SYMLINK 2
94#define AUTOFS_FIRST_DIR_INO (AUTOFS_FIRST_SYMLINK+AUTOFS_MAX_SYMLINKS)
95
96#define AUTOFS_SYMLINK_BITMAP_LEN \
97 ((AUTOFS_MAX_SYMLINKS+((sizeof(long)*1)-1))/(sizeof(long)*8))
98
99#define AUTOFS_SBI_MAGIC 0x6d4a556d
100
101struct autofs_sb_info {
102 u32 magic;
103 struct file *pipe;
104 struct pid *oz_pgrp;
105 int catatonic;
106 struct super_block *sb;
107 unsigned long exp_timeout;
108 ino_t next_dir_ino;
109 struct autofs_wait_queue *queues; /* Wait queue pointer */
110 struct autofs_dirhash dirhash; /* Root directory hash */
111 struct autofs_symlink symlink[AUTOFS_MAX_SYMLINKS];
112 unsigned long symlink_bitmap[AUTOFS_SYMLINK_BITMAP_LEN];
113};
114
115static inline struct autofs_sb_info *autofs_sbi(struct super_block *sb)
116{
117 return (struct autofs_sb_info *)(sb->s_fs_info);
118}
119
120/* autofs_oz_mode(): do we see the man behind the curtain? (The
121 processes which do manipulations for us in user space sees the raw
122 filesystem without "magic".) */
123
124static inline int autofs_oz_mode(struct autofs_sb_info *sbi) {
125 return sbi->catatonic || task_pgrp(current) == sbi->oz_pgrp;
126}
127
128/* Hash operations */
129
130void autofs_initialize_hash(struct autofs_dirhash *);
131struct autofs_dir_ent *autofs_hash_lookup(const struct autofs_dirhash *,struct qstr *);
132void autofs_hash_insert(struct autofs_dirhash *,struct autofs_dir_ent *);
133void autofs_hash_delete(struct autofs_dir_ent *);
134struct autofs_dir_ent *autofs_hash_enum(const struct autofs_dirhash *,off_t *,struct autofs_dir_ent *);
135void autofs_hash_dputall(struct autofs_dirhash *);
136void autofs_hash_nuke(struct autofs_sb_info *);
137
138/* Expiration-handling functions */
139
140void autofs_update_usage(struct autofs_dirhash *,struct autofs_dir_ent *);
141struct autofs_dir_ent *autofs_expire(struct super_block *,struct autofs_sb_info *, struct vfsmount *mnt);
142
143/* Operations structures */
144
145extern const struct inode_operations autofs_root_inode_operations;
146extern const struct inode_operations autofs_symlink_inode_operations;
147extern const struct file_operations autofs_root_operations;
148
149/* Initializing function */
150
151int autofs_fill_super(struct super_block *, void *, int);
152void autofs_kill_sb(struct super_block *sb);
153struct inode *autofs_iget(struct super_block *, unsigned long);
154
155/* Queue management functions */
156
157int autofs_wait(struct autofs_sb_info *,struct qstr *);
158int autofs_wait_release(struct autofs_sb_info *,autofs_wqt_t,int);
159void autofs_catatonic_mode(struct autofs_sb_info *);
160
161#ifdef DEBUG
162void autofs_say(const char *name, int len);
163#else
164#define autofs_say(n,l) ((void)0)
165#endif
diff --git a/drivers/staging/autofs/dirhash.c b/drivers/staging/autofs/dirhash.c
deleted file mode 100644
index a08bd7355035..000000000000
--- a/drivers/staging/autofs/dirhash.c
+++ /dev/null
@@ -1,260 +0,0 @@
1/* -*- linux-c -*- --------------------------------------------------------- *
2 *
3 * drivers/staging/autofs/dirhash.c
4 *
5 * Copyright 1997-1998 Transmeta Corporation -- All Rights Reserved
6 *
7 * This file is part of the Linux kernel and is made available under
8 * the terms of the GNU General Public License, version 2, or at your
9 * option, any later version, incorporated herein by reference.
10 *
11 * ------------------------------------------------------------------------- */
12
13#include "autofs_i.h"
14
15/* Functions for maintenance of expiry queue */
16
17static void autofs_init_usage(struct autofs_dirhash *dh,
18 struct autofs_dir_ent *ent)
19{
20 list_add_tail(&ent->exp, &dh->expiry_head);
21 ent->last_usage = jiffies;
22}
23
24static void autofs_delete_usage(struct autofs_dir_ent *ent)
25{
26 list_del(&ent->exp);
27}
28
29void autofs_update_usage(struct autofs_dirhash *dh,
30 struct autofs_dir_ent *ent)
31{
32 autofs_delete_usage(ent); /* Unlink from current position */
33 autofs_init_usage(dh, ent); /* Relink at queue tail */
34}
35
36struct autofs_dir_ent *autofs_expire(struct super_block *sb,
37 struct autofs_sb_info *sbi,
38 struct vfsmount *mnt)
39{
40 struct autofs_dirhash *dh = &sbi->dirhash;
41 struct autofs_dir_ent *ent;
42 unsigned long timeout = sbi->exp_timeout;
43
44 while (1) {
45 struct path path;
46 int umount_ok;
47
48 if (list_empty(&dh->expiry_head) || sbi->catatonic)
49 return NULL; /* No entries */
50 /* We keep the list sorted by last_usage and want old stuff */
51 ent = list_entry(dh->expiry_head.next,
52 struct autofs_dir_ent, exp);
53 if (jiffies - ent->last_usage < timeout)
54 break;
55 /* Move to end of list in case expiry isn't desirable */
56 autofs_update_usage(dh, ent);
57
58 /* Check to see that entry is expirable */
59 if (ent->ino < AUTOFS_FIRST_DIR_INO)
60 return ent; /* Symlinks are always expirable */
61
62 /* Get the dentry for the autofs subdirectory */
63 path.dentry = ent->dentry;
64
65 if (!path.dentry) {
66 /* Should only happen in catatonic mode */
67 printk(KERN_DEBUG "autofs: dentry == NULL but inode \
68 range is directory, entry %s\n", ent->name);
69 autofs_delete_usage(ent);
70 continue;
71 }
72
73 if (!path.dentry->d_inode) {
74 dput(path.dentry);
75 printk(KERN_DEBUG "autofs: negative dentry on expiry queue: %s\n",
76 ent->name);
77 autofs_delete_usage(ent);
78 continue;
79 }
80
81 /* Make sure entry is mounted and unused; note that dentry will
82 point to the mounted-on-top root. */
83 if (!S_ISDIR(path.dentry->d_inode->i_mode) ||
84 !d_mountpoint(path.dentry)) {
85 DPRINTK(("autofs: not expirable \
86 (not a mounted directory): %s\n", ent->name));
87 continue;
88 }
89 path.mnt = mnt;
90 path_get(&path);
91 if (!follow_down_one(&path)) {
92 path_put(&path);
93 DPRINTK(("autofs: not expirable\
94 (not a mounted directory): %s\n", ent->name));
95 continue;
96 }
97 follow_down(&path, false); // TODO: need to check error
98 umount_ok = may_umount(path.mnt);
99 path_put(&path);
100
101 if (umount_ok) {
102 DPRINTK(("autofs: signaling expire on %s\n",
103 ent->name));
104 return ent; /* Expirable! */
105 }
106
107 DPRINTK(("autofs: didn't expire due to may_umount: %s\n",
108 ent->name));
109 }
110 return NULL; /* No expirable entries */
111}
112
113void autofs_initialize_hash(struct autofs_dirhash *dh)
114{
115 memset(&dh->h, 0, AUTOFS_HASH_SIZE*sizeof(struct autofs_dir_ent *));
116 INIT_LIST_HEAD(&dh->expiry_head);
117}
118
119struct autofs_dir_ent *autofs_hash_lookup(const struct autofs_dirhash *dh,
120 struct qstr *name)
121{
122 struct autofs_dir_ent *dhn;
123
124 DPRINTK(("autofs_hash_lookup: hash = 0x%08x, name = ", name->hash));
125 autofs_say(name->name, name->len);
126
127 for (dhn = dh->h[(unsigned) name->hash % AUTOFS_HASH_SIZE];
128 dhn;
129 dhn = dhn->next) {
130 if (name->hash == dhn->hash &&
131 name->len == dhn->len &&
132 !memcmp(name->name, dhn->name, name->len))
133 break;
134 }
135
136 return dhn;
137}
138
139void autofs_hash_insert(struct autofs_dirhash *dh, struct autofs_dir_ent *ent)
140{
141 struct autofs_dir_ent **dhnp;
142
143 DPRINTK(("autofs_hash_insert: hash = 0x%08x, name = ", ent->hash));
144 autofs_say(ent->name, ent->len);
145
146 autofs_init_usage(dh, ent);
147 if (ent->dentry)
148 dget(ent->dentry);
149
150 dhnp = &dh->h[(unsigned) ent->hash % AUTOFS_HASH_SIZE];
151 ent->next = *dhnp;
152 ent->back = dhnp;
153 *dhnp = ent;
154 if (ent->next)
155 ent->next->back = &(ent->next);
156}
157
158void autofs_hash_delete(struct autofs_dir_ent *ent)
159{
160 *(ent->back) = ent->next;
161 if (ent->next)
162 ent->next->back = ent->back;
163
164 autofs_delete_usage(ent);
165
166 if (ent->dentry)
167 dput(ent->dentry);
168 kfree(ent->name);
169 kfree(ent);
170}
171
172/*
173 * Used by readdir(). We must validate "ptr", so we can't simply make it
174 * a pointer. Values below 0xffff are reserved; calling with any value
175 * <= 0x10000 will return the first entry found.
176 *
177 * "last" can be NULL or the value returned by the last search *if* we
178 * want the next sequential entry.
179 */
180struct autofs_dir_ent *autofs_hash_enum(const struct autofs_dirhash *dh,
181 off_t *ptr, struct autofs_dir_ent *last)
182{
183 int bucket, ecount, i;
184 struct autofs_dir_ent *ent;
185
186 bucket = (*ptr >> 16) - 1;
187 ecount = *ptr & 0xffff;
188
189 if (bucket < 0)
190 bucket = ecount = 0;
191
192 DPRINTK(("autofs_hash_enum: bucket %d, entry %d\n", bucket, ecount));
193
194 ent = last ? last->next : NULL;
195
196 if (ent) {
197 ecount++;
198 } else {
199 while (bucket < AUTOFS_HASH_SIZE) {
200 ent = dh->h[bucket];
201 for (i = ecount ; ent && i ; i--)
202 ent = ent->next;
203
204 if (ent) {
205 ecount++; /* Point to *next* entry */
206 break;
207 }
208
209 bucket++; ecount = 0;
210 }
211 }
212
213#ifdef DEBUG
214 if (!ent)
215 printk(KERN_DEBUG "autofs_hash_enum: nothing found\n");
216 else {
217 printk(KERN_DEBUG "autofs_hash_enum: found hash %08x, name",
218 ent->hash);
219 autofs_say(ent->name, ent->len);
220 }
221#endif
222
223 *ptr = ((bucket+1) << 16) + ecount;
224 return ent;
225}
226
227/* Iterate over all the ents, and remove all dentry pointers. Used on
228 entering catatonic mode, in order to make the filesystem unmountable. */
229void autofs_hash_dputall(struct autofs_dirhash *dh)
230{
231 int i;
232 struct autofs_dir_ent *ent;
233
234 for (i = 0 ; i < AUTOFS_HASH_SIZE ; i++) {
235 for (ent = dh->h[i] ; ent ; ent = ent->next) {
236 if (ent->dentry) {
237 dput(ent->dentry);
238 ent->dentry = NULL;
239 }
240 }
241 }
242}
243
244/* Delete everything. This is used on filesystem destruction, so we
245 make no attempt to keep the pointers valid */
246void autofs_hash_nuke(struct autofs_sb_info *sbi)
247{
248 int i;
249 struct autofs_dir_ent *ent, *nent;
250
251 for (i = 0 ; i < AUTOFS_HASH_SIZE ; i++) {
252 for (ent = sbi->dirhash.h[i] ; ent ; ent = nent) {
253 nent = ent->next;
254 if (ent->dentry)
255 dput(ent->dentry);
256 kfree(ent->name);
257 kfree(ent);
258 }
259 }
260}
diff --git a/drivers/staging/autofs/init.c b/drivers/staging/autofs/init.c
deleted file mode 100644
index 5e4b372ea663..000000000000
--- a/drivers/staging/autofs/init.c
+++ /dev/null
@@ -1,52 +0,0 @@
1/* -*- linux-c -*- --------------------------------------------------------- *
2 *
3 * drivers/staging/autofs/init.c
4 *
5 * Copyright 1997-1998 Transmeta Corporation -- All Rights Reserved
6 *
7 * This file is part of the Linux kernel and is made available under
8 * the terms of the GNU General Public License, version 2, or at your
9 * option, any later version, incorporated herein by reference.
10 *
11 * ------------------------------------------------------------------------- */
12
13#include <linux/module.h>
14#include <linux/init.h>
15#include "autofs_i.h"
16
17static struct dentry *autofs_mount(struct file_system_type *fs_type,
18 int flags, const char *dev_name, void *data)
19{
20 return mount_nodev(fs_type, flags, data, autofs_fill_super);
21}
22
23static struct file_system_type autofs_fs_type = {
24 .owner = THIS_MODULE,
25 .name = "autofs",
26 .mount = autofs_mount,
27 .kill_sb = autofs_kill_sb,
28};
29
30static int __init init_autofs_fs(void)
31{
32 return register_filesystem(&autofs_fs_type);
33}
34
35static void __exit exit_autofs_fs(void)
36{
37 unregister_filesystem(&autofs_fs_type);
38}
39
40module_init(init_autofs_fs);
41module_exit(exit_autofs_fs);
42
43#ifdef DEBUG
44void autofs_say(const char *name, int len)
45{
46 printk("(%d: ", len);
47 while ( len-- )
48 printk("%c", *name++);
49 printk(")\n");
50}
51#endif
52MODULE_LICENSE("GPL");
diff --git a/drivers/staging/autofs/inode.c b/drivers/staging/autofs/inode.c
deleted file mode 100644
index 74db190ae845..000000000000
--- a/drivers/staging/autofs/inode.c
+++ /dev/null
@@ -1,288 +0,0 @@
1/* -*- linux-c -*- --------------------------------------------------------- *
2 *
3 * drivers/staging/autofs/inode.c
4 *
5 * Copyright 1997-1998 Transmeta Corporation -- All Rights Reserved
6 *
7 * This file is part of the Linux kernel and is made available under
8 * the terms of the GNU General Public License, version 2, or at your
9 * option, any later version, incorporated herein by reference.
10 *
11 * ------------------------------------------------------------------------- */
12
13#include <linux/kernel.h>
14#include <linux/mm.h>
15#include <linux/slab.h>
16#include <linux/file.h>
17#include <linux/parser.h>
18#include <linux/bitops.h>
19#include <linux/magic.h>
20#include "autofs_i.h"
21#include <linux/module.h>
22
23void autofs_kill_sb(struct super_block *sb)
24{
25 struct autofs_sb_info *sbi = autofs_sbi(sb);
26 unsigned int n;
27
28 /*
29 * In the event of a failure in get_sb_nodev the superblock
30 * info is not present so nothing else has been setup, so
31 * just call kill_anon_super when we are called from
32 * deactivate_super.
33 */
34 if (!sbi)
35 goto out_kill_sb;
36
37 if (!sbi->catatonic)
38 autofs_catatonic_mode(sbi); /* Free wait queues, close pipe */
39
40 put_pid(sbi->oz_pgrp);
41
42 autofs_hash_nuke(sbi);
43 for (n = 0; n < AUTOFS_MAX_SYMLINKS; n++) {
44 if (test_bit(n, sbi->symlink_bitmap))
45 kfree(sbi->symlink[n].data);
46 }
47
48 kfree(sb->s_fs_info);
49
50out_kill_sb:
51 DPRINTK(("autofs: shutting down\n"));
52 kill_anon_super(sb);
53}
54
55static const struct super_operations autofs_sops = {
56 .statfs = simple_statfs,
57 .show_options = generic_show_options,
58};
59
60enum {Opt_err, Opt_fd, Opt_uid, Opt_gid, Opt_pgrp, Opt_minproto, Opt_maxproto};
61
62static const match_table_t autofs_tokens = {
63 {Opt_fd, "fd=%u"},
64 {Opt_uid, "uid=%u"},
65 {Opt_gid, "gid=%u"},
66 {Opt_pgrp, "pgrp=%u"},
67 {Opt_minproto, "minproto=%u"},
68 {Opt_maxproto, "maxproto=%u"},
69 {Opt_err, NULL}
70};
71
72static int parse_options(char *options, int *pipefd, uid_t *uid, gid_t *gid,
73 pid_t *pgrp, int *minproto, int *maxproto)
74{
75 char *p;
76 substring_t args[MAX_OPT_ARGS];
77 int option;
78
79 *uid = current_uid();
80 *gid = current_gid();
81 *pgrp = task_pgrp_nr(current);
82
83 *minproto = *maxproto = AUTOFS_PROTO_VERSION;
84
85 *pipefd = -1;
86
87 if (!options)
88 return 1;
89
90 while ((p = strsep(&options, ",")) != NULL) {
91 int token;
92 if (!*p)
93 continue;
94
95 token = match_token(p, autofs_tokens, args);
96 switch (token) {
97 case Opt_fd:
98 if (match_int(&args[0], &option))
99 return 1;
100 *pipefd = option;
101 break;
102 case Opt_uid:
103 if (match_int(&args[0], &option))
104 return 1;
105 *uid = option;
106 break;
107 case Opt_gid:
108 if (match_int(&args[0], &option))
109 return 1;
110 *gid = option;
111 break;
112 case Opt_pgrp:
113 if (match_int(&args[0], &option))
114 return 1;
115 *pgrp = option;
116 break;
117 case Opt_minproto:
118 if (match_int(&args[0], &option))
119 return 1;
120 *minproto = option;
121 break;
122 case Opt_maxproto:
123 if (match_int(&args[0], &option))
124 return 1;
125 *maxproto = option;
126 break;
127 default:
128 return 1;
129 }
130 }
131 return (*pipefd < 0);
132}
133
134int autofs_fill_super(struct super_block *s, void *data, int silent)
135{
136 struct inode * root_inode;
137 struct dentry * root;
138 struct file * pipe;
139 int pipefd;
140 struct autofs_sb_info *sbi;
141 int minproto, maxproto;
142 pid_t pgid;
143
144 save_mount_options(s, data);
145
146 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
147 if (!sbi)
148 goto fail_unlock;
149 DPRINTK(("autofs: starting up, sbi = %p\n",sbi));
150
151 s->s_fs_info = sbi;
152 sbi->magic = AUTOFS_SBI_MAGIC;
153 sbi->pipe = NULL;
154 sbi->catatonic = 1;
155 sbi->exp_timeout = 0;
156 autofs_initialize_hash(&sbi->dirhash);
157 sbi->queues = NULL;
158 memset(sbi->symlink_bitmap, 0, sizeof(long)*AUTOFS_SYMLINK_BITMAP_LEN);
159 sbi->next_dir_ino = AUTOFS_FIRST_DIR_INO;
160 s->s_blocksize = 1024;
161 s->s_blocksize_bits = 10;
162 s->s_magic = AUTOFS_SUPER_MAGIC;
163 s->s_op = &autofs_sops;
164 s->s_time_gran = 1;
165 sbi->sb = s;
166
167 root_inode = autofs_iget(s, AUTOFS_ROOT_INO);
168 if (IS_ERR(root_inode))
169 goto fail_free;
170 root = d_alloc_root(root_inode);
171 pipe = NULL;
172
173 if (!root)
174 goto fail_iput;
175
176 /* Can this call block? - WTF cares? s is locked. */
177 if (parse_options(data, &pipefd, &root_inode->i_uid,
178 &root_inode->i_gid, &pgid, &minproto,
179 &maxproto)) {
180 printk("autofs: called with bogus options\n");
181 goto fail_dput;
182 }
183
184 /* Couldn't this be tested earlier? */
185 if (minproto > AUTOFS_PROTO_VERSION ||
186 maxproto < AUTOFS_PROTO_VERSION) {
187 printk("autofs: kernel does not match daemon version\n");
188 goto fail_dput;
189 }
190
191 DPRINTK(("autofs: pipe fd = %d, pgrp = %u\n", pipefd, pgid));
192 sbi->oz_pgrp = find_get_pid(pgid);
193
194 if (!sbi->oz_pgrp) {
195 printk("autofs: could not find process group %d\n", pgid);
196 goto fail_dput;
197 }
198
199 pipe = fget(pipefd);
200
201 if (!pipe) {
202 printk("autofs: could not open pipe file descriptor\n");
203 goto fail_put_pid;
204 }
205
206 if (!pipe->f_op || !pipe->f_op->write)
207 goto fail_fput;
208 sbi->pipe = pipe;
209 sbi->catatonic = 0;
210
211 /*
212 * Success! Install the root dentry now to indicate completion.
213 */
214 s->s_root = root;
215 return 0;
216
217fail_fput:
218 printk("autofs: pipe file descriptor does not contain proper ops\n");
219 fput(pipe);
220fail_put_pid:
221 put_pid(sbi->oz_pgrp);
222fail_dput:
223 dput(root);
224 goto fail_free;
225fail_iput:
226 printk("autofs: get root dentry failed\n");
227 iput(root_inode);
228fail_free:
229 kfree(sbi);
230 s->s_fs_info = NULL;
231fail_unlock:
232 return -EINVAL;
233}
234
235struct inode *autofs_iget(struct super_block *sb, unsigned long ino)
236{
237 unsigned int n;
238 struct autofs_sb_info *sbi = autofs_sbi(sb);
239 struct inode *inode;
240
241 inode = iget_locked(sb, ino);
242 if (!inode)
243 return ERR_PTR(-ENOMEM);
244 if (!(inode->i_state & I_NEW))
245 return inode;
246
247 /* Initialize to the default case (stub directory) */
248
249 inode->i_op = &simple_dir_inode_operations;
250 inode->i_fop = &simple_dir_operations;
251 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
252 inode->i_nlink = 2;
253 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
254
255 if (ino == AUTOFS_ROOT_INO) {
256 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
257 inode->i_op = &autofs_root_inode_operations;
258 inode->i_fop = &autofs_root_operations;
259 goto done;
260 }
261
262 inode->i_uid = inode->i_sb->s_root->d_inode->i_uid;
263 inode->i_gid = inode->i_sb->s_root->d_inode->i_gid;
264
265 if (ino >= AUTOFS_FIRST_SYMLINK && ino < AUTOFS_FIRST_DIR_INO) {
266 /* Symlink inode - should be in symlink list */
267 struct autofs_symlink *sl;
268
269 n = ino - AUTOFS_FIRST_SYMLINK;
270 if (n >= AUTOFS_MAX_SYMLINKS || !test_bit(n,sbi->symlink_bitmap)) {
271 printk("autofs: Looking for bad symlink inode %u\n", (unsigned int) ino);
272 goto done;
273 }
274
275 inode->i_op = &autofs_symlink_inode_operations;
276 sl = &sbi->symlink[n];
277 inode->i_private = sl;
278 inode->i_mode = S_IFLNK | S_IRWXUGO;
279 inode->i_mtime.tv_sec = inode->i_ctime.tv_sec = sl->mtime;
280 inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = 0;
281 inode->i_size = sl->len;
282 inode->i_nlink = 1;
283 }
284
285done:
286 unlock_new_inode(inode);
287 return inode;
288}
diff --git a/drivers/staging/autofs/root.c b/drivers/staging/autofs/root.c
deleted file mode 100644
index bf0e9755da67..000000000000
--- a/drivers/staging/autofs/root.c
+++ /dev/null
@@ -1,648 +0,0 @@
1/* -*- linux-c -*- --------------------------------------------------------- *
2 *
3 * drivers/staging/autofs/root.c
4 *
5 * Copyright 1997-1998 Transmeta Corporation -- All Rights Reserved
6 *
7 * This file is part of the Linux kernel and is made available under
8 * the terms of the GNU General Public License, version 2, or at your
9 * option, any later version, incorporated herein by reference.
10 *
11 * ------------------------------------------------------------------------- */
12
13#include <linux/capability.h>
14#include <linux/errno.h>
15#include <linux/stat.h>
16#include <linux/slab.h>
17#include <linux/param.h>
18#include <linux/time.h>
19#include <linux/compat.h>
20#include <linux/smp_lock.h>
21#include "autofs_i.h"
22
23static int autofs_root_readdir(struct file *,void *,filldir_t);
24static struct dentry *autofs_root_lookup(struct inode *,struct dentry *, struct nameidata *);
25static int autofs_root_symlink(struct inode *,struct dentry *,const char *);
26static int autofs_root_unlink(struct inode *,struct dentry *);
27static int autofs_root_rmdir(struct inode *,struct dentry *);
28static int autofs_root_mkdir(struct inode *,struct dentry *,int);
29static long autofs_root_ioctl(struct file *,unsigned int,unsigned long);
30#ifdef CONFIG_COMPAT
31static long autofs_root_compat_ioctl(struct file *,unsigned int,unsigned long);
32#endif
33
34const struct file_operations autofs_root_operations = {
35 .llseek = generic_file_llseek,
36 .read = generic_read_dir,
37 .readdir = autofs_root_readdir,
38 .unlocked_ioctl = autofs_root_ioctl,
39#ifdef CONFIG_COMPAT
40 .compat_ioctl = autofs_root_compat_ioctl,
41#endif
42};
43
44const struct inode_operations autofs_root_inode_operations = {
45 .lookup = autofs_root_lookup,
46 .unlink = autofs_root_unlink,
47 .symlink = autofs_root_symlink,
48 .mkdir = autofs_root_mkdir,
49 .rmdir = autofs_root_rmdir,
50};
51
52static int autofs_root_readdir(struct file *filp, void *dirent, filldir_t filldir)
53{
54 struct autofs_dir_ent *ent = NULL;
55 struct autofs_dirhash *dirhash;
56 struct autofs_sb_info *sbi;
57 struct inode * inode = filp->f_path.dentry->d_inode;
58 off_t onr, nr;
59
60 lock_kernel();
61
62 sbi = autofs_sbi(inode->i_sb);
63 dirhash = &sbi->dirhash;
64 nr = filp->f_pos;
65
66 switch(nr)
67 {
68 case 0:
69 if (filldir(dirent, ".", 1, nr, inode->i_ino, DT_DIR) < 0)
70 goto out;
71 filp->f_pos = ++nr;
72 /* fall through */
73 case 1:
74 if (filldir(dirent, "..", 2, nr, inode->i_ino, DT_DIR) < 0)
75 goto out;
76 filp->f_pos = ++nr;
77 /* fall through */
78 default:
79 while (onr = nr, ent = autofs_hash_enum(dirhash,&nr,ent)) {
80 if (!ent->dentry || d_mountpoint(ent->dentry)) {
81 if (filldir(dirent,ent->name,ent->len,onr,ent->ino,DT_UNKNOWN) < 0)
82 goto out;
83 filp->f_pos = nr;
84 }
85 }
86 break;
87 }
88
89out:
90 unlock_kernel();
91 return 0;
92}
93
94static int try_to_fill_dentry(struct dentry *dentry, struct super_block *sb, struct autofs_sb_info *sbi)
95{
96 struct inode * inode;
97 struct autofs_dir_ent *ent;
98 int status = 0;
99
100 if (!(ent = autofs_hash_lookup(&sbi->dirhash, &dentry->d_name))) {
101 do {
102 if (status && dentry->d_inode) {
103 if (status != -ENOENT)
104 printk("autofs warning: lookup failure on positive dentry, status = %d, name = %s\n", status, dentry->d_name.name);
105 return 0; /* Try to get the kernel to invalidate this dentry */
106 }
107
108 /* Turn this into a real negative dentry? */
109 if (status == -ENOENT) {
110 dentry->d_time = jiffies + AUTOFS_NEGATIVE_TIMEOUT;
111 dentry->d_flags &= ~DCACHE_AUTOFS_PENDING;
112 return 1;
113 } else if (status) {
114 /* Return a negative dentry, but leave it "pending" */
115 return 1;
116 }
117 status = autofs_wait(sbi, &dentry->d_name);
118 } while (!(ent = autofs_hash_lookup(&sbi->dirhash, &dentry->d_name)));
119 }
120
121 /* Abuse this field as a pointer to the directory entry, used to
122 find the expire list pointers */
123 dentry->d_time = (unsigned long) ent;
124
125 if (!dentry->d_inode) {
126 inode = autofs_iget(sb, ent->ino);
127 if (IS_ERR(inode)) {
128 /* Failed, but leave pending for next time */
129 return 1;
130 }
131 dentry->d_inode = inode;
132 }
133
134 /* If this is a directory that isn't a mount point, bitch at the
135 daemon and fix it in user space */
136 if (S_ISDIR(dentry->d_inode->i_mode) && !d_mountpoint(dentry)) {
137 return !autofs_wait(sbi, &dentry->d_name);
138 }
139
140 /* We don't update the usages for the autofs daemon itself, this
141 is necessary for recursive autofs mounts */
142 if (!autofs_oz_mode(sbi)) {
143 autofs_update_usage(&sbi->dirhash,ent);
144 }
145
146 dentry->d_flags &= ~DCACHE_AUTOFS_PENDING;
147 return 1;
148}
149
150
151/*
152 * Revalidate is called on every cache lookup. Some of those
153 * cache lookups may actually happen while the dentry is not
154 * yet completely filled in, and revalidate has to delay such
155 * lookups..
156 */
157static int autofs_revalidate(struct dentry *dentry, struct nameidata *nd)
158{
159 struct inode * dir;
160 struct autofs_sb_info *sbi;
161 struct autofs_dir_ent *ent;
162 int res;
163
164 if (nd->flags & LOOKUP_RCU)
165 return -ECHILD;
166
167 lock_kernel();
168 dir = dentry->d_parent->d_inode;
169 sbi = autofs_sbi(dir->i_sb);
170
171 /* Pending dentry */
172 if (dentry->d_flags & DCACHE_AUTOFS_PENDING) {
173 if (autofs_oz_mode(sbi))
174 res = 1;
175 else
176 res = try_to_fill_dentry(dentry, dir->i_sb, sbi);
177 unlock_kernel();
178 return res;
179 }
180
181 /* Negative dentry.. invalidate if "old" */
182 if (!dentry->d_inode) {
183 unlock_kernel();
184 return (dentry->d_time - jiffies <= AUTOFS_NEGATIVE_TIMEOUT);
185 }
186
187 /* Check for a non-mountpoint directory */
188 if (S_ISDIR(dentry->d_inode->i_mode) && !d_mountpoint(dentry)) {
189 if (autofs_oz_mode(sbi))
190 res = 1;
191 else
192 res = try_to_fill_dentry(dentry, dir->i_sb, sbi);
193 unlock_kernel();
194 return res;
195 }
196
197 /* Update the usage list */
198 if (!autofs_oz_mode(sbi)) {
199 ent = (struct autofs_dir_ent *) dentry->d_time;
200 if (ent)
201 autofs_update_usage(&sbi->dirhash,ent);
202 }
203 unlock_kernel();
204 return 1;
205}
206
207static const struct dentry_operations autofs_dentry_operations = {
208 .d_revalidate = autofs_revalidate,
209};
210
211static struct dentry *autofs_root_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
212{
213 struct autofs_sb_info *sbi;
214 int oz_mode;
215
216 DPRINTK(("autofs_root_lookup: name = "));
217 lock_kernel();
218 autofs_say(dentry->d_name.name,dentry->d_name.len);
219
220 if (dentry->d_name.len > NAME_MAX) {
221 unlock_kernel();
222 return ERR_PTR(-ENAMETOOLONG);/* File name too long to exist */
223 }
224
225 sbi = autofs_sbi(dir->i_sb);
226
227 oz_mode = autofs_oz_mode(sbi);
228 DPRINTK(("autofs_lookup: pid = %u, pgrp = %u, catatonic = %d, "
229 "oz_mode = %d\n", task_pid_nr(current),
230 task_pgrp_nr(current), sbi->catatonic,
231 oz_mode));
232
233 /*
234 * Mark the dentry incomplete, but add it. This is needed so
235 * that the VFS layer knows about the dentry, and we can count
236 * on catching any lookups through the revalidate.
237 *
238 * Let all the hard work be done by the revalidate function that
239 * needs to be able to do this anyway..
240 *
241 * We need to do this before we release the directory semaphore.
242 */
243 d_set_d_op(dentry, &autofs_dentry_operations);
244 dentry->d_flags |= DCACHE_AUTOFS_PENDING;
245 d_add(dentry, NULL);
246
247 mutex_unlock(&dir->i_mutex);
248 autofs_revalidate(dentry, nd);
249 mutex_lock(&dir->i_mutex);
250
251 /*
252 * If we are still pending, check if we had to handle
253 * a signal. If so we can force a restart..
254 */
255 if (dentry->d_flags & DCACHE_AUTOFS_PENDING) {
256 /* See if we were interrupted */
257 if (signal_pending(current)) {
258 sigset_t *sigset = &current->pending.signal;
259 if (sigismember (sigset, SIGKILL) ||
260 sigismember (sigset, SIGQUIT) ||
261 sigismember (sigset, SIGINT)) {
262 unlock_kernel();
263 return ERR_PTR(-ERESTARTNOINTR);
264 }
265 }
266 }
267 unlock_kernel();
268
269 /*
270 * If this dentry is unhashed, then we shouldn't honour this
271 * lookup even if the dentry is positive. Returning ENOENT here
272 * doesn't do the right thing for all system calls, but it should
273 * be OK for the operations we permit from an autofs.
274 */
275 if (dentry->d_inode && d_unhashed(dentry))
276 return ERR_PTR(-ENOENT);
277
278 return NULL;
279}
280
281static int autofs_root_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
282{
283 struct autofs_sb_info *sbi = autofs_sbi(dir->i_sb);
284 struct autofs_dirhash *dh = &sbi->dirhash;
285 struct autofs_dir_ent *ent;
286 unsigned int n;
287 int slsize;
288 struct autofs_symlink *sl;
289 struct inode *inode;
290
291 DPRINTK(("autofs_root_symlink: %s <- ", symname));
292 autofs_say(dentry->d_name.name,dentry->d_name.len);
293
294 lock_kernel();
295 if (!autofs_oz_mode(sbi)) {
296 unlock_kernel();
297 return -EACCES;
298 }
299
300 if (autofs_hash_lookup(dh, &dentry->d_name)) {
301 unlock_kernel();
302 return -EEXIST;
303 }
304
305 n = find_first_zero_bit(sbi->symlink_bitmap,AUTOFS_MAX_SYMLINKS);
306 if (n >= AUTOFS_MAX_SYMLINKS) {
307 unlock_kernel();
308 return -ENOSPC;
309 }
310
311 set_bit(n,sbi->symlink_bitmap);
312 sl = &sbi->symlink[n];
313 sl->len = strlen(symname);
314 sl->data = kmalloc(slsize = sl->len+1, GFP_KERNEL);
315 if (!sl->data) {
316 clear_bit(n,sbi->symlink_bitmap);
317 unlock_kernel();
318 return -ENOSPC;
319 }
320
321 ent = kmalloc(sizeof(struct autofs_dir_ent), GFP_KERNEL);
322 if (!ent) {
323 kfree(sl->data);
324 clear_bit(n,sbi->symlink_bitmap);
325 unlock_kernel();
326 return -ENOSPC;
327 }
328
329 ent->name = kmalloc(dentry->d_name.len+1, GFP_KERNEL);
330 if (!ent->name) {
331 kfree(sl->data);
332 kfree(ent);
333 clear_bit(n,sbi->symlink_bitmap);
334 unlock_kernel();
335 return -ENOSPC;
336 }
337
338 memcpy(sl->data,symname,slsize);
339 sl->mtime = get_seconds();
340
341 ent->ino = AUTOFS_FIRST_SYMLINK + n;
342 ent->hash = dentry->d_name.hash;
343 memcpy(ent->name, dentry->d_name.name, 1+(ent->len = dentry->d_name.len));
344 ent->dentry = NULL; /* We don't keep the dentry for symlinks */
345
346 autofs_hash_insert(dh,ent);
347
348 inode = autofs_iget(dir->i_sb, ent->ino);
349 if (IS_ERR(inode))
350 return PTR_ERR(inode);
351
352 d_instantiate(dentry, inode);
353 unlock_kernel();
354 return 0;
355}
356
357/*
358 * NOTE!
359 *
360 * Normal filesystems would do a "d_delete()" to tell the VFS dcache
361 * that the file no longer exists. However, doing that means that the
362 * VFS layer can turn the dentry into a negative dentry, which we
363 * obviously do not want (we're dropping the entry not because it
364 * doesn't exist, but because it has timed out).
365 *
366 * Also see autofs_root_rmdir()..
367 */
368static int autofs_root_unlink(struct inode *dir, struct dentry *dentry)
369{
370 struct autofs_sb_info *sbi = autofs_sbi(dir->i_sb);
371 struct autofs_dirhash *dh = &sbi->dirhash;
372 struct autofs_dir_ent *ent;
373 unsigned int n;
374
375 /* This allows root to remove symlinks */
376 lock_kernel();
377 if (!autofs_oz_mode(sbi) && !capable(CAP_SYS_ADMIN)) {
378 unlock_kernel();
379 return -EACCES;
380 }
381
382 ent = autofs_hash_lookup(dh, &dentry->d_name);
383 if (!ent) {
384 unlock_kernel();
385 return -ENOENT;
386 }
387
388 n = ent->ino - AUTOFS_FIRST_SYMLINK;
389 if (n >= AUTOFS_MAX_SYMLINKS) {
390 unlock_kernel();
391 return -EISDIR; /* It's a directory, dummy */
392 }
393 if (!test_bit(n,sbi->symlink_bitmap)) {
394 unlock_kernel();
395 return -EINVAL; /* Nonexistent symlink? Shouldn't happen */
396 }
397
398 dentry->d_time = (unsigned long)(struct autofs_dirhash *)NULL;
399 autofs_hash_delete(ent);
400 clear_bit(n,sbi->symlink_bitmap);
401 kfree(sbi->symlink[n].data);
402 d_drop(dentry);
403
404 unlock_kernel();
405 return 0;
406}
407
408static int autofs_root_rmdir(struct inode *dir, struct dentry *dentry)
409{
410 struct autofs_sb_info *sbi = autofs_sbi(dir->i_sb);
411 struct autofs_dirhash *dh = &sbi->dirhash;
412 struct autofs_dir_ent *ent;
413
414 lock_kernel();
415 if (!autofs_oz_mode(sbi)) {
416 unlock_kernel();
417 return -EACCES;
418 }
419
420 ent = autofs_hash_lookup(dh, &dentry->d_name);
421 if (!ent) {
422 unlock_kernel();
423 return -ENOENT;
424 }
425
426 if ((unsigned int)ent->ino < AUTOFS_FIRST_DIR_INO) {
427 unlock_kernel();
428 return -ENOTDIR; /* Not a directory */
429 }
430
431 if (ent->dentry != dentry) {
432 printk("autofs_rmdir: odentry != dentry for entry %s\n", dentry->d_name.name);
433 }
434
435 dentry->d_time = (unsigned long)(struct autofs_dir_ent *)NULL;
436 autofs_hash_delete(ent);
437 drop_nlink(dir);
438 d_drop(dentry);
439 unlock_kernel();
440
441 return 0;
442}
443
444static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
445{
446 struct autofs_sb_info *sbi = autofs_sbi(dir->i_sb);
447 struct autofs_dirhash *dh = &sbi->dirhash;
448 struct autofs_dir_ent *ent;
449 struct inode *inode;
450 ino_t ino;
451
452 lock_kernel();
453 if (!autofs_oz_mode(sbi)) {
454 unlock_kernel();
455 return -EACCES;
456 }
457
458 ent = autofs_hash_lookup(dh, &dentry->d_name);
459 if (ent) {
460 unlock_kernel();
461 return -EEXIST;
462 }
463
464 if (sbi->next_dir_ino < AUTOFS_FIRST_DIR_INO) {
465 printk("autofs: Out of inode numbers -- what the heck did you do??\n");
466 unlock_kernel();
467 return -ENOSPC;
468 }
469 ino = sbi->next_dir_ino++;
470
471 ent = kmalloc(sizeof(struct autofs_dir_ent), GFP_KERNEL);
472 if (!ent) {
473 unlock_kernel();
474 return -ENOSPC;
475 }
476
477 ent->name = kmalloc(dentry->d_name.len+1, GFP_KERNEL);
478 if (!ent->name) {
479 kfree(ent);
480 unlock_kernel();
481 return -ENOSPC;
482 }
483
484 ent->hash = dentry->d_name.hash;
485 memcpy(ent->name, dentry->d_name.name, 1+(ent->len = dentry->d_name.len));
486 ent->ino = ino;
487 ent->dentry = dentry;
488 autofs_hash_insert(dh,ent);
489
490 inc_nlink(dir);
491
492 inode = autofs_iget(dir->i_sb, ino);
493 if (IS_ERR(inode)) {
494 drop_nlink(dir);
495 return PTR_ERR(inode);
496 }
497
498 d_instantiate(dentry, inode);
499 unlock_kernel();
500
501 return 0;
502}
503
504/* Get/set timeout ioctl() operation */
505#ifdef CONFIG_COMPAT
506static inline int autofs_compat_get_set_timeout(struct autofs_sb_info *sbi,
507 unsigned int __user *p)
508{
509 unsigned long ntimeout;
510
511 if (get_user(ntimeout, p) ||
512 put_user(sbi->exp_timeout / HZ, p))
513 return -EFAULT;
514
515 if (ntimeout > UINT_MAX/HZ)
516 sbi->exp_timeout = 0;
517 else
518 sbi->exp_timeout = ntimeout * HZ;
519
520 return 0;
521}
522#endif
523
524static inline int autofs_get_set_timeout(struct autofs_sb_info *sbi,
525 unsigned long __user *p)
526{
527 unsigned long ntimeout;
528
529 if (get_user(ntimeout, p) ||
530 put_user(sbi->exp_timeout / HZ, p))
531 return -EFAULT;
532
533 if (ntimeout > ULONG_MAX/HZ)
534 sbi->exp_timeout = 0;
535 else
536 sbi->exp_timeout = ntimeout * HZ;
537
538 return 0;
539}
540
541/* Return protocol version */
542static inline int autofs_get_protover(int __user *p)
543{
544 return put_user(AUTOFS_PROTO_VERSION, p);
545}
546
547/* Perform an expiry operation */
548static inline int autofs_expire_run(struct super_block *sb,
549 struct autofs_sb_info *sbi,
550 struct vfsmount *mnt,
551 struct autofs_packet_expire __user *pkt_p)
552{
553 struct autofs_dir_ent *ent;
554 struct autofs_packet_expire pkt;
555
556 memset(&pkt,0,sizeof pkt);
557
558 pkt.hdr.proto_version = AUTOFS_PROTO_VERSION;
559 pkt.hdr.type = autofs_ptype_expire;
560
561 if (!sbi->exp_timeout || !(ent = autofs_expire(sb,sbi,mnt)))
562 return -EAGAIN;
563
564 pkt.len = ent->len;
565 memcpy(pkt.name, ent->name, pkt.len);
566 pkt.name[pkt.len] = '\0';
567
568 if (copy_to_user(pkt_p, &pkt, sizeof(struct autofs_packet_expire)))
569 return -EFAULT;
570
571 return 0;
572}
573
574/*
575 * ioctl()'s on the root directory is the chief method for the daemon to
576 * generate kernel reactions
577 */
578static int autofs_do_root_ioctl(struct inode *inode, struct file *filp,
579 unsigned int cmd, unsigned long arg)
580{
581 struct autofs_sb_info *sbi = autofs_sbi(inode->i_sb);
582 void __user *argp = (void __user *)arg;
583
584 DPRINTK(("autofs_ioctl: cmd = 0x%08x, arg = 0x%08lx, sbi = %p, pgrp = %u\n",cmd,arg,sbi,task_pgrp_nr(current)));
585
586 if (_IOC_TYPE(cmd) != _IOC_TYPE(AUTOFS_IOC_FIRST) ||
587 _IOC_NR(cmd) - _IOC_NR(AUTOFS_IOC_FIRST) >= AUTOFS_IOC_COUNT)
588 return -ENOTTY;
589
590 if (!autofs_oz_mode(sbi) && !capable(CAP_SYS_ADMIN))
591 return -EPERM;
592
593 switch(cmd) {
594 case AUTOFS_IOC_READY: /* Wait queue: go ahead and retry */
595 return autofs_wait_release(sbi,(autofs_wqt_t)arg,0);
596 case AUTOFS_IOC_FAIL: /* Wait queue: fail with ENOENT */
597 return autofs_wait_release(sbi,(autofs_wqt_t)arg,-ENOENT);
598 case AUTOFS_IOC_CATATONIC: /* Enter catatonic mode (daemon shutdown) */
599 autofs_catatonic_mode(sbi);
600 return 0;
601 case AUTOFS_IOC_PROTOVER: /* Get protocol version */
602 return autofs_get_protover(argp);
603#ifdef CONFIG_COMPAT
604 case AUTOFS_IOC_SETTIMEOUT32:
605 return autofs_compat_get_set_timeout(sbi, argp);
606#endif
607 case AUTOFS_IOC_SETTIMEOUT:
608 return autofs_get_set_timeout(sbi, argp);
609 case AUTOFS_IOC_EXPIRE:
610 return autofs_expire_run(inode->i_sb, sbi, filp->f_path.mnt,
611 argp);
612 default:
613 return -ENOSYS;
614 }
615
616}
617
618static long autofs_root_ioctl(struct file *filp,
619 unsigned int cmd, unsigned long arg)
620{
621 int ret;
622
623 lock_kernel();
624 ret = autofs_do_root_ioctl(filp->f_path.dentry->d_inode,
625 filp, cmd, arg);
626 unlock_kernel();
627
628 return ret;
629}
630
631#ifdef CONFIG_COMPAT
632static long autofs_root_compat_ioctl(struct file *filp,
633 unsigned int cmd, unsigned long arg)
634{
635 struct inode *inode = filp->f_path.dentry->d_inode;
636 int ret;
637
638 lock_kernel();
639 if (cmd == AUTOFS_IOC_READY || cmd == AUTOFS_IOC_FAIL)
640 ret = autofs_do_root_ioctl(inode, filp, cmd, arg);
641 else
642 ret = autofs_do_root_ioctl(inode, filp, cmd,
643 (unsigned long)compat_ptr(arg));
644 unlock_kernel();
645
646 return ret;
647}
648#endif
diff --git a/drivers/staging/autofs/symlink.c b/drivers/staging/autofs/symlink.c
deleted file mode 100644
index ff2c65cde753..000000000000
--- a/drivers/staging/autofs/symlink.c
+++ /dev/null
@@ -1,26 +0,0 @@
1/* -*- linux-c -*- --------------------------------------------------------- *
2 *
3 * drivers/staging/autofs/symlink.c
4 *
5 * Copyright 1997-1998 Transmeta Corporation -- All Rights Reserved
6 *
7 * This file is part of the Linux kernel and is made available under
8 * the terms of the GNU General Public License, version 2, or at your
9 * option, any later version, incorporated herein by reference.
10 *
11 * ------------------------------------------------------------------------- */
12
13#include "autofs_i.h"
14
15/* Nothing to release.. */
16static void *autofs_follow_link(struct dentry *dentry, struct nameidata *nd)
17{
18 char *s=((struct autofs_symlink *)dentry->d_inode->i_private)->data;
19 nd_set_link(nd, s);
20 return NULL;
21}
22
23const struct inode_operations autofs_symlink_inode_operations = {
24 .readlink = generic_readlink,
25 .follow_link = autofs_follow_link
26};
diff --git a/drivers/staging/autofs/waitq.c b/drivers/staging/autofs/waitq.c
deleted file mode 100644
index d3c8cc9eb4d1..000000000000
--- a/drivers/staging/autofs/waitq.c
+++ /dev/null
@@ -1,205 +0,0 @@
1/* -*- linux-c -*- --------------------------------------------------------- *
2 *
3 * drivers/staging/autofs/waitq.c
4 *
5 * Copyright 1997-1998 Transmeta Corporation -- All Rights Reserved
6 *
7 * This file is part of the Linux kernel and is made available under
8 * the terms of the GNU General Public License, version 2, or at your
9 * option, any later version, incorporated herein by reference.
10 *
11 * ------------------------------------------------------------------------- */
12
13#include <linux/slab.h>
14#include <linux/time.h>
15#include <linux/signal.h>
16#include <linux/file.h>
17#include "autofs_i.h"
18
19/* We make this a static variable rather than a part of the superblock; it
20 is better if we don't reassign numbers easily even across filesystems */
21static autofs_wqt_t autofs_next_wait_queue = 1;
22
23/* These are the signals we allow interrupting a pending mount */
24#define SHUTDOWN_SIGS (sigmask(SIGKILL) | sigmask(SIGINT) | sigmask(SIGQUIT))
25
26void autofs_catatonic_mode(struct autofs_sb_info *sbi)
27{
28 struct autofs_wait_queue *wq, *nwq;
29
30 DPRINTK(("autofs: entering catatonic mode\n"));
31
32 sbi->catatonic = 1;
33 wq = sbi->queues;
34 sbi->queues = NULL; /* Erase all wait queues */
35 while ( wq ) {
36 nwq = wq->next;
37 wq->status = -ENOENT; /* Magic is gone - report failure */
38 kfree(wq->name);
39 wq->name = NULL;
40 wake_up(&wq->queue);
41 wq = nwq;
42 }
43 fput(sbi->pipe); /* Close the pipe */
44 sbi->pipe = NULL;
45 autofs_hash_dputall(&sbi->dirhash); /* Remove all dentry pointers */
46}
47
48static int autofs_write(struct file *file, const void *addr, int bytes)
49{
50 unsigned long sigpipe, flags;
51 mm_segment_t fs;
52 const char *data = (const char *)addr;
53 ssize_t wr = 0;
54
55 /** WARNING: this is not safe for writing more than PIPE_BUF bytes! **/
56
57 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
58
59 /* Save pointer to user space and point back to kernel space */
60 fs = get_fs();
61 set_fs(KERNEL_DS);
62
63 while (bytes &&
64 (wr = file->f_op->write(file,data,bytes,&file->f_pos)) > 0) {
65 data += wr;
66 bytes -= wr;
67 }
68
69 set_fs(fs);
70
71 /* Keep the currently executing process from receiving a
72 SIGPIPE unless it was already supposed to get one */
73 if (wr == -EPIPE && !sigpipe) {
74 spin_lock_irqsave(&current->sighand->siglock, flags);
75 sigdelset(&current->pending.signal, SIGPIPE);
76 recalc_sigpending();
77 spin_unlock_irqrestore(&current->sighand->siglock, flags);
78 }
79
80 return (bytes > 0);
81}
82
83static void autofs_notify_daemon(struct autofs_sb_info *sbi, struct autofs_wait_queue *wq)
84{
85 struct autofs_packet_missing pkt;
86
87 DPRINTK(("autofs_wait: wait id = 0x%08lx, name = ", wq->wait_queue_token));
88 autofs_say(wq->name,wq->len);
89
90 memset(&pkt,0,sizeof pkt); /* For security reasons */
91
92 pkt.hdr.proto_version = AUTOFS_PROTO_VERSION;
93 pkt.hdr.type = autofs_ptype_missing;
94 pkt.wait_queue_token = wq->wait_queue_token;
95 pkt.len = wq->len;
96 memcpy(pkt.name, wq->name, pkt.len);
97 pkt.name[pkt.len] = '\0';
98
99 if ( autofs_write(sbi->pipe,&pkt,sizeof(struct autofs_packet_missing)) )
100 autofs_catatonic_mode(sbi);
101}
102
103int autofs_wait(struct autofs_sb_info *sbi, struct qstr *name)
104{
105 struct autofs_wait_queue *wq;
106 int status;
107
108 /* In catatonic mode, we don't wait for nobody */
109 if ( sbi->catatonic )
110 return -ENOENT;
111
112 /* We shouldn't be able to get here, but just in case */
113 if ( name->len > NAME_MAX )
114 return -ENOENT;
115
116 for ( wq = sbi->queues ; wq ; wq = wq->next ) {
117 if ( wq->hash == name->hash &&
118 wq->len == name->len &&
119 wq->name && !memcmp(wq->name,name->name,name->len) )
120 break;
121 }
122
123 if ( !wq ) {
124 /* Create a new wait queue */
125 wq = kmalloc(sizeof(struct autofs_wait_queue),GFP_KERNEL);
126 if ( !wq )
127 return -ENOMEM;
128
129 wq->name = kmalloc(name->len,GFP_KERNEL);
130 if ( !wq->name ) {
131 kfree(wq);
132 return -ENOMEM;
133 }
134 wq->wait_queue_token = autofs_next_wait_queue++;
135 init_waitqueue_head(&wq->queue);
136 wq->hash = name->hash;
137 wq->len = name->len;
138 wq->status = -EINTR; /* Status return if interrupted */
139 memcpy(wq->name, name->name, name->len);
140 wq->next = sbi->queues;
141 sbi->queues = wq;
142
143 /* autofs_notify_daemon() may block */
144 wq->wait_ctr = 2;
145 autofs_notify_daemon(sbi,wq);
146 } else
147 wq->wait_ctr++;
148
149 /* wq->name is NULL if and only if the lock is already released */
150
151 if ( sbi->catatonic ) {
152 /* We might have slept, so check again for catatonic mode */
153 wq->status = -ENOENT;
154 kfree(wq->name);
155 wq->name = NULL;
156 }
157
158 if ( wq->name ) {
159 /* Block all but "shutdown" signals while waiting */
160 sigset_t sigmask;
161
162 siginitsetinv(&sigmask, SHUTDOWN_SIGS);
163 sigprocmask(SIG_BLOCK, &sigmask, &sigmask);
164
165 interruptible_sleep_on(&wq->queue);
166
167 sigprocmask(SIG_SETMASK, &sigmask, NULL);
168 } else {
169 DPRINTK(("autofs_wait: skipped sleeping\n"));
170 }
171
172 status = wq->status;
173
174 if ( ! --wq->wait_ctr ) /* Are we the last process to need status? */
175 kfree(wq);
176
177 return status;
178}
179
180
181int autofs_wait_release(struct autofs_sb_info *sbi, autofs_wqt_t wait_queue_token, int status)
182{
183 struct autofs_wait_queue *wq, **wql;
184
185 for (wql = &sbi->queues; (wq = *wql) != NULL; wql = &wq->next) {
186 if ( wq->wait_queue_token == wait_queue_token )
187 break;
188 }
189 if ( !wq )
190 return -EINVAL;
191
192 *wql = wq->next; /* Unlink from chain */
193 kfree(wq->name);
194 wq->name = NULL; /* Do not wait on this queue */
195
196 wq->status = status;
197
198 if ( ! --wq->wait_ctr ) /* Is anyone still waiting for this guy? */
199 kfree(wq);
200 else
201 wake_up(&wq->queue);
202
203 return 0;
204}
205