* Re: [PATCH] getdents.2: Use 'ssize_t' instead of 'int' [not found] ` <ed5937c4-a590-1735-b716-0894657ff8fc@gmail.com> @ 2020-10-29 11:02 ` Alejandro Colomar 2020-10-29 13:42 ` [PATCH v2] getdents.2: Use appropriate types Alejandro Colomar 0 siblings, 1 reply; 5+ messages in thread From: Alejandro Colomar @ 2020-10-29 11:02 UTC (permalink / raw) To: Michael Kerrisk (man-pages); +Cc: linux-man, linux-kernel, libc-alpha [[ CC += linux-kernel, libc-alpha ]] Hi Michael, On 2020-10-29 08:13, Michael Kerrisk (man-pages) wrote: > Hi Alex, > > On 10/28/20 11:11 PM, Alejandro Colomar wrote: >> The glibc wrapper for getdents64() uses ssize_t. > > It also changed the types for the arguments, so those need to be > fixed too. I saw that, but I sent an email to glibc asking if it was a bug. I'll hold this patch, and I'll CC this list in that other thread. > >> And let's use it also for getdents(). > > I actually think we should *not* change that. So long as their is > no wrapper, we should show pretty much what the ABI exposes. (That > makes me think that the return type should really be long; see > what you think about DEFINE_SYSCALL3 in the kernel sources.) Agreed; then getdents() (and all syscalls without a wrapper) should use 'long', as you said. BTW: My mind explodes when I try to read through SYSCALL_DEFINEx :) > > And you added an include for <sys/types.h>. I'm not sure > whether that's needed, but it should be explained in the > commit message. Agreed. I should be able to check if it's needed, in ssize_t(3) :p ... Actually it's not needed (<stdio.h> already provides it). Thanks, Alex ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] getdents.2: Use appropriate types 2020-10-29 11:02 ` [PATCH] getdents.2: Use 'ssize_t' instead of 'int' Alejandro Colomar @ 2020-10-29 13:42 ` Alejandro Colomar 2020-10-29 13:55 ` Michael Kerrisk (man-pages) 0 siblings, 1 reply; 5+ messages in thread From: Alejandro Colomar @ 2020-10-29 13:42 UTC (permalink / raw) To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, linux-kernel, libc-alpha 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 for the return type, and 'size_t' for the count argument. Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com> --- man2/getdents.2 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/man2/getdents.2 b/man2/getdents.2 index a187fbcef..e14627e6e 100644 --- a/man2/getdents.2 +++ b/man2/getdents.2 @@ -33,14 +33,14 @@ 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) */" .B #include <dirent.h> .PP -.BI "int getdents64(unsigned int " fd ", struct linux_dirent64 *" dirp , -.BI " unsigned int " count ); +.BI "ssize_t getdents64(unsigned int " fd ", struct linux_dirent64 *" dirp , +.BI " size_t " count ); .fi .PP .IR Note : @@ -282,7 +282,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 +302,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); -- 2.28.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] getdents.2: Use appropriate types 2020-10-29 13:42 ` [PATCH v2] getdents.2: Use appropriate types Alejandro Colomar @ 2020-10-29 13:55 ` Michael Kerrisk (man-pages) 2020-10-29 14:10 ` [PATCH v3] " Alejandro Colomar 0 siblings, 1 reply; 5+ messages in thread From: Michael Kerrisk (man-pages) @ 2020-10-29 13:55 UTC (permalink / raw) To: Alejandro Colomar; +Cc: linux-man, lkml, libc-alpha Hi Alex, On Thu, 29 Oct 2020 at 14:42, Alejandro Colomar <colomar.6.4.3@gmail.com> wrote: > > 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 for the return type, > and 'size_t' for the count argument. Take a look in the header file at the argument types for getdents64(); there's still some changes needed. Thanks, Michael > Signed-off-by: Alejandro Colomar <colomar.6.4.3@gmail.com> > --- > man2/getdents.2 | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/man2/getdents.2 b/man2/getdents.2 > index a187fbcef..e14627e6e 100644 > --- a/man2/getdents.2 > +++ b/man2/getdents.2 > @@ -33,14 +33,14 @@ > 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) */" > .B #include <dirent.h> > .PP > -.BI "int getdents64(unsigned int " fd ", struct linux_dirent64 *" dirp , > -.BI " unsigned int " count ); > +.BI "ssize_t getdents64(unsigned int " fd ", struct linux_dirent64 *" dirp , > +.BI " size_t " count ); > .fi > .PP > .IR Note : > @@ -282,7 +282,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 +302,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); > -- > 2.28.0 > -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3] getdents.2: Use appropriate types 2020-10-29 13:55 ` Michael Kerrisk (man-pages) @ 2020-10-29 14:10 ` Alejandro Colomar 2020-10-29 19:54 ` Michael Kerrisk (man-pages) 0 siblings, 1 reply; 5+ messages in thread From: Alejandro Colomar @ 2020-10-29 14:10 UTC (permalink / raw) To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, linux-kernel, libc-alpha 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> --- Hi Michael, Sorry, I'm being a bit distracted these days :) It should be good enough now, I think. Cheers, Alex man2/getdents.2 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/man2/getdents.2 b/man2/getdents.2 index a187fbcef..ed3bb40b1 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) */" .B #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); -- 2.28.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3] getdents.2: Use appropriate types 2020-10-29 14:10 ` [PATCH v3] " Alejandro Colomar @ 2020-10-29 19:54 ` Michael Kerrisk (man-pages) 0 siblings, 0 replies; 5+ messages in thread From: Michael Kerrisk (man-pages) @ 2020-10-29 19:54 UTC (permalink / raw) To: Alejandro Colomar; +Cc: mtk.manpages, linux-man, linux-kernel, libc-alpha On 10/29/20 3:10 PM, Alejandro Colomar wrote: > 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> Thanks, Alex. Applied. Cheers, Michael > --- > > Hi Michael, > > Sorry, I'm being a bit distracted these days :) > It should be good enough now, I think. > > Cheers, > > Alex > > man2/getdents.2 | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/man2/getdents.2 b/man2/getdents.2 > index a187fbcef..ed3bb40b1 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) */" > .B #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); > -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-10-29 19:55 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20201028221118.158108-1-colomar.6.4.3@gmail.com> [not found] ` <ed5937c4-a590-1735-b716-0894657ff8fc@gmail.com> 2020-10-29 11:02 ` [PATCH] getdents.2: Use 'ssize_t' instead of 'int' Alejandro Colomar 2020-10-29 13:42 ` [PATCH v2] getdents.2: Use appropriate types Alejandro Colomar 2020-10-29 13:55 ` Michael Kerrisk (man-pages) 2020-10-29 14:10 ` [PATCH v3] " Alejandro Colomar 2020-10-29 19:54 ` Michael Kerrisk (man-pages)
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).