[PATCH] fcntl fix

Andries.Brouwer@cwi.nl
Mon, 27 May 2002 17:46:53 +0200 (MEST)


People asked me to document that Linux has a non-POSIX-compliant
fcntl system call. Maybe fixing fcntl is better.
No doubt the same patch should be applied to 2.2 and 2.4,
but let's do 2.5 first.

--- /linux/2.5/linux-2.5.18/linux/fs/locks.c Tue May 21 07:07:37 2002
+++ /linux/2.5/linux-2.5.18a/linux/fs/locks.c Mon May 27 17:25:33 2002
@@ -274,9 +274,18 @@
return -EINVAL;
}

- if (((start += l->l_start) < 0) || (l->l_len < 0))
+ /* POSIX-1996 leaves the case l->l_len < 0 undefined;
+ POSIX-2001 defines it. */
+ start += l->l_start;
+ if (l->l_len < 0) {
+ end = start - 1;
+ start += l->l_len;
+ } else {
+ end = start + l->l_len - 1;
+ }
+
+ if (start < 0)
return -EINVAL;
- end = start + l->l_len - 1;
if (l->l_len > 0 && end < 0)
return -EOVERFLOW;
fl->fl_start = start; /* we record the absolute position */

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