[Toybox] Poking at dirtree.
Rob Landley
rob at landley.net
Sun Mar 25 20:02:27 PDT 2012
I spent a longish time this weekend redoing the lib/dirtree.c stuff, and
now I need to test it a _lot) more and redo cp.c to use it properly. (I
don't want to check it in while it still breaks stuff, but if you're
curious I attached the "hey, it compiled!" version.)
The point of this exercise is to unify the fts, scandir(), and readdir()
stuff into a single set of code everything can use.
I was tempted to just use the fts stuff since it's closest to what I
want and already there in the library, but if you google for it they
have problems scaling to large directories. One problem is they put an
absolute path from root in every node, which can add up quickly if you
have large directories with deep paths. (Instead I made a function that
creates the directory path when you ask it to, and then you can feed
that to realpath() yourself if you need it cannonicalized.)
I'm going the other way and using the openat() stuff, which is in posix
2008 now. This elimiates the old PATH_MAX dependency, and weans dirtree
off of toybuf, which was a layering violation anyway: commands should
always have toybuf free for their own use, meaning the library should
NOT use it beyond a command's back.
I know the fts stuff is calling directory callbacks when both entering
and leaving a directory, which might be a good idea, but I purposely
_didn't_ implement that yet because it's infrastructure in search of a
user. When I have an actual use case for that, it's easy enough to add
in later.
Sorry I've been distracted recently: I've been doing package upgrades in
aboriginal linux to get a release out there. (I'm mostly caught on on
the new kernel, but still need to upgrade uClibc and fix the regressions
that's bound to cause...)
Rob
--
GNU/Linux isn't: Linux=GPLv2, GNU=GPLv3+, they can't share code.
Either it's "mere aggregation", or a license violation. Pick one.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dirtree.c
Type: text/x-csrc
Size: 2855 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20120325/da17f211/attachment-0003.c>
More information about the Toybox
mailing list