kboot: Implement mount(2)

Create a wrapper for the mount system call. To ensure a sane early boot
environment and to gather data we need for kexec, we may need to mount
some special filesystems.

Sponsored by:		Netflix
This commit is contained in:
Warner Losh 2022-06-30 12:16:46 -06:00
parent a99d47bcaa
commit 8138a766b0
4 changed files with 14 additions and 0 deletions

View File

@ -7,6 +7,7 @@
#define SYS_lseek 8
#define SYS_mkdirat 258
#define SYS_mmap 9
#define SYS_mount 165
#define SYS_munmap 11
#define SYS_newfstat 5
#define SYS_newfstatat 262

View File

@ -8,6 +8,7 @@
#define SYS_llseek 140
#define SYS_mkdirat 287
#define SYS_mmap 90
#define SYS_mount 21
#define SYS_munmap 91
#define SYS_newfstat SYS_fstat
#define SYS_newfstatat 291

View File

@ -88,6 +88,9 @@ struct host_timeval {
#define HOST_AT_FDCWD -100 /* Relative to current directory */
/* Mount flags from uapi */
#define MS_RELATIME (1 << 21)
/*
* System Calls
*/
@ -101,6 +104,8 @@ 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_mount(const char *src, const char *target, const char *type,
unsigned long flags, void *data);
int host_munmap(void *addr, size_t len);
int host_open(const char *path, int flags, int mode);
ssize_t host_read(int fd, void *buf, size_t nbyte);

View File

@ -75,6 +75,13 @@ host_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t off)
return (void *)host_syscall(SYS_mmap, (uintptr_t)addr, len, prot, flags, fd, off);
}
int
host_mount(const char *src, const char *target, const char *type, unsigned long flags,
void *data)
{
return host_syscall(SYS_mount, src, target, type, flags, data);
}
int
host_munmap(void *addr, size_t len)
{