Skip to content

Commit

Permalink
Replace SYSCALLS.doStat with SYSCALLS.writeStat NFC (#23242)
Browse files Browse the repository at this point in the history
Split off from #23058.
  • Loading branch information
hoodmane authored Dec 22, 2024
1 parent dc2b1c2 commit 0101114
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/library_syscall.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ var SyscallsLibrary = {
return dir + '/' + path;
},

doStat(func, path, buf) {
var stat = func(path);
writeStat(buf, stat) {
{{{ makeSetValue('buf', C_STRUCTS.stat.st_dev, 'stat.dev', 'i32') }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.st_mode, 'stat.mode', 'i32') }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.st_nlink, 'stat.nlink', SIZE_TYPE) }}};
Expand Down Expand Up @@ -672,15 +671,15 @@ var SyscallsLibrary = {
},
__syscall_stat64: (path, buf) => {
path = SYSCALLS.getStr(path);
return SYSCALLS.doStat(FS.stat, path, buf);
return SYSCALLS.writeStat(buf, FS.stat(path));
},
__syscall_lstat64: (path, buf) => {
path = SYSCALLS.getStr(path);
return SYSCALLS.doStat(FS.lstat, path, buf);
return SYSCALLS.writeStat(buf, FS.lstat(path));
},
__syscall_fstat64: (fd, buf) => {
var stream = SYSCALLS.getStreamFromFD(fd);
return SYSCALLS.doStat(FS.stat, stream.path, buf);
return SYSCALLS.writeStat(buf, FS.stat(stream.path));
},
__syscall_fchown32: (fd, owner, group) => {
FS.fchown(fd, owner, group);
Expand Down Expand Up @@ -872,7 +871,7 @@ var SyscallsLibrary = {
assert(!flags, `unknown flags in __syscall_newfstatat: ${flags}`);
#endif
path = SYSCALLS.calculateAt(dirfd, path, allowEmpty);
return SYSCALLS.doStat(nofollow ? FS.lstat : FS.stat, path, buf);
return SYSCALLS.writeStat(buf, nofollow ? FS.lstat(path) : FS.stat(path));
},
__syscall_unlinkat: (dirfd, path, flags) => {
path = SYSCALLS.getStr(path);
Expand Down

0 comments on commit 0101114

Please sign in to comment.