diff options
author | Alejandro Colomar <colomar.6.4.3@gmail.com> | 2020-10-29 20:10:21 +0100 |
---|---|---|
committer | Michael Kerrisk <mtk.manpages@gmail.com> | 2020-10-29 20:10:56 +0100 |
commit | 13e88b70707183489228cd26deb939a27a00d661 (patch) | |
tree | 26d87e6ac26812467bc055aa49206717de5b5c20 | |
parent | 833ba57027e36b7cf8f3f77d738c424cd193cf20 (diff) | |
download | man-pages-13e88b70707183489228cd26deb939a27a00d661.tar.gz |
getdents.2: Use appropriate types
[mtk: Applied patch manually]
getdents():
This function has no glibc wrapper.
As such, we should use the same types the Linux kernel uses:
Use 'long' as the return type.
getdents64():
The glibc wrapper uses:
ssize_t getdents64(int, void *, size_t);
Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
-rw-r--r-- | man2/getdents.2 | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/man2/getdents.2 b/man2/getdents.2 index 1211ceccb4..fa4c0340e6 100644 --- a/man2/getdents.2 +++ b/man2/getdents.2 @@ -33,14 +33,13 @@ getdents, getdents64 \- get directory entries .SH SYNOPSIS .nf -.BI "int getdents(unsigned int " fd ", struct linux_dirent *" dirp , +.BI "long getdents(unsigned int " fd ", struct linux_dirent *" dirp , .BI " unsigned int " count ); .PP .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" .BR "#include <dirent.h>" .PP -.BI "int getdents64(unsigned int " fd ", struct linux_dirent64 *" dirp , -.BI " unsigned int " count ); +.BI "ssize_t getdents64(int " fd ", void *" dirp ", size_t " count ); .fi .PP .IR Note : @@ -282,7 +281,8 @@ struct linux_dirent { int main(int argc, char *argv[]) { - int fd, nread; + int fd; + long nread; char buf[BUF_SIZE]; struct linux_dirent *d; char d_type; @@ -301,7 +301,7 @@ main(int argc, char *argv[]) printf("\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- nread=%d \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\en", nread); printf("inode# file type d_reclen d_off d_name\en"); - for (int bpos = 0; bpos < nread;) { + for (long bpos = 0; bpos < nread;) { d = (struct linux_dirent *) (buf + bpos); printf("%8ld ", d\->d_ino); d_type = *(buf + bpos + d\->d_reclen \- 1); |