patch-2.1.45 linux/fs/binfmt_elf.c

Next file: linux/fs/binfmt_em86.c
Previous file: linux/fs/binfmt_aout.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.44/linux/fs/binfmt_elf.c linux/fs/binfmt_elf.c
@@ -186,7 +186,7 @@
    an ELF header */
 
 static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex,
-				     struct inode * interpreter_inode,
+				     struct dentry * interpreter_dentry,
 				     unsigned long *interp_load_addr)
 {
 	struct file * file;
@@ -208,8 +208,8 @@
 	if ((interp_elf_ex->e_type != ET_EXEC &&
 	    interp_elf_ex->e_type != ET_DYN) ||
 	   !elf_check_arch(interp_elf_ex->e_machine) ||
-	   (!interpreter_inode->i_op ||
-	    !interpreter_inode->i_op->default_file_ops->mmap)){
+	   (!interpreter_dentry->d_inode->i_op ||
+	    !interpreter_dentry->d_inode->i_op->default_file_ops->mmap)){
 		return ~0UL;
 	}
 
@@ -236,7 +236,7 @@
 	    return ~0UL;
 	  }
 
-	retval = read_exec(interpreter_inode, interp_elf_ex->e_phoff,
+	retval = read_exec(interpreter_dentry, interp_elf_ex->e_phoff,
 			   (char *) elf_phdata,
 			   sizeof(struct elf_phdr) * interp_elf_ex->e_phnum, 1);
 
@@ -245,7 +245,7 @@
 		return retval;
  	}
 
