android-boot: Remove dependency on ostree= karg, use androidboot.slot_suffix=
authorEric Curtin <ecurtin@redhat.com>
Mon, 17 Jul 2023 12:22:49 +0000 (13:22 +0100)
committerEric Curtin <ecurtin@redhat.com>
Mon, 17 Jul 2023 12:22:49 +0000 (13:22 +0100)
Given the kernel argument androidboot.slot_suffix= is required in
Android AB updates [1] there is no need to check for ostree= or ostree=aboot
at all in the aboot case. This also ensures if the dependancy on ostree=
is removed, the android-boot technique will work regardless.

[1]: https://source.android.com/docs/core/ota/ab/ab_implement

src/switchroot/ostree-mount-util.h

index 180ab2e4e424d4a4fc9e6f4146f24111c13d761d..4404c232dd87ce9a429bb0cda014e86e5511126b 100644 (file)
@@ -134,12 +134,8 @@ read_proc_cmdline_key (const char *key)
 }
 
 static inline char *
-get_aboot_root_slot (void)
+get_aboot_root_slot (const char *slot_suffix)
 {
-  autofree char *slot_suffix = read_proc_cmdline_key ("androidboot.slot_suffix");
-  if (!slot_suffix)
-    errx (EXIT_FAILURE, "Missing androidboot.slot_suffix");
-
   if (strcmp (slot_suffix, "_a") == 0)
     return strdup ("/ostree/root.a");
   else if (strcmp (slot_suffix, "_b") == 0)
@@ -153,15 +149,11 @@ get_aboot_root_slot (void)
 static inline char *
 get_ostree_target (void)
 {
-  autofree char *ostree_cmdline = read_proc_cmdline_key ("ostree");
-
-  if (!ostree_cmdline)
-    return NULL;
-
-  if (strcmp (ostree_cmdline, "aboot") == 0)
-    return get_aboot_root_slot ();
+  autofree char *slot_suffix = read_proc_cmdline_key ("androidboot.slot_suffix");
+  if (slot_suffix)
+    return get_aboot_root_slot (slot_suffix);
 
-  return steal_pointer (&ostree_cmdline);
+  return read_proc_cmdline_key ("ostree");
 }
 
 /* This is an API for other projects to determine whether or not the