Skip to content

Commit 6bac5f5

Browse files
committed
stat64 syscall
1 parent 7c7fb5d commit 6bac5f5

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/library_syscall.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,39 @@ mergeInto(LibraryManager.library, {
533533
}
534534
return ret;
535535
}
536+
case 195: { // SYS_stat64
537+
var path = get(), buf = get();
538+
path = Pointer_stringify(path);
539+
try {
540+
var stat = FS.stat(path);
541+
{{{ makeSetValue('buf', C_STRUCTS.stat.st_dev, 'stat.dev', 'i32') }}};
542+
{{{ makeSetValue('buf', C_STRUCTS.stat.__st_dev_padding, '0', 'i32') }}};
543+
{{{ makeSetValue('buf', C_STRUCTS.stat.__st_ino_truncated, 'stat.ino', 'i32') }}};
544+
{{{ makeSetValue('buf', C_STRUCTS.stat.st_mode, 'stat.mode', 'i32') }}};
545+
{{{ makeSetValue('buf', C_STRUCTS.stat.st_nlink, 'stat.nlink', 'i32') }}};
546+
{{{ makeSetValue('buf', C_STRUCTS.stat.st_uid, 'stat.uid', 'i32') }}};
547+
{{{ makeSetValue('buf', C_STRUCTS.stat.st_gid, 'stat.gid', 'i32') }}};
548+
{{{ makeSetValue('buf', C_STRUCTS.stat.st_rdev, 'stat.rdev', 'i32') }}};
549+
{{{ makeSetValue('buf', C_STRUCTS.stat.__st_rdev_padding, '0', 'i32') }}};
550+
{{{ makeSetValue('buf', C_STRUCTS.stat.st_size, 'stat.size', 'i32') }}};
551+
{{{ makeSetValue('buf', C_STRUCTS.stat.st_blksize, '4096', 'i32') }}};
552+
{{{ makeSetValue('buf', C_STRUCTS.stat.st_blocks, 'stat.blocks', 'i32') }}};
553+
{{{ makeSetValue('buf', C_STRUCTS.stat.st_atim.tv_sec, '(stat.atime.getTime() / 1000)|0', 'i32') }}};
554+
{{{ makeSetValue('buf', C_STRUCTS.stat.st_atim.tv_nsec, '0', 'i32') }}};
555+
{{{ makeSetValue('buf', C_STRUCTS.stat.st_mtim.tv_sec, '(stat.mtime.getTime() / 1000)|0', 'i32') }}};
556+
{{{ makeSetValue('buf', C_STRUCTS.stat.st_mtim.tv_nsec, '0', 'i32') }}};
557+
{{{ makeSetValue('buf', C_STRUCTS.stat.st_ctim.tv_sec, '(stat.ctime.getTime() / 1000)|0', 'i32') }}};
558+
{{{ makeSetValue('buf', C_STRUCTS.stat.st_ctim.tv_nsec, '0', 'i32') }}};
559+
{{{ makeSetValue('buf', C_STRUCTS.stat.st_ino, 'stat.ino', 'i32') }}};
560+
return 0;
561+
} catch (e) {
562+
if (e && e.node && PATH.normalize(path) !== PATH.normalize(FS.getPath(e.node))) {
563+
// an error occurred while trying to look up the path; we should just report ENOTDIR
564+
return -ERRNO_CODES.ENOTDIR;
565+
}
566+
throw e;
567+
}
568+
}
536569
case 220: { // SYS_getdents64
537570
var fd = get(), dirp = get(), count = get();
538571
var stream = FS.getStream(fd);

0 commit comments

Comments
 (0)