|
|
Message-ID: <CANfL31wVPurztDCUhx=t6ovev5zfrw7Db+F8HJ5W6KxCdUweDw@mail.gmail.com> Date: Wed, 3 Dec 2025 20:25:03 +0530 From: Neeraj Sharma <neerajsharma.live@...il.com> To: Rich Felker <dalias@...c.org> Cc: musl@...ts.openwall.com Subject: Re: Re: Potential bug in musl in nftw implementation On Wed, Dec 3, 2025 at 7:08 PM Rich Felker <dalias@...c.org> wrote: > > Are you saying you'd deem it a better behavior to return with an error > when it can't traverse within the fd limit, instead of skipping > descent past what it can do within the limit? > > That's probably more correct. My understanding is that historically, > the limit was a depth limit, but POSIX repurposed it into a "fd limit" > with an expectation that implementations somehow do the traversal with > fewer fds than the depth if the limit is exceeded (or error out?). > Trying to actually do it seems error-prone (requires unbounded working > space that grows with size of a single directory, vs growth only with > depth for fds, and involves caching potentially-stale data) but maybe > just erroring so the caller knows to use a larger limit would be the > right thing to do here...? I would suggest aligning with common understanding across nix in this case. This was the main reason for my confusion in the beginning. Silently skipping or erroring out both seems unaligned with common understanding as in [1], [2], [3]. The documentation in linux [1] is more explicit about the functionality than IEEE [2] or opengroup [3] in this case. Quotes from [1] or linux man page ftw(3). "To avoid using up all of the calling process's file descriptors, nopenfd specifies the maximum number of directories that ftw() will hold open simultaneously. When the search depth exceeds this, ftw() will become slower because directories have to be closed and reopened. ftw() uses at most one file descriptor for each level in the directory tree." "The function nftw() is the same as ftw(), except that it has one additional argument, flags, and calls fn() with one more argument, ftwbuf." [1] https://linux.die.net/man/3/nftw [2] IEEE Std 1003.1-2001/Cor 2-2004, item XSH/TC2/D6/6 Change Number: XSH/TC2/D6/64 [XSH ERN 73] - p52, https://pubs.opengroup.org/onlinepubs/7899949099/toc.pdf [3] https://pubs.opengroup.org/onlinepubs/000095399/functions/nftw.html Regards, Neeraj
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.