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

Commit 3b7b73b5 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5422062 from da70b93f to qt-release

Change-Id: Icce4874e3c73348a5001b4ab827e5607ccb615c6
parents 64b8ca19 da70b93f
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
@@ -168,7 +168,8 @@ struct ScopedAioContext {
struct UsbFfsConnection : public Connection {
    UsbFfsConnection(unique_fd control, unique_fd read, unique_fd write,
                     std::promise<void> destruction_notifier)
        : stopped_(false),
        : worker_started_(false),
          stopped_(false),
          destruction_notifier_(std::move(destruction_notifier)),
          control_fd_(std::move(control)),
          read_fd_(std::move(read)),
@@ -194,6 +195,7 @@ struct UsbFfsConnection : public Connection {

        // We need to explicitly close our file descriptors before we notify our destruction,
        // because the thread listening on the future will immediately try to reopen the endpoint.
        aio_context_.reset();
        control_fd_.reset();
        read_fd_.reset();
        write_fd_.reset();
@@ -274,11 +276,16 @@ struct UsbFfsConnection : public Connection {
                  { .fd = control_fd_.get(), .events = POLLIN, .revents = 0 },
                  { .fd = monitor_event_fd_.get(), .events = POLLIN, .revents = 0 },
                };
                int rc = TEMP_FAILURE_RETRY(adb_poll(pfd, 2, -1));

                // If we don't see our first bind within a second, try again.
                int timeout_ms = bound ? -1 : 1000;

                int rc = TEMP_FAILURE_RETRY(adb_poll(pfd, 2, timeout_ms));
                if (rc == -1) {
                    PLOG(FATAL) << "poll on USB control fd failed";
                } else if (rc == 0) {
                    LOG(FATAL) << "poll on USB control fd returned 0";
                    LOG(WARNING) << "timed out while waiting for FUNCTIONFS_BIND, trying again";
                    break;
                }

                if (pfd[1].revents) {
@@ -330,13 +337,13 @@ struct UsbFfsConnection : public Connection {
            }

            StopWorker();
            aio_context_.reset();
            read_fd_.reset();
            write_fd_.reset();
            HandleError("monitor thread finished");
        });
    }

    void StartWorker() {
        CHECK(!worker_started_);
        worker_started_ = true;
        worker_thread_ = std::thread([this]() {
            adb_thread_setname("UsbFfs-worker");
            for (size_t i = 0; i < kUsbReadQueueDepth; ++i) {
@@ -361,6 +368,10 @@ struct UsbFfsConnection : public Connection {
    }

    void StopWorker() {
        if (!worker_started_) {
            return;
        }

        pthread_t worker_thread_handle = worker_thread_.native_handle();
        while (true) {
            int rc = pthread_kill(worker_thread_handle, kInterruptionSignal);
@@ -590,6 +601,8 @@ struct UsbFfsConnection : public Connection {
    }

    std::thread monitor_thread_;

    bool worker_started_;
    std::thread worker_thread_;

    std::atomic<bool> stopped_;
+3 −0
Original line number Diff line number Diff line
@@ -105,6 +105,9 @@ class unique_fd_impl final {
  int get() const { return fd_; }
  operator int() const { return get(); }  // NOLINT

  // Catch bogus error checks (i.e.: "!fd" instead of "fd != -1").
  bool operator!() const = delete;

  int release() __attribute__((warn_unused_result)) {
    tag(fd_, this, nullptr);
    int ret = fd_;
+30 −8
Original line number Diff line number Diff line
@@ -1602,6 +1602,14 @@ bool fs_mgr_load_verity_state(int* mode) {
    return true;
}

std::string fs_mgr_get_verity_device_name(const FstabEntry& entry) {
    if (entry.mount_point == "/") {
        // In AVB, the dm device name is vroot instead of system.
        return entry.fs_mgr_flags.avb ? "vroot" : "system";
    }
    return Basename(entry.mount_point);
}

bool fs_mgr_is_verity_enabled(const FstabEntry& entry) {
    if (!entry.fs_mgr_flags.verify && !entry.fs_mgr_flags.avb) {
        return false;
@@ -1609,14 +1617,7 @@ bool fs_mgr_is_verity_enabled(const FstabEntry& entry) {

    DeviceMapper& dm = DeviceMapper::Instance();

    std::string mount_point;
    if (entry.mount_point == "/") {
        // In AVB, the dm device name is vroot instead of system.
        mount_point = entry.fs_mgr_flags.avb ? "vroot" : "system";
    } else {
        mount_point = Basename(entry.mount_point);
    }

    std::string mount_point = fs_mgr_get_verity_device_name(entry);
    if (dm.GetState(mount_point) == DmDeviceState::INVALID) {
        return false;
    }
@@ -1639,6 +1640,27 @@ bool fs_mgr_is_verity_enabled(const FstabEntry& entry) {
    return false;
}

bool fs_mgr_verity_is_check_at_most_once(const android::fs_mgr::FstabEntry& entry) {
    if (!entry.fs_mgr_flags.verify && !entry.fs_mgr_flags.avb) {
        return false;
    }

    DeviceMapper& dm = DeviceMapper::Instance();
    std::string device = fs_mgr_get_verity_device_name(entry);

    std::vector<DeviceMapper::TargetInfo> table;
    if (dm.GetState(device) == DmDeviceState::INVALID || !dm.GetTableInfo(device, &table)) {
        return false;
    }
    for (const auto& target : table) {
        if (strcmp(target.spec.target_type, "verity") == 0 &&
            target.data.find("check_at_most_once") != std::string::npos) {
            return true;
        }
    }
    return false;
}

std::string fs_mgr_get_super_partition_name(int slot) {
    // Devices upgrading to dynamic partitions are allowed to specify a super
    // partition name, assumed to be A/B (non-A/B retrofit is not supported).
+4 −0
Original line number Diff line number Diff line
@@ -77,6 +77,10 @@ bool fs_mgr_is_verity_enabled(const android::fs_mgr::FstabEntry& entry);
bool fs_mgr_swapon_all(const android::fs_mgr::Fstab& fstab);
bool fs_mgr_update_logical_partition(android::fs_mgr::FstabEntry* entry);

// Returns true if the given fstab entry has verity enabled, *and* the verity
// device is in "check_at_most_once" mode.
bool fs_mgr_verity_is_check_at_most_once(const android::fs_mgr::FstabEntry& entry);

int fs_mgr_do_format(const android::fs_mgr::FstabEntry& entry, bool reserve_footer);

#define FS_MGR_SETUP_VERITY_SKIPPED  (-3)
+1 −1
Original line number Diff line number Diff line
@@ -316,7 +316,7 @@ static int TableCmdHandler(int argc, char** argv) {

    DeviceMapper& dm = DeviceMapper::Instance();
    std::vector<DeviceMapper::TargetInfo> table;
    if (!dm.GetTableStatus(argv[0], &table)) {
    if (!dm.GetTableInfo(argv[0], &table)) {
        std::cerr << "Could not query table status of device \"" << argv[0] << "\"." << std::endl;
        return -EINVAL;
    }
Loading