patch-2.3.99-pre3 linux/arch/mips/kernel/irixelf.c
Next file: linux/arch/mips64/config.in
Previous file: linux/arch/mips/defconfig
Back to the patch index
Back to the overall index
- Lines: 311
- Date:
Wed Mar 22 22:15:56 2000
- Orig file:
v2.3.99-pre2/linux/arch/mips/kernel/irixelf.c
- Orig date:
Sun Mar 19 18:35:30 2000
diff -u --recursive --new-file v2.3.99-pre2/linux/arch/mips/kernel/irixelf.c linux/arch/mips/kernel/irixelf.c
@@ -230,15 +230,13 @@
* an ELF header.
*/
static unsigned int load_irix_interp(struct elfhdr * interp_elf_ex,
- struct dentry * interpreter_dentry,
+ struct file * interpreter,
unsigned int *interp_load_addr)
{
- struct file * file;
struct elf_phdr *elf_phdata = NULL;
struct elf_phdr *eppnt;
unsigned int len;
unsigned int load_addr;
- int elf_exec_fileno;
int elf_bss;
int retval;
unsigned int last_bss;
@@ -258,8 +256,7 @@
if((interp_elf_ex->e_type != ET_EXEC &&
interp_elf_ex->e_type != ET_DYN) ||
!elf_check_arch(interp_elf_ex->e_machine) ||
- (!interpreter_dentry->d_inode->i_fop ||
- !interpreter_dentry->d_inode->i_fop->mmap)) {
+ !interpreter->f_op->mmap) {
printk("IRIX interp has bad e_type %d\n", interp_elf_ex->e_type);
return 0xffffffff;
}
@@ -290,23 +287,14 @@
return 0xffffffff;
}
- retval = read_exec(interpreter_dentry, interp_elf_ex->e_phoff,
+ retval = kernel_read(interpreter, interp_elf_ex->e_phoff,
(char *) elf_phdata,
- sizeof(struct elf_phdr) * interp_elf_ex->e_phnum, 1);
+ sizeof(struct elf_phdr) * interp_elf_ex->e_phnum);
#ifdef DEBUG_ELF
dump_phdrs(elf_phdata, interp_elf_ex->e_phnum);
#endif
- elf_exec_fileno = open_dentry(interpreter_dentry, O_RDONLY);
- if (elf_exec_fileno < 0) {
- printk("Could not open IRIX interp inode.\n");
- kfree(elf_phdata);
- return 0xffffffff;
- }
-
- file = fget(elf_exec_fileno);
-
eppnt = elf_phdata;
for(i=0; i<interp_elf_ex->e_phnum; i++, eppnt++) {
if(eppnt->p_type == PT_LOAD) {
@@ -321,12 +309,12 @@
#ifdef DEBUG_ELF
printk("INTERP do_mmap(%p, %08lx, %08lx, %08lx, %08lx, %08lx) ",
- file, vaddr,
+ interpreter, vaddr,
(unsigned long) (eppnt->p_filesz + (eppnt->p_vaddr & 0xfff)),
(unsigned long) elf_prot, (unsigned long) elf_type,
(unsigned long) (eppnt->p_offset & 0xfffff000));
#endif
- error = do_mmap(file, vaddr,
+ error = do_mmap(interpreter, vaddr,
eppnt->p_filesz + (eppnt->p_vaddr & 0xfff),
elf_prot, elf_type,
eppnt->p_offset & 0xfffff000);
@@ -363,8 +351,6 @@
}
/* Now use mmap to map the library into memory. */
- fput(file);
- sys_close(elf_exec_fileno);
if(error < 0 && error > -1024) {
#ifdef DEBUG_ELF
printk("got error %d\n", error);
@@ -407,9 +393,7 @@
/* First of all, some simple consistency checks */
if((ehp->e_type != ET_EXEC && ehp->e_type != ET_DYN) ||
- !elf_check_arch(ehp->e_machine) ||
- (!bprm->dentry->d_inode->i_fop ||
- !bprm->dentry->d_inode->i_fop->mmap)) {
+ !elf_check_arch(ehp->e_machine) || !bprm->file->f_op->mmap) {
return -ENOEXEC;
}
@@ -435,7 +419,7 @@
/* Look for an IRIX ELF interpreter. */
static inline int look_for_irix_interpreter(char **name,
- struct dentry **interpreter_dentry,
+ struct file **interpreter,
struct elfhdr *interp_elf_ex,
struct elf_phdr *epp,
struct linux_binprm *bprm, int pnum)
@@ -443,7 +427,7 @@
mm_segment_t old_fs;
int i;
int retval = -EINVAL;
- struct dentry *dentry = NULL;
+ struct file *file = NULL;
*name = NULL;
for(i = 0; i < pnum; i++, epp++) {
@@ -461,29 +445,27 @@
return -ENOMEM;
strcpy(*name, IRIX_INTERP_PREFIX);
- retval = read_exec(bprm->dentry, epp->p_offset, (*name + 16),
- epp->p_filesz, 1);
+ retval = kernel_read(bprm->file, epp->p_offset, (*name + 16),
+ epp->p_filesz);
if(retval < 0)
goto out;
- old_fs = get_fs(); set_fs(get_ds());
- dentry = namei(*name);
- set_fs(old_fs);
- if(IS_ERR(dentry)) {
- retval = PTR_ERR(dentry);
+ file = open_exec(*name);
+ if(IS_ERR(file)) {
+ retval = PTR_ERR(file);
goto out;
}
- retval = read_exec(dentry, 0, bprm->buf, 128, 1);
+ retval = kernel_read(file, 0, bprm->buf, 128);
if(retval < 0)
goto dput_and_out;
*interp_elf_ex = *((struct elfhdr *) bprm->buf);
}
- *interpreter_dentry = dentry;
+ *interpreter = file;
return 0;
dput_and_out:
- dput(dentry);
+ fput(file);
out:
kfree(*name);
return retval;
@@ -544,7 +526,7 @@
}
static inline int map_interpreter(struct elf_phdr *epp, struct elfhdr *ihp,
- struct dentry *identry, unsigned int *iladdr,
+ struct file *interp, unsigned int *iladdr,
int pnum, mm_segment_t old_fs,
unsigned int *eentry)
{
@@ -560,11 +542,11 @@
return -1;
set_fs(old_fs);
- *eentry = load_irix_interp(ihp, identry, iladdr);
+ *eentry = load_irix_interp(ihp, interp, iladdr);
old_fs = get_fs();
set_fs(get_ds());
- dput(identry);
+ fput(interp);
if(*eentry == 0xffffffff)
return -1;
@@ -603,14 +585,13 @@
static int load_irix_binary(struct linux_binprm * bprm, struct pt_regs * regs)
{
struct elfhdr elf_ex, interp_elf_ex;
- struct dentry *interpreter_dentry;
+ struct file *interpreter;
struct elf_phdr *elf_phdata, *elf_ihdr, *elf_ephdr;
unsigned int load_addr, elf_bss, elf_brk;
unsigned int elf_entry, interp_load_addr = 0;
unsigned int start_code, end_code, end_data, elf_stack;
- int elf_exec_fileno, retval, has_interp, has_ephdr, size, i;
+ int retval, has_interp, has_ephdr, size, i;
char *elf_interpreter;
- struct file *file;
mm_segment_t old_fs;
load_addr = 0;
@@ -636,8 +617,7 @@
goto out;
}
- retval = read_exec(bprm->dentry, elf_ex.e_phoff,
- (char *) elf_phdata, size, 1);
+ retval = kernel_read(bprm->file, elf_ex.e_phoff, (char *)elf_phdata, size);
if (retval < 0)
goto out_free_ph;
@@ -664,10 +644,6 @@
elf_bss = 0;
elf_brk = 0;
- retval = open_dentry(bprm->dentry, O_RDONLY);
- if (retval < 0)
- goto out_free_ph;
- file = fget(elf_exec_fileno = retval);
elf_stack = 0xffffffff;
elf_interpreter = NULL;
@@ -676,7 +652,7 @@
end_data = 0;
retval = look_for_irix_interpreter(&elf_interpreter,
- &interpreter_dentry,
+ &interpreter,
&interp_elf_ex, elf_phdata, bprm,
elf_ex.e_phnum);
if(retval)
@@ -720,13 +696,13 @@
old_fs = get_fs();
set_fs(get_ds());
- map_executable(file, elf_phdata, elf_ex.e_phnum, &elf_stack,
+ map_executable(bprm->file, elf_phdata, elf_ex.e_phnum, &elf_stack,
&load_addr, &start_code, &elf_bss, &end_code,
&end_data, &elf_brk);
if(elf_interpreter) {
retval = map_interpreter(elf_phdata, &interp_elf_ex,
- interpreter_dentry, &interp_load_addr,
+ interpreter, &interp_load_addr,
elf_ex.e_phnum, old_fs, &elf_entry);
kfree(elf_interpreter);
if(retval) {
@@ -741,8 +717,6 @@
set_fs(old_fs);
kfree(elf_phdata);
- fput(file);
- sys_close(elf_exec_fileno);
current->personality = PER_IRIX32;
put_exec_domain(current->exec_domain);
@@ -805,13 +779,11 @@
return retval;
out_free_dentry:
- dput(interpreter_dentry);
+ fput(interpreter);
out_free_interp:
if (elf_interpreter)
kfree(elf_interpreter);
out_free_file:
- fput(file);
- sys_close(elf_exec_fileno);
out_free_ph:
kfree (elf_phdata);
goto out;
@@ -824,31 +796,14 @@
{
struct elfhdr elf_ex;
struct elf_phdr *elf_phdata = NULL;
- struct dentry *dentry;
- struct inode *inode;
- unsigned int len;
- int elf_bss;
+ unsigned int len = 0;
+ int elf_bss = 0;
int retval;
unsigned int bss;
int error;
int i,j, k;
- len = 0;
- dentry = file->f_dentry;
- inode = dentry->d_inode;
- elf_bss = 0;
-
- /* Seek to the beginning of the file. */
- if (file->f_op->llseek) {
- if ((error = file->f_op->llseek(file, 0, 0)) != 0)
- return -ENOEXEC;
- } else
- file->f_pos = 0;
-
- set_fs(KERNEL_DS);
- error = file->f_op->read(file, (char *) &elf_ex, sizeof(elf_ex),
- &file->f_pos);
- set_fs(USER_DS);
+ error = kernel_read(file, 0, (char *) &elf_ex, sizeof(elf_ex));
if (error != sizeof(elf_ex))
return -ENOEXEC;
@@ -857,9 +812,7 @@
/* First of all, some simple consistency checks. */
if(elf_ex.e_type != ET_EXEC || elf_ex.e_phnum > 2 ||
- !elf_check_arch(elf_ex.e_machine) ||
- (!dentry->d_inode->i_fop ||
- !dentry->d_inode->i_fop->mmap))
+ !elf_check_arch(elf_ex.e_machine) || !file->f_op->mmap)
return -ENOEXEC;
/* Now read in all of the header information. */
@@ -871,8 +824,8 @@
if (elf_phdata == NULL)
return -ENOMEM;
- retval = read_exec(dentry, elf_ex.e_phoff, (char *) elf_phdata,
- sizeof(struct elf_phdr) * elf_ex.e_phnum, 1);
+ retval = kernel_read(file, elf_ex.e_phoff, (char *) elf_phdata,
+ sizeof(struct elf_phdr) * elf_ex.e_phnum);
j = 0;
for(i=0; i<elf_ex.e_phnum; i++)
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)