From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [PATCH 2/3] io: Add closefrom [BZ #10353]
Date: Tue, 22 Dec 2020 10:28:12 -0300 [thread overview]
Message-ID: <9185e071-1bfb-0f2c-f3d9-4711e4d6e156@linaro.org> (raw)
In-Reply-To: <87y2hqt1x7.fsf@oldenburg2.str.redhat.com>
On 22/12/2020 10:17, Florian Weimer wrote:
> * Adhemerval Zanella:
>
>>> Right, but I think it's needed for correctness. closefrom (3) should
>>> work even if all descriptors are open.
>>
>> Alright, I think we can do something like:
>>
>> int dirfd = __open_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY, 0);
>> if (dirfd == -1 && errno == EMFILE)
>> {
>> int maxfd = __getdtablesize ();
>> for (int i = lowfd; i < maxfd; i++)
>> if (__close_nocancel (i) == 0)
>> break;
>> dirfd = __open_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY, 0);
>> if (dirfd == -1)
>> goto err;
>> }
>>
>
> I suggest errno != ENOENT (not mounted /proc), but otherwise looks good.
Do you mean fail with /proc is not mounted?
int dirfd = __open_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY, 0);
if (dirfd == -1)
{
if (errno != EMFILE)
goto err;
int maxfd = __getdtablesize ();
for (int i = lowfd; i < maxfd; i++)
if (__close_nocancel (i) == 0)
break;
dirfd = __open_nocancel (FD_TO_FILENAME_PREFIX, O_RDONLY | O_DIRECTORY, 0);
if (dirfd == -1)
goto err;
}
next prev parent reply other threads:[~2020-12-22 13:28 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-21 21:50 [PATCH 1/3] Linux: Add close_range Adhemerval Zanella
2020-12-21 21:50 ` [PATCH 2/3] io: Add closefrom [BZ #10353] Adhemerval Zanella
2020-12-22 10:49 ` Florian Weimer
2020-12-22 11:50 ` Adhemerval Zanella
2020-12-22 11:57 ` Florian Weimer
2020-12-22 12:41 ` Adhemerval Zanella
2020-12-22 13:17 ` Florian Weimer
2020-12-22 13:28 ` Adhemerval Zanella [this message]
2020-12-22 13:34 ` Florian Weimer
2020-12-21 21:50 ` [PATCH 3/3] posix: Add posix_spawn_file_actions_closefrom Adhemerval Zanella
2020-12-22 11:32 ` Florian Weimer
2020-12-22 11:56 ` Adhemerval Zanella
2020-12-22 12:00 ` Florian Weimer
2020-12-22 12:46 ` Adhemerval Zanella
2020-12-22 9:05 ` [PATCH 1/3] Linux: Add close_range Florian Weimer
2020-12-22 11:35 ` Adhemerval Zanella
2020-12-22 11:41 ` Florian Weimer
2020-12-22 11:47 ` Adhemerval Zanella
2020-12-23 12:33 ` Christian Brauner
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=9185e071-1bfb-0f2c-f3d9-4711e4d6e156@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).