From: Eric Curtin Date: Tue, 22 Aug 2023 12:04:03 +0000 (+0100) Subject: prepare-root: On a non-A/B androidboot system, boot system slot a X-Git-Tag: archive/raspbian/2023.7-3+rpi1~1^2~9^2^2~12^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=650a053795d53d3f5e3054a03b3341e828f58b2c;p=ostree.git prepare-root: On a non-A/B androidboot system, boot system slot a Sometimes android bootloaders boot in a nonab way: https://source.android.com/docs/core/ota/nonab In this case, "androidboot." kargs are present but not "androidboot.slot_suffix" specifically. In this case, rather than getting stuck in a partially booted environment, boot system slot a. --- diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c index 93167272..155189b9 100644 --- a/src/switchroot/ostree-prepare-root.c +++ b/src/switchroot/ostree-prepare-root.c @@ -163,6 +163,24 @@ get_aboot_root_slot (const char *slot_suffix) return NULL; } +static bool +proc_cmdline_has_key_starting_with (const char *cmdline, const char *key) +{ + for (const char *iter = cmdline; iter;) + { + if (g_str_has_prefix (iter, key)) + return true; + + iter = strchr (iter, ' '); + if (iter == NULL) + return false; + + iter += strspn (iter, " "); + } + + return false; +} + static inline char * get_ostree_target (const char *cmdline) { @@ -170,6 +188,12 @@ get_ostree_target (const char *cmdline) if (slot_suffix) return get_aboot_root_slot (slot_suffix); + /* Non-A/B androidboot: + * https://source.android.com/docs/core/ota/nonab + */ + if (proc_cmdline_has_key_starting_with (cmdline, "androidboot.")) + return strdup ("/ostree/root.a"); + return find_proc_cmdline_key (cmdline, "ostree"); }