The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v3 0/3] nolibc: Add getcwd() and readlink()
@ 2026-07-02  8:50 Daniel Palmer
  2026-07-02  8:50 ` [PATCH v3 1/3] tools/nolibc: unistd: Add getcwd() Daniel Palmer
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Daniel Palmer @ 2026-07-02  8:50 UTC (permalink / raw)
  To: w, linux; +Cc: linux-kernel, Daniel Palmer

I needed getcwd() for something. So I added that, then realised
I also needed readlink() to test the result of getcwd().

This adds getcwd() and readlink() then adds a test that uses
both.

Note: getcwd() has some behaviour where if the current directory
is unreachable then the kernel returns "(unreachable)" and this
needs some special handling. I checked what musl was doing for
this. It seems pretty difficult to test and maybe needs some
calls nolibc doesn't have yet. Basically: It looks right but
there is no test.

v3:
   - Addressed the issues noted by sashiko (impressed by how good it is now)
   - Use __LINE__ for the error numbers in the test to make it
     easy to spot where it broke.
   - Redid the nolibc test for all archs, all passed.

v2:
   - Addressed Thomas' comments for readlink() and making the test depend on proc.
   - Filled out getcwd() so it matches what musl is doing.
   - Expanded the test a little to try to cover passing bad arguments.

Daniel Palmer (3):
  tools/nolibc: unistd: Add getcwd()
  tools/nolibc: unistd: Add readlink()
  selftests/nolibc: Add test for getcwd() and readlink()

 tools/include/nolibc/unistd.h                | 58 ++++++++++++++++++++
 tools/testing/selftests/nolibc/nolibc-test.c | 53 ++++++++++++++++++
 2 files changed, 111 insertions(+)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-07-02 11:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-02  8:50 [PATCH v3 0/3] nolibc: Add getcwd() and readlink() Daniel Palmer
2026-07-02  8:50 ` [PATCH v3 1/3] tools/nolibc: unistd: Add getcwd() Daniel Palmer
2026-07-02 11:33   ` Willy Tarreau
2026-07-02  8:51 ` [PATCH v3 2/3] tools/nolibc: unistd: Add readlink() Daniel Palmer
2026-07-02 11:34   ` Willy Tarreau
2026-07-02  8:51 ` [PATCH v3 3/3] selftests/nolibc: Add test for getcwd() and readlink() Daniel Palmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox