From: vursc <vursc@vursc.org>
To: linux-man@vger.kernel.org
Cc: vursc <vursc@vursc.org>
Subject: [PATCH v3] man/man2/getdents.2: Document system call interface of getdents64
Date: Mon, 6 Apr 2026 09:21:14 +0000 [thread overview]
Message-ID: <20260406092113.184487-2-vursc@vursc.org> (raw)
In-Reply-To: <20260406053554.150929-1-vursc@vursc.org>
The count argument of the getdents64 system call is assumed to not exceed
INT_MAX. The glibc function accepts a size_t and passes INT_MAX to the kernel
if count exceeds INT_MAX.
Also document the dirent64 structure in glibc.
Signed-off-by: vursc <vursc@vursc.org>
---
man/man2/getdents.2 | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/man/man2/getdents.2 b/man/man2/getdents.2
index 8c5bbebbc..de91f3800 100644
--- a/man/man2/getdents.2
+++ b/man/man2/getdents.2
@@ -42,7 +42,6 @@ These are not the interfaces you are interested in.
Look at
.BR readdir (3)
for the POSIX-conforming C library interface.
-This page documents the bare kernel system call interfaces.
.SS getdents()
The system call
.BR getdents ()
@@ -216,10 +215,31 @@ using
.BR syscall (2).
In that case you will need to define the
.I linux_dirent
-or
-.I linux_dirent64
structure yourself.
.P
+The
+.B getdents64
+system call accepts an
+.B unsigned int
+argument
+.I count
+and assumes that
+.I count
+does not exceed
+.BR INT_MAX .
+The glibc wrapper function sets
+.I count
+to
+.B INT_MAX
+if it exceeds
+.BR INT_MAX .
+glibc defines a
+.I dirent64
+structure, which is similar to
+.I linux_dirent64
+but with a 256-byte
+.IR d_name .
+.P
Probably, you want to use
.BR readdir (3)
instead of these system calls.
--
2.53.0
next prev parent reply other threads:[~2026-04-06 9:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-06 5:35 [PATCH v2] man/man2/getdents.2: Document system call interface of getdents64 vursc
2026-04-06 9:21 ` vursc [this message]
2026-04-06 22:14 ` [PATCH v3] " Alejandro Colomar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260406092113.184487-2-vursc@vursc.org \
--to=vursc@vursc.org \
--cc=linux-man@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox