diff options
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 |
