[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
|
|
Subscribe / Log in / New account

read/write: pass down a copy of f_pos, not f_pos itself.

From:  Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
To:  bk-commits-head@vger.kernel.org
Subject:  read/write: pass down a copy of f_pos, not f_pos itself.
Date:  Tue, 10 Aug 2004 00:28:42 +0000

ChangeSet 1.1960, 2004/08/09 17:28:42-07:00, torvalds@ppc970.osdl.org

	read/write: pass down a copy of f_pos, not f_pos itself.
	
	This allows the VFS layer to the update rather than the
	low-level drivers. 



 read_write.c |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)


diff -Nru a/fs/read_write.c b/fs/read_write.c
--- a/fs/read_write.c	2004-08-09 20:06:11 -07:00
+++ b/fs/read_write.c	2004-08-09 20:06:11 -07:00
@@ -270,6 +270,16 @@
 
 EXPORT_SYMBOL(vfs_write);
 
+static inline loff_t file_pos_read(struct file *file)
+{
+	return file->f_pos;
+}
+
+static inline void file_pos_write(struct file *file, loff_t pos)
+{
+	file->f_pos = pos;
+}
+
 asmlinkage ssize_t sys_read(unsigned int fd, char __user * buf, size_t count)
 {
 	struct file *file;
@@ -278,7 +288,9 @@
 
 	file = fget_light(fd, &fput_needed);
 	if (file) {
-		ret = vfs_read(file, buf, count, &file->f_pos);
+		loff_t pos = file_pos_read(file);
+		ret = vfs_read(file, buf, count, &pos);
+		file_pos_write(file, pos);
 		fput_light(file, fput_needed);
 	}
 
@@ -294,7 +306,9 @@
 
 	file = fget_light(fd, &fput_needed);
 	if (file) {
-		ret = vfs_write(file, buf, count, &file->f_pos);
+		loff_t pos = file_pos_read(file);
+		ret = vfs_write(file, buf, count, &pos);
+		file_pos_write(file, pos);
 		fput_light(file, fput_needed);
 	}
 
@@ -520,7 +534,9 @@
 
 	file = fget_light(fd, &fput_needed);
 	if (file) {
-		ret = vfs_readv(file, vec, vlen, &file->f_pos);
+		loff_t pos = file_pos_read(file);
+		ret = vfs_readv(file, vec, vlen, &pos);
+		file_pos_write(file, pos);
 		fput_light(file, fput_needed);
 	}
 
@@ -536,7 +552,9 @@
 
 	file = fget_light(fd, &fput_needed);
 	if (file) {
-		ret = vfs_writev(file, vec, vlen, &file->f_pos);
+		loff_t pos = file_pos_read(file);
+		ret = vfs_writev(file, vec, vlen, &pos);
+		file_pos_write(file, pos);
 		fput_light(file, fput_needed);
 	}
 
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Copyright © 2004, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds