A file lock patch

H.J. Lu (hjl@varesearch.com)
Sat, 13 Feb 1999 17:42:04 -0800 (PST)


Hi,

I found out these while working on NFS.

1. Shouldn't OFFSET_MAX be 0x7fffffffffffffffUL if off_t is 8 bytes?
2. The NFS testsuite expects EINVAL when length > 0 and start +
length - 1 is beyond OFFSET_MAX.

Are I am right on these?

Thanks.

-- 
H.J. Lu (hjl@gnu.org)
---
Index: fs/locks.c
===================================================================
RCS file: /local/work/cvs/linux/linux/fs/locks.c,v
retrieving revision 1.1.1.16
diff -u -p -r1.1.1.16 locks.c
--- locks.c	1999/01/27 00:28:56	1.1.1.16
+++ locks.c	1999/02/14 01:26:10
@@ -111,7 +111,9 @@
 
 #include <asm/uaccess.h>
 
-#define OFFSET_MAX	((off_t)0x7fffffff)	/* FIXME: move elsewhere? */
+/* FIXME: move elsewhere? */
+#define OFFSET_MAX	((off_t) (sizeof (off_t) == 4 \
+				  ? 0x7fffffff : 0x7fffffffffffffffUL))
 
 static int flock_make_lock(struct file *filp, struct file_lock *fl,
 			       unsigned int cmd);
@@ -672,8 +674,11 @@ static int posix_make_lock(struct file *
 
 	if (((start += l->l_start) < 0) || (l->l_len < 0))
 		return (0);
+	fl->fl_end = start + l->l_len - 1;
+	if (l->l_len > 0 && fl->fl_end < 0)
+		return (0);
 	fl->fl_start = start;	/* we record the absolute position */
-	if ((l->l_len == 0) || ((fl->fl_end = start + l->l_len - 1) < 0))
+	if (l->l_len == 0)
 		fl->fl_end = OFFSET_MAX;
 	
 	fl->fl_file = filp;

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/