init: fix trying mount devtmpfs into /dev
This commit is contained in:
parent
267ca6e7d1
commit
515053b74f
29
init.c
29
init.c
@ -79,7 +79,7 @@ static void fatal(const char *) __attribute__((noreturn));
|
|||||||
|
|
||||||
static void fatal(const char *msg)
|
static void fatal(const char *msg)
|
||||||
{
|
{
|
||||||
printf("FATAL ERROR IN INIT: %s\nI can't recover from this,"
|
printf("FATAL ERROR IN INIT: %s\nI can't recover from this, "
|
||||||
"please reboot manually and send bugreport.\n", msg);
|
"please reboot manually and send bugreport.\n", msg);
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
@ -371,22 +371,21 @@ int main(int argc, char **argv)
|
|||||||
if (mount("sysfs", "/sys", "sysfs", 0, NULL))
|
if (mount("sysfs", "/sys", "sysfs", 0, NULL))
|
||||||
fatal("failed to mount sysfs filesystem");
|
fatal("failed to mount sysfs filesystem");
|
||||||
|
|
||||||
if (statfs("/dev", &sfs))
|
if (stat("/", &rst))
|
||||||
fatal("statfs /dev");
|
fatal("stat /");
|
||||||
/* Don't mount /dev if it is already mounted as tmpfs */
|
|
||||||
if (sfs.f_type != TMPFS_MAGIC) {
|
/* Don't mount /dev if it is already mounted */
|
||||||
|
if (stat("/dev", &cst))
|
||||||
|
fatal("stat /dev");
|
||||||
|
if (rst.st_dev == cst.st_dev && rst.st_ino != cst.st_ino)
|
||||||
/* Try mount devtmpfs into /dev */
|
/* Try mount devtmpfs into /dev */
|
||||||
if (mount("udevfs", "/dev", "devtmpfs", 0, "size=10M,mode=0755")) {
|
if (mount("udevfs", "/dev", "devtmpfs", 0, "size=8M,mode=0755")) {
|
||||||
if (errno == ENODEV) {
|
if (errno != ENODEV)
|
||||||
/* There is no devtmpfs for current kernel,
|
|
||||||
* try mount tmpfs */
|
|
||||||
if (mount("udev", "/dev", "tmpfs", 0, "size=10M,mode=0755"))
|
|
||||||
fatal("failed to mount tmpfs filesystem");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
fatal("failed to mount devtmpfs filesystem");
|
fatal("failed to mount devtmpfs filesystem");
|
||||||
|
/* There is no devtmpfs for current kernel, try mount tmpfs */
|
||||||
|
if (mount("udev", "/dev", "tmpfs", 0, "size=8M,mode=0755"))
|
||||||
|
fatal("failed to mount tmpfs filesystem");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* ignore Control-C and keyboard stop signals */
|
/* ignore Control-C and keyboard stop signals */
|
||||||
sigemptyset(&sig);
|
sigemptyset(&sig);
|
||||||
@ -551,7 +550,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
/* Make sure the current directory is not on the same filesystem
|
/* Make sure the current directory is not on the same filesystem
|
||||||
as the root directory */
|
as the root directory */
|
||||||
if ( stat("/", &rst) || stat(".", &cst) )
|
if (stat(".", &cst))
|
||||||
fatal("stat");
|
fatal("stat");
|
||||||
|
|
||||||
if ( rst.st_dev == cst.st_dev )
|
if ( rst.st_dev == cst.st_dev )
|
||||||
|
Loading…
Reference in New Issue
Block a user