Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e48db657 authored by Sandeep Patil's avatar Sandeep Patil Committed by android-build-merger
Browse files

Merge "fs_mgr: remove code that gets slot_suffix from misc partition" am: 5a306ec6

am: 622a82f2

Change-Id: I5b0727d9d30881d4c736e4d1d23240cba25afa0f
parents cced4446 622a82f2
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -29,8 +29,7 @@ LOCAL_SRC_FILES:= \
LOCAL_C_INCLUDES := \
LOCAL_C_INCLUDES := \
    $(LOCAL_PATH)/include \
    $(LOCAL_PATH)/include \
    system/vold \
    system/vold \
    system/extras/ext4_utils \
    system/extras/ext4_utils
    bootable/recovery
LOCAL_MODULE:= libfs_mgr
LOCAL_MODULE:= libfs_mgr
LOCAL_STATIC_LIBRARIES := $(common_static_libraries)
LOCAL_STATIC_LIBRARIES := $(common_static_libraries)
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
+8 −65
Original line number Original line Diff line number Diff line
@@ -33,53 +33,6 @@
#include "fs_mgr.h"
#include "fs_mgr.h"
#include "fs_mgr_priv.h"
#include "fs_mgr_priv.h"


#include "bootloader.h"

// Copies slot_suffix from misc into |out_suffix|. Returns 0 on
// success, -1 on error or if there is no non-empty slot_suffix.
static int get_active_slot_suffix_from_misc(struct fstab *fstab,
                                            char *out_suffix,
                                            size_t suffix_len)
{
    int n;
    int misc_fd;
    ssize_t num_read;
    struct bootloader_message_ab msg;

    misc_fd = -1;
    for (n = 0; n < fstab->num_entries; n++) {
        if (strcmp(fstab->recs[n].mount_point, "/misc") == 0) {
            misc_fd = open(fstab->recs[n].blk_device, O_RDONLY);
            if (misc_fd == -1) {
                PERROR << "Error opening misc partition '"
                       << fstab->recs[n].blk_device << "'";
                return -1;
            } else {
                break;
            }
        }
    }

    if (misc_fd == -1) {
        LERROR << "Error finding misc partition";
        return -1;
    }

    num_read = TEMP_FAILURE_RETRY(read(misc_fd, &msg, sizeof(msg)));
    // Linux will never return partial reads when reading from block
    // devices so no need to worry about them.
    if (num_read != sizeof(msg)) {
        PERROR << "Error reading bootloader_message";
        close(misc_fd);
        return -1;
    }
    close(misc_fd);
    if (msg.slot_suffix[0] == '\0')
        return -1;
    strncpy(out_suffix, msg.slot_suffix, suffix_len);
    return 0;
}

// finds slot_suffix in androidboot.slot_suffix kernel command line argument
// finds slot_suffix in androidboot.slot_suffix kernel command line argument
// or in the device tree node at /firmware/android/slot_suffix property
// or in the device tree node at /firmware/android/slot_suffix property
static int get_active_slot_suffix_from_kernel(char *out_suffix,
static int get_active_slot_suffix_from_kernel(char *out_suffix,
@@ -123,11 +76,10 @@ static int get_active_slot_suffix_from_kernel(char *out_suffix,
    return -1;
    return -1;
}
}


// Gets slot_suffix from either the kernel cmdline / device tree / firmware
// Gets slot_suffix from either the kernel cmdline / device tree.  Sets
// or the misc partition. Sets |out_suffix| on success and returns 0. Returns
// |out_suffix| on success and returns 0. Returns -1 if slot_suffix could not
// -1 if slot_suffix could not be determined.
// be determined.
static int get_active_slot_suffix(struct fstab *fstab, char *out_suffix,
static int get_active_slot_suffix(char *out_suffix, size_t suffix_len)
                                  size_t suffix_len)
{
{
    char propbuf[PROPERTY_VALUE_MAX];
    char propbuf[PROPERTY_VALUE_MAX];


@@ -140,22 +92,14 @@ static int get_active_slot_suffix(struct fstab *fstab, char *out_suffix,
        return 0;
        return 0;
    }
    }


    // if the property is not set, we are either being invoked too early
    // if the property is not set, we are probably being invoked early during
    // or the slot suffix in mentioned in the misc partition. If its
    // boot.  Try to find the slotsuffix ourselves in the kernel command line
    // "too early", try to find the slotsuffix ourselves in the kernel command
    // or the device tree
    // line or the device tree
    if (get_active_slot_suffix_from_kernel(out_suffix, suffix_len) == 0) {
    if (get_active_slot_suffix_from_kernel(out_suffix, suffix_len) == 0) {
        LINFO << "Using slot suffix '" << out_suffix << "' from kernel";
        LINFO << "Using slot suffix '" << out_suffix << "' from kernel";
        return 0;
        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) {
        LINFO << "Using slot suffix '" << out_suffix << "' from misc";
        return 0;
    }

    LERROR << "Error determining slot_suffix";
    LERROR << "Error determining slot_suffix";


    return -1;
    return -1;
@@ -174,8 +118,7 @@ int fs_mgr_update_for_slotselect(struct fstab *fstab)


            if (!got_suffix) {
            if (!got_suffix) {
                memset(suffix, '\0', sizeof(suffix));
                memset(suffix, '\0', sizeof(suffix));
                if (get_active_slot_suffix(fstab, suffix,
                if (get_active_slot_suffix(suffix, sizeof(suffix) - 1) != 0) {
                                           sizeof(suffix) - 1) != 0) {
                  return -1;
                  return -1;
                }
                }
                got_suffix = 1;
                got_suffix = 1;