public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* fcntl error
@ 2004-03-18 16:44 David Howells
  2004-03-18 17:30 ` Linus Torvalds
  0 siblings, 1 reply; 4+ messages in thread
From: David Howells @ 2004-03-18 16:44 UTC (permalink / raw)
  To: Andrew Morton, torvalds; +Cc: linux-kernel


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;

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-03-19  9:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-18 16:44 fcntl error David Howells
2004-03-18 17:30 ` Linus Torvalds
2004-03-18 17:47   ` Andreas Schwab
2004-03-19  9:38   ` David Howells

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox