@@ -7926,6 +7926,33 @@ StatFs {
79267926}
79277927` ` `
79287928
7929+ To calculate disk space from a ` StatFs` object, multiply the block count
7930+ properties by ` statfs .bsize ` (the block size in bytes):
7931+
7932+ ` ` ` mjs
7933+ import { statfs } from ' node:fs/promises' ;
7934+
7935+ const stats = await statfs (' /' );
7936+ const byteSize = stats .bsize ;
7937+
7938+ console .log (` Total: ${ stats .blocks * byteSize} bytes` );
7939+ console .log (` Free: ${ stats .bfree * byteSize} bytes` );
7940+ console .log (` Available: ${ stats .bavail * byteSize} bytes` );
7941+ ` ` `
7942+
7943+ ` ` ` cjs
7944+ const { statfs } = require (' node:fs' );
7945+
7946+ statfs (' /' , (err , stats ) => {
7947+ if (err) throw err;
7948+ const byteSize = stats .bsize ;
7949+
7950+ console .log (` Total: ${ stats .blocks * byteSize} bytes` );
7951+ console .log (` Free: ${ stats .bfree * byteSize} bytes` );
7952+ console .log (` Available: ${ stats .bavail * byteSize} bytes` );
7953+ });
7954+ ` ` `
7955+
79297956#### ` statfs .bavail `
79307957
79317958<!-- YAML
@@ -7936,7 +7963,9 @@ added:
79367963
79377964* Type: {number|bigint}
79387965
7939- Free blocks available to unprivileged users.
7966+ Free blocks available to unprivileged users. This value accounts for
7967+ space reserved by the operating system (unlike [` statfs .bfree ` ][]). Use
7968+ ` statfs .bavail * statfs .bsize ` to get the available space in bytes.
79407969
79417970#### ` statfs .bfree `
79427971
@@ -7948,7 +7977,10 @@ added:
79487977
79497978* Type: {number|bigint}
79507979
7951- Free blocks in file system.
7980+ Free blocks in file system, including reserved blocks that are not
7981+ available to unprivileged users. See [` statfs .bavail ` ][] for the
7982+ unreserved count. Use ` statfs .bfree * statfs .bsize ` to get the free
7983+ space in bytes.
79527984
79537985#### ` statfs .blocks `
79547986
@@ -7960,7 +7992,8 @@ added:
79607992
79617993* Type: {number|bigint}
79627994
7963- Total data blocks in file system.
7995+ Total data blocks in file system. Use ` statfs .blocks * statfs .bsize `
7996+ to get the total size in bytes.
79647997
79657998#### ` statfs .bsize `
79667999
@@ -7972,7 +8005,9 @@ added:
79728005
79738006* Type: {number|bigint}
79748007
7975- Optimal transfer block size.
8008+ Optimal transfer block size, in bytes. Multiply this value by block count
8009+ properties (such as [` statfs .blocks ` ][], [` statfs .bfree ` ][], and
8010+ [` statfs .bavail ` ][]) to convert them to bytes.
79768011
79778012#### ` statfs .frsize `
79788013
@@ -7982,7 +8017,8 @@ added: REPLACEME
79828017
79838018* Type: {number|bigint}
79848019
7985- Fundamental file system block size.
8020+ Fundamental file system block size, in bytes. On most POSIX systems this
8021+ has the same value as [` statfs .bsize ` ][].
79868022
79878023#### ` statfs .ffree `
79888024
@@ -7994,7 +8030,7 @@ added:
79948030
79958031* Type: {number|bigint}
79968032
7997- Free file nodes in file system.
8033+ Free file nodes (inodes) in file system.
79988034
79998035#### ` statfs .files `
80008036
@@ -8006,7 +8042,7 @@ added:
80068042
80078043* Type: {number|bigint}
80088044
8009- Total file nodes in file system.
8045+ Total file nodes (inodes) in file system.
80108046
80118047#### ` statfs .type `
80128048
@@ -8018,7 +8054,9 @@ added:
80188054
80198055* Type: {number|bigint}
80208056
8021- Type of file system.
8057+ Type of file system, as a filesystem magic number. Common values include
8058+ ` 0xEF53 ` (ext2/ext3/ext4), ` 0x5346544e ` (NTFS), ` 0x01021994 ` (tmpfs),
8059+ and ` 0x6969 ` (NFS). See the statfs(2) man page for more values.
80228060
80238061### Class: ` fs .Utf8Stream `
80248062
@@ -9052,6 +9090,10 @@ the file contents.
90529090[` fs .rmdir ()` ]: #fsrmdirpath-options-callback
90539091[` fs .stat ()` ]: #fsstatpath-options-callback
90549092[` fs .statfs ()` ]: #fsstatfspath-options-callback
9093+ [` statfs .bavail ` ]: #statfsbavail
9094+ [` statfs .bfree ` ]: #statfsbfree
9095+ [` statfs .blocks ` ]: #statfsblocks
9096+ [` statfs .bsize ` ]: #statfsbsize
90559097[` fs .symlink ()` ]: #fssymlinktarget-path-type-callback
90569098[` fs .utimes ()` ]: #fsutimespath-atime-mtime-callback
90579099[` fs .watch ()` ]: #fswatchfilename-options-listener
0 commit comments