Skip to content

Commit

Permalink
CAPI: Pin capifs instead of mounting it
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jan Kiszka authored and David S. Miller committed Feb 17, 2010
1 parent 07ad603 commit e11e7ac
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions drivers/isdn/capi/capifs.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ static char *revision = "$Revision: 1.1.2.3 $";
#define CAPIFS_SUPER_MAGIC (('C'<<8)|'N')

static struct vfsmount *capifs_mnt;
static int capifs_mnt_count;

static struct {
int setuid;
Expand Down Expand Up @@ -140,7 +141,7 @@ static struct file_system_type capifs_fs_type = {
.kill_sb = kill_anon_super,
};

struct dentry *capifs_new_ncci(unsigned int number, dev_t device)
static struct dentry *new_ncci(unsigned int number, dev_t device)
{
struct super_block *s = capifs_mnt->mnt_sb;
struct dentry *root = s->s_root;
Expand Down Expand Up @@ -187,6 +188,20 @@ struct dentry *capifs_new_ncci(unsigned int number, dev_t device)
return dentry;
}

struct dentry *capifs_new_ncci(unsigned int number, dev_t device)
{
struct dentry *dentry;

if (simple_pin_fs(&capifs_fs_type, &capifs_mnt, &capifs_mnt_count) < 0)
return NULL;

dentry = new_ncci(number, device);
if (!dentry)
simple_release_fs(&capifs_mnt, &capifs_mnt_count);

return dentry;
}

void capifs_free_ncci(struct dentry *dentry)
{
struct dentry *root = capifs_mnt->mnt_sb->s_root;
Expand All @@ -206,6 +221,8 @@ void capifs_free_ncci(struct dentry *dentry)
dput(dentry);

mutex_unlock(&root->d_inode->i_mutex);

simple_release_fs(&capifs_mnt, &capifs_mnt_count);
}

static int __init capifs_init(void)
Expand All @@ -222,13 +239,6 @@ static int __init capifs_init(void)
strcpy(rev, "1.0");

err = register_filesystem(&capifs_fs_type);
if (!err) {
capifs_mnt = kern_mount(&capifs_fs_type);
if (IS_ERR(capifs_mnt)) {
err = PTR_ERR(capifs_mnt);
unregister_filesystem(&capifs_fs_type);
}
}
if (!err)
printk(KERN_NOTICE "capifs: Rev %s\n", rev);
return err;
Expand All @@ -237,7 +247,6 @@ static int __init capifs_init(void)
static void __exit capifs_exit(void)
{
unregister_filesystem(&capifs_fs_type);
mntput(capifs_mnt);
}

EXPORT_SYMBOL(capifs_new_ncci);
Expand Down

0 comments on commit e11e7ac

Please sign in to comment.