kboot: Implement symlink(2)

Linux's /dev/fd is implemented inside of /proc/self/fd, so we may need
to create a symlink to it early in boot. "/dev/fd" and "/dev/std*" might
not be strictly required for the boot loader, but should be present for
maximum flexibility.

Sponsored by:		Netflix
This commit is contained in:
Warner Losh 2022-06-30 12:22:33 -06:00
parent 764780294f
commit a4ed0eb1aa
4 changed files with 11 additions and 0 deletions

View File

@ -12,6 +12,7 @@
#define SYS_pselect6 270
#define SYS_read 0
#define SYS_reboot 169
#define SYS_symlinkat 266
#define SYS_uname 63
#define SYS_write 1

View File

@ -13,6 +13,7 @@
#define SYS_pselect6 280
#define SYS_read 3
#define SYS_reboot 88
#define SYS_symlinkat 295
#define SYS_uname 120
#define SYS_write 4

View File

@ -68,6 +68,8 @@ typedef int64_t host_blkcnt_t;
#define HOST_O_APPEND 02000
#define HOST_O_NONBLOCK 04000
#define HOST_AT_FDCWD -100 /* Relative to current directory */
/*
* Data types
*/
@ -104,6 +106,7 @@ int host_reboot(int, int, int, uintptr_t);
int host_select(int nfds, long *readfds, long *writefds, long *exceptfds,
struct host_timeval *timeout);
int host_stat(const char *path, struct host_kstat *sb);
int host_symlink(const char *path1, const char *path2);
int host_uname(struct old_utsname *);
ssize_t host_write(int fd, const void *buf, size_t nbyte);

View File

@ -110,6 +110,12 @@ host_stat(const char *path, struct host_kstat *sb)
return host_syscall(SYS_newfstatat, HOST_AT_FDCWD, (uintptr_t)path, (uintptr_t)sb, 0);
}
int
host_symlink(const char *path1, const char *path2)
{
return host_syscall(SYS_symlinkat, HOST_AT_FDCWD, path1, path2);
}
int
host_uname(struct old_utsname *uts)
{