Skip to content

Commit 319e116

Browse files
andrea-adamimthuurne
authored andcommitted
syspart.c: klibc specific fix for pivot_root syscall
Compiling against klibc we invoke directly the syscall (generated into syscall stubs in their own files). See /usr/klibc/SYSCALLS.def Fixing: | syspart.c: In function 'switch_root': | syspart.c:26:2: warning: implicit declaration of function 'syscall' [-Wimplicit-function-declaration] | if (syscall(SYS_pivot_root, ".", "boot")) { | ^ | syspart.c:26:14: error: 'SYS_pivot_root' undeclared (first use in this function) | if (syscall(SYS_pivot_root, ".", "boot")) { | ^ Signed-off-by: Andrea Adami <[email protected]>
1 parent e7db5b6 commit 319e116

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

syspart.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33

44
#include <errno.h>
55
#include <stdlib.h>
6+
7+
#ifndef __KLIBC__
68
#include <sys/syscall.h>
9+
#else
10+
#include <sys/mount.h>
11+
#endif /* __KLIBC__ */
712
#include <unistd.h>
813

914
#include "debug.h"
@@ -23,7 +28,11 @@ int open_dir_to_clean(void)
2328
int switch_root(void)
2429
{
2530
DEBUG("Pivoting root\n");
31+
#ifndef __KLIBC__
2632
if (syscall(SYS_pivot_root, ".", "boot")) {
33+
#else
34+
if (pivot_root(".", "boot") < 0) {
35+
#endif /* __KLIBC__ */
2736
ERROR("Unable to pivot root: %d\n", errno);
2837
return -1;
2938
}

0 commit comments

Comments
 (0)