blob: 4d7f8a3d10da4841fe4faa77422d0f61a3b83ba0 [file] [log] [blame]
Eric Andersen6fd8c662001-02-13 20:04:30 +00001/* vi: set sw=4 ts=4: */
2/*
3 * pivot_root.c - Change root file system. Based on util-linux 2.10s
4 *
5 * busyboxed by Evin Robertson
Eric Andersend160a272001-02-24 19:17:07 +00006 * pivot_root syscall stubbed by Erik Andersen, so it will compile
7 * regardless of the kernel being used.
Eric Andersen6fd8c662001-02-13 20:04:30 +00008 */
Eric Andersen6fd8c662001-02-13 20:04:30 +00009#include <stdlib.h>
10#include <stdio.h>
Eric Andersend160a272001-02-24 19:17:07 +000011#include <errno.h>
Eric Andersen6fd8c662001-02-13 20:04:30 +000012#include <sys/syscall.h>
13#include <linux/unistd.h>
Eric Andersencbe31da2001-02-20 06:14:08 +000014#include "busybox.h"
Eric Andersen6fd8c662001-02-13 20:04:30 +000015
16#ifndef __NR_pivot_root
Eric Andersen0ed99232001-02-23 02:31:03 +000017#warning This kernel does not support the pivot_root syscall
Eric Andersend160a272001-02-24 19:17:07 +000018#warning The pivot_root system call is being stubbed out...
19int pivot_root(const char * new_root,const char * put_old)
Eric Andersen0ed99232001-02-23 02:31:03 +000020{
Eric Andersend160a272001-02-24 19:17:07 +000021 /* BusyBox was compiled against a kernel that did not support
22 * the pivot_root system call. To make this application work,
23 * you will need to recompile with a kernel supporting the
24 * pivot_root system call.
25 */
26 fprintf(stderr, "\n\nTo make this application work, you will need to recompile\n");
27 fprintf(stderr, "with a kernel supporting the pivot_root system call. -Erik\n\n");
28 errno=ENOSYS;
29 return -1;
Eric Andersen0ed99232001-02-23 02:31:03 +000030}
31#else
Eric Andersen6fd8c662001-02-13 20:04:30 +000032static _syscall2(int,pivot_root,const char *,new_root,const char *,put_old)
Eric Andersend160a272001-02-24 19:17:07 +000033#endif
34
Eric Andersen6fd8c662001-02-13 20:04:30 +000035
36
37int pivot_root_main(int argc, char **argv)
38{
39 if (argc != 3)
Eric Andersen67991cf2001-02-14 21:23:06 +000040 show_usage();
Eric Andersen6fd8c662001-02-13 20:04:30 +000041
Eric Andersend160a272001-02-24 19:17:07 +000042 if (pivot_root(argv[1],argv[2]) < 0)
43 perror_msg_and_die("pivot_root");
Eric Andersen6fd8c662001-02-13 20:04:30 +000044
45 return EXIT_SUCCESS;
46
47}
Eric Andersen6fd8c662001-02-13 20:04:30 +000048
49
50/*
51Local Variables:
52c-file-style: "linux"
53c-basic-offset: 4
54tab-width: 4
55End:
56*/