From: Christopher Yeoh <cyeoh@samba.org>
To: Linus Torvalds <torvalds@transmeta.com>,
Marcelo Tosatti <marcelo@conectiva.com.br>
Cc: linux-kernel@vger.kernel.org, trivial@rustcorp.com.au
Subject: [PATCH] fcntl returns wrong error code
Date: Thu, 21 Mar 2002 17:09:27 +1100 [thread overview]
Message-ID: <15513.30999.494913.910369@gargle.gargle.HOWL> (raw)
When fcntl(fd, F_DUPFD, b) is called where 'b' is greater than the
maximum allowable value EINVAL should be returned. From POSIX:
"[EINVAL] The cmd argument is invalid, or the cmd argument is F_DUPFD and
arg is negative or greater than or equal to {OPEN_MAX}, or ..."
Currently we instead return EMFILE. The following patch (against
2.4.19pre-4) fixes this behaviour:
--- linux-2.4.18/fs/fcntl.c~ Mon Sep 24 05:13:11 2001
+++ linux-2.4.18/fs/fcntl.c Thu Mar 21 16:50:06 2002
@@ -120,8 +120,13 @@
int ret;
ret = locate_fd(files, file, start);
- if (ret < 0)
+ if (ret < 0) {
+ /* We should return EINVAL instead of EMFILE if the
+ request for the fd starts beyond the valid range */
+ if (ret==-EMFILE && start>=current->rlim[RLIMIT_NOFILE].rlim_cur)
+ ret = -EINVAL;
goto out_putf;
+ }
allocate_fd(files, file, ret);
return ret;
Chris.
--
cyeoh@au.ibm.com
IBM OzLabs Linux Development Group
Canberra, Australia
next reply other threads:[~2002-03-21 6:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-21 6:09 Christopher Yeoh [this message]
2002-03-21 13:28 ` Alan Cox
2002-03-21 13:58 ` Christopher Yeoh
2002-03-22 2:56 ` [PATCH] fcntl returns wrong error code (Updated) Christopher Yeoh
2002-03-26 23:50 [PATCH] fcntl returns wrong error code Andries.Brouwer
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=15513.30999.494913.910369@gargle.gargle.HOWL \
--to=cyeoh@samba.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo@conectiva.com.br \
--cc=torvalds@transmeta.com \
--cc=trivial@rustcorp.com.au \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®