mirror of
https://github.com/troglobit/finit.git
synced 2026-11-06 15:51:03 +00:00
Remount / as read-write as soon as possible (after fsck)
We may need to create directories early, e.g., /sys and directories in /var that plugins rely on. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
389328c99f
commit
2f87c10cf1
1 file changed
+37
-32
+37
-32
@@ -290,6 +290,7 @@ int main(int argc, char *argv[])
|
|||||||
uev_ctx_t loop;
|
uev_ctx_t loop;
|
||||||
char cmd[256];
|
char cmd[256];
|
||||||
char *path;
|
char *path;
|
||||||
|
int rc;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* finit/init/telinit client tool uses /dev/initctl pipe
|
* finit/init/telinit client tool uses /dev/initctl pipe
|
||||||
@@ -375,12 +376,48 @@ int main(int argc, char *argv[])
|
|||||||
/*
|
/*
|
||||||
* Check file filesystems in /etc/fstab
|
* Check file filesystems in /etc/fstab
|
||||||
*/
|
*/
|
||||||
|
rc = 0;
|
||||||
for (int pass = 1; pass < 10 && !rescue; pass++) {
|
for (int pass = 1; pass < 10 && !rescue; pass++) {
|
||||||
if (fsck(pass)) {
|
if (fsck(pass)) {
|
||||||
|
rc++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Mount filesystems
|
||||||
|
*/
|
||||||
|
if (!rescue) {
|
||||||
|
#ifndef SYSROOT
|
||||||
|
/*
|
||||||
|
* Remount / read-write if it exists in fstab is not 'ro'.
|
||||||
|
* This is what the Debian sysv initscripts does.
|
||||||
|
*/
|
||||||
|
if (setfsent()) {
|
||||||
|
struct fstab *fs;
|
||||||
|
|
||||||
|
while ((fs = getfsent())) {
|
||||||
|
if (strcmp(fs->fs_file, "/"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (strcmp(fs->fs_type, "ro")) {
|
||||||
|
if (!rc)
|
||||||
|
print(1, "Cannot remount / as read-write, fsck failed before");
|
||||||
|
else
|
||||||
|
run_interactive("mount -n -o remount,rw /", "Remounting / as read-write");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
endfsent();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
* XXX: Untested, in the initramfs age we should
|
||||||
|
* probably use switch_root instead.
|
||||||
|
*/
|
||||||
|
mount(SYSROOT, "/", NULL, MS_MOVE, NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -471,38 +508,6 @@ int main(int argc, char *argv[])
|
|||||||
if (which(FINIT_LIBPATH_ "/watchdogd"))
|
if (which(FINIT_LIBPATH_ "/watchdogd"))
|
||||||
service_register(SVC_TYPE_SERVICE, FINIT_LIBPATH_ "/watchdogd -- Finit watchdog daemon", global_rlimit, NULL);
|
service_register(SVC_TYPE_SERVICE, FINIT_LIBPATH_ "/watchdogd -- Finit watchdog daemon", global_rlimit, NULL);
|
||||||
|
|
||||||
/*
|
|
||||||
* Mount filesystems
|
|
||||||
*/
|
|
||||||
if (!rescue) {
|
|
||||||
#ifndef SYSROOT
|
|
||||||
/*
|
|
||||||
* Remount / read-write if it exists in fstab is not 'ro'.
|
|
||||||
* This is what the Debian sysv initscripts does.
|
|
||||||
*/
|
|
||||||
if (setfsent()) {
|
|
||||||
struct fstab *fs;
|
|
||||||
|
|
||||||
while ((fs = getfsent())) {
|
|
||||||
if (strcmp(fs->fs_file, "/"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (strcmp(fs->fs_type, "ro"))
|
|
||||||
run_interactive("mount -n -o remount,rw /", "Remounting / as read-write");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
endfsent();
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
/*
|
|
||||||
* XXX: Untested, in the initramfs age we should
|
|
||||||
* probably use switch_root instead.
|
|
||||||
*/
|
|
||||||
mount(SYSROOT, "/", NULL, MS_MOVE, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!rescue) {
|
if (!rescue) {
|
||||||
_d("Root FS up, calling hooks ...");
|
_d("Root FS up, calling hooks ...");
|
||||||
plugin_run_hooks(HOOK_ROOTFS_UP);
|
plugin_run_hooks(HOOK_ROOTFS_UP);
|
||||||
|
|||||||
Reference in new issue
Block a user