mirror of
https://github.com/troglobit/finit.git
synced 2026-10-21 11:29:42 +00:00
Allow fsck for read-only mounted filesystems
When starting up a system booted from initramfs / may already be mounted (read-only), so we can safely fsck it before proceeding to remount it as read-write later (possibly). Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
e3884597a5
commit
389328c99f
3 files changed
+33
-11
No files matched your search
+24
-5
@@ -429,12 +429,28 @@ void endfsent(void)
|
||||
}
|
||||
#endif /* HAVE_GETFSENT */
|
||||
|
||||
static int hasopt(char *opts, char *opt)
|
||||
{
|
||||
char buf[strlen(opts) + 1];
|
||||
char *ptr;
|
||||
|
||||
int ismnt(char *file, char *dir)
|
||||
memcpy(buf, opts, sizeof(buf));
|
||||
ptr = strtok(buf, ",");
|
||||
while (ptr) {
|
||||
if (!strcmp(ptr, opt))
|
||||
return 1;
|
||||
|
||||
ptr = strtok(NULL, ",");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ismnt(char *file, char *dir, char *mode)
|
||||
{
|
||||
FILE *fp;
|
||||
int found = 0;
|
||||
struct mntent *mnt;
|
||||
int found = 0;
|
||||
FILE *fp;
|
||||
|
||||
fp = setmntent(file, "r");
|
||||
if (!fp)
|
||||
@@ -442,7 +458,10 @@ int ismnt(char *file, char *dir)
|
||||
|
||||
while ((mnt = getmntent(fp))) {
|
||||
if (!strcmp(mnt->mnt_dir, dir)) {
|
||||
found = 1;
|
||||
if (mode && hasopt(mnt->mnt_opts, mode))
|
||||
found = 1;
|
||||
else
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -454,7 +473,7 @@ int ismnt(char *file, char *dir)
|
||||
/* Requires /proc to be mounted */
|
||||
int fismnt(char *dir)
|
||||
{
|
||||
return ismnt("/proc/mounts", dir);
|
||||
return ismnt("/proc/mounts", dir, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user