diff options
Diffstat (limited to 'toys/chroot.c')
-rw-r--r-- | toys/chroot.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/toys/chroot.c b/toys/chroot.c new file mode 100644 index 00000000..0126d968 --- /dev/null +++ b/toys/chroot.c @@ -0,0 +1,14 @@ +/* vi: set sw=4 ts=4: */ +/* + * chroot.c - Run command in new root directory. + */ + +#include "toys.h" + +void chroot_main(void) +{ + char *binsh[] = {"/bin/sh", 0}; + if (chdir(*toys.optargs) || chroot(".")) + perror_exit("%s", *toys.optargs); + xexec(toys.optargs[1] ? toys.optargs+1 : binsh); +} |