From 764780294f1df220174c1eb2208c0774d685d594 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Thu, 30 Jun 2022 12:12:51 -0600 Subject: [PATCH] kboot: Implement getpid(2) Add host_getpid() so we can know if we're running as init(8) or not. If we are, we may chose to do early system setup / sanity operations. Sponsored by: Netflix --- stand/kboot/arch/amd64/syscall_nr.h | 1 + stand/kboot/arch/powerpc64/syscall_nr.h | 1 + stand/kboot/host_syscall.h | 1 + stand/kboot/host_syscalls.c | 6 ++++++ 4 files changed, 9 insertions(+) diff --git a/stand/kboot/arch/amd64/syscall_nr.h b/stand/kboot/arch/amd64/syscall_nr.h index 7813eff9289..47bb84cc3a3 100644 --- a/stand/kboot/arch/amd64/syscall_nr.h +++ b/stand/kboot/arch/amd64/syscall_nr.h @@ -1,5 +1,6 @@ #define SYS_close 3 #define SYS_getdents 78 +#define SYS_getpid 39 #define SYS_gettimeofday 96 #define SYS_kexec_load 246 #define SYS_lseek 8 diff --git a/stand/kboot/arch/powerpc64/syscall_nr.h b/stand/kboot/arch/powerpc64/syscall_nr.h index 9471fd48ceb..2b0599b4743 100644 --- a/stand/kboot/arch/powerpc64/syscall_nr.h +++ b/stand/kboot/arch/powerpc64/syscall_nr.h @@ -1,6 +1,7 @@ #define SYS_close 6 #define SYS_fstat 108 #define SYS_getdents 141 +#define SYS_getpid 20 #define SYS_gettimeofday 78 #define SYS_kexec_load 268 #define SYS_llseek 140 diff --git a/stand/kboot/host_syscall.h b/stand/kboot/host_syscall.h index 8007f29feb9..4a3ff3ea818 100644 --- a/stand/kboot/host_syscall.h +++ b/stand/kboot/host_syscall.h @@ -92,6 +92,7 @@ struct host_timeval { int host_close(int fd); int host_fstat(int fd, struct host_kstat *sb); int host_getdents(int fd, void *dirp, int count); +int host_getpid(void); int host_gettimeofday(struct host_timeval *a, void *b); int host_kexec_load(uint32_t start, int nsegs, uint32_t segs, uint32_t flags); ssize_t host_llseek(int fd, int32_t offset_high, int32_t offset_lo, uint64_t *result, int whence); diff --git a/stand/kboot/host_syscalls.c b/stand/kboot/host_syscalls.c index 3cfccdc0c71..a83bc3bbfe0 100644 --- a/stand/kboot/host_syscalls.c +++ b/stand/kboot/host_syscalls.c @@ -25,6 +25,12 @@ host_getdents(int fd, void *dirp, int count) return host_syscall(SYS_getdents, fd, (uintptr_t)dirp, count); } +int +host_getpid(void) +{ + return host_syscall(SYS_getpid); +} + int host_gettimeofday(struct host_timeval *a, void *b) {