mirror of
https://github.com/troglobit/finit.git
synced 2026-10-20 11:19:35 +00:00
Support for checking file systems from /etc/fstab
This patch adds support for running fsck on all file systems listed in /etc/fstab with a passno > 0. The fsck runs sequentially, starting with the root fs (passno 1). Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
501deae4ed
commit
d2a5e65862
5 files changed
+46
-8
No files matched your search
@@ -27,6 +27,7 @@
|
||||
#include <ctype.h>
|
||||
#include <glob.h>
|
||||
#include <dirent.h>
|
||||
#include <fstab.h>
|
||||
#include <mntent.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h> /* umask(), mkdir() */
|
||||
@@ -71,6 +72,40 @@ static int banner(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check all filesystems in /etc/fstab with a fs_passno > 0
|
||||
*/
|
||||
static int fsck(int pass)
|
||||
{
|
||||
struct fstab *fs;
|
||||
|
||||
if (!setfsent()) {
|
||||
_pe("Failed opening fstab");
|
||||
return 1;
|
||||
}
|
||||
|
||||
while ((fs = getfsent())) {
|
||||
char cmd[80];
|
||||
struct stat st;
|
||||
|
||||
if (fs->fs_passno < pass)
|
||||
continue;
|
||||
|
||||
errno = 0;
|
||||
if (stat(fs->fs_spec, &st) || !S_ISBLK(st.st_mode)) {
|
||||
_d("Cannot fsck %s, not a block device: %s", fs->fs_spec, strerror(errno));
|
||||
continue;
|
||||
}
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "/sbin/fsck -C -a %s", fs->fs_spec);
|
||||
run_interactive(cmd, "Checking file system %s", fs->fs_spec);
|
||||
}
|
||||
|
||||
endfsent();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void networking(void)
|
||||
{
|
||||
size_t i;
|
||||
@@ -231,6 +266,14 @@ int main(int argc, char* argv[])
|
||||
#endif
|
||||
run_interactive(SETUP_DEVFS, "Populating device tree");
|
||||
|
||||
/*
|
||||
* Check file filesystems in /etc/fstab
|
||||
*/
|
||||
for (int pass = 1; pass < 10; pass++) {
|
||||
if (fsck(pass))
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Load plugins first, finit.conf may contain references to
|
||||
* features implemented by plugins.
|
||||
|
||||
Reference in new issue
Block a user