patch-2.1.89 linux/fs/stat.c

Next file: linux/include/asm-alpha/hwrpb.h
Previous file: linux/fs/smbfs/sock.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.88/linux/fs/stat.c linux/fs/stat.c
@@ -4,13 +4,14 @@
  *  Copyright (C) 1991, 1992  Linus Torvalds
  */
 
+#include <linux/sched.h>
+#include <linux/mm.h>
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/stat.h>
 #include <linux/fs.h>
-#include <linux/sched.h>
+#include <linux/file.h>
 #include <linux/kernel.h>
-#include <linux/mm.h>
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
 
@@ -220,12 +221,14 @@
 	int err = -EBADF;
 
 	lock_kernel();
-	if (fd < NR_OPEN && (f = current->files->fd[fd]) != NULL) {
+	f = fget(fd);
+	if (f) {
 		struct dentry * dentry = f->f_dentry;
 
 		err = do_revalidate(dentry);
 		if (!err)
 			err = cp_old_stat(dentry->d_inode, statbuf);
+		fput(f);
 	}
 	unlock_kernel();
 	return err;
@@ -239,12 +242,14 @@
 	int err = -EBADF;
 
 	lock_kernel();
-	if (fd < NR_OPEN && (f = current->files->fd[fd]) != NULL) {
+	f = fget(fd);
+	if (f) {
 		struct dentry * dentry = f->f_dentry;
 
 		err = do_revalidate(dentry);
 		if (!err)
 			err = cp_new_stat(dentry->d_inode, statbuf);
+		fput(f);
 	}
 	unlock_kernel();
 	return err;

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