]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - fs/binfmt_misc.c
[PATCH] restore sane ->umount_begin() API
[linux-2.6.git] / fs / binfmt_misc.c
index 07a4996cca3f76c03a1a6434decc88f0dacfdc42..b53c7e5f41bbcffd8f936642117ecfce5f258a21 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  binfmt_misc.c
  *
- *  Copyright (C) 1997 Richard Günther
+ *  Copyright (C) 1997 Richard Günther
  *
  *  binfmt_misc detects binaries via a magic or filename extension and invokes
  *  a specified wrapper. This should obsolete binfmt_java, binfmt_em86 and
@@ -18,7 +18,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
-
+#include <linux/sched.h>
 #include <linux/binfmts.h>
 #include <linux/slab.h>
 #include <linux/ctype.h>
@@ -55,6 +55,7 @@ typedef struct {
 } Node;
 
 static DEFINE_RWLOCK(entries_lock);
+static struct file_system_type bm_fs_type;
 static struct vfsmount *bm_mnt;
 static int entry_count;
 
@@ -125,7 +126,9 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs)
                goto _ret;
 
        if (!(fmt->flags & MISC_FMT_PRESERVE_ARGV0)) {
-               remove_arg_zero(bprm);
+               retval = remove_arg_zero(bprm);
+               if (retval)
+                       goto _ret;
        }
 
        if (fmt->flags & MISC_FMT_OPEN_BINARY) {
@@ -214,10 +217,8 @@ _error:
        bprm->interp_flags = 0;
        bprm->interp_data = 0;
 _unshare:
-       if (files) {
-               put_files_struct(current->files);
-               current->files = files;
-       }
+       if (files)
+               reset_files_struct(current, files);
        goto _ret;
 }
 
@@ -312,7 +313,7 @@ static Node *create_entry(const char __user *buffer, size_t count)
 
        err = -ENOMEM;
        memsize = sizeof(Node) + count + 8;
-       e = (Node *) kmalloc(memsize, GFP_USER);
+       e = kmalloc(memsize, GFP_USER);
        if (!e)
                goto out;
 
@@ -506,7 +507,6 @@ static struct inode *bm_get_inode(struct super_block *sb, int mode)
                inode->i_mode = mode;
                inode->i_uid = 0;
                inode->i_gid = 0;
-               inode->i_blksize = PAGE_CACHE_SIZE;
                inode->i_blocks = 0;
                inode->i_atime = inode->i_mtime = inode->i_ctime =
                        current_fs_time(inode->i_sb);
@@ -516,7 +516,7 @@ static struct inode *bm_get_inode(struct super_block *sb, int mode)
 
 static void bm_clear_inode(struct inode *inode)
 {
-       kfree(inode->u.generic_ip);
+       kfree(inode->i_private);
 }
 
 static void kill_node(Node *e)
@@ -544,7 +544,7 @@ static void kill_node(Node *e)
 static ssize_t
 bm_entry_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos)
 {
-       Node *e = file->f_dentry->d_inode->u.generic_ip;
+       Node *e = file->f_path.dentry->d_inode->i_private;
        loff_t pos = *ppos;
        ssize_t res;
        char *page;
@@ -578,7 +578,7 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
                                size_t count, loff_t *ppos)
 {
        struct dentry *root;
-       Node *e = file->f_dentry->d_inode->u.generic_ip;
+       Node *e = file->f_path.dentry->d_inode->i_private;
        int res = parse_command(buffer, count);
 
        switch (res) {
@@ -586,7 +586,7 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
                        break;
                case 2: set_bit(Enabled, &e->flags);
                        break;
-               case 3: root = dget(file->f_vfsmnt->mnt_sb->s_root);
+               case 3: root = dget(file->f_path.mnt->mnt_sb->s_root);
                        mutex_lock(&root->d_inode->i_mutex);
 
                        kill_node(e);
@@ -612,7 +612,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
        Node *e;
        struct inode *inode;
        struct dentry *root, *dentry;
-       struct super_block *sb = file->f_vfsmnt->mnt_sb;
+       struct super_block *sb = file->f_path.mnt->mnt_sb;
        int err = 0;
 
        e = create_entry(buffer, count);
@@ -637,7 +637,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
        if (!inode)
                goto out2;
 
-       err = simple_pin_fs("binfmt_misc", &bm_mnt, &entry_count);
+       err = simple_pin_fs(&bm_fs_type, &bm_mnt, &entry_count);
        if (err) {
                iput(inode);
                inode = NULL;
@@ -645,7 +645,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
        }
 
        e->dentry = dget(dentry);
-       inode->u.generic_ip = e;
+       inode->i_private = e;
        inode->i_fop = &bm_entry_operations;
 
        d_instantiate(dentry, inode);
@@ -677,19 +677,8 @@ static ssize_t
 bm_status_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
 {
        char *s = enabled ? "enabled" : "disabled";
-       int len = strlen(s);
-       loff_t pos = *ppos;
 
-       if (pos < 0)
-               return -EINVAL;
-       if (pos >= len)
-               return 0;
-       if (len < pos + nbytes)
-               nbytes = len - pos;
-       if (copy_to_user(buf, s + pos, nbytes))
-               return -EFAULT;
-       *ppos = pos + nbytes;
-       return nbytes;
+       return simple_read_from_buffer(buf, nbytes, ppos, s, strlen(s));
 }
 
 static ssize_t bm_status_write(struct file * file, const char __user * buffer,
@@ -701,7 +690,7 @@ static ssize_t bm_status_write(struct file * file, const char __user * buffer,
        switch (res) {
                case 1: enabled = 0; break;
                case 2: enabled = 1; break;
-               case 3: root = dget(file->f_vfsmnt->mnt_sb->s_root);
+               case 3: root = dget(file->f_path.mnt->mnt_sb->s_root);
                        mutex_lock(&root->d_inode->i_mutex);
 
                        while (!list_empty(&entries))
@@ -721,7 +710,7 @@ static const struct file_operations bm_status_operations = {
 
 /* Superblock handling */
 
-static struct super_operations s_ops = {
+static const struct super_operations s_ops = {
        .statfs         = simple_statfs,
        .clear_inode    = bm_clear_inode,
 };
@@ -729,8 +718,8 @@ static struct super_operations s_ops = {
 static int bm_fill_super(struct super_block * sb, void * data, int silent)
 {
        static struct tree_descr bm_files[] = {
-               [1] = {"status", &bm_status_operations, S_IWUSR|S_IRUGO},
-               [2] = {"register", &bm_register_operations, S_IWUSR},
+               [2] = {"status", &bm_status_operations, S_IWUSR|S_IRUGO},
+               [3] = {"register", &bm_register_operations, S_IWUSR},
                /* last one */ {""}
        };
        int err = simple_fill_super(sb, 0x42494e4d, bm_files);