@@ -7926,6 +7926,35 @@ StatFs {
79267926}
79277927` ` `
79287928
7929+ To calculate disk space from a ` StatFs` object, multiply the block count
7930+ properties by the fundamental block size (` statfs .frsize ` ) to convert
7931+ them to bytes. Pass ` { bigint: true }` to avoid loss of precision on
7932+ large file systems:
7933+
7934+ ` ` ` mjs
7935+ import { statfs } from ' node:fs/promises' ;
7936+
7937+ const stats = await statfs (' /' , { bigint: true });
7938+ const blockSize = stats .frsize ;
7939+
7940+ console .log (` Total: ${ stats .blocks * blockSize} bytes` );
7941+ console .log (` Free: ${ stats .bfree * blockSize} bytes` );
7942+ console .log (` Available: ${ stats .bavail * blockSize} bytes` );
7943+ ` ` `
7944+
7945+ ` ` ` cjs
7946+ const { statfs } = require (' node:fs' );
7947+
7948+ statfs (' /' , { bigint: true }, (err , stats ) => {
7949+ if (err) throw err;
7950+ const blockSize = stats .frsize ;
7951+
7952+ console .log (` Total: ${ stats .blocks * blockSize} bytes` );
7953+ console .log (` Free: ${ stats .bfree * blockSize} bytes` );
7954+ console .log (` Available: ${ stats .bavail * blockSize} bytes` );
7955+ });
7956+ ` ` `
7957+
79297958#### ` statfs .bavail `
79307959
79317960<!-- YAML
@@ -7936,7 +7965,8 @@ added:
79367965
79377966* Type: {number|bigint}
79387967
7939- Free blocks available to unprivileged users.
7968+ Free blocks available to unprivileged users. Unlike [` statfs .bfree ` ][],
7969+ this value excludes blocks reserved for privileged processes.
79407970
79417971#### ` statfs .bfree `
79427972
@@ -7948,7 +7978,9 @@ added:
79487978
79497979* Type: {number|bigint}
79507980
7951- Free blocks in file system.
7981+ Free blocks in file system, including blocks reserved for privileged
7982+ processes. See [` statfs .bavail ` ][] for the count available to
7983+ unprivileged users.
79527984
79537985#### ` statfs .blocks `
79547986
@@ -7972,7 +8004,7 @@ added:
79728004
79738005* Type: {number|bigint}
79748006
7975- Optimal transfer block size.
8007+ Optimal transfer block size, in bytes .
79768008
79778009#### ` statfs .frsize `
79788010
@@ -7982,7 +8014,7 @@ added: REPLACEME
79828014
79838015* Type: {number|bigint}
79848016
7985- Fundamental file system block size.
8017+ Fundamental file system block size, in bytes .
79868018
79878019#### ` statfs .ffree `
79888020
@@ -7994,7 +8026,7 @@ added:
79948026
79958027* Type: {number|bigint}
79968028
7997- Free file nodes in file system.
8029+ Free file nodes (inodes) in file system.
79988030
79998031#### ` statfs .files `
80008032
@@ -8006,7 +8038,7 @@ added:
80068038
80078039* Type: {number|bigint}
80088040
8009- Total file nodes in file system.
8041+ Total file nodes (inodes) in file system.
80108042
80118043#### ` statfs .type `
80128044
@@ -8018,7 +8050,11 @@ added:
80188050
80198051* Type: {number|bigint}
80208052
8021- Type of file system.
8053+ Type of file system. On Linux this is a filesystem magic number (for
8054+ example, ` 0xEF53 ` for ext2/ext3/ext4, ` 0x5346544e ` for NTFS,
8055+ ` 0x01021994 ` for tmpfs, and ` 0x6969 ` for NFS). The value is
8056+ platform-dependent and may be ` 0 ` on systems where libuv does not
8057+ report it.
80228058
80238059### Class: ` fs .Utf8Stream `
80248060
@@ -9052,6 +9088,8 @@ the file contents.
90529088[` fs .rmdir ()` ]: #fsrmdirpath-options-callback
90539089[` fs .stat ()` ]: #fsstatpath-options-callback
90549090[` fs .statfs ()` ]: #fsstatfspath-options-callback
9091+ [` statfs .bavail ` ]: #statfsbavail
9092+ [` statfs .bfree ` ]: #statfsbfree
90559093[` fs .symlink ()` ]: #fssymlinktarget-path-type-callback
90569094[` fs .utimes ()` ]: #fsutimespath-atime-mtime-callback
90579095[` fs .watch ()` ]: #fswatchfilename-options-listener
0 commit comments