From 8e34ca64823183b94c5e1fdc632b311bafc5d9da Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 3 Dec 2007 19:28:51 -0600 Subject: Add chroot. --- toys/chroot.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 toys/chroot.c (limited to 'toys/chroot.c') 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); +} -- cgit v1.2.3