From: David Laight <david.laight.linux@gmail.com>
To: Daniel Palmer <daniel@thingy.jp>
Cc: w@1wt.eu, linux@weissschuh.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] tools/nolibc: Add dirfd()
Date: Thu, 8 Oct 2026 08:59:23 +0100 [thread overview]
Message-ID: <20261008085923.4f141f4a@pumpkin> (raw)
In-Reply-To: <20261007052914.888956-2-daniel@thingy.jp>
On Wed, 7 Oct 2026 14:29:12 +0900
Daniel Palmer <daniel@thingy.jp> wrote:
> This is useful for things like fstatat() on children of a directory
> opened with opendir().
>
> At the same time use the new internal helper to replace the two places
> that are converting the DIR pointer back into an fd.
>
> Signed-off-by: Daniel Palmer <daniel@thingy.jp>
> ---
> tools/include/nolibc/dirent.h | 38 +++++++++++++++++++++++++++--------
> 1 file changed, 30 insertions(+), 8 deletions(-)
>
> diff --git a/tools/include/nolibc/dirent.h b/tools/include/nolibc/dirent.h
> index 4e02ef25e72d..d282ea8eb5d3 100644
> --- a/tools/include/nolibc/dirent.h
> +++ b/tools/include/nolibc/dirent.h
> @@ -27,6 +27,18 @@ typedef struct {
> char dummy[1];
> } DIR;
>
> +/* Internal dirfd() that does not set errno */
> +static __attribute__((unused))
> +int __nolibc_dirfd(DIR *dirp)
> +{
> + intptr_t i = (intptr_t)dirp;
> +
> + if (i >= 0)
> + return -1;
> +
> + return ~i;
Might be better to use a different name for the variable.
The two return statements look the same at a first glance.
David
next prev parent reply other threads:[~2026-10-08 7:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 5:29 [PATCH v2 0/2] nolibc: " Daniel Palmer
2026-10-07 5:29 ` [PATCH v2 1/2] tools/nolibc: " Daniel Palmer
2026-10-07 8:03 ` Thomas Weißschuh
2026-10-08 7:59 ` David Laight [this message]
2026-10-07 5:29 ` [PATCH v2 2/2] selftests/nolibc: Add test for dirfd() Daniel Palmer
2026-10-07 8:09 ` Thomas Weißschuh
2026-10-07 6:43 ` [PATCH v2 0/2] nolibc: Add dirfd() Willy Tarreau
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=20261008085923.4f141f4a@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=daniel@thingy.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--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
all inboxes | Powered by JetHome®