3 ms·
Huh, I'd never heard of FTS before, the functions used by Coreutils to traverse the filesystem: http://man7.org/linux/man-pages/man3/fts.3.html http://man7.org
by AceJohnny2 7y ago
Huh, I'd never heard of FTS before, the functions used by Coreutils to traverse the filesystem:
http://man7.org/linux/man-pages/man3/fts.3.html http://man7.org/linux/man-pages/man3/fts.3.html
- woodruffw 7y agoFWIW, the POSIX equivalents are `ftw` and `nftw`[1]. POSIX 2008 deprecates `ftw`. [1]: https://pubs.opengroup.org/onlinepubs/9699919799//functions/nftw.html https://pubs.opengroup.org/onlinepubs/9699919799//functions/...
- wahern 7y agoftw/nftw is a crap interface as it relies on C callbacks and isn't re-entrant.[1] Android/Bionic, Darwin/macOS, DragonflyBSD, FreeBSD, glibc, musl libc, OpenBSD, NetBSD, and even Solaris all support the FTS API.[2] Of the extant Unix environments only AIX and QNX seems to lack it. HP-UX doesn't seem to support it, either, but I don't count HP-UX as extant. In any event it's trivial to copy an FTS implementation from a BSD. I'm a strong advocate for adherence to POSIX, but in this case there's significant benefit from using FTS and very little, if any, cost. [1] FTS uses a C callback for its comparator, which can be a headache but not nearly to the same extent as it is with nftw. [2] It's originally from BSD Reno. It was adopted by glibc, which in turn has forced commercial vendors like Solaris to support it as they're chasing Linux/glibc API compatibility. I would expect AIX to add it eventually.
- woodruffw 7y agoAh, linux-man bites again: the Linux versions of `nftw` and `ftw` claim to be re-entrant, so I assumed that POSIX specified them as such. Looks like I was wrong about that.
- Anthony-G 7y agoRed Hat-based distributions include POSIX man pages out of the box. $ whatis ftw ftw (3) - file tree walk ftw (3p) - traverse (walk) a file tree Run `man 3p ftw` to read the POSIX version. On Ubuntu systems, the following packages can be installed to provide the POSIX man pages: manpages-posix manpages-posix-dev
- rwmj 7y agoAnnoyingly FTS was completely broken on 64 bit platforms in glibc before 2016. This still affects some enterprise systems (RHEL 7 in my case). Coreutils uses gnulib to replace glibc FTS with a working version on these systems.