If you are getting (-1) and EINVAL, EINVAL is not an error code set by either fstat or ftw(). It has to be coming from your callback function. Something in that function fails, it is not an nftw() problem.
This is how nftw works - if the nftw function itself fails it returns -1. If the (l/f)stat call it makes it returns (-1) nftw quits and returns (-1). You can control this behavior. If your fn() returns with anything but zero,
nftw bails out and returns that value. Since errno is EINVAL and stat and nftw do not set that error code, then your function has to be doing it.
|