view toys/other/chroot.c @ 694:786841fdb1e0

Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style. The actual code should be the same afterward, this is just cosmetic refactoring.
author Rob Landley <>
date Tue, 13 Nov 2012 17:14:08 -0600
parents 6df4ccc0acbe
children 144d5ba7d410
line wrap: on
line source

/* chroot.c - Run command in new root directory.
 * Copyright 2007 Rob Landley <>


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);