]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - fs/binfmt_misc.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus
[linux-2.6.git] / fs / binfmt_misc.c
index 7191306367c5d11912ceed01c5fce4925b528eba..1befe2ec8186768a7b7baebc4a4c4d20418cfc14 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/namei.h>
 #include <linux/mount.h>
 #include <linux/syscalls.h>
+#include <linux/fs.h>
 
 #include <asm/uaccess.h>
 
@@ -107,7 +108,7 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs)
        Node *fmt;
        struct file * interp_file = NULL;
        char iname[BINPRM_BUF_SIZE];
-       char *iname_addr = iname;
+       const char *iname_addr = iname;
        int retval;
        int fd_binary = -1;
 
@@ -116,11 +117,9 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs)
                goto _ret;
 
        retval = -ENOEXEC;
-       if (bprm->misc_bang)
+       if (bprm->recursion_depth > BINPRM_MAX_RECURSION)
                goto _ret;
 
-       bprm->misc_bang = 1;
-
        /* to keep locking time low, we copy the interpreter string */
        read_lock(&entries_lock);
        fmt = check_file(bprm);
@@ -198,6 +197,8 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs)
        if (retval < 0)
                goto _error;
 
+       bprm->recursion_depth++;
+
        retval = search_binary_handler (bprm, regs);
        if (retval < 0)
                goto _error;
@@ -494,18 +495,17 @@ static struct inode *bm_get_inode(struct super_block *sb, int mode)
        struct inode * inode = new_inode(sb);
 
        if (inode) {
+               inode->i_ino = get_next_ino();
                inode->i_mode = mode;
-               inode->i_uid = 0;
-               inode->i_gid = 0;
-               inode->i_blocks = 0;
                inode->i_atime = inode->i_mtime = inode->i_ctime =
                        current_fs_time(inode->i_sb);
        }
        return inode;
 }
 
-static void bm_clear_inode(struct inode *inode)
+static void bm_evict_inode(struct inode *inode)
 {
+       end_writeback(inode);
        kfree(inode->i_private);
 }
 
@@ -535,31 +535,16 @@ static ssize_t
 bm_entry_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos)
 {
        Node *e = file->f_path.dentry->d_inode->i_private;
-       loff_t pos = *ppos;
        ssize_t res;
        char *page;
-       int len;
 
        if (!(page = (char*) __get_free_page(GFP_KERNEL)))
                return -ENOMEM;
 
        entry_status(e, page);
-       len = strlen(page);
 
-       res = -EINVAL;
-       if (pos < 0)
-               goto out;
-       res = 0;
-       if (pos >= len)
-               goto out;
-       if (len < pos + nbytes)
-               nbytes = len - pos;
-       res = -EFAULT;
-       if (copy_to_user(buf, page + pos, nbytes))
-               goto out;
-       *ppos = pos + nbytes;
-       res = nbytes;
-out:
+       res = simple_read_from_buffer(buf, nbytes, ppos, page, strlen(page));
+
        free_page((unsigned long) page);
        return res;
 }
@@ -592,6 +577,7 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
 static const struct file_operations bm_entry_operations = {
        .read           = bm_entry_read,
        .write          = bm_entry_write,
+       .llseek         = default_llseek,
 };
 
 /* /register */
@@ -659,6 +645,7 @@ out:
 
 static const struct file_operations bm_register_operations = {
        .write          = bm_register_write,
+       .llseek         = noop_llseek,
 };
 
 /* /status */
@@ -666,7 +653,7 @@ static const struct file_operations bm_register_operations = {
 static ssize_t
 bm_status_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
 {
-       char *s = enabled ? "enabled" : "disabled";
+       char *s = enabled ? "enabled\n" : "disabled\n";
 
        return simple_read_from_buffer(buf, nbytes, ppos, s, strlen(s));
 }
@@ -696,13 +683,14 @@ static ssize_t bm_status_write(struct file * file, const char __user * buffer,
 static const struct file_operations bm_status_operations = {
        .read           = bm_status_read,
        .write          = bm_status_write,
+       .llseek         = default_llseek,
 };
 
 /* Superblock handling */
 
 static const struct super_operations s_ops = {
        .statfs         = simple_statfs,
-       .clear_inode    = bm_clear_inode,
+       .evict_inode    = bm_evict_inode,
 };
 
 static int bm_fill_super(struct super_block * sb, void * data, int silent)
@@ -718,10 +706,10 @@ static int bm_fill_super(struct super_block * sb, void * data, int silent)
        return err;
 }
 
-static int bm_get_sb(struct file_system_type *fs_type,
-       int flags, const char *dev_name, void *data, struct vfsmount *mnt)
+static struct dentry *bm_mount(struct file_system_type *fs_type,
+       int flags, const char *dev_name, void *data)
 {
-       return get_sb_single(fs_type, flags, data, bm_fill_super, mnt);
+       return mount_single(fs_type, flags, data, bm_fill_super);
 }
 
 static struct linux_binfmt misc_format = {
@@ -732,7 +720,7 @@ static struct linux_binfmt misc_format = {
 static struct file_system_type bm_fs_type = {
        .owner          = THIS_MODULE,
        .name           = "binfmt_misc",
-       .get_sb         = bm_get_sb,
+       .mount          = bm_mount,
        .kill_sb        = kill_litter_super,
 };
 
@@ -740,7 +728,7 @@ static int __init init_misc_binfmt(void)
 {
        int err = register_filesystem(&bm_fs_type);
        if (!err) {
-               err = register_binfmt(&misc_format);
+               err = insert_binfmt(&misc_format);
                if (err)
                        unregister_filesystem(&bm_fs_type);
        }