@@ -44,8 +44,9 @@ type Config struct {
4444 // Blksize is the preferred I/O size advertised via st_blksize on
4545 // every stat. Callers should derive it from Import.UnixFSChunker via
4646 // fusemnt.BlksizeFromChunker so the hint matches the chunker MFS
47- // will use for writes. Zero is normalized to fusemnt.DefaultBlksize
48- // by NewDir.
47+ // will use for writes. If zero, NewDir writes fusemnt.DefaultBlksize
48+ // into this field in place, so fillAttr on every inode can read
49+ // cfg.Blksize without a nil-check on each stat.
4950 Blksize uint32
5051}
5152
@@ -58,10 +59,9 @@ func NewDir(d *mfs.Directory, cfg *Config) *Dir {
5859 if cfg == nil || cfg .DAG == nil {
5960 panic ("fuse/writable: Config.DAG is required" )
6061 }
61- // Normalize Blksize once so fillAttr on every inode can read
62- // cfg.Blksize directly. Tests and callers that don't plumb
63- // Import.UnixFSChunker leave this zero; we fall back to the FUSE
64- // default so stat still advertises a usable st_blksize.
62+ // Tests and callers that don't plumb Import.UnixFSChunker leave
63+ // Blksize zero; fall back to the FUSE default so stat advertises a
64+ // usable st_blksize. See Config.Blksize for why we mutate in place.
6565 if cfg .Blksize == 0 {
6666 cfg .Blksize = fusemnt .DefaultBlksize
6767 }
@@ -75,11 +75,11 @@ type Dir struct {
7575 Cfg * Config
7676}
7777
78- // fillAttr fills stat attributes for a directory. Blksize is set on
79- // every entry: go-fuse's setBlocks otherwise auto-fills both st_blocks
80- // and st_blksize with a 4 KiB page-based fallback. For directories that
81- // fallback computes Blocks from Size=0 and yields st_blocks=0, which
82- // some tools treat as "unsupported".
78+ // fillAttr fills stat attributes for a directory. Blocks and Blksize
79+ // are set explicitly because go-fuse's setBlocks otherwise auto-fills
80+ // them from Size with a 4 KiB page-based fallback. For directories
81+ // Size is 0, so the fallback yields st_blocks=0, which some tools
82+ // (dedup scanners, file managers) treat as "unsupported".
8383func (d * Dir ) fillAttr (a * fuse.Attr ) {
8484 a .Mode = uint32 (fusemnt .DefaultDirModeRW .Perm ())
8585 a .Blocks = 1
0 commit comments