]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/syscall_shim: Add stat struct
authorMarc Rittinghaus <marc.rittinghaus@unikraft.io>
Fri, 14 Apr 2023 14:49:53 +0000 (16:49 +0200)
committerUnikraft <monkey@unikraft.io>
Wed, 26 Apr 2023 23:10:14 +0000 (23:10 +0000)
This commit adds a definition of the stat struct to prsyscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836

lib/syscall_shim/uk_prsyscall.c

index e389d0296a606b2206f47c1772c6c23ab9c06f5a..3df603a604553e9098a212655ebedbd520cfabf8 100644 (file)
@@ -7,6 +7,8 @@
 #include <string.h>
 #include <fcntl.h>
 
+#include <sys/stat.h>
+
 #include <uk/arch/types.h>
 #include <uk/plat/console.h> /* ANSI definitions */
 #include <uk/arch/limits.h>
@@ -334,6 +336,7 @@ enum param_type {
        PT_MSGFLAGS,
        PT_CLONEFLAGS,
        PT_STRUCT(timespec),
+       PT_STRUCT(stat),
 };
 #define PT_BUFP(len)                                                   \
        (long)(_PT_BUFP | ((MIN((unsigned long) __U16_MAX,              \
@@ -346,7 +349,6 @@ enum param_type {
 #define PT_STATUS PT_BOOL
 #define PT_PATH PT_CHARP
 #define PT_TID PT_PID
-#define PT_STRUCTSTAT PT_VADDR
 
 /*
  * Individual parameter type formats
@@ -759,6 +761,11 @@ static void pr_param(struct uk_streambuf *sb, int fmtf,
                          PT_UDEC, tv_sec,
                          PT_UDEC, tv_nsec);
                break;
+       case PT_STRUCT(stat):
+               PR_STRUCT(sb, fmtf, stat, flags, param, 1, succ,
+                         PT_UDEC, st_size,
+                         PT_OCTAL, st_mode);
+               break;
        default:
                uk_streambuf_shcc(sb, fmtf, VALUE);
                uk_streambuf_printf(sb, "0x%lx", (unsigned long) param);
@@ -947,7 +954,7 @@ static void pr_syscall(struct uk_streambuf *sb, int fmtf,
 #ifdef HAVE_uk_syscall_stat
        case SYS_stat:
                VPR_SYSCALL(sb, fmtf, syscall_num, args, rc == 0,
-                           PT_PATH, PT_STRUCTSTAT);
+                           PT_PATH, PT_STRUCT(stat) | PT_OUT);
                PR_SYSRET(sb, fmtf, PT_STATUS, rc);
                break;
 #endif /* HAVE_uk_syscall_stat */
@@ -955,7 +962,7 @@ static void pr_syscall(struct uk_streambuf *sb, int fmtf,
 #ifdef HAVE_uk_syscall_fstat
        case SYS_fstat:
                VPR_SYSCALL(sb, fmtf, syscall_num, args, rc == 0,
-                           PT_FD, PT_STRUCTSTAT);
+                           PT_FD, PT_STRUCT(stat) | PT_OUT);
                PR_SYSRET(sb, fmtf, PT_STATUS, rc);
                break;
 #endif /* HAVE_uk_syscall_fstat */