patch-2.3.34 linux/fs/read_write.c

Next file: linux/fs/stat.c
Previous file: linux/fs/qnx4/file.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.33/linux/fs/read_write.c linux/fs/read_write.c
@@ -39,11 +39,15 @@
 static inline loff_t llseek(struct file *file, loff_t offset, int origin)
 {
 	loff_t (*fn)(struct file *, loff_t, int);
+	loff_t retval;
 
 	fn = default_llseek;
 	if (file->f_op && file->f_op->llseek)
 		fn = file->f_op->llseek;
-	return fn(file, offset, origin);
+	lock_kernel();
+	retval = fn(file, offset, origin);
+	unlock_kernel();
+	return retval;
 }
 
 asmlinkage off_t sys_lseek(unsigned int fd, off_t offset, unsigned int origin)
@@ -53,7 +57,6 @@
 	struct dentry * dentry;
 	struct inode * inode;
 
-	lock_kernel();
 	retval = -EBADF;
 	file = fget(fd);
 	if (!file)
@@ -72,7 +75,6 @@
 out_putf:
 	fput(file);
 bad:
-	unlock_kernel();
 	return retval;
 }
 
@@ -87,7 +89,6 @@
 	struct inode * inode;
 	loff_t offset;
 
-	lock_kernel();
 	retval = -EBADF;
 	file = fget(fd);
 	if (!file)
@@ -112,7 +113,6 @@
 out_putf:
 	fput(file);
 bad:
-	unlock_kernel();
 	return retval;
 }
 #endif
@@ -264,7 +264,6 @@
 	struct file * file;
 	ssize_t ret;
 
-	lock_kernel();
 
 	ret = -EBADF;
 	file = fget(fd);
@@ -275,7 +274,6 @@
 	fput(file);
 
 bad_file:
-	unlock_kernel();
 	return ret;
 }
 
@@ -285,19 +283,16 @@
 	struct file * file;
 	ssize_t ret;
 
-	lock_kernel();
 
 	ret = -EBADF;
 	file = fget(fd);
 	if (!file)
 		goto bad_file;
-	if (file->f_op && file->f_op->write && (file->f_mode & FMODE_WRITE)) {
+	if (file->f_op && file->f_op->write && (file->f_mode & FMODE_WRITE))
 		ret = do_readv_writev(VERIFY_READ, file, vector, count);
-	}
 	fput(file);
 
 bad_file:
-	unlock_kernel();
 	return ret;
 }
 
@@ -312,8 +307,6 @@
 	struct file * file;
 	ssize_t (*read)(struct file *, char *, size_t, loff_t *);
 
-	lock_kernel();
-
 	ret = -EBADF;
 	file = fget(fd);
 	if (!file)
@@ -333,7 +326,6 @@
 out:
 	fput(file);
 bad_file:
-	unlock_kernel();
 	return ret;
 }
 
@@ -344,8 +336,6 @@
 	struct file * file;
 	ssize_t (*write)(struct file *, const char *, size_t, loff_t *);
 
-	lock_kernel();
-
 	ret = -EBADF;
 	file = fget(fd);
 	if (!file)
@@ -366,6 +356,5 @@
 out:
 	fput(file);
 bad_file:
-	unlock_kernel();
 	return ret;
 }

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