statfs.blocks


文件系统中的数据块总数。乘以 statfs.bsize 可得到总字节数。

🌐 Total data blocks in file system. Multiply by statfs.bsize to get the total size in bytes.

import { statfs } from 'node:fs/promises';

const stats = await statfs('/');
const totalBytes = stats.bsize * stats.blocks;
console.log(`Total space: ${totalBytes} bytes`);const { statfs } = require('node:fs/promises');

(async () => {
  const stats = await statfs('/');
  const totalBytes = stats.bsize * stats.blocks;
  console.log(`Total space: ${totalBytes} bytes`);
})();