Visitar URL original
fs: add statfs to fs by SheikhSajid · Pull Request #31351 · nodejs/node · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove spare field(s)
  • Loading branch information
SheikhSajid committed Feb 11, 2020
commit 5313e93be012a4b67eb0ace7ac672d254c3d85db
9 changes: 4 additions & 5 deletions lib/internal/fs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,22 +458,21 @@ function getStatsFromBinding(stats, offset = 0) {
);
}

function StatFs(type, bsize, blocks, bfree, bavail, files, ffree,
spare1, spare2, spare3, spare4) {
function StatFs(type, bsize, blocks, bfree,
bavail, files, ffree) {
this.type = type;
this.bsize = bsize;
this.blocks = blocks;
this.bfree = bfree;
this.bavail = bavail;
this.files = files;
this.ffree = ffree;
this.spare = [ spare1, spare2, spare3, spare4 ];
}

function getStatFsFromBinding(stats) {
return new StatFs(
stats[0], stats[1], stats[2], stats[3], stats[4], stats[5],
stats[6], stats[7], stats[8], stats[9], stats[10]
stats[0], stats[1], stats[2], stats[3],
stats[4], stats[5], stats[6]
);
}

Expand Down
4 changes: 0 additions & 4 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ enum class FsStatfsOffset {
kBAvail,
kFiles,
kFFree,
kSpare1,
kSpare2,
kSpare3,
kSpare4,
kFsStatFsFieldsNumber
};

Expand Down
8 changes: 2 additions & 6 deletions src/node_file-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,12 @@ void FillStatfsArray(AliasedBufferBase<NativeT, V8T>* fields,
SET_FIELD(kBAvail, s->f_bavail);
SET_FIELD(kFiles, s->f_files);
SET_FIELD(kFFree, s->f_ffree);
SET_FIELD(kSpare1, s->f_spare[0]);
SET_FIELD(kSpare2, s->f_spare[1]);
SET_FIELD(kSpare3, s->f_spare[2]);
SET_FIELD(kSpare4, s->f_spare[3]);
#undef SET_FIELD
}

v8::Local<v8::Value> FillGlobalStatfsArray(Environment* env,
const bool use_bigint,
const uv_statfs_t* s) {
const bool use_bigint,
const uv_statfs_t* s) {
if (use_bigint) {
auto* const arr = env->fs_statfs_field_bigint_array();
FillStatfsArray(arr, s);
Expand Down
2 changes: 1 addition & 1 deletion src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ void AfterStatfs(uv_fs_t* req) {
FSReqAfterScope after(req_wrap, req);

if (after.Proceed()) {
req_wrap->ResolveStatfs(reinterpret_cast<uv_statfs_t*>(req->ptr));
req_wrap->ResolveStatfs(static_cast<uv_statfs_t*>(req->ptr));
}
}

Expand Down
1 change: 0 additions & 1 deletion test/parallel/test-fs-promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ function verifyStatfsObject(stat) {
assert.strictEqual(typeof stat.bavail, 'number');
assert.strictEqual(typeof stat.files, 'number');
assert.strictEqual(typeof stat.ffree, 'number');
assert.ok(stat.spare instanceof Array);
}

async function getHandle(dest) {
Expand Down
2 changes: 0 additions & 2 deletions test/parallel/test-fs-statfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ fs.statfs(__filename, common.mustCall(function(err, stats) {
assert.ok(stats.hasOwnProperty(k));
assert.strictEqual(typeof stats[k], 'number', `${k} should be a number`);
});
assert.ok(stats.hasOwnProperty('spare'));
assert.ok(stats.spare instanceof Array);
// Confirm that we are not running in the context of the internal binding
// layer.
// Ref: https://github.com/nodejs/node/commit/463d6bac8b349acc462d345a6e298a76f7d06fb1
Expand Down