From d38e3c522c162972bb348c0258e3f9e975191c4f Mon Sep 17 00:00:00 2001 From: Daniel Rosenberg Date: Thu, 7 Apr 2016 20:10:25 -0700 Subject: [PATCH] Add nofail fstab option This option allows fs_mgr to ignore mount errors on an optional partition to allow booting to continue. Bug: 28071890 Change-Id: I71a2b3c1c573297cab18884b4c4bd7c27ced2901 --- fs_mgr/fs_mgr.c | 17 ++++++++++++----- fs_mgr/fs_mgr_fstab.c | 6 ++++++ fs_mgr/fs_mgr_priv.h | 1 + fs_mgr/include/fs_mgr.h | 1 + 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/fs_mgr/fs_mgr.c b/fs_mgr/fs_mgr.c index 15d44eff5..8e59a3379 100644 --- a/fs_mgr/fs_mgr.c +++ b/fs_mgr/fs_mgr.c @@ -626,11 +626,18 @@ int fs_mgr_mount_all(struct fstab *fstab) } encryptable = FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED; } else { - ERROR("Failed to mount an un-encryptable or wiped partition on" - "%s at %s options: %s error: %s\n", - fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point, - fstab->recs[attempted_idx].fs_options, strerror(mount_errno)); - ++error_count; + if (fs_mgr_is_nofail(&fstab->recs[attempted_idx])) { + ERROR("Ignoring failure to mount an un-encryptable or wiped partition on" + "%s at %s options: %s error: %s\n", + fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point, + fstab->recs[attempted_idx].fs_options, strerror(mount_errno)); + } else { + ERROR("Failed to mount an un-encryptable or wiped partition on" + "%s at %s options: %s error: %s\n", + fstab->recs[attempted_idx].blk_device, fstab->recs[attempted_idx].mount_point, + fstab->recs[attempted_idx].fs_options, strerror(mount_errno)); + ++error_count; + } continue; } } diff --git a/fs_mgr/fs_mgr_fstab.c b/fs_mgr/fs_mgr_fstab.c index f24af1f1d..cc774f033 100644 --- a/fs_mgr/fs_mgr_fstab.c +++ b/fs_mgr/fs_mgr_fstab.c @@ -74,6 +74,7 @@ static struct flag_list fs_mgr_flags[] = { { "noemulatedsd", MF_NOEMULATEDSD }, { "notrim", MF_NOTRIM }, { "formattable", MF_FORMATTABLE }, + { "nofail", MF_NOFAIL }, { "defaults", 0 }, { 0, 0 }, }; @@ -480,3 +481,8 @@ int fs_mgr_is_formattable(struct fstab_rec *fstab) { return fstab->fs_mgr_flags & (MF_FORMATTABLE); } + +int fs_mgr_is_nofail(struct fstab_rec *fstab) +{ + return fstab->fs_mgr_flags & MF_NOFAIL; +} diff --git a/fs_mgr/fs_mgr_priv.h b/fs_mgr/fs_mgr_priv.h index 682fd1101..ed5594c2c 100644 --- a/fs_mgr/fs_mgr_priv.h +++ b/fs_mgr/fs_mgr_priv.h @@ -79,6 +79,7 @@ #define MF_NOTRIM 0x1000 #define MF_FILEENCRYPTION 0x2000 #define MF_FORMATTABLE 0x4000 +#define MF_NOFAIL 0x40000 #define DM_BUF_SIZE 4096 diff --git a/fs_mgr/include/fs_mgr.h b/fs_mgr/include/fs_mgr.h index 27fccf72e..c5e1f3286 100644 --- a/fs_mgr/include/fs_mgr.h +++ b/fs_mgr/include/fs_mgr.h @@ -105,6 +105,7 @@ int fs_mgr_is_file_encrypted(const struct fstab_rec *fstab); int fs_mgr_is_noemulatedsd(const struct fstab_rec *fstab); int fs_mgr_is_notrim(struct fstab_rec *fstab); int fs_mgr_is_formattable(struct fstab_rec *fstab); +int fs_mgr_is_nofail(struct fstab_rec *fstab); int fs_mgr_swapon_all(struct fstab *fstab); int fs_mgr_do_format(struct fstab_rec *fstab);