Created attachment 209871 [details] ntfw-example.c Looks like nftw(3) gets confused with files inside directories, since are not show at all. # tree /tmp/test /tmp/test ├── lowerdir │ ├── d1 │ │ ├── d11 │ │ │ ├── d111 │ │ │ │ └── f1111 │ │ │ └── f111 │ │ └── f11 │ └── f1 ├── mntdir ├── upperdir └── workdir # mount -t overlay tstovly /tmp/test/mntdir/ -o lowerdir=/tmp/test/lowerdir,upperdir=/tmp/test/upperdir,workdir=/tmp/test/workdir,ro example from ntfw(3) manpage modified: Without FTW_MOUNT $ ./nftw-example /tmp/test/mntdir/d1/ d 0 80 /tmp/test/mntdir/d1 17 d1 f 1 0 /tmp/test/mntdir/d1/f11 20 f11 d 1 80 /tmp/test/mntdir/d1/d11 20 d11 d 2 60 /tmp/test/mntdir/d1/d11/d111 24 d111 f 3 0 /tmp/test/mntdir/d1/d11/d111/f1111 29 f1111 f 2 0 /tmp/test/mntdir/d1/d11/f111 24 f111 With FTW_MOUNT $ ./nftw-example /tmp/test/mntdir/d1/ m d 0 80 /tmp/test/mntdir/d1 17 d1 d 1 80 /tmp/test/mntdir/d1/d11 20 d11 d 2 60 /tmp/test/mntdir/d1/d11/d111 24 d111
From glibc2-24/io/ftw.c: <snippet> if (result == 0 && (flag == FTW_NS || !(data->flags & FTW_MOUNT) || st.st_dev == data->dev)) <snippet> st.st_dev == data->dev is false in the cases of non-directory objects, since st_dev is reported from upper/lower filesystem and ->dev is reported from overlayfs [0]. So when FTW_NS and FTW_MOUNT are positionned, non-directory objects will not be reported by nftw(3). I sent a patch to lkml: https://lkml.org/lkml/2016/11/14/351
When flag is not equal to FTW_NS and FTW_MOUNT is positionned, non-directory objects will not be reported by nftw(3). sorry for the mistake.
patch is not applied to upstream.