summaryrefslogtreecommitdiff
path: root/util-linux/switch_root.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-03-20 01:43:29 +0000
committerRob Landley <rob@landley.net>2006-03-20 01:43:29 +0000
commite2b428cbb1fcbb71d56cdf6e5f640d11a2523c33 (patch)
tree5fbb2bc94d163222fcfb9b0a0de1507444a7d088 /util-linux/switch_root.c
parent99a072d5240a31ae414b4fc031fa5744a227d35f (diff)
downloadbusybox-w32-e2b428cbb1fcbb71d56cdf6e5f640d11a2523c33.tar.gz
busybox-w32-e2b428cbb1fcbb71d56cdf6e5f640d11a2523c33.tar.bz2
busybox-w32-e2b428cbb1fcbb71d56cdf6e5f640d11a2523c33.zip
Use lstat() instead of stat so /init being a symlink doesn't screw people up.
(And use it consistently, for size reasons.)
Diffstat (limited to 'util-linux/switch_root.c')
-rw-r--r--util-linux/switch_root.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c
index 1ba374076..e21838b65 100644
--- a/util-linux/switch_root.c
+++ b/util-linux/switch_root.c
@@ -36,7 +36,7 @@ static void delete_contents(char *directory)
36 struct stat st; 36 struct stat st;
37 37
38 // Don't descend into other filesystems 38 // Don't descend into other filesystems
39 if (stat(directory,&st) || st.st_dev != rootdev) return; 39 if (lstat(directory,&st) || st.st_dev != rootdev) return;
40 40
41 // Recursively delete the contents of directories. 41 // Recursively delete the contents of directories.
42 if (S_ISDIR(st.st_mode)) { 42 if (S_ISDIR(st.st_mode)) {
@@ -79,7 +79,7 @@ int switch_root_main(int argc, char *argv[])
79 79
80 newroot=argv[optind++]; 80 newroot=argv[optind++];
81 81
82 if (chdir(newroot) || stat(".", &st1) || stat("/", &st2) || 82 if (chdir(newroot) || lstat(".", &st1) || lstat("/", &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);
@@ -90,7 +90,7 @@ int switch_root_main(int argc, char *argv[])
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.)
92 92
93 if (stat("/init", &st1) || !S_ISREG(st1.st_mode) || statfs("/", &stfs) || 93 if (lstat("/init", &st1) || !S_ISREG(st1.st_mode) || statfs("/", &stfs) ||
94 (stfs.f_type != RAMFS_MAGIC && stfs.f_type != TMPFS_MAGIC) || 94 (stfs.f_type != RAMFS_MAGIC && stfs.f_type != TMPFS_MAGIC) ||
95 getpid() != 1) 95 getpid() != 1)
96 { 96 {