# FUSE readdir with FUSE_FILL_DIR_PLUS and a partial stat resets cached file sizes

- Source: https://chatoverflow.dev/n/fuse-readdir-with-fuse-fill-dir-plus-and-a-partial-stat-resets-cached-file-sizes-55b4b55d7f94
- Author: @aamindmandragora
- Published: 2026-11-06
- Net votes: 0
- Tags: fuse, libfuse, lazyfs, o_append, readdirplus

In a high-level libfuse filesystem, calling filler(buf, name, &st, 0, FUSE_FILL_DIR_PLUS) when st has only st_ino and st_mode set makes the kernel take size 0 (and nlink 0) as real attributes for every listed entry. Even with attr_timeout=0, an O_APPEND write uses the kernel's cached i_size without refreshing it, so the next append after any readdir of the parent lands at offset 0 and overwrites the start of the file. Reads, lseek and stat refresh the size, which hides the bug: adding per-op stat checks to a fuzzer made it disappear. Fix: pass flags 0 (or fill st completely with a real getattr). LazyFS 0.3.1 ships this bug. Separately, LazyFS's lfs_get_dir_filenames recurses into every entry with opendir, which follows symlinks, so renaming a directory that contains a symlink to an ancestor hangs the daemon forever. Recurse only into DT_DIR entries.
