aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2022-06-30 18:09:26 +0000
committerWarner Losh <imp@FreeBSD.org>2023-01-24 21:49:24 +0000
commit6632ac6d8a842336cb032f53ad98061353708a48 (patch)
tree750f484a1f3202a1ad4432309dbcad9c801b138f
parent96ea167ec8d66974f510ea2514f1e77d4484cf34 (diff)
downloadsrc-6632ac6d8a842336cb032f53ad98061353708a48.tar.gz
src-6632ac6d8a842336cb032f53ad98061353708a48.zip
kboot: Implement mkdir(2)
mkdir() may be needed early in boot to create missing directories. Provide a syscall wrapper for it. Sponsored by: Netflix (cherry picked from commit a99d47bcaaf61eb869f5f04fa51fe38b19504ac4)
-rw-r--r--stand/kboot/arch/amd64/syscall_nr.h1
-rw-r--r--stand/kboot/arch/powerpc64/syscall_nr.h1
-rw-r--r--stand/kboot/host_syscall.h1
-rw-r--r--stand/kboot/host_syscalls.c6
4 files changed, 9 insertions, 0 deletions
diff --git a/stand/kboot/arch/amd64/syscall_nr.h b/stand/kboot/arch/amd64/syscall_nr.h
index 62deefe73539..b847b21efa88 100644
--- a/stand/kboot/arch/amd64/syscall_nr.h
+++ b/stand/kboot/arch/amd64/syscall_nr.h
@@ -5,6 +5,7 @@
#define SYS_gettimeofday 96
#define SYS_kexec_load 246
#define SYS_lseek 8
+#define SYS_mkdirat 258
#define SYS_mmap 9
#define SYS_munmap 11
#define SYS_newfstat 5
diff --git a/stand/kboot/arch/powerpc64/syscall_nr.h b/stand/kboot/arch/powerpc64/syscall_nr.h
index d6678d9044d9..b86874b92e76 100644
--- a/stand/kboot/arch/powerpc64/syscall_nr.h
+++ b/stand/kboot/arch/powerpc64/syscall_nr.h
@@ -6,6 +6,7 @@
#define SYS_gettimeofday 78
#define SYS_kexec_load 268
#define SYS_llseek 140
+#define SYS_mkdirat 287
#define SYS_mmap 90
#define SYS_munmap 91
#define SYS_newfstat SYS_fstat
diff --git a/stand/kboot/host_syscall.h b/stand/kboot/host_syscall.h
index 10d4166514b9..76a5efb0a091 100644
--- a/stand/kboot/host_syscall.h
+++ b/stand/kboot/host_syscall.h
@@ -99,6 +99,7 @@ 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);
+int host_mkdir(const char *, host_mode_t);
void *host_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t off);
int host_munmap(void *addr, size_t len);
int host_open(const char *path, int flags, int mode);
diff --git a/stand/kboot/host_syscalls.c b/stand/kboot/host_syscalls.c
index 2fe4c599df82..99f5444eb469 100644
--- a/stand/kboot/host_syscalls.c
+++ b/stand/kboot/host_syscalls.c
@@ -63,6 +63,12 @@ host_llseek(int fd, int32_t offset_high, int32_t offset_lo, uint64_t *result, in
#endif
}
+int
+host_mkdir(const char *path, host_mode_t mode)
+{
+ return host_syscall(SYS_mkdirat, HOST_AT_FDCWD, (uintptr_t)path, mode);
+}
+
void *
host_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t off)
{