From c848da39913db1b39f187b21d57f26da66c82e70 Mon Sep 17 00:00:00 2001 From: verycosy Date: Mon, 16 Mar 2026 22:31:00 +0900 Subject: [PATCH] fs: expose frsize field in statfs Expose `f_frsize` from libuv's `uv_statfs_t` as `statfs.frsize`. Per POSIX, `f_blocks`, `f_bfree`, and `f_bavail` are expressed in units of `f_frsize`, not `f_bsize`. On most filesystems the two values are typically equal, but some filesystem drivers report a different `f_bsize`, making it impossible to compute accurate disk usage without `frsize`. Refs: https://github.com/libuv/libuv/issues/4983 --- doc/api/fs.md | 12 ++++++++++++ lib/internal/fs/utils.js | 5 +++-- src/node_file-inl.h | 1 + src/node_file.h | 1 + test/parallel/test-fs-promises.js | 1 + test/parallel/test-fs-statfs.js | 2 +- 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 8481a6458faf45..5cea7f571e00b4 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -7632,6 +7632,7 @@ numeric values will be `bigint` instead of `number`. StatFs { type: 1397114950, bsize: 4096, + frsize: 4096, blocks: 121938943, bfree: 61058895, bavail: 61058895, @@ -7646,6 +7647,7 @@ StatFs { StatFs { type: 1397114950n, bsize: 4096n, + frsize: 4096n, blocks: 121938943n, bfree: 61058895n, bavail: 61058895n, @@ -7702,6 +7704,16 @@ added: Optimal transfer block size. +#### `statfs.frsize` + + + +* Type: {number|bigint} + +Fundamental file system block size. + #### `statfs.ffree`