patch-2.1.91 linux/fs/exec.c

Next file: linux/fs/ext2/truncate.c
Previous file: linux/fs/buffer.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.90/linux/fs/exec.c linux/fs/exec.c
@@ -138,10 +138,9 @@
 /* N.B. Error returns must be < 0 */
 int open_dentry(struct dentry * dentry, int mode)
 {
-	int fd;
 	struct inode * inode = dentry->d_inode;
 	struct file * f;
-	int error;
+	int fd, error;
 
 	error = -EINVAL;
 	if (!inode->i_op || !inode->i_op->default_file_ops)
@@ -163,7 +162,7 @@
 			if (error)
 				goto out_filp;
 		}
-		current->files->fd[fd] = f;
+		fd_install(fd, f);
 		dget(dentry);
 	}
 	return fd;
@@ -195,18 +194,20 @@
 	retval = fd;
 	if (fd < 0)
 		goto out;
-	file = current->files->fd[fd];
+	file = fget(fd);
 	retval = -ENOEXEC;
 	if (file && file->f_dentry && file->f_op && file->f_op->read) {
 		for (fmt = formats ; fmt ; fmt = fmt->next) {
 			int (*fn)(int) = fmt->load_shlib;
 			if (!fn)
 				continue;
+			/* N.B. Should use file instead of fd */
 			retval = fn(fd);
 			if (retval != -ENOEXEC)
 				break;
 		}
 	}
+	fput(file);
 	sys_close(fd);
 out:
 	unlock_kernel();
@@ -491,7 +492,7 @@
 		unsigned long set, i;
 
 		i = j * __NFDBITS;
-		if (i >= NR_OPEN)
+		if (i >= files->max_fds)
 			break;
 		set = files->close_on_exec.fds_bits[j];
 		files->close_on_exec.fds_bits[j] = 0;

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