This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Linux: Add <sys/direntries.h>


* Rich Felker:

> On Tue, Jun 18, 2019 at 04:24:58PM +0200, Florian Weimer wrote:
>> This header file provides the types struct direntry and struct
>> direntries, and the functions direntries_init, direntries_read,
>> and direntries_next.  Using a separate header file (instead of
>> augmenting <dirent.h>) allows more straightforward type names
>> because identifier collisions are less of a problem (new code
>> can work around them).
>
> I don't understand the motivation for these interfaces vs using the
> standard ones. It seems like adding them explicitly discourages
> portable code and has few if any benefits.

Using these interfaces together with getdents64 has the following
benefits:

* The combination is async-signal-safe (except on MIPS on older kernels,
  which is hopefully fixable).

* There is no buffer bloat due to auto-sizing the DIR * buffer based on
  preferred I/O sizes, as advertised by the file system.

* The combination does not suffer from the telldir problem (which
  returns long on 32-bit architectures, which is incompatible with
  struct dirent64 in the kernel).  (Only seeking to the beginning is
  supported.)

* Exposing the block read size means that the application knows when it
  has to rewind after deleting enumerated files, to avoid skipping
  entries or returning entries twice.

Whether these benefits are substantial enough to warrant the addition of
the new interfaces is of course subject to debate.

Thanks,
Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]