diff options
author | Rob Landley <rob@landley.net> | 2007-12-03 19:28:51 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2007-12-03 19:28:51 -0600 |
commit | 8e34ca64823183b94c5e1fdc632b311bafc5d9da (patch) | |
tree | c59abeeef90bb1d7e6d705ad4c1753d147979917 /toys/chroot.c | |
parent | f76040136405d824fa8c2c47f7643c31f52bff93 (diff) | |
download | toybox-8e34ca64823183b94c5e1fdc632b311bafc5d9da.tar.gz |
Add chroot.
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); +} |