diff options
author | Jan Kiszka <jan.kiszka@web.de> | 2010-02-08 05:12:08 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-02-16 19:01:19 -0500 |
commit | e11e7ac1ecac6b25439c003c5ca661cd399ec35d (patch) | |
tree | 54c19b00dcc2fb4f208652361508324136e8feaa /drivers/isdn/capi | |
parent | 07ad603ab8e3cc35762c15043b59a6ef76542454 (diff) |
CAPI: Pin capifs instead of mounting it
Auto-mounting the capifs during module init prevents unloading its
module. Instead, pin the filesystem as long as some NCCI node exists.
Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/capi')
-rw-r--r-- | drivers/isdn/capi/capifs.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/isdn/capi/capifs.c b/drivers/isdn/capi/capifs.c index 6ae0edf29c85..51c01efe2fe4 100644 --- a/drivers/isdn/capi/capifs.c +++ b/drivers/isdn/capi/capifs.c | |||
@@ -32,6 +32,7 @@ static char *revision = "$Revision: 1.1.2.3 $"; | |||
32 | #define CAPIFS_SUPER_MAGIC (('C'<<8)|'N') | 32 | #define CAPIFS_SUPER_MAGIC (('C'<<8)|'N') |
33 | 33 | ||
34 | static struct vfsmount *capifs_mnt; | 34 | static struct vfsmount *capifs_mnt; |
35 | static int capifs_mnt_count; | ||
35 | 36 | ||
36 | static struct { | 37 | static struct { |
37 | int setuid; | 38 | int setuid; |
@@ -140,7 +141,7 @@ static struct file_system_type capifs_fs_type = { | |||
140 | .kill_sb = kill_anon_super, | 141 | .kill_sb = kill_anon_super, |
141 | }; | 142 | }; |
142 | 143 | ||
143 | struct dentry *capifs_new_ncci(unsigned int number, dev_t device) | 144 | static struct dentry *new_ncci(unsigned int number, dev_t device) |
144 | { | 145 | { |
145 | struct super_block *s = capifs_mnt->mnt_sb; | 146 | struct super_block *s = capifs_mnt->mnt_sb; |
146 | struct dentry *root = s->s_root; | 147 | struct dentry *root = s->s_root; |
@@ -187,6 +188,20 @@ unlock_out: | |||
187 | return dentry; | 188 | return dentry; |
188 | } | 189 | } |
189 | 190 | ||
191 | struct dentry *capifs_new_ncci(unsigned int number, dev_t device) | ||
192 | { | ||
193 | struct dentry *dentry; | ||
194 | |||
195 | if (simple_pin_fs(&capifs_fs_type, &capifs_mnt, &capifs_mnt_count) < 0) | ||
196 | return NULL; | ||
197 | |||
198 | dentry = new_ncci(number, device); | ||
199 | if (!dentry) | ||
200 | simple_release_fs(&capifs_mnt, &capifs_mnt_count); | ||
201 | |||
202 | return dentry; | ||
203 | } | ||
204 | |||
190 | void capifs_free_ncci(struct dentry *dentry) | 205 | void capifs_free_ncci(struct dentry *dentry) |
191 | { | 206 | { |
192 | struct dentry *root = capifs_mnt->mnt_sb->s_root; | 207 | struct dentry *root = capifs_mnt->mnt_sb->s_root; |
@@ -206,6 +221,8 @@ void capifs_free_ncci(struct dentry *dentry) | |||
206 | dput(dentry); | 221 | dput(dentry); |
207 | 222 | ||
208 | mutex_unlock(&root->d_inode->i_mutex); | 223 | mutex_unlock(&root->d_inode->i_mutex); |
224 | |||
225 | simple_release_fs(&capifs_mnt, &capifs_mnt_count); | ||
209 | } | 226 | } |
210 | 227 | ||
211 | static int __init capifs_init(void) | 228 | static int __init capifs_init(void) |
@@ -222,13 +239,6 @@ static int __init capifs_init(void) | |||
222 | strcpy(rev, "1.0"); | 239 | strcpy(rev, "1.0"); |
223 | 240 | ||
224 | err = register_filesystem(&capifs_fs_type); | 241 | err = register_filesystem(&capifs_fs_type); |
225 | if (!err) { | ||
226 | capifs_mnt = kern_mount(&capifs_fs_type); | ||
227 | if (IS_ERR(capifs_mnt)) { | ||
228 | err = PTR_ERR(capifs_mnt); | ||
229 | unregister_filesystem(&capifs_fs_type); | ||
230 | } | ||
231 | } | ||
232 | if (!err) | 242 | if (!err) |
233 | printk(KERN_NOTICE "capifs: Rev %s\n", rev); | 243 | printk(KERN_NOTICE "capifs: Rev %s\n", rev); |
234 | return err; | 244 | return err; |
@@ -237,7 +247,6 @@ static int __init capifs_init(void) | |||
237 | static void __exit capifs_exit(void) | 247 | static void __exit capifs_exit(void) |
238 | { | 248 | { |
239 | unregister_filesystem(&capifs_fs_type); | 249 | unregister_filesystem(&capifs_fs_type); |
240 | mntput(capifs_mnt); | ||
241 | } | 250 | } |
242 | 251 | ||
243 | EXPORT_SYMBOL(capifs_new_ncci); | 252 | EXPORT_SYMBOL(capifs_new_ncci); |