From: Daniel Palmer <daniel@thingy.jp>
To: w@1wt.eu, linux@weissschuh.net
Cc: linux-kernel@vger.kernel.org, david.laight.linux@gmail.com,
Daniel Palmer <daniel@thingy.jp>
Subject: [PATCH v3 2/3] tools/nolibc: Add dirfd()
Date: Sat, 31 Oct 2026 13:29:59 +0900 [thread overview]
Message-ID: <20261031043000.145709-3-daniel@thingy.jp> (raw)
In-Reply-To: <20261031043000.145709-1-daniel@thingy.jp>
This is useful for things like fstatat() on children of a directory
opened with opendir().
Signed-off-by: Daniel Palmer <daniel@thingy.jp>
---
tools/include/nolibc/dirent.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/tools/include/nolibc/dirent.h b/tools/include/nolibc/dirent.h
index 7666dc69506f..76331ed65560 100644
--- a/tools/include/nolibc/dirent.h
+++ b/tools/include/nolibc/dirent.h
@@ -74,6 +74,19 @@ DIR *opendir(const char *name)
return (DIR *)(intptr_t)~fd;
}
+static __attribute__((unused))
+int dirfd(DIR *dirp)
+{
+ int fd = __nolibc_dirfd(dirp);
+
+ if (fd < 0) {
+ SET_ERRNO(EINVAL);
+ return -1;
+ }
+
+ return fd;
+}
+
static __attribute__((unused))
int closedir(DIR *dirp)
{
--
2.53.0
next prev parent reply other threads:[~2026-10-31 4:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-31 4:29 [PATCH v3 0/3] nolibc: " Daniel Palmer
2026-10-31 4:29 ` [PATCH v3 1/3] tools/nolibc: Add internal __nolibc_dirfd() helper Daniel Palmer
2026-10-31 4:29 ` Daniel Palmer [this message]
2026-10-31 4:30 ` [PATCH v3 3/3] selftests/nolibc: Add test for dirfd() Daniel Palmer
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=20261031043000.145709-3-daniel@thingy.jp \
--to=daniel@thingy.jp \
--cc=david.laight.linux@gmail.com \
--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®