From: Willy Tarreau <w@1wt.eu>
To: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Cc: "Thomas Weißschuh" <linux@weissschuh.net>,
"Shuah Khan" <shuah@kernel.org>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH] tools/nolibc: add support for fchdir()
Date: Sat, 8 Nov 2025 13:33:18 +0100 [thread overview]
Message-ID: <20251108123318.GA6898@1wt.eu> (raw)
In-Reply-To: <20251107-nolibc-fchdir-v1-1-4a1ab8141f68@linutronix.de>
Hi Thomas,
On Fri, Nov 07, 2025 at 03:13:38PM +0100, Thomas Weißschuh wrote:
> Add support for the file descriptor based variant of chdir().
>
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> ---
> tools/include/nolibc/sys.h | 13 +++++++++++++
> tools/testing/selftests/nolibc/nolibc-test.c | 2 ++
> 2 files changed, 15 insertions(+)
>
> diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
> index c5564f57deec88b8aa70291fcf6f9ca4dbc1d03f..a4b0fdb9b641230174f5e62d62762f59af81a00e 100644
> --- a/tools/include/nolibc/sys.h
> +++ b/tools/include/nolibc/sys.h
> @@ -118,6 +118,7 @@ void *sbrk(intptr_t inc)
>
> /*
> * int chdir(const char *path);
> + * int fchdir(int fildes);
> */
>
> static __attribute__((unused))
> @@ -132,6 +133,18 @@ int chdir(const char *path)
> return __sysret(sys_chdir(path));
> }
>
> +static __attribute__((unused))
> +int sys_fchdir(int fildes)
> +{
> + return my_syscall1(__NR_fchdir, fildes);
> +}
> +
> +static __attribute__((unused))
> +int fchdir(int fildes)
> +{
> + return __sysret(sys_fchdir(fildes));
> +}
> +
>
> /*
> * int chmod(const char *path, mode_t mode);
> diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
> index 29de21595fc95341c2aa975375a8d471cb3933fc..5927a84466cc0ede3b99611e134a8c6b8ab91e72 100644
> --- a/tools/testing/selftests/nolibc/nolibc-test.c
> +++ b/tools/testing/selftests/nolibc/nolibc-test.c
> @@ -1343,6 +1343,8 @@ int run_syscall(int min, int max)
> CASE_TEST(dup3_0); tmp = dup3(0, 100, 0); EXPECT_SYSNE(1, tmp, -1); close(tmp); break;
> CASE_TEST(dup3_m1); tmp = dup3(-1, 100, 0); EXPECT_SYSER(1, tmp, -1, EBADF); if (tmp != -1) close(tmp); break;
> CASE_TEST(execve_root); EXPECT_SYSER(1, execve("/", (char*[]){ [0] = "/", [1] = NULL }, NULL), -1, EACCES); break;
> + CASE_TEST(fchdir_stdin); EXPECT_SYSER(1, fchdir(STDIN_FILENO), -1, ENOTDIR); break;
> + CASE_TEST(fchdir_badfd); EXPECT_SYSER(1, fchdir(-1), -1, EBADF); break;
> CASE_TEST(file_stream); EXPECT_SYSZR(1, test_file_stream()); break;
> CASE_TEST(fork); EXPECT_SYSZR(1, test_fork(FORK_STANDARD)); break;
> CASE_TEST(getdents64_root); EXPECT_SYSNE(1, test_getdents64("/"), -1); break;
>
> ---
> base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
> change-id: 20251107-nolibc-fchdir-2645c298a538
Looks good to me!
Acked-by: Willy Tarreau <w@1wt.eu>
Willy
prev parent reply other threads:[~2025-11-08 12:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-07 14:13 [PATCH] tools/nolibc: add support for fchdir() Thomas Weißschuh
2025-11-08 12:33 ` Willy Tarreau [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=20251108123318.GA6898@1wt.eu \
--to=w@1wt.eu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=shuah@kernel.org \
--cc=thomas.weissschuh@linutronix.de \
/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