From: David Howells <dhowells@redhat.com>
To: Andrew Morton <akpm@osdl.org>, torvalds@osdl.org
Cc: linux-kernel@vger.kernel.org
Subject: fcntl error
Date: Thu, 18 Mar 2004 16:44:57 +0000 [thread overview]
Message-ID: <7051.1079628297@redhat.com> (raw)
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;
next reply other threads:[~2004-03-18 16:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-18 16:44 David Howells [this message]
2004-03-18 17:30 ` fcntl error Linus Torvalds
2004-03-18 17:47 ` Andreas Schwab
2004-03-19 9:38 ` David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7051.1079628297@redhat.com \
--to=dhowells@redhat.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.