diff options
| author | Tim Riker <tim@rikers.org> | 2006-01-25 00:08:53 +0000 |
|---|---|---|
| committer | Tim Riker <tim@rikers.org> | 2006-01-25 00:08:53 +0000 |
| commit | c1ef7bdd8d002ae0889efcf883d0e1b7faa938d4 (patch) | |
| tree | 5f329b7d0c7f20ecced0dc7581a9ba6dc720d965 /util-linux/switch_root.c | |
| parent | f64ff682a3d58dbb627e760e6fe1ec21d9ccdf61 (diff) | |
| download | busybox-w32-c1ef7bdd8d002ae0889efcf883d0e1b7faa938d4.tar.gz busybox-w32-c1ef7bdd8d002ae0889efcf883d0e1b7faa938d4.tar.bz2 busybox-w32-c1ef7bdd8d002ae0889efcf883d0e1b7faa938d4.zip | |
just whitespace
Diffstat (limited to 'util-linux/switch_root.c')
| -rw-r--r-- | util-linux/switch_root.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c index 0c86eec08..bcc4443ab 100644 --- a/util-linux/switch_root.c +++ b/util-linux/switch_root.c | |||
| @@ -47,20 +47,20 @@ static void delete_contents(char *directory) | |||
| 47 | // Skip . and .. | 47 | // Skip . and .. |
| 48 | if(*newdir=='.' && (!newdir[1] || (newdir[1]=='.' && !newdir[2]))) | 48 | if(*newdir=='.' && (!newdir[1] || (newdir[1]=='.' && !newdir[2]))) |
| 49 | continue; | 49 | continue; |
| 50 | 50 | ||
| 51 | // Recurse to delete contents | 51 | // Recurse to delete contents |
| 52 | newdir = alloca(strlen(directory) + strlen(d->d_name) + 2); | 52 | newdir = alloca(strlen(directory) + strlen(d->d_name) + 2); |
| 53 | sprintf(newdir, "%s/%s", directory, d->d_name); | 53 | sprintf(newdir, "%s/%s", directory, d->d_name); |
| 54 | delete_contents(newdir); | 54 | delete_contents(newdir); |
| 55 | } | 55 | } |
| 56 | closedir(dir); | 56 | closedir(dir); |
| 57 | 57 | ||
| 58 | // Directory should now be empty. Zap it. | 58 | // Directory should now be empty. Zap it. |
| 59 | rmdir(directory); | 59 | rmdir(directory); |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | // It wasn't a directory. Zap it. | 62 | // It wasn't a directory. Zap it. |
| 63 | 63 | ||
| 64 | } else unlink(directory); | 64 | } else unlink(directory); |
| 65 | } | 65 | } |
| 66 | 66 | ||
| @@ -74,18 +74,18 @@ int switch_root_main(int argc, char *argv[]) | |||
| 74 | 74 | ||
| 75 | bb_opt_complementally="-2"; | 75 | bb_opt_complementally="-2"; |
| 76 | bb_getopt_ulflags(argc,argv,"c:",&console); | 76 | bb_getopt_ulflags(argc,argv,"c:",&console); |
| 77 | 77 | ||
| 78 | // Change to new root directory and verify it's a different fs. | 78 | // Change to new root directory and verify it's a different fs. |
| 79 | 79 | ||
| 80 | newroot=argv[optind++]; | 80 | newroot=argv[optind++]; |
| 81 | 81 | ||
| 82 | if (chdir(newroot) || stat(".", &st1) || stat("/", &st2) || | 82 | if (chdir(newroot) || stat(".", &st1) || stat("/", &st2) || |
| 83 | st1.st_dev == st2.st_dev) | 83 | st1.st_dev == st2.st_dev) |
| 84 | { | 84 | { |
| 85 | bb_error_msg_and_die("bad newroot %s",newroot); | 85 | bb_error_msg_and_die("bad newroot %s",newroot); |
| 86 | } | 86 | } |
| 87 | rootdev=st2.st_dev; | 87 | rootdev=st2.st_dev; |
| 88 | 88 | ||
| 89 | // Additional sanity checks: we're about to rm -rf /, so be REALLY SURE | 89 | // Additional sanity checks: we're about to rm -rf /, so be REALLY SURE |
| 90 | // we mean it. (I could make this a CONFIG option, but I would get email | 90 | // we mean it. (I could make this a CONFIG option, but I would get email |
| 91 | // from all the people who WILL eat their filesystemss.) | 91 | // from all the people who WILL eat their filesystemss.) |
| @@ -100,13 +100,13 @@ int switch_root_main(int argc, char *argv[]) | |||
| 100 | // Zap everything out of rootdev | 100 | // Zap everything out of rootdev |
| 101 | 101 | ||
| 102 | delete_contents("/"); | 102 | delete_contents("/"); |
| 103 | 103 | ||
| 104 | // Overmount / with newdir and chroot into it. The chdir is needed to | 104 | // Overmount / with newdir and chroot into it. The chdir is needed to |
| 105 | // recalculate "." and ".." links. | 105 | // recalculate "." and ".." links. |
| 106 | 106 | ||
| 107 | if (mount(".", "/", NULL, MS_MOVE, NULL) || chroot(".") || chdir("/")) | 107 | if (mount(".", "/", NULL, MS_MOVE, NULL) || chroot(".") || chdir("/")) |
| 108 | bb_error_msg_and_die("moving root"); | 108 | bb_error_msg_and_die("moving root"); |
| 109 | 109 | ||
| 110 | // If a new console specified, redirect stdin/stdout/stderr to that. | 110 | // If a new console specified, redirect stdin/stdout/stderr to that. |
| 111 | 111 | ||
| 112 | if (console) { | 112 | if (console) { |
