mirror of
https://github.com/troglobit/finit.git
synced 2026-10-30 12:50:34 +00:00
finit.c: Mount /proc and /sys before fsck()
For issue #64 we need to have /proc/mounts, or /etc/mtab but that's usually symlinked to /proc/mounts. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
750712d28d
commit
33ae64495a
1 file changed
+30
-30
+30
-30
@@ -77,6 +77,28 @@ static int banner(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Requires /proc to be mounted */
|
||||||
|
static int fismnt(char *dir)
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
int found = 0;
|
||||||
|
struct mntent *mnt;
|
||||||
|
|
||||||
|
fp = setmntent("/proc/mounts", "r");
|
||||||
|
if (!fp)
|
||||||
|
return 0; /* Dunno, maybe not */
|
||||||
|
|
||||||
|
while ((mnt = getmntent(fp))) {
|
||||||
|
if (!strcmp(mnt->mnt_dir, dir)) {
|
||||||
|
found = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
endmntent(fp);
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check all filesystems in /etc/fstab with a fs_passno > 0
|
* Check all filesystems in /etc/fstab with a fs_passno > 0
|
||||||
*/
|
*/
|
||||||
@@ -164,28 +186,6 @@ static void networking(void)
|
|||||||
ifconfig("lo", "127.0.0.1", "255.0.0.0", 1);
|
ifconfig("lo", "127.0.0.1", "255.0.0.0", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Requires /proc to be mounted */
|
|
||||||
static int fismnt(char *dir)
|
|
||||||
{
|
|
||||||
FILE *fp;
|
|
||||||
int found = 0;
|
|
||||||
struct mntent *mnt;
|
|
||||||
|
|
||||||
fp = setmntent("/proc/mounts", "r");
|
|
||||||
if (!fp)
|
|
||||||
return 0; /* Dunno, maybe not */
|
|
||||||
|
|
||||||
while ((mnt = getmntent(fp))) {
|
|
||||||
if (!strcmp(mnt->mnt_dir, dir)) {
|
|
||||||
found = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
endmntent(fp);
|
|
||||||
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If everything goes south we can use this to give the operator an
|
* If everything goes south we can use this to give the operator an
|
||||||
* emergency shell to debug the problem -- Finit should not crash!
|
* emergency shell to debug the problem -- Finit should not crash!
|
||||||
@@ -246,14 +246,6 @@ int main(int argc, char* argv[])
|
|||||||
uev_init(&loop);
|
uev_init(&loop);
|
||||||
ctx = &loop;
|
ctx = &loop;
|
||||||
|
|
||||||
/*
|
|
||||||
* Check file filesystems in /etc/fstab
|
|
||||||
*/
|
|
||||||
for (int pass = 1; pass < 10; pass++) {
|
|
||||||
if (fsck(pass))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mount base file system, kernel is assumed to run devtmpfs for /dev
|
* Mount base file system, kernel is assumed to run devtmpfs for /dev
|
||||||
*/
|
*/
|
||||||
@@ -263,6 +255,14 @@ int main(int argc, char* argv[])
|
|||||||
mount("none", "/proc/bus/usb", "usbfs", 0, NULL);
|
mount("none", "/proc/bus/usb", "usbfs", 0, NULL);
|
||||||
mount("none", "/sys", "sysfs", 0, NULL);
|
mount("none", "/sys", "sysfs", 0, NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check file filesystems in /etc/fstab
|
||||||
|
*/
|
||||||
|
for (int pass = 1; pass < 10; pass++) {
|
||||||
|
if (fsck(pass))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some non-embedded systems without an initramfs may not have /dev mounted yet
|
* Some non-embedded systems without an initramfs may not have /dev mounted yet
|
||||||
* If they do, check if system has udevadm and perform cleanup from initramfs
|
* If they do, check if system has udevadm and perform cleanup from initramfs
|
||||||
|
|||||||
Reference in new issue
Block a user