diff options
author | Rob Landley | 2006-03-20 01:43:29 +0000 |
---|---|---|
committer | Rob Landley | 2006-03-20 01:43:29 +0000 |
commit | e2b428cbb1fcbb71d56cdf6e5f640d11a2523c33 (patch) | |
tree | 5fbb2bc94d163222fcfb9b0a0de1507444a7d088 | |
parent | 99a072d5240a31ae414b4fc031fa5744a227d35f (diff) | |
download | busybox-e2b428cbb1fcbb71d56cdf6e5f640d11a2523c33.zip busybox-e2b428cbb1fcbb71d56cdf6e5f640d11a2523c33.tar.gz |
Use lstat() instead of stat so /init being a symlink doesn't screw people up.
(And use it consistently, for size reasons.)
-rw-r--r-- | util-linux/switch_root.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c index 1ba3740..e21838b 100644 --- a/util-linux/switch_root.c +++ b/util-linux/switch_root.c @@ -36,7 +36,7 @@ static void delete_contents(char *directory) struct stat st; // Don't descend into other filesystems - if (stat(directory,&st) || st.st_dev != rootdev) return; + if (lstat(directory,&st) || st.st_dev != rootdev) return; // Recursively delete the contents of directories. if (S_ISDIR(st.st_mode)) { @@ -79,7 +79,7 @@ int switch_root_main(int argc, char *argv[]) newroot=argv[optind++]; - if (chdir(newroot) || stat(".", &st1) || stat("/", &st2) || + if (chdir(newroot) || lstat(".", &st1) || lstat("/", &st2) || st1.st_dev == st2.st_dev) { bb_error_msg_and_die("bad newroot %s",newroot); @@ -90,7 +90,7 @@ int switch_root_main(int argc, char *argv[]) // we mean it. (I could make this a CONFIG option, but I would get email // from all the people who WILL eat their filesystemss.) - if (stat("/init", &st1) || !S_ISREG(st1.st_mode) || statfs("/", &stfs) || + if (lstat("/init", &st1) || !S_ISREG(st1.st_mode) || statfs("/", &stfs) || (stfs.f_type != RAMFS_MAGIC && stfs.f_type != TMPFS_MAGIC) || getpid() != 1) { |