summaryrefslogtreecommitdiffstats
path: root/fs_mgr
diff options
context:
space:
mode:
authorDavid Zeuthen <zeuthen@google.com>2015-09-14 15:39:49 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-09-14 15:39:49 +0000
commit77557e90915d600028d17c513c70309ab706ef55 (patch)
tree600545e8b94cec052b483c76ed2138c1fd9844c1 /fs_mgr
parent1b2bbba3061af685b0205a15bebf0e075203a459 (diff)
parentd906b2973b9f708b34d4df90a2496753f83199ec (diff)
downloadcore-77557e90915d600028d17c513c70309ab706ef55.tar.gz
core-77557e90915d600028d17c513c70309ab706ef55.tar.bz2
core-77557e90915d600028d17c513c70309ab706ef55.zip
am d906b297: Merge "fs_mgr: Error out if unable to determine slot_suffix"
* commit 'd906b2973b9f708b34d4df90a2496753f83199ec': fs_mgr: Error out if unable to determine slot_suffix
Diffstat (limited to 'fs_mgr')
-rw-r--r--fs_mgr/fs_mgr_slotselect.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/fs_mgr/fs_mgr_slotselect.c b/fs_mgr/fs_mgr_slotselect.c
index 99dcd0e53..ca07b189b 100644
--- a/fs_mgr/fs_mgr_slotselect.c
+++ b/fs_mgr/fs_mgr_slotselect.c
@@ -78,10 +78,11 @@ static int get_active_slot_suffix_from_misc(struct fstab *fstab,
return 0;
}
-// Gets slot_suffix from either the kernel cmdline / firmware, the
-// misc partition or built-in fallback.
-static void get_active_slot_suffix(struct fstab *fstab, char *out_suffix,
- size_t suffix_len)
+// Gets slot_suffix from either the kernel cmdline / firmware or the
+// misc partition. Sets |out_suffix| on success and returns 0. Returns
+// -1 if slot_suffix could not be determined.
+static int get_active_slot_suffix(struct fstab *fstab, char *out_suffix,
+ size_t suffix_len)
{
char propbuf[PROPERTY_VALUE_MAX];
@@ -91,30 +92,19 @@ static void get_active_slot_suffix(struct fstab *fstab, char *out_suffix,
property_get("ro.boot.slot_suffix", propbuf, "");
if (propbuf[0] != '\0') {
strncpy(out_suffix, propbuf, suffix_len);
- return;
+ return 0;
}
// If we couldn't get the suffix from the kernel cmdline, try the
// the misc partition.
if (get_active_slot_suffix_from_misc(fstab, out_suffix, suffix_len) == 0) {
INFO("Using slot suffix \"%s\" from misc\n", out_suffix);
- return;
+ return 0;
}
- // If that didn't work, fall back to _a. The reasoning here is
- // that since the fstab has the slotselect option set (otherwise
- // we wouldn't end up here) we must assume that partitions are
- // indeed set up for A/B. This corner-case is important because we
- // may be on this codepath on newly provisioned A/B devices where
- // misc isn't set up properly (it's just zeroes) and the
- // bootloader does not (yet) natively support A/B.
- //
- // Why '_a'? Because that's what system/extras/boot_control_copy
- // is using and since the bootloader isn't A/B aware we assume
- // slots are set up this way.
- WARNING("Could not determine slot suffix, falling back to \"_a\"\n");
- strncpy(out_suffix, "_a", suffix_len);
- return;
+ ERROR("Error determining slot_suffix\n");
+
+ return -1;
}
// Updates |fstab| for slot_suffix. Returns 0 on success, -1 on error.
@@ -130,7 +120,10 @@ int fs_mgr_update_for_slotselect(struct fstab *fstab)
if (!got_suffix) {
memset(suffix, '\0', sizeof(suffix));
- get_active_slot_suffix(fstab, suffix, sizeof(suffix) - 1);
+ if (get_active_slot_suffix(fstab, suffix,
+ sizeof(suffix) - 1) != 0) {
+ return -1;
+ }
got_suffix = 1;
}