Date: Fri, 15 Jul 2022 18:04:01 GMT From: Warner Losh <imp@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: bc84de741dfd - main - kboot: Implement dup(2) Message-ID: <202207151804.26FI414D060286@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=bc84de741dfd3b81cc7d332f8e6f0d84afe4eee1 commit bc84de741dfd3b81cc7d332f8e6f0d84afe4eee1 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2022-06-30 18:25:49 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2022-07-15 18:00:50 +0000 kboot: Implement dup(2) Early in boot, we need to create the normal stdin/out/err env for the boot loader to run in. To do that, we need to open the console and duplicate the file descriptors which requires dup(2). Implement a wrapper as host_dup. 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 756b3e93af9a..62deefe73539 100644 --- a/stand/kboot/arch/amd64/syscall_nr.h +++ b/stand/kboot/arch/amd64/syscall_nr.h @@ -1,4 +1,5 @@ #define SYS_close 3 +#define SYS_dup 32 #define SYS_getdents 78 #define SYS_getpid 39 #define SYS_gettimeofday 96 diff --git a/stand/kboot/arch/powerpc64/syscall_nr.h b/stand/kboot/arch/powerpc64/syscall_nr.h index 13f26d80f6a3..d6678d9044d9 100644 --- a/stand/kboot/arch/powerpc64/syscall_nr.h +++ b/stand/kboot/arch/powerpc64/syscall_nr.h @@ -1,4 +1,5 @@ #define SYS_close 6 +#define SYS_dup 41 #define SYS_fstat 108 #define SYS_getdents 141 #define SYS_getpid 20 diff --git a/stand/kboot/host_syscall.h b/stand/kboot/host_syscall.h index 3b02f2e78304..10d4166514b9 100644 --- a/stand/kboot/host_syscall.h +++ b/stand/kboot/host_syscall.h @@ -92,6 +92,7 @@ struct host_timeval { * System Calls */ int host_close(int fd); +int host_dup(int fd); int host_fstat(int fd, struct host_kstat *sb); int host_getdents(int fd, void *dirp, int count); int host_getpid(void); diff --git a/stand/kboot/host_syscalls.c b/stand/kboot/host_syscalls.c index a69937a5a0e1..2fe4c599df82 100644 --- a/stand/kboot/host_syscalls.c +++ b/stand/kboot/host_syscalls.c @@ -13,6 +13,12 @@ host_close(int fd) return host_syscall(SYS_close, fd); } +int +host_dup(int fd) +{ + return host_syscall(SYS_dup, fd); +} + int host_fstat(int fd, struct host_kstat *sb) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202207151804.26FI414D060286>