diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-12-15 01:55:55 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-12-15 01:55:55 +0100 |
commit | cb37637b47d56726856ab8801ee6fdd049ad16eb (patch) | |
tree | 174c2d5a3e95f0aa42ea2133c06947c93c5c9114 /util-linux/switch_root.c | |
parent | 4e60f304d4525b37344a141bf28b46456dbf6203 (diff) | |
download | busybox-w32-cb37637b47d56726856ab8801ee6fdd049ad16eb.tar.gz busybox-w32-cb37637b47d56726856ab8801ee6fdd049ad16eb.tar.bz2 busybox-w32-cb37637b47d56726856ab8801ee6fdd049ad16eb.zip |
switch_root: more clear error messages
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux/switch_root.c')
-rw-r--r-- | util-linux/switch_root.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c index ff0551843..e2da119de 100644 --- a/util-linux/switch_root.c +++ b/util-linux/switch_root.c | |||
@@ -85,12 +85,14 @@ int switch_root_main(int argc UNUSED_PARAM, char **argv) | |||
85 | // Additional sanity checks: we're about to rm -rf /, so be REALLY SURE | 85 | // Additional sanity checks: we're about to rm -rf /, so be REALLY SURE |
86 | // we mean it. I could make this a CONFIG option, but I would get email | 86 | // we mean it. I could make this a CONFIG option, but I would get email |
87 | // from all the people who WILL destroy their filesystems. | 87 | // from all the people who WILL destroy their filesystems. |
88 | if (stat("/init", &st) != 0 || !S_ISREG(st.st_mode)) { | ||
89 | bb_error_msg_and_die("/init is not a regular file"); | ||
90 | } | ||
88 | statfs("/", &stfs); // this never fails | 91 | statfs("/", &stfs); // this never fails |
89 | if (stat("/init", &st) != 0 || !S_ISREG(st.st_mode) | 92 | if ((unsigned)stfs.f_type != RAMFS_MAGIC |
90 | || ((unsigned)stfs.f_type != RAMFS_MAGIC | 93 | && (unsigned)stfs.f_type != TMPFS_MAGIC |
91 | && (unsigned)stfs.f_type != TMPFS_MAGIC) | ||
92 | ) { | 94 | ) { |
93 | bb_error_msg_and_die("not rootfs"); | 95 | bb_error_msg_and_die("root filesystem is not ramfs/tmpfs"); |
94 | } | 96 | } |
95 | 97 | ||
96 | // Zap everything out of rootdev | 98 | // Zap everything out of rootdev |