bug#70586: cp walks dir differently than rm and is hitting "File name too long" where this could be avoided

Paul Eggert <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Organization UCLA Computer Science Department
Message-ID <[email protected]>
On 2025-10-19 19:18, Collin Funk wrote:

>       $ ulimit -n
>       1024
> 
> It is easy to hit this limit even if you only open file descriptors to
> the parents of the file that you want to copy.

(I assume by "parents" you mean "ancestors".)

Yes, and that's why Gnulib fts doesn't do that.


>     int
>     open_deep (char const *filename, int flags, ...)
>     {
...>       /* Loop through the patch components using openat on each
>          until we open FILENAME.  */
>       return result;

That's O(N * D) if you open N files nested D deep, which is not a good 
thing. We should be able to do O(N + D).


> is there a reason why savewd and
> mkancesdirs don't use openat + mkdirat instead of using chdir in a child
> process? Do these functions just predate the *at interfaces

Yes, precisely. Some day it will be time to give up on those old 
platforms, I suppose. We haven't done that yet because there hasn't been 
motivation to get rid of them, or rewrite them.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.