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

Commit c6b08aa2 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10872577 from 3599a091 to 24Q1-release

Change-Id: I8b2aafee05129b5f22990e713cf9c370d49c5911
parents ad36651b 3599a091
Loading
Loading
Loading
Loading
+29 −19
Original line number Original line Diff line number Diff line
@@ -1185,9 +1185,10 @@ static uint64_t get_partition_size(const std::string& partition) {
    return partition_size;
    return partition_size;
}
}


static void copy_avb_footer(const std::string& partition, struct fastboot_buffer* buf) {
static void copy_avb_footer(const ImageSource* source, const std::string& partition,
                            struct fastboot_buffer* buf) {
    if (buf->sz < AVB_FOOTER_SIZE || is_logical(partition) ||
    if (buf->sz < AVB_FOOTER_SIZE || is_logical(partition) ||
        should_flash_in_userspace(partition)) {
        should_flash_in_userspace(source, partition)) {
        return;
        return;
    }
    }
    // If overflows and negative, it should be < buf->sz.
    // If overflows and negative, it should be < buf->sz.
@@ -1244,9 +1245,9 @@ void flash_partition_files(const std::string& partition, const std::vector<Spars
    }
    }
}
}


static void flash_buf(const std::string& partition, struct fastboot_buffer* buf,
static void flash_buf(const ImageSource* source, const std::string& partition,
                      const bool apply_vbmeta) {
                      struct fastboot_buffer* buf, const bool apply_vbmeta) {
    copy_avb_footer(partition, buf);
    copy_avb_footer(source, partition, buf);


    // Rewrite vbmeta if that's what we're flashing and modification has been requested.
    // Rewrite vbmeta if that's what we're flashing and modification has been requested.
    if (g_disable_verity || g_disable_verification) {
    if (g_disable_verity || g_disable_verification) {
@@ -1524,7 +1525,7 @@ void do_flash(const char* pname, const char* fname, const bool apply_vbmeta,
        fb->ResizePartition(pname, std::to_string(buf.image_size));
        fb->ResizePartition(pname, std::to_string(buf.image_size));
    }
    }
    std::string flash_pname = repack_ramdisk(pname, &buf, fp->fb);
    std::string flash_pname = repack_ramdisk(pname, &buf, fp->fb);
    flash_buf(flash_pname, &buf, apply_vbmeta);
    flash_buf(fp->source, flash_pname, &buf, apply_vbmeta);
}
}


// Sets slot_override as the active slot. If slot_override is blank,
// Sets slot_override as the active slot. If slot_override is blank,
@@ -1807,9 +1808,9 @@ std::vector<std::unique_ptr<Task>> FlashAllTool::CollectTasks() {
        tasks = CollectTasksFromImageList();
        tasks = CollectTasksFromImageList();
    }
    }
    if (fp_->exclude_dynamic_partitions) {
    if (fp_->exclude_dynamic_partitions) {
        auto is_non_static_flash_task = [](const auto& task) -> bool {
        auto is_non_static_flash_task = [&](const auto& task) -> bool {
            if (auto flash_task = task->AsFlashTask()) {
            if (auto flash_task = task->AsFlashTask()) {
                if (!should_flash_in_userspace(flash_task->GetPartitionAndSlot())) {
                if (!should_flash_in_userspace(fp_->source, flash_task->GetPartitionAndSlot())) {
                    return false;
                    return false;
                }
                }
            }
            }
@@ -1885,7 +1886,7 @@ std::vector<std::unique_ptr<Task>> FlashAllTool::CollectTasksFromImageList() {
        // this, we delete any logical partitions for the "other" slot.
        // this, we delete any logical partitions for the "other" slot.
        if (is_retrofit_device(fp_->source)) {
        if (is_retrofit_device(fp_->source)) {
            std::string partition_name = image->part_name + "_" + slot;
            std::string partition_name = image->part_name + "_" + slot;
            if (image->IsSecondary() && should_flash_in_userspace(partition_name)) {
            if (image->IsSecondary() && should_flash_in_userspace(fp_->source, partition_name)) {
                tasks.emplace_back(std::make_unique<DeleteTask>(fp_, partition_name));
                tasks.emplace_back(std::make_unique<DeleteTask>(fp_, partition_name));
            }
            }
        }
        }
@@ -2087,7 +2088,8 @@ void fb_perform_format(const std::string& partition, int skip_if_not_supported,
    if (!load_buf_fd(std::move(fd), &buf, fp)) {
    if (!load_buf_fd(std::move(fd), &buf, fp)) {
        die("Cannot read image: %s", strerror(errno));
        die("Cannot read image: %s", strerror(errno));
    }
    }
    flash_buf(partition, &buf, is_vbmeta_partition(partition));

    flash_buf(fp->source, partition, &buf, is_vbmeta_partition(partition));
    return;
    return;


failed:
failed:
@@ -2101,7 +2103,8 @@ failed:
    }
    }
}
}


bool should_flash_in_userspace(const std::string& partition_name) {
bool should_flash_in_userspace(const ImageSource* source, const std::string& partition_name) {
    if (!source) {
        if (!get_android_product_out()) {
        if (!get_android_product_out()) {
            return false;
            return false;
        }
        }
@@ -2115,6 +2118,13 @@ bool should_flash_in_userspace(const std::string& partition_name) {
        }
        }
        return should_flash_in_userspace(*metadata.get(), partition_name);
        return should_flash_in_userspace(*metadata.get(), partition_name);
    }
    }
    std::vector<char> contents;
    if (!source->ReadFile("super_empty.img", &contents)) {
        return false;
    }
    auto metadata = android::fs_mgr::ReadFromImageBlob(contents.data(), contents.size());
    return should_flash_in_userspace(*metadata.get(), partition_name);
}


static bool wipe_super(const android::fs_mgr::LpMetadata& metadata, const std::string& slot,
static bool wipe_super(const android::fs_mgr::LpMetadata& metadata, const std::string& slot,
                       std::string* message, const FlashingPlan* fp) {
                       std::string* message, const FlashingPlan* fp) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -148,7 +148,7 @@ class LocalImageSource final : public ImageSource {
};
};


char* get_android_product_out();
char* get_android_product_out();
bool should_flash_in_userspace(const std::string& partition_name);
bool should_flash_in_userspace(const ImageSource* source, const std::string& partition_name);
bool is_userspace_fastboot();
bool is_userspace_fastboot();
void do_flash(const char* pname, const char* fname, const bool apply_vbmeta,
void do_flash(const char* pname, const char* fname, const bool apply_vbmeta,
              const FlashingPlan* fp);
              const FlashingPlan* fp);
+2 −1
Original line number Original line Diff line number Diff line
@@ -41,7 +41,8 @@ bool FlashTask::IsDynamicParitition(const ImageSource* source, const FlashTask*


void FlashTask::Run() {
void FlashTask::Run() {
    auto flash = [&](const std::string& partition) {
    auto flash = [&](const std::string& partition) {
        if (should_flash_in_userspace(partition) && !is_userspace_fastboot() && !fp_->force_flash) {
        if (should_flash_in_userspace(fp_->source, partition) && !is_userspace_fastboot() &&
            !fp_->force_flash) {
            die("The partition you are trying to flash is dynamic, and "
            die("The partition you are trying to flash is dynamic, and "
                "should be flashed via fastbootd. Please run:\n"
                "should be flashed via fastbootd. Please run:\n"
                "\n"
                "\n"
+6 −4
Original line number Original line Diff line number Diff line
@@ -171,11 +171,15 @@ cc_library {
                "libasync_safe",
                "libasync_safe",
            ],
            ],
        },
        },
        linux: {
            srcs: [
                "canned_fs_config.cpp",
                "fs_config.cpp",
            ],
        },
        not_windows: {
        not_windows: {
            srcs: libcutils_nonwindows_sources + [
            srcs: libcutils_nonwindows_sources + [
                "ashmem-host.cpp",
                "ashmem-host.cpp",
                "canned_fs_config.cpp",
                "fs_config.cpp",
                "trace-host.cpp",
                "trace-host.cpp",
            ],
            ],
        },
        },
@@ -201,8 +205,6 @@ cc_library {
            srcs: libcutils_nonwindows_sources + [
            srcs: libcutils_nonwindows_sources + [
                "android_reboot.cpp",
                "android_reboot.cpp",
                "ashmem-dev.cpp",
                "ashmem-dev.cpp",
                "canned_fs_config.cpp",
                "fs_config.cpp",
                "klog.cpp",
                "klog.cpp",
                "partition_utils.cpp",
                "partition_utils.cpp",
                "qtaguid.cpp",
                "qtaguid.cpp",
+0 −119
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2013 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Taken from linux/capability.h, with minor modifications
 */

#ifndef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_FILESYSTEM_CAPABILITY_H
#define _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_FILESYSTEM_CAPABILITY_H

#include <stdint.h>

#define __user
#define __u32 uint32_t
#define __le32 uint32_t

#define _LINUX_CAPABILITY_VERSION_1 0x19980330
#define _LINUX_CAPABILITY_U32S_1 1
#define _LINUX_CAPABILITY_VERSION_2 0x20071026
#define _LINUX_CAPABILITY_U32S_2 2
#define _LINUX_CAPABILITY_VERSION_3 0x20080522
#define _LINUX_CAPABILITY_U32S_3 2

typedef struct __user_cap_header_struct {
    __u32 version;
    int pid;
} __user* cap_user_header_t;

typedef struct __user_cap_data_struct {
    __u32 effective;
    __u32 permitted;
    __u32 inheritable;
} __user* cap_user_data_t;

#define VFS_CAP_REVISION_MASK 0xFF000000
#define VFS_CAP_REVISION_SHIFT 24
#define VFS_CAP_FLAGS_MASK ~VFS_CAP_REVISION_MASK
#define VFS_CAP_FLAGS_EFFECTIVE 0x000001
#define VFS_CAP_REVISION_1 0x01000000
#define VFS_CAP_U32_1 1
#define XATTR_CAPS_SZ_1 (sizeof(__le32) * (1 + 2 * VFS_CAP_U32_1))
#define VFS_CAP_REVISION_2 0x02000000
#define VFS_CAP_U32_2 2
#define XATTR_CAPS_SZ_2 (sizeof(__le32) * (1 + 2 * VFS_CAP_U32_2))
#define XATTR_CAPS_SZ XATTR_CAPS_SZ_2
#define VFS_CAP_U32 VFS_CAP_U32_2
#define VFS_CAP_REVISION VFS_CAP_REVISION_2

struct vfs_cap_data {
    __le32 magic_etc;
    struct {
        __le32 permitted;
        __le32 inheritable;
    } data[VFS_CAP_U32];
};

#define _LINUX_CAPABILITY_VERSION _LINUX_CAPABILITY_VERSION_1
#define _LINUX_CAPABILITY_U32S _LINUX_CAPABILITY_U32S_1
#define CAP_CHOWN 0
#define CAP_DAC_OVERRIDE 1
#define CAP_DAC_READ_SEARCH 2
#define CAP_FOWNER 3
#define CAP_FSETID 4
#define CAP_KILL 5
#define CAP_SETGID 6
#define CAP_SETUID 7
#define CAP_SETPCAP 8
#define CAP_LINUX_IMMUTABLE 9
#define CAP_NET_BIND_SERVICE 10
#define CAP_NET_BROADCAST 11
#define CAP_NET_ADMIN 12
#define CAP_NET_RAW 13
#define CAP_IPC_LOCK 14
#define CAP_IPC_OWNER 15
#define CAP_SYS_MODULE 16
#define CAP_SYS_RAWIO 17
#define CAP_SYS_CHROOT 18
#define CAP_SYS_PTRACE 19
#define CAP_SYS_PACCT 20
#define CAP_SYS_ADMIN 21
#define CAP_SYS_BOOT 22
#define CAP_SYS_NICE 23
#define CAP_SYS_RESOURCE 24
#define CAP_SYS_TIME 25
#define CAP_SYS_TTY_CONFIG 26
#define CAP_MKNOD 27
#define CAP_LEASE 28
#define CAP_AUDIT_WRITE 29
#define CAP_AUDIT_CONTROL 30
#define CAP_SETFCAP 31
#define CAP_MAC_OVERRIDE 32
#define CAP_MAC_ADMIN 33
#define CAP_SYSLOG 34
#define CAP_WAKE_ALARM 35
#define CAP_BLOCK_SUSPEND 36
#define CAP_AUDIT_READ 37
#define CAP_LAST_CAP CAP_AUDIT_READ
#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
#define CAP_TO_INDEX(x) ((x) >> 5)
#define CAP_TO_MASK(x) (1 << ((x)&31))

#undef __user
#undef __u32
#undef __le32

#endif
Loading