patch-1.3.4 linux/fs/read_write.c

Next file: linux/fs/readdir.c
Previous file: linux/fs/proc/link.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.3/linux/fs/read_write.c linux/fs/read_write.c
@@ -65,7 +65,15 @@
 	if ((err = verify_area(VERIFY_WRITE, result, sizeof(loff_t))))
 		return err;
 	offset = (loff_t) (((unsigned long long) offset_high << 32) | offset_low);
-/* there is no fs specific llseek handler */
+
+	/* if there is a fs-specific handler, we can't just ignore it.. */
+	/* accept llseek() only for the signed long subset of long long */
+	if (file->f_op && file->f_op->lseek) {
+		if (offset != (long) offset)
+			return -EINVAL;
+		return file->f_op->lseek(file->f_inode,file,offset,origin);
+	}
+
 	switch (origin) {
 		case 0:
 			tmp = offset;
@@ -81,9 +89,11 @@
 	}
 	if (tmp < 0)
 		return -EINVAL;
-	file->f_pos = tmp;
-	file->f_reada = 0;
-	file->f_version = ++event;
+	if (tmp != file->f_pos) {
+		file->f_pos = tmp;
+		file->f_reada = 0;
+		file->f_version = ++event;
+	}
 	memcpy_tofs(result, &file->f_pos, sizeof(loff_t));
 	return 0;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this