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