-	elf_exec_fileno = open_inode(interpreter_inode, O_RDONLY);
+	elf_exec_fileno = open_dentry(interpreter_dentry, O_RDONLY);
 	if (elf_exec_fileno < 0) {
 	  kfree(elf_phdata);
 	  return ~0UL;
@@ -333,7 +333,7 @@
 }
 
 static unsigned long load_aout_interp(struct exec * interp_ex,
-			     struct inode * interpreter_inode)
+			     struct dentry * interpreter_dentry)
 {
   int retval;
   unsigned long elf_entry;
@@ -348,13 +348,13 @@
     do_mmap(NULL, 0, interp_ex->a_text+interp_ex->a_data,
 	    PROT_READ|PROT_WRITE|PROT_EXEC,
 	    MAP_FIXED|MAP_PRIVATE, 0);
-    retval = read_exec(interpreter_inode, 32, (char *) 0,
+    retval = read_exec(interpreter_dentry, 32, (char *) 0,
 		       interp_ex->a_text+interp_ex->a_data, 0);
   } else if (N_MAGIC(*interp_ex) == ZMAGIC || N_MAGIC(*interp_ex) == QMAGIC) {
     do_mmap(NULL, 0, interp_ex->a_text+interp_ex->a_data,
 	    PROT_READ|PROT_WRITE|PROT_EXEC,
 	    MAP_FIXED|MAP_PRIVATE, 0);
-    retval = read_exec(interpreter_inode,
+    retval = read_exec(interpreter_dentry,
 		       N_TXTOFF(*interp_ex) ,
 		       (char *) N_TXTADDR(*interp_ex),
 		       interp_ex->a_text+interp_ex->a_data, 0);
@@ -389,7 +389,7 @@
 	struct elfhdr interp_elf_ex;
 	struct file * file;
   	struct exec interp_ex;
-	struct inode *interpreter_inode;
+	struct dentry *interpreter_dentry;
 	unsigned long load_addr;
 	int load_addr_set = 0;
 	unsigned int interpreter_type = INTERPRETER_NONE;
@@ -423,8 +423,8 @@
 	if ((elf_ex.e_type != ET_EXEC &&
 	    elf_ex.e_type != ET_DYN) ||
 	   (! elf_check_arch(elf_ex.e_machine)) ||
-	   (!bprm->inode->i_op || !bprm->inode->i_op->default_file_ops ||
-	    !bprm->inode->i_op->default_file_ops->mmap)){
+	   (!bprm->dentry->d_inode->i_op || !bprm->dentry->d_inode->i_op->default_file_ops ||
+	    !bprm->dentry->d_inode->i_op->default_file_ops->mmap)){
 		return -ENOEXEC;
 	}
 
@@ -436,7 +436,7 @@
 		return -ENOMEM;
 	}
 
-	retval = read_exec(bprm->inode, elf_ex.e_phoff, (char *) elf_phdata,
+	retval = read_exec(bprm->dentry, elf_ex.e_phoff, (char *) elf_phdata,
 			   elf_ex.e_phentsize * elf_ex.e_phnum, 1);
 	if (retval < 0) {
 		kfree (elf_phdata);
@@ -448,7 +448,7 @@
 	elf_bss = 0;
 	elf_brk = 0;
 
-	elf_exec_fileno = open_inode(bprm->inode, O_RDONLY);
+	elf_exec_fileno = open_dentry(bprm->dentry, O_RDONLY);
 
 	if (elf_exec_fileno < 0) {
 		kfree (elf_phdata);
@@ -486,7 +486,7 @@
 				return -ENOMEM;
 			}
 
-			retval = read_exec(bprm->inode,elf_ppnt->p_offset,
+			retval = read_exec(bprm->dentry,elf_ppnt->p_offset,
 					   elf_interpreter,
 					   elf_ppnt->p_filesz, 1);
 			/* If the program interpreter is one of these two,
@@ -501,13 +501,14 @@
 			if (retval >= 0) {
 				old_fs = get_fs(); /* This could probably be optimized */
 				set_fs(get_ds());
-				retval = open_namei(elf_interpreter, 0, 0,
-						    &interpreter_inode, NULL);
+				interpreter_dentry = open_namei(elf_interpreter, 0, 0);
 				set_fs(old_fs);
+				if (IS_ERR(interpreter_dentry))
+					retval = PTR_ERR(interpreter_dentry);
 			}
 
 			if (retval >= 0)
-				retval = read_exec(interpreter_inode,0,bprm->buf,128, 1);
+				retval = read_exec(interpreter_dentry,0,bprm->buf,128, 1);
 
 			if (retval >= 0) {
 				interp_ex = *((struct exec *) bprm->buf);		/* exec-header */
@@ -643,13 +644,13 @@
 	if (elf_interpreter) {
 		if (interpreter_type & 1)
 			elf_entry = load_aout_interp(&interp_ex,
-						     interpreter_inode);
+						     interpreter_dentry);
 		else if (interpreter_type & 2)
 			elf_entry = load_elf_interp(&interp_elf_ex,
-						    interpreter_inode,
+						    interpreter_dentry,
 						    &interp_load_addr);
 
-		iput(interpreter_inode);
+		dput(interpreter_dentry);
 		kfree(elf_interpreter);
 
 		if (elf_entry == ~0UL) {
@@ -677,8 +678,7 @@
 		__MOD_INC_USE_COUNT(current->binfmt->module);
 
 #ifndef VM_STACK_FLAGS
-	current->executable = bprm->inode;
-	atomic_inc(&bprm->inode->i_count);
+	current->executable = dget(bprm->dentry);
 #endif
 #ifdef LOW_ELF_STACK
 	current->start_stack = bprm->p = elf_stack - 4;
@@ -763,7 +763,8 @@
 	struct file * file;
 	struct elfhdr elf_ex;
 	struct elf_phdr *elf_phdata  =  NULL;
-	struct  inode * inode;
+	struct dentry * dentry;
+	struct inode * inode;
 	unsigned long len;
 	int elf_bss;
 	int retval;
@@ -773,7 +774,8 @@
 
 	len = 0;
 	file = current->files->fd[fd];
-	inode = file->f_inode;
+	dentry = file->f_dentry;
+	inode = dentry->d_inode;
 	elf_bss = 0;
 
 	if (!file || !file->f_op)
@@ -812,7 +814,7 @@
 	if (elf_phdata == NULL)
 		return -ENOMEM;
 
-	retval = read_exec(inode, elf_ex.e_phoff, (char *) elf_phdata,
+	retval = read_exec(dentry, elf_ex.e_phoff, (char *) elf_phdata,
 			   sizeof(struct elf_phdr) * elf_ex.e_phnum, 1);
 
 	j = 0;
@@ -884,14 +886,13 @@
  */
 static int dump_write(struct file *file, const void *addr, int nr)
 {
-	file->f_inode->i_status |= ST_MODIFIED;
-	return file->f_op->write(file->f_inode, file, addr, nr) == nr;
+	return file->f_op->write(file->f_dentry->d_inode, file, addr, nr) == nr;
 }
 
 static int dump_seek(struct file *file, off_t off)
 {
 	if (file->f_op->llseek) {
-		if (file->f_op->llseek(file->f_inode, file, off, 0) != off)
+		if (file->f_op->llseek(file->f_dentry->d_inode, file, off, 0) != off)
 			return 0;
 	} else
 		file->f_pos = off;
@@ -1006,6 +1007,7 @@
 {
 	int has_dumped = 0;
 	struct file file;
+	struct dentry *dentry;
 	struct inode *inode;
 	unsigned short fs;
 	char corefile[6+sizeof(current->comm)];
@@ -1079,10 +1081,12 @@
 #else
 	corefile[4] = '\0';
 #endif
-	if (open_namei(corefile,O_CREAT | 2 | O_TRUNC,0600,&inode,NULL)) {
-		inode = NULL;
+	dentry = open_namei(corefile, O_CREAT | 2 | O_TRUNC, 0600);
+	if (IS_ERR(dentry)) {
+		dentry = NULL;
 		goto end_coredump;
 	}
+	inode = dentry->d_inode;
 	if (!S_ISREG(inode->i_mode))
 		goto end_coredump;
 	if (!inode->i_op || !inode->i_op->default_file_ops)
@@ -1090,7 +1094,7 @@
 	file.f_mode = 3;
 	file.f_flags = 0;
 	file.f_count = 1;
-	file.f_inode = inode;
+	file.f_dentry = dentry;
 	file.f_pos = 0;
 	file.f_reada = 0;
 	file.f_op = inode->i_op->default_file_ops;
@@ -1287,7 +1291,7 @@
 
  end_coredump:
 	set_fs(fs);
-	iput(inode);
+	dput(dentry);
 #ifndef CONFIG_BINFMT_ELF
 	MOD_DEC_USE_COUNT;
 #endif

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov