view toys/chroot.c @ 233:d4176f3f3835

Zap toys/ and instead create generated/ from contents of toys/*.c. Move relevant info into comment at the top of each toys/*.c. Also convert more of Makefile into a thin wrapper around shell scripts that actually do the work. (Makefile is only still there for the user interface.)
author Rob Landley <>
date Sat, 19 Jan 2008 17:08:39 -0600
parents 0efba0e70c43
children 163498bf547b
line wrap: on
line source

/* vi: set sw=4 ts=4:
 * chroot.c - Run command in new root directory.
 * Copyright 2007 Rob Landley <>
 * Not in SUSv3.

config CHROOT
	bool "chroot"
	default y
	  usage: chroot NEWPATH [commandline...]

	  Run command within a new root directory.  If no command, run /bin/sh.

#include "toys.h"

void chroot_main(void)
	char *binsh[] = {"/bin/sh", "-i", 0};
	if (chdir(*toys.optargs) || chroot("."))
		perror_exit("%s", *toys.optargs);
	xexec(toys.optargs[1] ? toys.optargs+1 : binsh);