linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / fs / binfmt_flat.c
index 561c313..5b32e27 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
@@ -35,7 +36,6 @@
 #include <linux/personality.h>
 #include <linux/init.h>
 #include <linux/flat.h>
-#include <linux/syscalls.h>
 #include <linux/vs_memory.h>
 
 #include <asm/byteorder.h>
@@ -427,7 +427,6 @@ static int load_flat_file(struct linux_binprm * bprm,
        int i, rev, relocs = 0;
        loff_t fpos;
        unsigned long start_code, end_code;
-       int ret;
 
        hdr = ((struct flat_hdr *) bprm->buf);          /* exec-header */
        inode = bprm->file->f_dentry->d_inode;
@@ -452,8 +451,7 @@ static int load_flat_file(struct linux_binprm * bprm,
                 */
                if (strncmp(hdr->magic, "#!", 2))
                        printk("BINFMT_FLAT: bad header magic\n");
-               ret = -ENOEXEC;
-               goto err;
+               return -ENOEXEC;
        }
 
        if (flags & FLAT_FLAG_KTRACE)
@@ -461,16 +459,14 @@ static int load_flat_file(struct linux_binprm * bprm,
 
        if (rev != FLAT_VERSION && rev != OLD_FLAT_VERSION) {
                printk("BINFMT_FLAT: bad flat file version 0x%x (supported 0x%x and 0x%x)\n", rev, FLAT_VERSION, OLD_FLAT_VERSION);
-               ret = -ENOEXEC;
-               goto err;
+               return -ENOEXEC;
        }
        
        /* Don't allow old format executables to use shared libraries */
        if (rev == OLD_FLAT_VERSION && id != 0) {
                printk("BINFMT_FLAT: shared libraries are not available before rev 0x%x\n",
                                (int) FLAT_VERSION);
-               ret = -ENOEXEC;
-               goto err;
+               return -ENOEXEC;
        }
 
        /*
@@ -483,8 +479,7 @@ static int load_flat_file(struct linux_binprm * bprm,
 #ifndef CONFIG_BINFMT_ZFLAT
        if (flags & (FLAT_FLAG_GZIP|FLAT_FLAG_GZDATA)) {
                printk("Support for ZFLAT executables is not enabled.\n");
-               ret = -ENOEXEC;
-               goto err;
+               return -ENOEXEC;
        }
 #endif
 
@@ -496,21 +491,17 @@ static int load_flat_file(struct linux_binprm * bprm,
        rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
        if (rlim >= RLIM_INFINITY)
                rlim = ~0;
-       if (data_len + bss_len > rlim) {
-               ret = -ENOMEM;
-               goto err;
-       }
+       if (data_len + bss_len > rlim)
+               return -ENOMEM;
 
        /* Flush all traces of the currently running executable */
        if (id == 0) {
                result = flush_old_exec(bprm);
-               if (result) {
-                       ret = result;
-                       goto err;
-               }
+               if (result)
+                       return result;
 
                /* OK, This is the point of no return */
-               set_personality(PER_LINUX_32BIT);
+               set_personality(PER_LINUX);
        }
 
        /*
@@ -537,8 +528,7 @@ static int load_flat_file(struct linux_binprm * bprm,
                        if (!textpos)
                                textpos = (unsigned long) -ENOMEM;
                        printk("Unable to mmap process text, errno %d\n", (int)-textpos);
-                       ret = textpos;
-                       goto err;
+                       return(textpos);
                }
 
                down_write(&current->mm->mmap_sem);
@@ -553,8 +543,7 @@ static int load_flat_file(struct linux_binprm * bprm,
                        printk("Unable to allocate RAM for process data, errno %d\n",
                                        (int)-datapos);
                        do_munmap(current->mm, textpos, text_len);
-                       ret = realdatastart;
-                       goto err;
+                       return realdatastart;
                }
                datapos = realdatastart + MAX_SHARED_LIBS * sizeof(unsigned long);
 
@@ -576,8 +565,7 @@ static int load_flat_file(struct linux_binprm * bprm,
                        printk("Unable to read data+bss, errno %d\n", (int)-result);
                        do_munmap(current->mm, textpos, text_len);
                        do_munmap(current->mm, realdatastart, data_len + extra);
-                       ret = result;
-                       goto err;
+                       return result;
                }
 
                reloc = (unsigned long *) (datapos+(ntohl(hdr->reloc_start)-text_len));
@@ -595,8 +583,7 @@ static int load_flat_file(struct linux_binprm * bprm,
                                textpos = (unsigned long) -ENOMEM;
                        printk("Unable to allocate RAM for process text/data, errno %d\n",
                                        (int)-textpos);
-                       ret = textpos;
-                       goto err;
+                       return(textpos);
                }
 
                realdatastart = textpos + ntohl(hdr->data_start);
@@ -641,8 +628,7 @@ static int load_flat_file(struct linux_binprm * bprm,
                        printk("Unable to read code+data+bss, errno %d\n",(int)-result);
                        do_munmap(current->mm, textpos, text_len + data_len + extra +
                                MAX_SHARED_LIBS * sizeof(unsigned long));
-                       ret = result;
-                       goto err;
+                       return result;
                }
        }
 
@@ -705,10 +691,8 @@ static int load_flat_file(struct linux_binprm * bprm,
                        unsigned long addr;
                        if (*rp) {
                                addr = calc_reloc(*rp, libinfo, id, 0);
-                               if (addr == RELOC_FAILED) {
-                                       ret = -ENOEXEC;
-                                       goto err;
-                               }
+                               if (addr == RELOC_FAILED)
+                                       return -ENOEXEC;
                                *rp = addr;
                        }
                }
@@ -735,10 +719,8 @@ static int load_flat_file(struct linux_binprm * bprm,
                        relval = ntohl(reloc[i]);
                        addr = flat_get_relocate_addr(relval);
                        rp = (unsigned long *) calc_reloc(addr, libinfo, id, 1);
-                       if (rp == (unsigned long *)RELOC_FAILED) {
-                               ret = -ENOEXEC;
-                               goto err;
-                       }
+                       if (rp == (unsigned long *)RELOC_FAILED)
+                               return -ENOEXEC;
 
                        /* Get the pointer's value.  */
                        addr = flat_get_addr_from_rp(rp, relval, flags);
@@ -750,10 +732,8 @@ static int load_flat_file(struct linux_binprm * bprm,
                                if ((flags & FLAT_FLAG_GOTPIC) == 0)
                                        addr = ntohl(addr);
                                addr = calc_reloc(addr, libinfo, id, 0);
-                               if (addr == RELOC_FAILED) {
-                                       ret = -ENOEXEC;
-                                       goto err;
-                               }
+                               if (addr == RELOC_FAILED)
+                                       return -ENOEXEC;
 
                                /* Write back the relocated pointer.  */
                                flat_put_addr_at_rp(rp, addr, relval);
@@ -773,8 +753,6 @@ static int load_flat_file(struct linux_binprm * bprm,
                        stack_len);
 
        return 0;
-err:
-       return ret;
 }