On 3/16/21, David Howells wrote:
John Reiser <jreiser(a)bitwagon.com> wrote:
> See the manual page "man 2 getdents".
Um, which bit? I don't see anything obvious to that end.
On that manual page:
=====
The system call getdents() reads several linux_dirent structures from the directory
referred to by the open file descriptor fd into the buffer pointed to by dirp.
[snip]]
On success, the number of bytes read is returned.
=====
So the return value is related to the size of the directory; the sum of the values
returned before End-Of-File should be quite close to the .st_size of the directory.
If a program is walking through the directory, reading all the entries via getdents64(),
then .st_size of the directory is the only thing known in advance about the total size.
(Of course anything involving a directory can depend on concurrent create/delete/rename
of files within the directory.)
>
> On AFS directories are handled as files that the filesystem downloads and
> parses locally. The size returned in st_size is the size of the directory
> content blob.