comparison toys/chroot.c @ 191:7f55c59f5122

Add chroot.
author Rob Landley <rob@landley.net>
date Mon, 03 Dec 2007 19:28:51 -0600
parents
children 0efba0e70c43
comparison
equal deleted inserted replaced
190:e864c5ed1d25 191:7f55c59f5122
1 /* vi: set sw=4 ts=4: */
2 /*
3 * chroot.c - Run command in new root directory.
4 */
5
6 #include "toys.h"
7
8 void chroot_main(void)
9 {
10 char *binsh[] = {"/bin/sh", 0};
11 if (chdir(*toys.optargs) || chroot("."))
12 perror_exit("%s", *toys.optargs);
13 xexec(toys.optargs[1] ? toys.optargs+1 : binsh);
14 }