pivot_root.c (682B)
1 /* see LICENSE file for copyright and license details */ 2 3 #if FEATURE_LINUX_SYSCALL 4 #ifndef _GNU_SOURCE 5 #define _GNU_SOURCE 6 #endif 7 #endif 8 #include <sys/syscall.h> 9 10 #include <stdio.h> 11 #include <stdlib.h> 12 #include <unistd.h> 13 14 #include "util.h" 15 16 static void 17 usage(void) 18 { 19 eprintf("usage: %s new-root put-old\n", argv0); 20 } 21 22 // ?man pivot_root: change the root filesystem 23 // ?man arguments: new-root put-old 24 // ?man change the root filesystem of the current process 25 int 26 main(int argc, char *argv[]) 27 { 28 ARGBEGIN 29 { 30 default: 31 usage(); 32 } 33 ARGEND; 34 35 if (argc < 2) 36 usage(); 37 38 if (syscall(SYS_pivot_root, argv[0], argv[1]) < 0) 39 eprintf("pivot_root:"); 40 41 return 0; 42 }