Do any POSIX functions or glibc extensions implement the width of the file tree in width?

I am writing a daemon that uses inotify to control access to files, and it is very important that I do not miss anything in a recursive search. I found this interesting idea and started to implement it.

ftw () and ftw64 () do not use the width algorithm, more "preliminary". nftw () gives me a choice of depth - at first, but I'm worried about racing in the upper leaves.

I hope I missed something, maybe the GNU extension? Or am I just looking at implementing my own type of secure callbacks (something that I really did not do)?

Or is my understanding of the benefits of width - first in depth - wrong at first for this type of application?

+3
source share
1 answer

Looking at the specification for nftw () ', the FTW_DEPTH flag performs a first-order crawl (in depth), visiting subdirectories before visiting the node directory.

I do not think that any of the standard algorithms does a width search.

Presumably you should write bfftw () based on the nftw () interface. Please note that when scanning, you must queue for objects that will visit recursively (directories).

+1
source

Source: https://habr.com/ru/post/1721456/


All Articles