← Commit list

e2b428cbb

Rob Landley
Rob Landley
2006-03-20
SOURCE BUG Duration: 31s

Subject

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

SOURCE BUG

This commit was genuinely broken at the time (not related to our build system): scripts/config/mkconfigs.c (2005-08-01 - 2006-10-05 arasi) uretilen bbconfigopts.h icine .config satirlarini kacissiz, ham newline'larla gömüyordu - gecerli C degildi, busybox'un kendi bb_mkdep araci bile parse edemiyordu (7d219aab7 ile duzeltildi, mkconfigs shell scripte cevrildi)

→ Bu hatanin tam hikayesini ve duzeltme diffini gor

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

util-linux/switch_root.c+3 -3
@@ -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)
{