Skip to content

Commit

Permalink
android-boot: Remove dependency on ostree= karg, use androidboot.slot…
Browse files Browse the repository at this point in the history
…_suffix=

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
  • Loading branch information
ericcurtin committed Jul 15, 2023
1 parent 845d68d commit f3266cc
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/switchroot/ostree-mount-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -153,15 +149,15 @@ 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;
autofree char *slot_suffix = read_proc_cmdline_key ("androidboot.slot_suffix");
if (slot_suffix)
return get_aboot_root_slot (slot_suffix);

if (strcmp (ostree_cmdline, "aboot") == 0)
return get_aboot_root_slot ();
autofree char *ostree_cmdline = read_proc_cmdline_key ("ostree");
if (ostree_cmdline)
return steal_pointer (&ostree_cmdline);

return steal_pointer (&ostree_cmdline);
return NULL;
}

/* This is an API for other projects to determine whether or not the
Expand Down

0 comments on commit f3266cc

Please sign in to comment.