Skip to content

Commit bebfc6b

Browse files
committed
Better argment names and comments
1 parent c961354 commit bebfc6b

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/library_nodefs.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,14 @@ addToLibrary({
148148
blocks: stat.blocks
149149
};
150150
},
151-
setattr(path, node, attr, chmod, utimes, truncate) {
151+
// Common code for both node and stream setattr
152+
// For node getatrr:
153+
// - arg is a native path
154+
// - chmod, utimes, truncate are fs.chmodSync, fs.utimesSync, fs.truncateSync
155+
// For stream getatrr:
156+
// - arg is a native file descriptor
157+
// - chmod, utimes, truncate are fs.fchmodSync, fs.futimesSync, fs.ftruncateSync
158+
setattr(arg, node, attr, chmod, utimes, truncate) {
152159
NODEFS.tryFSOperation(() => {
153160
if (attr.mode !== undefined) {
154161
var mode = attr.mode;
@@ -157,16 +164,16 @@ addToLibrary({
157164
// https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/chmod-wchmod
158165
mode &= {{{ cDefs.S_IRUSR | cDefs.S_IWUSR }}};
159166
}
160-
chmod(path, mode);
167+
chmod(arg, mode);
161168
// update the common node structure mode as well
162169
node.mode = attr.mode;
163170
}
164171
if (attr.timestamp !== undefined) {
165172
var date = new Date(attr.timestamp);
166-
utimes(path, date, date);
173+
utimes(arg, date, date);
167174
}
168175
if (attr.size !== undefined) {
169-
truncate(path, attr.size);
176+
truncate(arg, attr.size);
170177
}
171178
});
172179
},

src/library_syscall.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ var SyscallsLibrary = {
4040
}
4141
return PATH.join2(dir, path);
4242
},
43-
44-
doStat(func, path, buf) {
45-
var stat = func(path);
43+
// When called by stat, arg is a path. When called by fstat, arg is a file
44+
// descriptor.
45+
doStat(func, arg, buf) {
46+
var stat = func(arg);
4647
{{{ makeSetValue('buf', C_STRUCTS.stat.st_dev, 'stat.dev', 'i32') }}};
4748
{{{ makeSetValue('buf', C_STRUCTS.stat.st_mode, 'stat.mode', 'i32') }}};
4849
{{{ makeSetValue('buf', C_STRUCTS.stat.st_nlink, 'stat.nlink', SIZE_TYPE) }}};

0 commit comments

Comments
 (0)