erofs-utils: update i_nlink stat for directories

Previously, nlink of directories was treated as 1 for simplicity.

Since st_nlink for dirs is actually not well defined, nlink=1 seems
to pacify `find' (even without -noleaf option) and other utilities.
AFAICT, isofs, romfs and cramfs always set it to 1, Overlayfs sets
it to 1 conditionally, btrfs[1], ceph[2] and FUSE client historically
set it to 1.

The convention under unix is that it's # of subdirs including "."
and "..". This patch tries to follow such convention if possible to
optimize `find' performance since it's not quite hard for local fs.


Reviewed-by: Li Guifu <>
Signed-off-by: Gao Xiang <>
1 file changed