aboutsummaryrefslogtreecommitdiff
path: root/coreutils/chroot.c
diff options
context:
space:
mode:
authorerik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-02-08 19:58:47 +0000
committererik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-02-08 19:58:47 +0000
commita18125005d67c38a8ad7fb454571bb996664ad96 (patch)
treec90bda10731ad9333ce3b404f993354c9fc104b8 /coreutils/chroot.c
parent8ef3b44285a8ce5b83bed9cf32ce5f40b30ba72f (diff)
downloadbusybox-w32-a18125005d67c38a8ad7fb454571bb996664ad96.tar.gz
busybox-w32-a18125005d67c38a8ad7fb454571bb996664ad96.tar.bz2
busybox-w32-a18125005d67c38a8ad7fb454571bb996664ad96.zip
Some formatting updates (ran the code through indent)
-Erik git-svn-id: svn://busybox.net/trunk/busybox@357 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'coreutils/chroot.c')
-rw-r--r--coreutils/chroot.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/coreutils/chroot.c b/coreutils/chroot.c
index 16524d92e..6a01be603 100644
--- a/coreutils/chroot.c
+++ b/coreutils/chroot.c
@@ -1,3 +1,4 @@
1/* vi: set sw=4 ts=4: */
1/* 2/*
2 * Mini chroot implementation for busybox 3 * Mini chroot implementation for busybox
3 * 4 *
@@ -28,39 +29,39 @@
28 29
29 30
30static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n\n" 31static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n\n"
31"Run COMMAND with root directory set to NEWROOT.\n"; 32
33 "Run COMMAND with root directory set to NEWROOT.\n";
32 34
33 35
34 36
35int chroot_main(int argc, char **argv) 37int chroot_main(int argc, char **argv)
36{ 38{
37 if ( (argc < 2) || (**(argv+1) == '-') ) { 39 if ((argc < 2) || (**(argv + 1) == '-')) {
38 usage( chroot_usage); 40 usage(chroot_usage);
39 } 41 }
40 argc--; 42 argc--;
41 argv++; 43 argv++;
42 44
43 if (chroot (*argv) || (chdir ("/"))) { 45 if (chroot(*argv) || (chdir("/"))) {
44 fprintf(stderr, "chroot: cannot change root directory to %s: %s\n", 46 fprintf(stderr, "chroot: cannot change root directory to %s: %s\n",
45 *argv, strerror(errno)); 47 *argv, strerror(errno));
46 exit( FALSE); 48 exit(FALSE);
47 } 49 }
48 50
49 argc--; 51 argc--;
50 argv++; 52 argv++;
51 if (argc >= 1) { 53 if (argc >= 1) {
52 fprintf(stderr, "command: %s\n", *argv); 54 fprintf(stderr, "command: %s\n", *argv);
53 execvp (*argv, argv); 55 execvp(*argv, argv);
54 } 56 } else {
55 else { 57 char *prog;
56 char *prog;
57 prog = getenv ("SHELL");
58 if (!prog)
59 prog = "/bin/sh";
60 execlp (prog, prog, NULL);
61 }
62 fprintf(stderr, "chroot: cannot execute %s: %s\n",
63 *argv, strerror(errno));
64 exit( FALSE);
65}
66 58
59 prog = getenv("SHELL");
60 if (!prog)
61 prog = "/bin/sh";
62 execlp(prog, prog, NULL);
63 }
64 fprintf(stderr, "chroot: cannot execute %s: %s\n",
65 *argv, strerror(errno));
66 exit(FALSE);
67}