Commit Diff


commit - 9cb5624e66351c704ec986b94d38389a923eafdf
commit + a568a333b09a164552a0b93a45d0f71fc1145672
blob - 4c921f64a2976a7a459f2cb885b1080547dda6ff
blob + 7fab238b7561daa9397f8661042946dfbc82a782
--- src/data.dst
+++ src/data.dst
@@ -31,3 +31,26 @@ struct linux_iovec {
 	base: u64,
 	len: u64,
 };
+
+struct linux_stat64 {
+	dev:		u64,
+	ino:		u64,
+	mode:		u32,
+	nlink:		u32,
+	uid:		u32,
+	gid:		u32,
+	rdev:		u64,
+	__pad1:		u64,
+	size:		u64,
+	blksize:	u32,
+	__pad2:		u32,
+	blocks:		u64,
+	atime:		u32,
+	atime_ns:	u32,
+	mtime:		u32,
+	mtime_ns:	u32,
+	ctime:		u32,
+	ctime_ns:	u32,
+	__unused4:	u32,
+	__unused5:	u32,
+};
blob - ebb28a6be67eeb7b23209862c78f9fd75a3a20c9
blob + 78f2155e83608163d1b6f16b7280709090b1b650
--- src/ecall.c
+++ src/ecall.c
@@ -20,29 +20,6 @@
 #include "syscalls.h"
 #include "linurv.h"
 
-struct linux_stat64 {
-	u64 dev;
-	u64 ino;
-	u32 mode;
-	u32 nlink;
-	u32 uid;
-	u32 gid;
-	u64 rdev;
-	u64 __pad1;
-	u64 size;
-	u32 blksize;
-	u32 __pad2;
-	u64 blocks;
-	u32 atime;
-	u32 atime_ns;
-	u32 mtime;
-	u32 mtime_ns;
-	u32 ctime;
-	u32 ctime_ns;
-	u32 __unused4;
-	u32 __unused5;
-};
-
 struct linux_utsname {
 	char sysname[65];
 	char nodename[65];
@@ -549,14 +526,14 @@ void ecall (void)
 		tmp = map_at (i0);
 		ret = map (fstatat (tmp, str (a1), &st, i3));
 		stat_to_linux_stat (&lst, &st);
-		memcpy (ptr (void, a2), &lst, sizeof (lst));
+		encode_linux_stat64 (ptr (uint8_t, a2), &lst);
 		dbg ("fstatat(%d, \"%s\", %p, %d)", tmp, str (a1), ptr (void, a2), i3);
 		break;
 	case SYS_fstat:
 		tmp = map_at (i0);
 		ret = map (fstat (tmp, &st));
 		stat_to_linux_stat (&lst, &st);
-		memcpy (ptr (void, a1), &lst, sizeof (lst));
+		encode_linux_stat64 (ptr (uint8_t, a2), &lst);
 		dbg ("fstat(%d, %p)", tmp, ptr (void, a1));
 		break;
 	case SYS_sync:
@@ -1258,13 +1235,13 @@ void ecall (void)
 	case SYS_stat:
 		ret = map (stat (str (a0), &st));
 		stat_to_linux_stat (&lst, &st);
-		memcpy (ptr (void, a1), &lst, sizeof (lst));
+		encode_linux_stat64 (ptr (uint8_t, a1), &lst);
 		dbg ("stat(\"%s\", %p)", str (a0), ptr (void, a1));
 		break;
 	case SYS_lstat:
 		ret = map (lstat (str (a0), &st));
 		stat_to_linux_stat (&lst, &st);
-		memcpy (ptr (void, a1), &lst, sizeof (lst));
+		encode_linux_stat64 (ptr (uint8_t, a1), &lst);
 		dbg ("lstat(\"%s\", %p)", str (a0), ptr (void, a1));
 		break;
 	case SYS_time: