Skip to content

nolibc: Add dirfd()

Daniel Palmer lkml 3 versions – Applied

Status from this message: Applied, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest3 patches 1 replyApplied
  2. v22 patches 6 repliesSuperseded
  3. v11 patch 1 replySuperseded

Change log from the cover letter

v3 - Split the internal helper into its own commit.
- test: just stat one child instead of all of them
- According to POSIX (https://man7.org/linux/man-pages/man3/dirfd.3.html) errno should be EINVAL on failure, so closedir() is now untouched as it is setting EBADF. This makes the diff a little cleaner too.
- Replace i with fd in some places so isn't confused with -1.
- Due to all of the changes I didn't add trailers from v2.
v2 - Fix the name of the dirfd helper, I debated over removing the helper
as suggested by Thomas but it seems right to have the logic in a single place.
Add test a basic test to make sure dirfd() actually does convert back to the expected fd and using dirfd() with fstatat().

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/3tools/nolibc: Add internal __nolibc_dirfd() helpertools/include/nolibc/dirent.h+17 -70 replies
2/3tools/nolibc: Add dirfd()tools/include/nolibc/dirent.h+13 -00 replies
3/3selftests/nolibc: Add test for dirfd()tools/testing/selftests/nolibc/nolibc-test.c+40 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 0/3] nolibc: Add dirfd()

Add dirfd() to convert a DIR back to an fd for functions like fstatat() that take an fd.

Change log:
v3 - Split the internal helper into its own commit.
- test: just stat one child instead of all of them
- According to POSIX (https://man7.org/linux/man-pages/man3/dirfd.3.html) errno should be EINVAL on failure, so closedir() is now untouched as it is setting EBADF. This makes the diff a little cleaner too.
- Replace i with fd in some places so isn't confused with -1.
- Due to all of the changes I didn't add trailers from v2.
v2 - Fix the name of the dirfd helper, I debated over removing the helper
as suggested by Thomas but it seems right to have the logic in a single place.
Add test a basic test to make sure dirfd() actually does convert back to the expected fd and using dirfd() with fstatat().

Daniel Palmer (3):
tools/nolibc: Add internal __nolibc_dirfd() helper tools/nolibc: Add dirfd() selftests/nolibc: Add test for dirfd()

 tools/include/nolibc/dirent.h                | 37 ++++++++++++++----
 tools/testing/selftests/nolibc/nolibc-test.c | 40 ++++++++++++++++++++
 2 files changed, 70 insertions(+), 7 deletions(-)
Signature · 1 line
2.53.0