Skip to content

doc: improve fs.StatFs documentation#62791

Open
Jah-yee wants to merge 1 commit intonodejs:mainfrom
Jah-yee:doc/statfs-improvements
Open

doc: improve fs.StatFs documentation#62791
Jah-yee wants to merge 1 commit intonodejs:mainfrom
Jah-yee:doc/statfs-improvements

Conversation

@Jah-yee
Copy link
Copy Markdown

@Jah-yee Jah-yee commented Apr 17, 2026

Good day

Summary

This PR improves the documentation for fs.StatFs class based on issue #50749.

Changes made:

  1. Clarified bsize unit: Explicitly states that block size is in bytes (not bits)
  2. Added examples for calculating space:
    • bavail: Example showing how to calculate available space in bytes
    • bfree: Example showing how to calculate free space in bytes
    • blocks: Example showing how to calculate total file system size in bytes
  3. Improved files description: Clarified that it refers to inodes
  4. Enhanced type documentation: Added explanation of what the type identifier represents and examples of common file system type values

Example additions:

import { statfs } from "fs/promises";

const stats = await statfs("/tmp");
const availableBytes = stats.bsize * stats.bavail;
console.log(`Available space: ${availableBytes} bytes`);

These changes help developers understand how to use the StatFs properties correctly, especially for calculating disk space.

Thank you for your attention. If there are any issues or suggestions, please leave a comment and I will address them promptly.

Warmly,
RoomWithOutRoof

- Clarify that bsize is in bytes (not bits)
- Add examples for calculating available/free/total space
- Improve files description to mention inodes
- Add explanation for type field with examples

Fixes: nodejs#50749
@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. labels Apr 17, 2026
@lpinca
Copy link
Copy Markdown
Member

lpinca commented Apr 17, 2026

Duplicate of #62712.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants