public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] man/man3/opendir.3: document that long file names result in ENAMETOOLONG
@ 2025-10-17  8:18 Collin Funk
  2025-10-17  8:45 ` Jakub Wilk
  0 siblings, 1 reply; 4+ messages in thread
From: Collin Funk @ 2025-10-17  8:18 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: Collin Funk, linux-man

This behavior can be see with the following example program:

    $ cat main.c
    #include <string.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <dirent.h>
    #include <errno.h>
    int
    main (int argc, char **argv)
    {
      if (argc < 2)
        return EXIT_FAILURE;
      DIR *dir = opendir (argv[1]);
      if (dir == NULL)
        {
          fprintf (stderr, "%s\n", strerror (errno));
          return EXIT_FAILURE;
        }
      closedir (dir);
      return EXIT_SUCCESS;
    }
    $ gcc main.c
    $ mkdir -p `python3 -c 'print("./" + "a/" * 32768)'`
    $ ./a.out `python3 -c 'print("./" + "a/" * 32768)'`
    File name too long

Signed-off-by: Collin Funk <collin.funk1@gmail.com>
---
 man/man3/opendir.3 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/man/man3/opendir.3 b/man/man3/opendir.3
index a9af16269..6a5c7880f 100644
--- a/man/man3/opendir.3
+++ b/man/man3/opendir.3
@@ -73,6 +73,10 @@ .SH ERRORS
 .B EMFILE
 The per-process limit on the number of open file descriptors has been reached.
 .TP
+.B ENAMETOOLONG
+.I name
+was too long.
+.TP
 .B ENFILE
 The system-wide limit on the total number of open files has been reached.
 .TP
-- 
2.51.0


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

* Re: [PATCH] man/man3/opendir.3: document that long file names result in ENAMETOOLONG
  2025-10-17  8:18 [PATCH] man/man3/opendir.3: document that long file names result in ENAMETOOLONG Collin Funk
@ 2025-10-17  8:45 ` Jakub Wilk
  2025-10-28 23:37   ` Alejandro Colomar
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Wilk @ 2025-10-17  8:45 UTC (permalink / raw)
  To: Collin Funk; +Cc: Alejandro Colomar, linux-man

* Collin Funk <collin.funk1@gmail.com>, 2025-10-17 01:18:
>    $ mkdir -p `python3 -c 'print("./" + "a/" * 32768)'`
>    $ ./a.out `python3 -c 'print("./" + "a/" * 32768)'`
>    File name too long

Simpler reproducer:

$ ./a.out $(printf '%0999d')
File name too long

-- 
Jakub Wilk

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

* Re: [PATCH] man/man3/opendir.3: document that long file names result in ENAMETOOLONG
  2025-10-17  8:45 ` Jakub Wilk
@ 2025-10-28 23:37   ` Alejandro Colomar
  2025-10-29  0:29     ` Collin Funk
  0 siblings, 1 reply; 4+ messages in thread
From: Alejandro Colomar @ 2025-10-28 23:37 UTC (permalink / raw)
  To: Jakub Wilk; +Cc: Collin Funk, linux-man

[-- Attachment #1: Type: text/plain, Size: 731 bytes --]

Hi Collin, Jakub,

On Fri, Oct 17, 2025 at 10:45:53AM +0200, Jakub Wilk wrote:
> * Collin Funk <collin.funk1@gmail.com>, 2025-10-17 01:18:
> >    $ mkdir -p `python3 -c 'print("./" + "a/" * 32768)'`
> >    $ ./a.out `python3 -c 'print("./" + "a/" * 32768)'`
> >    File name too long

Thanks!  I've applied the patch.

> 
> Simpler reproducer:
> 
> $ ./a.out $(printf '%0999d')
> File name too long

And also thanks!  I've amended the commit message to use the simpler
reproducer.

I've also tweaked the source code for style.  I'll push to master
tomorrow.  (And probably, issue a new release too.)


Have a lovely night!
Alex

-- 
<https://www.alejandro-colomar.es>
Use port 80 (that is, <...:80/>).

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] man/man3/opendir.3: document that long file names result in ENAMETOOLONG
  2025-10-28 23:37   ` Alejandro Colomar
@ 2025-10-29  0:29     ` Collin Funk
  0 siblings, 0 replies; 4+ messages in thread
From: Collin Funk @ 2025-10-29  0:29 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: Jakub Wilk, linux-man

[-- Attachment #1: Type: text/plain, Size: 730 bytes --]

Alejandro Colomar <alx@kernel.org> writes:

> Hi Collin, Jakub,
>
> On Fri, Oct 17, 2025 at 10:45:53AM +0200, Jakub Wilk wrote:
>> * Collin Funk <collin.funk1@gmail.com>, 2025-10-17 01:18:
>> >    $ mkdir -p `python3 -c 'print("./" + "a/" * 32768)'`
>> >    $ ./a.out `python3 -c 'print("./" + "a/" * 32768)'`
>> >    File name too long
>
> Thanks!  I've applied the patch.
>
>> 
>> Simpler reproducer:
>> 
>> $ ./a.out $(printf '%0999d')
>> File name too long
>
> And also thanks!  I've amended the commit message to use the simpler
> reproducer.

Thanks! That is fine. My example was a longer than needed since I was
testing long path handling in Coreutils and wanted deep directory
entries.

Collin


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

end of thread, other threads:[~2025-10-29  0:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-17  8:18 [PATCH] man/man3/opendir.3: document that long file names result in ENAMETOOLONG Collin Funk
2025-10-17  8:45 ` Jakub Wilk
2025-10-28 23:37   ` Alejandro Colomar
2025-10-29  0:29     ` Collin Funk

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