[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251108123318.GA6898@1wt.eu>
Date: Sat, 8 Nov 2025 13:33:18 +0100
From: Willy Tarreau <w@....eu>
To: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
Cc: Thomas Weißschuh <linux@...ssschuh.net>,
Shuah Khan <shuah@...nel.org>, linux-kernel@...r.kernel.org,
linux-kselftest@...r.kernel.org
Subject: Re: [PATCH] tools/nolibc: add support for fchdir()
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@...utronix.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@....eu>
Willy
Powered by blists - more mailing lists