Skip to contentSkip to conversation

man/man2/getdents.2: Fix incorrect argument type

PATCH In review vursc 3 participants 5 messages Apr 4 – Apr 6 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore

vursc

author
#0 lore raw

PATCH 1/1 man/man2/getdents.2: Fix incorrect argument type

The count argument of getdents64 is an unsigned int; see SYSCALL_DEFINE3(getdents64, ...) in linux/fs/readdir.c.

---
 man/man2/getdents.2 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man/man2/getdents.2 +1 -1
index 8c5bbebbc..3890943ee 100644
@@ -23,7 +23,7 @@ Standard C library
 .B #include <dirent.h>
 .P
 .BR "ssize_t getdents64(" "size_t count;"
-.BI "                   int " fd ", void " dirp [ count "], size_t " count );
+.BI "                   int " fd ", void " dirp [ count "], unsigned int " count );
 .fi
 .P
 .IR Note :
Signature · 1 line
2.53.0
#1 lore raw
Quoted 14 lines · vursc

The count argument of getdents64 is an unsigned int; see SYSCALL_DEFINE3(getdents64, ...) in linux/fs/readdir.c.

---
 man/man2/getdents.2 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man/man2/getdents.2 +0 -0
index 8c5bbebbc..3890943ee 100644

man/man2/getdents.2 Standard C library · line 26

Quoted 5 lines
man/man2/getdents.2 +1 -1
@@ -23,7 +23,7 @@ Standard C library
 .B #include <dirent.h>
 .P
 .BR "ssize_t getdents64(" "size_t count;"
-.BI "                   int " fd ", void " dirp [ count "], size_t " count );
+.BI "                   int " fd ", void " dirp [ count "], unsigned int " count );

The third argument of the function has type size_t in glibc
(https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/getdents64.c;hb=HEAD)
and musl (https://git.musl-libc.org/cgit/musl/tree/src/linux/getdents.c).
According to intro(2): "the manual pages in Section 2 generally try to note the details of both the (usually GNU) C library API interface and the raw system call. Most commonly, the main DESCRIPTION will focus on the C library interface, and differences for the system call are covered in the NOTES section." So rather than changing the function prototype, adding a note to the NOTES section may be more appropriate.

That said, the DESCRIPTION section claims, "This page documents the bare kernel system call interfaces", so that should be corrected as well. It appears that that was written before the glibc function existed and is outdated.

- Mark

Quoted 7 lines
man/man2/getdents.2 +0 -1
 .fi
 .P
 .IR Note :
--

2.53.0

#2 lore raw

Hi Mark, vursc,

Quoted 31 lines · Mark Harris
Quoted 14 lines · vursc

The count argument of getdents64 is an unsigned int; see SYSCALL_DEFINE3(getdents64, ...) in linux/fs/readdir.c.

---
 man/man2/getdents.2 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man/man2/getdents.2 +0 -0
index 8c5bbebbc..3890943ee 100644

man/man2/getdents.2 Standard C library · line 26

Quoted 5 lines
man/man2/getdents.2 +1 -1
@@ -23,7 +23,7 @@ Standard C library
 .B #include <dirent.h>
 .P
 .BR "ssize_t getdents64(" "size_t count;"
-.BI "                   int " fd ", void " dirp [ count "], size_t " count );
+.BI "                   int " fd ", void " dirp [ count "], unsigned int " count );

The third argument of the function has type size_t in glibc
(https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/getdents64.c;hb=HEAD)
and musl (https://git.musl-libc.org/cgit/musl/tree/src/linux/getdents.c).
According to intro(2): "the manual pages in Section 2 generally try to note the details of both the (usually GNU) C library API interface and the raw system call. Most commonly, the main DESCRIPTION will focus on the C library interface, and differences for the system call are covered in the NOTES section." So rather than changing the function prototype, adding a note to the NOTES section may be more appropriate.

Quoted 4 lines

That said, the DESCRIPTION section claims, "This page documents the bare kernel system call interfaces", so that should be corrected as well. It appears that that was written before the glibc function existed and is outdated.

Thanks! That seems the appropriate solution. vursc, would you mind sending an updated patch set doing that? Or should I?

Have a lovely night!
Alex

Quoted 11 lines

- Mark

Quoted 7 lines
man/man2/getdents.2 +0 -1
 .fi
 .P
 .IR Note :
--

2.53.0

Signature · 2 lines
<https://www.alejandro-colomar.es>
Use port 80 (that is, <...:80/>).
author
#3 lore raw
In reply to Mark Harris

Should I document the dirent64 structure in glibc? There are two versions of struct dirent64 in glibc, in glibc/sysdeps/unix/sysv/linux/bits/dirent.h and glibc/bits/dirent.h, and the latter seems irrelevant on linux systems.

And I'm not sure about the wording. Feel free to reword it as you see fit.

-vursc

#4 lore raw

Hi vursc,

Quoted 1 line · vursc

Should I document the dirent64 structure in glibc?

Given that it's different from the kernel one, I think we should document both, yes.

Quoted 3 lines

versions of struct dirent64 in glibc, in glibc/sysdeps/unix/sysv/linux/bits/dirent.h and glibc/bits/dirent.h, and the latter seems irrelevant on linux systems.

Yes, I seem to have the former in the installed headers. I don't know why the latter exists. I've CCed libc-help@ in case they can help.

Quoted 3 lines

And I'm not sure about the wording. Feel free to reword it as you see fit.

The current patch seems reasonable. If you add the glibc struct, I'll add it, and later maybe I'll tweak that page to look more like other pages.

Have a lovely day!
Alex

Quoted 3 lines

-vursc

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