diff options
author | Ludwig Nussel <ludwig.nussel@suse.de> | 2009-11-27 10:15:53 +0100 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2009-12-01 12:15:10 +0100 |
commit | 1bb516c34bf42d2ae9dc4aa40ae34b0df4e464a7 (patch) | |
tree | d4274d49f8ee19ef71e5e5b138ab7941a8edbcd8 /fsck | |
parent | c2deb20f747e574acb571b3410e97bdcc5fb5261 (diff) | |
download | util-linux-old-1bb516c34bf42d2ae9dc4aa40ae34b0df4e464a7.tar.gz |
fsck: honor nofail option in fsck
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>
Diffstat (limited to 'fsck')
-rw-r--r-- | fsck/fsck.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/fsck/fsck.c b/fsck/fsck.c index e11bbe9b..66c027c7 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -847,6 +847,22 @@ static int fs_match(struct fs_info *fs, struct fs_type_compile *cmp) 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) { @@ -869,6 +885,15 @@ 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); /* |