fcntl error

From: David Howells
Date: Thu Mar 18 2004 - 11:47:19 EST



Hi Andrew, Linus,

The attached patch fixes a minor problem with fcntl.

get_close_on_exec() uses FD_ISSET() to determine the fd state. However,
FD_ISSET() does not return 0 or 1 on all archs. On some it returns 0 or non-0,
which is fine by POSIX.

Also, the argument of set_close_on_exec() is being AND'ed with literal 1. This
is incorrect - there's no requirement for FD_CLOEXEC to be 1.

This is also wrong on 2.4 kernels.

David


--- fs/fcntl.c.orig 2004-03-18 16:29:57.000000000 +0000
+++ fs/fcntl.c 2004-03-18 16:30:27.000000000 +0000
@@ -293,11 +293,11 @@
err = dupfd(filp, arg);
break;
case F_GETFD:
- err = get_close_on_exec(fd);
+ err = get_close_on_exec(fd) ? FD_CLOEXEC : 0;
break;
case F_SETFD:
err = 0;
- set_close_on_exec(fd, arg&1);
+ set_close_on_exec(fd, arg & FD_CLOEXEC);
break;
case F_GETFL:
err = filp->f_flags;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/