diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-12-15 03:55:55 +0300 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-12-15 03:55:55 +0300 |
commit | cb37637b47d56726856ab8801ee6fdd049ad16eb (patch) | |
tree | 174c2d5a3e95f0aa42ea2133c06947c93c5c9114 /util-linux | |
parent | 4e60f304d4525b37344a141bf28b46456dbf6203 (diff) |
switch_root: more clear error messages
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux')
-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) // Additional sanity checks: we're about to rm -rf /, so be REALLY SURE // we mean it. I could make this a CONFIG option, but I would get email // from all the people who WILL destroy their filesystems. + if (stat("/init", &st) != 0 || !S_ISREG(st.st_mode)) { + bb_error_msg_and_die("/init is not a regular file"); + } statfs("/", &stfs); // this never fails - if (stat("/init", &st) != 0 || !S_ISREG(st.st_mode) - || ((unsigned)stfs.f_type != RAMFS_MAGIC - && (unsigned)stfs.f_type != TMPFS_MAGIC) + if ((unsigned)stfs.f_type != RAMFS_MAGIC + && (unsigned)stfs.f_type != TMPFS_MAGIC ) { - bb_error_msg_and_die("not rootfs"); + bb_error_msg_and_die("root filesystem is not ramfs/tmpfs"); } // Zap everything out of rootdev |