From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Willy Tarreau <w@1wt.eu>
Cc: "Shuah Khan" <shuah@kernel.org>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Subject: Re: [PATCH 2/2] tools/nolibc: add support for directory access
Date: Sun, 2 Feb 2025 21:56:02 +0100 [thread overview]
Message-ID: <4d670db0-eaf0-4151-b98c-1e5c84e1f275@t-8ch.de> (raw)
In-Reply-To: <20250201104659.GA8168@1wt.eu>
On 2025-02-01 11:46:59+0100, Willy Tarreau wrote:
> On Sat, Feb 01, 2025 at 11:41:58AM +0100, Thomas Weißschuh wrote:
> > On 2025-02-01 11:34:38+0100, Willy Tarreau wrote:
> > > On Thu, Jan 30, 2025 at 08:54:03PM +0100, Thomas Weißschuh wrote:
> > > > From: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> > > >
> > > > Add an allocation-free implementation of readdir() and related
> > > > functions. The implementation is modelled after the one for FILE.
> > >
> > > I think you'd need to mention/remind the two important points that
> > > come out of that choice, one being that DIR is a fake pointer that
> > > instead stores ~fd so that it can be turned back to a valid FD, and
> > > that subsequent readdir() calls will only work from the same file
> > > unit since it relies on a local static storage.
> >
> > Point one is true.
> > Point two not so much. It is fine to have multiple directories open at
> > the same time. All state is kept inside the kernel.
> > Only the *current* return value is in the static buffer.
>
> Excellent point! It also needs to be mentioned.
Unfortunately POSIX is more specific in it's definition and forbids this:
The returned pointer, and pointers within the structure, might
be invalidated or the structure or the storage areas might be
overwritten by a subsequent call to readdir() on the same
directory stream.
I see two possibilities:
Allocate one 'struct dirent' as part of DIR.
Only implement readdir_r().
While readdir_r() is deprecated (according to readdir(3) but not
readdir(3p)) this seems to be due to ABI issues, which shouldn't matter
for nolibc anyways.
Personally I would prefer readdir_r().
<snip>
prev parent reply other threads:[~2025-02-02 20:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-30 19:54 [PATCH 0/2] tools/nolibc: add support for directory access Thomas Weißschuh
2025-01-30 19:54 ` [PATCH 1/2] tools/nolibc: add support for sys_llseek() Thomas Weißschuh
2025-01-30 19:54 ` [PATCH 2/2] tools/nolibc: add support for directory access Thomas Weißschuh
2025-02-01 10:34 ` Willy Tarreau
2025-02-01 10:41 ` Thomas Weißschuh
2025-02-01 10:46 ` Willy Tarreau
2025-02-02 20:56 ` Thomas Weißschuh [this message]
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=4d670db0-eaf0-4151-b98c-1e5c84e1f275@t-8ch.de \
--to=linux@weissschuh.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=thomas.weissschuh@linutronix.de \
--cc=w@1wt.eu \
/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