public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* Issue in man page readlink.2
@ 2023-11-01 14:02 Helge Kreutzmann
  2023-11-01 16:33 ` Alejandro Colomar
  0 siblings, 1 reply; 5+ messages in thread
From: Helge Kreutzmann @ 2023-11-01 14:02 UTC (permalink / raw)
  To: alx.manpages; +Cc: mario.blaettermann, linux-man

Without further ado, the following was found:

Issue:    the link target → link target

"#include E<lt>limits.hE<gt>\n"
"#include E<lt>stdio.hE<gt>\n"
"#include E<lt>stdlib.hE<gt>\n"
"#include E<lt>sys/stat.hE<gt>\n"
"#include E<lt>unistd.hE<gt>\n"
"\\&\n"
"int\n"
"main(int argc, char *argv[])\n"
"{\n"
"    char         *buf;\n"
"    ssize_t      nbytes, bufsiz;\n"
"    struct stat  sb;\n"
"\\&\n"
"    if (argc != 2) {\n"
"        fprintf(stderr, \"Usage: %s E<lt>pathnameE<gt>\\en\", argv[0]);\n"
"        exit(EXIT_FAILURE);\n"
"    }\n"
"\\&\n"
"    if (lstat(argv[1], &sb) == -1) {\n"
"        perror(\"lstat\");\n"
"        exit(EXIT_FAILURE);\n"
"    }\n"
"\\&\n"
"    /* Add one to the link size, so that we can determine whether\n"
"       the buffer returned by readlink() was truncated. */\n"
"\\&\n"
"    bufsiz = sb.st_size + 1;\n"
"\\&\n"
"    /* Some magic symlinks under (for example) /proc and /sys\n"
"       report \\[aq]st_size\\[aq] as zero. In that case, take PATH_MAX as\n"
"       a \"good enough\" estimate. */\n"
"\\&\n"
"    if (sb.st_size == 0)\n"
"        bufsiz = PATH_MAX;\n"
"\\&\n"
"    buf = malloc(bufsiz);\n"
"    if (buf == NULL) {\n"
"        perror(\"malloc\");\n"
"        exit(EXIT_FAILURE);\n"
"    }\n"
"\\&\n"
"    nbytes = readlink(argv[1], buf, bufsiz);\n"
"    if (nbytes == -1) {\n"
"        perror(\"readlink\");\n"
"        exit(EXIT_FAILURE);\n"
"    }\n"
"\\&\n"
"    /* Print only \\[aq]nbytes\\[aq] of \\[aq]buf\\[aq], as it doesn't contain a terminating\n"
"       null byte (\\[aq]\\e0\\[aq]). */\n"
"    printf(\"\\[aq]%s\\[aq] points to \\[aq]%.*s\\[aq]\\en\", argv[1], (int) nbytes, buf);\n"
"\\&\n"
"    /* If the return value was equal to the buffer size, then the\n"
"       the link target was larger than expected (perhaps because the\n"
"       target was changed between the call to lstat() and the call to\n"
"       readlink()). Warn the user that the returned target may have\n"
"       been truncated. */\n"
"\\&\n"
"    if (nbytes == bufsiz)\n"
"        printf(\"(Returned buffer may have been truncated)\\en\");\n"
"\\&\n"
"    free(buf);\n"
"    exit(EXIT_SUCCESS);\n"
"}\n"

^ permalink raw reply	[flat|nested] 5+ messages in thread
* Issue in man page readlink.2
@ 2025-08-24 14:48 Helge Kreutzmann
  0 siblings, 0 replies; 5+ messages in thread
From: Helge Kreutzmann @ 2025-08-24 14:48 UTC (permalink / raw)
  To: alx; +Cc: mario.blaettermann, linux-man

Without further ado, the following was found:

Issue:    B<…>size_t bufsiz → B<…size_t> I<bufsiz>

"B<ssize_t readlink(>size_t bufsiz;\n"
"B<                 const char *restrict >I<path>B<,>\n"
"B<                 char >I<buf>B<[restrict >I<bufsiz>B<], size_t >I<bufsiz>B<);>\n"

"B<ssize_t readlinkat(>size_t bufsiz;\n"
"B<                 int >I<dirfd>B<, const char *restrict >I<path>B<,>\n"
"B<                 char >I<buf>B<[restrict >I<bufsiz>B<], size_t >I<bufsiz>B<);>\n"

^ permalink raw reply	[flat|nested] 5+ messages in thread
* Issue in man page readlink.2
@ 2025-08-24 14:48 Helge Kreutzmann
  2025-08-24 19:09 ` Alejandro Colomar
  0 siblings, 1 reply; 5+ messages in thread
From: Helge Kreutzmann @ 2025-08-24 14:48 UTC (permalink / raw)
  To: alx; +Cc: mario.blaettermann, linux-man

Without further ado, the following was found:

Issue:    What does "like B<readlink>()" refer to? This is the man page of readlink(2)

"If I<path> is relative and I<dirfd> is the special value B<AT_FDCWD>, then "
"I<path> is interpreted relative to the current working directory of the "
"calling process (like B<readlink>())."

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

end of thread, other threads:[~2025-08-24 19:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-01 14:02 Issue in man page readlink.2 Helge Kreutzmann
2023-11-01 16:33 ` Alejandro Colomar
  -- strict thread matches above, loose matches on Subject: below --
2025-08-24 14:48 Helge Kreutzmann
2025-08-24 14:48 Helge Kreutzmann
2025-08-24 19:09 ` Alejandro Colomar

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