]> git.ipfire.org Git - thirdparty/man-pages.git/commit
man/man3/getcwd.3: VERSIONS: The syscall can return "(unreachable)", but modern glibc...
authorAskar Safin <safinaskar@zohomail.com>
Thu, 20 Feb 2025 09:19:25 +0000 (09:19 +0000)
committerAlejandro Colomar <alx@kernel.org>
Thu, 20 Feb 2025 12:15:31 +0000 (13:15 +0100)
commit82fc3796b345caa08653dcba8ef6db37d9a4c05c
tree70e29122796f62ab19b8a50c1fdd3207d651255d
parent4da273dfd6880399f0ea87aa1a452fe07a60ed3a
man/man3/getcwd.3: VERSIONS: The syscall can return "(unreachable)", but modern glibc wrapper cannot

I verified using an expirement (see below) that the modern glibc wrapper
getcwd() actually never returns "(unreachable)".  I have also read the
modern glibc sources for all three functions documented here.  None of
them return "(unreachable)".

Now let me describe my expirement:

d-user@comp:/tmp$ cat getcwd.c
#include <unistd.h>
#include <stdio.h>
#include <sys/syscall.h>

int
main(void)
{
char  buf[1000];

if (syscall(SYS_getcwd, buf, sizeof(buf)) == -1)
perror("SYS_getcwd");
else
printf("SYS_getcwd: %s\n", buf);

if (getcwd(buf, sizeof(buf)) == NULL)
perror("getcwd");
else
printf("getcwd: %s\n", buf);

return 0;
}
d-user@comp:/tmp$ gcc -Wall -Wextra -o getcwd getcwd.c
d-user@comp:/tmp$ sudo unshare --mount bash
d-root@comp:/tmp# mkdir /tmp/dir
d-root@comp:/tmp# mount -t tmpfs tmpfs /tmp/dir
d-root@comp:/tmp# cd /tmp/dir
d-root@comp:/tmp/dir# umount -l .
d-root@comp:/tmp/dir# /tmp/getcwd
SYS_getcwd: (unreachable)/
getcwd: No such file or directory
d-root@comp:/tmp/dir# exit
exit

Link: <https://sourceware.org/bugzilla/show_bug.cgi?id=18203>
Link: <https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=52a713fdd0a30e1bd79818e2e3c4ab44ddca1a94>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Signed-off-by: Askar Safin <safinaskar@zohomail.com>
Message-ID: <20250220091926.3985504-2-safinaskar@zohomail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
man/man3/getcwd.3