patch-2.3.50 linux/arch/mips/kernel/sysirix.c

Next file: linux/arch/ppc/configs/common_defconfig
Previous file: linux/arch/ia64/Makefile
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.49/linux/arch/mips/kernel/sysirix.c linux/arch/mips/kernel/sysirix.c
@@ -2025,12 +2025,10 @@
 asmlinkage int irix_ngetdents(unsigned int fd, void * dirent, unsigned int count, int *eob)
 {
 	struct file *file;
-	struct inode *inode;
 	struct irix_dirent32 *lastdirent;
 	struct irix_dirent32_callback buf;
 	int error;
 
-	lock_kernel();
 #ifdef DEBUG_GETDENTS
 	printk("[%s:%ld] ngetdents(%d, %p, %d, %p) ", current->comm,
 	       current->pid, fd, dirent, count, eob);
@@ -2040,26 +2038,14 @@
 	if (!file)
 		goto out;
 
-	inode = file->f_dentry->d_inode;
-	if (!inode)
-		goto out_putf;
+	lock_kernel();
 
 	buf.current_dir = (struct irix_dirent32 *) dirent;
 	buf.previous = NULL;
 	buf.count = count;
 	buf.error = 0;
 
-	error = -ENOTDIR;
-	if (!file->f_op || !file->f_op->readdir)
-		goto out_putf;
-
-	/*
-	 * Get the inode's semaphore to prevent changes
-	 * to the directory while we read it.
-	 */
-	down(&inode->i_sem);
-	error = file->f_op->readdir(file, &buf, irix_filldir32);
-	up(&inode->i_sem);
+	error = vfs_readdir(file, irix_filldir32, &buf);
 	if (error < 0)
 		goto out_putf;
 	error = buf.error;
@@ -2081,9 +2067,9 @@
 	error = count - buf.count;
 
 out_putf:
+	unlock_kernel();
 	fput(file);
 out:
-	unlock_kernel();
 	return error;
 }
 
@@ -2134,12 +2120,10 @@
 asmlinkage int irix_getdents64(int fd, void *dirent, int cnt)
 {
 	struct file *file;
-	struct inode *inode;
 	struct irix_dirent64 *lastdirent;
 	struct irix_dirent64_callback buf;
 	int error;
 
-	lock_kernel();
 #ifdef DEBUG_GETDENTS
 	printk("[%s:%d] getdents64(%d, %p, %d) ", current->comm,
 	       current->pid, fd, dirent, cnt);
@@ -2148,13 +2132,7 @@
 	if (!(file = fget(fd)))
 		goto out;
 
-	inode = file->f_dentry->d_inode;
-	if (!inode)
-		goto out_f;
-
-	error = -ENOTDIR;
-	if (!file->f_op || !file->f_op->readdir)
-		goto out_f;
+	lock_kernel();
 
 	error = -EFAULT;
 	if(!access_ok(VERIFY_WRITE, dirent, cnt))
@@ -2168,9 +2146,7 @@
 	buf.previous = NULL;
 	buf.count = cnt;
 	buf.error = 0;
-	down(&inode->i_sem);
-	error = file->f_op->readdir(file, &buf, irix_filldir64);
-	up(&inode->i_sem);
+	error = vfs_readdir(file, irix_filldir64, &buf);
 	if (error < 0)
 		goto out_f;
 	lastdirent = buf.previous;
@@ -2185,21 +2161,19 @@
 	error = cnt - buf.count;
 
 out_f:
+	unlock_kernel();
 	fput(file);
 out:
-	unlock_kernel();
 	return error;
 }
 
 asmlinkage int irix_ngetdents64(int fd, void *dirent, int cnt, int *eob)
 {
 	struct file *file;
-	struct inode *inode;
 	struct irix_dirent64 *lastdirent;
 	struct irix_dirent64_callback buf;
 	int error;
 
-	lock_kernel();
 #ifdef DEBUG_GETDENTS
 	printk("[%s:%d] ngetdents64(%d, %p, %d) ", current->comm,
 	       current->pid, fd, dirent, cnt);
@@ -2208,13 +2182,7 @@
 	if (!(file = fget(fd)))
 		goto out;
 
-	inode = file->f_dentry->d_inode;
-	if (!inode)
-		goto out_f;
-
-	error = -ENOTDIR;
-	if (!file->f_op || !file->f_op->readdir)
-		goto out_f;
+	lock_kernel();
 
 	error = -EFAULT;
 	if(!access_ok(VERIFY_WRITE, dirent, cnt) ||
@@ -2230,9 +2198,7 @@
 	buf.previous = NULL;
 	buf.count = cnt;
 	buf.error = 0;
-	down(&inode->i_sem);
-	error = file->f_op->readdir(file, &buf, irix_filldir64);
-	up(&inode->i_sem);
+	error = vfs_readdir(file, irix_filldir64, &buf);
 	if (error < 0)
 		goto out_f;
 	lastdirent = buf.previous;
@@ -2247,9 +2213,9 @@
 	error = cnt - buf.count;
 
 out_f:
+	unlock_kernel();
 	fput(file);
 out:
-	unlock_kernel();
 	return error;
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)