patch-2.3.99-pre2 linux/arch/sparc64/kernel/binfmt_aout32.c
Next file: linux/arch/sparc64/kernel/ioctl32.c
Previous file: linux/arch/sparc64/defconfig
Back to the patch index
Back to the overall index
- Lines: 92
- Date:
Thu Mar 16 22:23:22 2000
- Orig file:
v2.3.99-pre1/linux/arch/sparc64/kernel/binfmt_aout32.c
- Orig date:
Tue Mar 14 19:10:39 2000
diff -u --recursive --new-file v2.3.99-pre1/linux/arch/sparc64/kernel/binfmt_aout32.c linux/arch/sparc64/kernel/binfmt_aout32.c
@@ -33,7 +33,7 @@
#include <asm/pgalloc.h>
static int load_aout32_binary(struct linux_binprm *, struct pt_regs * regs);
-static int load_aout32_library(int fd);
+static int load_aout32_library(struct file*);
static int aout32_core_dump(long signr, struct pt_regs * regs, struct file *file);
extern void dump_thread(struct pt_regs *, struct user *);
@@ -343,9 +343,8 @@
}
/* N.B. Move to .h file and use code in fs/binfmt_aout.c? */
-static int load_aout32_library(int fd)
+static int load_aout32_library(struct file *file)
{
- struct file * file;
struct inode * inode;
unsigned long bss, start_addr, len;
unsigned long error;
@@ -353,12 +352,6 @@
loff_t offset = 0;
struct exec ex;
- retval = -EACCES;
- file = fget(fd);
- if (!file)
- goto out;
- if (!file->f_op)
- goto out_putf;
inode = file->f_dentry->d_inode;
retval = -ENOEXEC;
@@ -367,23 +360,23 @@
error = file->f_op->read(file, (char *) &ex, sizeof(ex), &offset);
set_fs(USER_DS);
if (error != sizeof(ex))
- goto out_putf;
+ goto out;
/* We come in here for the regular a.out style of shared libraries */
if ((N_MAGIC(ex) != ZMAGIC && N_MAGIC(ex) != QMAGIC) || N_TRSIZE(ex) ||
N_DRSIZE(ex) || ((ex.a_entry & 0xfff) && N_MAGIC(ex) == ZMAGIC) ||
inode->i_size < ex.a_text+ex.a_data+N_SYMSIZE(ex)+N_TXTOFF(ex)) {
- goto out_putf;
+ goto out;
}
if (N_MAGIC(ex) == ZMAGIC && N_TXTOFF(ex) &&
(N_TXTOFF(ex) < inode->i_sb->s_blocksize)) {
printk("N_TXTOFF < BLOCK_SIZE. Please convert library\n");
- goto out_putf;
+ goto out;
}
if (N_FLAGS(ex))
- goto out_putf;
+ goto out;
/* For QMAGIC, the starting address is 0x20 into the page. We mask
this off to get the starting address for the page */
@@ -391,13 +384,15 @@
start_addr = ex.a_entry & 0xfffff000;
/* Now use mmap to map the library into memory. */
+ down(¤t->mm->mmap_sem);
error = do_mmap(file, start_addr, ex.a_text + ex.a_data,
PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE,
N_TXTOFF(ex));
+ up(¤t->mm->mmap_sem);
retval = error;
if (error != start_addr)
- goto out_putf;
+ goto out;
len = PAGE_ALIGN(ex.a_text + ex.a_data);
bss = ex.a_text + ex.a_data + ex.a_bss;
@@ -405,12 +400,9 @@
error = do_brk(start_addr + len, bss - len);
retval = error;
if (error != start_addr + len)
- goto out_putf;
+ goto out;
}
retval = 0;
-
-out_putf:
- fput(file);
out:
return retval;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)