From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Daniel Palmer <daniel@thingy.jp>
Cc: w@1wt.eu, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] tools/nolibc: unistd: Add readlink()
Date: Sat, 2 May 2026 15:42:50 +0200 [thread overview]
Message-ID: <3d6b1280-c320-489d-8d07-2b37046bdb87@weissschuh.net> (raw)
In-Reply-To: <20260502072527.1805108-3-daniel@thingy.jp>
May 2, 2026 09:25:44 Daniel Palmer <daniel@thingy.jp>:
> Add readlink(). This is needed to test getcwd();
>
> Signed-off-by: Daniel Palmer <daniel@thingy.jp>
> ---
> tools/include/nolibc/unistd.h | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/tools/include/nolibc/unistd.h b/tools/include/nolibc/unistd.h
> index c7f89c56bc9b..309a4e0e65d2 100644
> --- a/tools/include/nolibc/unistd.h
> +++ b/tools/include/nolibc/unistd.h
> @@ -84,6 +84,26 @@ int msleep(unsigned int msecs)
> return 0;
> }
>
> +/*
> + * ssize_t readlink(const char *path, char *buf, size_t bufsiz);
> + */
> +
> +static __attribute__((unused))
> +ssize_t _sys_readlink(const char *path, char *buf, size_t bufsiz)
> +{
> +#ifdef __NR_readlink
> + return __nolibc_syscall3(__NR_readlink, path, buf, bufsiz);
> +#else
> + return __nolibc_syscall4(__NR_readlinkat, AT_FDCWD, path, buf, bufsiz);
> +#endif
Every architecture should have readli kat, no?
Then I think we can drop the fallback to regular readlink.
> +}
> +
> +static __attribute__((unused))
> +ssize_t readlink(const char *path, char *buf, size_t bufsiz)
> +{
> + return __sysret(_sys_readlink(path, buf, bufsiz));
> +}
> +
> static __attribute__((unused))
> unsigned int sleep(unsigned int seconds)
> {
> --
> 2.53.0
next prev parent reply other threads:[~2026-05-02 13:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-02 7:25 [PATCH 0/3] nolibc: Add getcwd() and readlink() Daniel Palmer
2026-05-02 7:25 ` [PATCH 1/3] tools/nolibc: unistd: Add getcwd() Daniel Palmer
2026-05-02 13:41 ` Thomas Weißschuh
2026-05-05 9:07 ` Daniel Palmer
2026-05-02 7:25 ` [PATCH 2/3] tools/nolibc: unistd: Add readlink() Daniel Palmer
2026-05-02 13:42 ` Thomas Weißschuh [this message]
2026-05-02 7:25 ` [PATCH 3/3] selftests/nolibc: Add test for getcwd() and readlink() Daniel Palmer
2026-05-02 13:43 ` Thomas Weißschuh
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=3d6b1280-c320-489d-8d07-2b37046bdb87@weissschuh.net \
--to=linux@weissschuh.net \
--cc=daniel@thingy.jp \
--cc=linux-kernel@vger.kernel.org \
--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®