@@ -7510,13 +7510,19 @@ added:
7510
7510
7511
7511
Free blocks available to unprivileged users.
7512
7512
7513
- Example:
7514
7513
` ` ` js
7515
- const fs = require (' fs' );
7516
- // Calculate available space in bytes
7517
- fs .statfs (' .' , (err ,stats ) => {
7514
+ const fs = require (' fs' );
7515
+ // Calculate available space in bytes
7516
+ fs .statfs (' .' , (err ,stats ) => {
7517
+ const availableSpace = stats .bavail * stats .bsize ;
7518
+ console .log (` Available space for unprivileged users: ${ availableSpace} bytes` );
7519
+ });
7520
+ ` ` `
7521
+ ` ` ` mjs
7522
+ import { statfs } from ' fs' ;
7523
+ // Calculate available space in bytes
7524
+ statfs (' .' , (err , stats ) => {
7518
7525
const availableSpace = stats .bavail * stats .bsize ;
7519
-
7520
7526
console .log (` Available space for unprivileged users: ${ availableSpace} bytes` );
7521
7527
});
7522
7528
` ` `
@@ -7533,13 +7539,19 @@ added:
7533
7539
7534
7540
Free blocks in file system.
7535
7541
7536
- Example:
7537
7542
` ` ` js
7538
- const fs = require (' fs' );
7539
- // Calculate total free space in bytes using bfree and bsize
7540
- fs .statfs (' .' , (err ,stats ) => {
7543
+ const fs = require (' fs' );
7544
+ // Calculate total free space in bytes using bfree and bsize
7545
+ fs .statfs (' .' , (err ,stats ) => {
7546
+ const totalFreeSpace = stats .bfree * stats .bsize ;
7547
+ console .log (` Total free space (including reserved blocks): ${ totalFreeSpace} bytes` );
7548
+ });
7549
+ ` ` `
7550
+ ` ` ` mjs
7551
+ import { statfs } from ' fs' ;
7552
+ // Calculate total free space in bytes using bfree and bsize
7553
+ statfs (' .' , (err , stats ) => {
7541
7554
const totalFreeSpace = stats .bfree * stats .bsize ;
7542
-
7543
7555
console .log (` Total free space (including reserved blocks): ${ totalFreeSpace} bytes` );
7544
7556
});
7545
7557
` ` `
@@ -7556,13 +7568,19 @@ added:
7556
7568
7557
7569
Total data blocks in file system.
7558
7570
7559
- Example:
7560
7571
` ` ` js
7561
- const fs = require (' fs' );
7562
- // Get the total number of blocks
7563
- fs .statfs (' .' , (err ,stats ) => {
7572
+ const fs = require (' fs' );
7573
+ // Get the total number of blocks
7574
+ fs .statfs (' .' , (err ,stats ) => {
7575
+ const totalBlocks = stats .blocks ;
7576
+ console .log (` Total number of blocks on the filesystem: ${ totalBlocks} ` );
7577
+ });
7578
+ ` ` `
7579
+ ` ` ` mjs
7580
+ import { statfs } from ' fs' ;
7581
+ // Get the total number of blocks
7582
+ statfs (' .' , (err , stats ) => {
7564
7583
const totalBlocks = stats .blocks ;
7565
-
7566
7584
console .log (` Total number of blocks on the filesystem: ${ totalBlocks} ` );
7567
7585
});
7568
7586
` ` `
@@ -7603,14 +7621,20 @@ added:
7603
7621
7604
7622
Total file nodes in file system.
7605
7623
7606
- Example:
7607
7624
` ` ` js
7608
- const fs = require (' fs' );
7609
- fs .statfs (' .' , (err , stats ) => {
7610
- // Calculate total free space in bytes using bfree and bsize
7611
- const totalFreeSpace = stats .bfree * stats .bsize ;
7612
-
7613
- console .log (` Total free space (including reserved blocks): ${ totalFreeSpace} bytes` );
7625
+ const fs = require (' fs' );
7626
+ // Calculate total file nodes in file system
7627
+ fs .statfs (' .' , (err , stats ) => {
7628
+ const totalInodes = stats .files ;
7629
+ console .log (` Total number of inodes (files) on filesystem: ${ totalInodes} ` );
7630
+ });
7631
+ ` ` `
7632
+ ` ` ` mjs
7633
+ import { statfs } from ' fs' ;
7634
+ // Calculate total file nodes in file system
7635
+ statfs (' .' , (err , stats ) => {
7636
+ const totalInodes = stats .files ;
7637
+ console .log (` Total number of inodes (files) on filesystem: ${ totalInodes} ` );
7614
7638
});
7615
7639
` ` `
7616
7640
0 commit comments