analog to mount gracefully ignoring non existing devices if the "nofail"
option is specified in fstab, also have fsck -A skip them. This way it's
possible to have devices optionally not available during boot but still
have them fsck'd if they are there.
Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
return (cmp->negate ? !ret : ret);
}
+/*
+ * Check if a device exists
+ */
+static int device_exists(const char *device)
+{
+ struct stat st;
+
+ if (stat(device, &st) == -1)
+ return 0;
+
+ if (!S_ISBLK(st.st_mode))
+ return 0;
+
+ return 1;
+}
+
/* Check if we should ignore this filesystem. */
static int ignore(struct fs_info *fs)
{
return 1;
}
+ /*
+ * ignore devices that don't exist and have the "nofail" mount option
+ */
+ if (!device_exists(fs->device) && opt_in_list("nofail", fs->opts)) {
+ if (verbose)
+ printf(_("%s: skipping nonexistent device\n"), fs->device);
+ return 1;
+ }
+
interpret_type(fs);
/*