From f8ee196c15784c372f30bfbb7d70956fc4d7eb63 Mon Sep 17 00:00:00 2001 From: Jinho Jang Date: Wed, 1 Apr 2026 05:51:44 +0900 Subject: [PATCH] fs: expose frsize field in statfs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 PR-URL: https://github.com/nodejs/node/pull/62277 Reviewed-By: Anna Henningsen Reviewed-By: Juan José Arboleda Reviewed-By: Luigi Pinca Reviewed-By: Gürgün Dayıoğlu --- 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 6330a921732..c793dc67830 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -7895,6 +7895,7 @@ numeric values will be `bigint` instead of `number`. StatFs { type: 1397114950, bsize: 4096, + frsize: 4096, blocks: 121938943, bfree: 61058895, bavail: 61058895, @@ -7909,6 +7910,7 @@ StatFs { StatFs { type: 1397114950n, bsize: 4096n, + frsize: 4096n, blocks: 121938943n, bfree: 61058895n, bavail: 61058895n, @@ -7965,6 +7967,16 @@ added: Optimal transfer block size. +#### `statfs.frsize` + + + +* Type: {number|bigint} + +Fundamental file system block size. + #### `statfs.ffree`