-
-
Notifications
You must be signed in to change notification settings - Fork 35.1k
doc: clarify fs.StatFs field descriptions #62262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AkaHarshit
wants to merge
2
commits into
nodejs:main
Choose a base branch
from
AkaHarshit:docs/fs-statfs-clarify-field-descriptions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+52
−7
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7654,6 +7654,39 @@ StatFs { | |||||
| } | ||||||
| ``` | ||||||
| The following example shows how to calculate disk space information from a | ||||||
| `StatFs` object. The total, free, and available space in bytes can be | ||||||
| calculated by multiplying the respective block counts by the block size | ||||||
| (`bsize`). | ||||||
| ```mjs | ||||||
| import { statfs } from 'node:fs/promises'; | ||||||
|
|
||||||
| const stats = await statfs('/'); | ||||||
| const totalSpace = stats.blocks * stats.bsize; | ||||||
| const freeSpace = stats.bfree * stats.bsize; | ||||||
| const availableSpace = stats.bavail * stats.bsize; | ||||||
|
|
||||||
| console.log(`Total: ${totalSpace / (1024 ** 3)} GiB`); | ||||||
| console.log(`Free: ${freeSpace / (1024 ** 3)} GiB`); | ||||||
| console.log(`Available: ${availableSpace / (1024 ** 3)} GiB`); | ||||||
| ``` | ||||||
| ```cjs | ||||||
| const { statfs } = require('node:fs'); | ||||||
|
|
||||||
| statfs('/', (err, stats) => { | ||||||
| if (err) throw err; | ||||||
| const totalSpace = stats.blocks * stats.bsize; | ||||||
| const freeSpace = stats.bfree * stats.bsize; | ||||||
| const availableSpace = stats.bavail * stats.bsize; | ||||||
|
|
||||||
| console.log(`Total: ${totalSpace / (1024 ** 3)} GiB`); | ||||||
| console.log(`Free: ${freeSpace / (1024 ** 3)} GiB`); | ||||||
| console.log(`Available: ${availableSpace / (1024 ** 3)} GiB`); | ||||||
| }); | ||||||
| ``` | ||||||
| #### `statfs.bavail` | ||||||
| <!-- YAML | ||||||
|
|
@@ -7664,7 +7697,10 @@ added: | |||||
| * Type: {number|bigint} | ||||||
| Free blocks available to unprivileged users. | ||||||
| The number of free blocks available to unprivileged users. The available disk | ||||||
| space in bytes can be calculated as `statfs.bavail * statfs.bsize`. This value | ||||||
| may be less than `statfs.bfree` because the file system may reserve blocks for | ||||||
| the superuser. | ||||||
| #### `statfs.bfree` | ||||||
|
|
@@ -7676,7 +7712,9 @@ added: | |||||
| * Type: {number|bigint} | ||||||
| Free blocks in file system. | ||||||
| The total number of free blocks in the file system, including reserved blocks | ||||||
| that are not available to unprivileged users. The total free disk space in | ||||||
| bytes can be calculated as `statfs.bfree * statfs.bsize`. | ||||||
| #### `statfs.blocks` | ||||||
|
|
@@ -7688,7 +7726,8 @@ added: | |||||
| * Type: {number|bigint} | ||||||
| Total data blocks in file system. | ||||||
| The total number of data blocks in the file system. The total file system size | ||||||
| in bytes can be calculated as `statfs.blocks * statfs.bsize`. | ||||||
| #### `statfs.bsize` | ||||||
|
|
@@ -7700,7 +7739,8 @@ added: | |||||
| * Type: {number|bigint} | ||||||
| Optimal transfer block size. | ||||||
| The optimal transfer block size in bytes. This value represents the fundamental | ||||||
| block size used by the file system for allocating and transferring data. | ||||||
| #### `statfs.ffree` | ||||||
|
|
@@ -7712,7 +7752,10 @@ added: | |||||
| * Type: {number|bigint} | ||||||
| Free file nodes in file system. | ||||||
| The number of free file nodes (inodes) in the file system. An inode is a data | ||||||
| structure used by the file system to store information about a file or | ||||||
| directory. A lack of free inodes can prevent the creation of new files even | ||||||
| when disk space is available. | ||||||
| #### `statfs.files` | ||||||
|
|
@@ -7724,7 +7767,8 @@ added: | |||||
| * Type: {number|bigint} | ||||||
| Total file nodes in file system. | ||||||
| The total number of file nodes (inodes) in the file system. This represents the | ||||||
| maximum number of files and directories the file system can hold. | ||||||
| #### `statfs.type` | ||||||
|
|
@@ -7736,7 +7780,9 @@ added: | |||||
| * Type: {number|bigint} | ||||||
| Type of file system. | ||||||
| A numeric identifier for the file system type. This value is a filesystem magic | ||||||
| number set by the operating system kernel, such as `0xEF53` for ext4 or | ||||||
| `0x01021994` for tmpfs on Linux. On Windows, this value is `0`. | ||||||
|
||||||
| `0x01021994` for tmpfs on Linux. On Windows, this value is `0`. | |
| `0x01021994` for tmpfs on Linux. On some platforms (e.g., Windows, Solaris), this value is `0`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bsize POSIX defines the optimal transfer block size, not the allocation block size. Just appending "in bytes"