svn commit: trunk/busybox/util-linux

landley at busybox.net landley at busybox.net
Mon Mar 20 01:43:31 UTC 2006


Author: landley
Date: 2006-03-19 17:43:29 -0800 (Sun, 19 Mar 2006)
New Revision: 14577

Log:
Use lstat() instead of stat so /init being a symlink doesn't screw people up.
(And use it consistently, for size reasons.)


Modified:
   trunk/busybox/util-linux/switch_root.c


Changeset:
Modified: trunk/busybox/util-linux/switch_root.c
===================================================================
--- trunk/busybox/util-linux/switch_root.c	2006-03-19 21:18:45 UTC (rev 14576)
+++ trunk/busybox/util-linux/switch_root.c	2006-03-20 01:43:29 UTC (rev 14577)
@@ -36,7 +36,7 @@
 	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 @@
 
 	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 @@
 	// 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)
 	{




More information about the busybox-cvs mailing list