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

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

Merge changes Ica6bf5c6,I3f626433

am: 56f76ec0

Change-Id: I5f98902dafea961c892ace0145fbcf923b6838cb
parents c97372e7 56f76ec0
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -111,5 +111,9 @@ std::string DmTargetVerity::GetParameterString() const {
    return base + " " + std::to_string(optional_args_.size()) + " " + optional;
    return base + " " + std::to_string(optional_args_.size()) + " " + optional;
}
}


std::string DmTargetAndroidVerity::GetParameterString() const {
    return keyid_ + " " + block_device_;
}

}  // namespace dm
}  // namespace dm
}  // namespace android
}  // namespace android
+14 −0
Original line number Original line Diff line number Diff line
@@ -128,6 +128,20 @@ class DmTargetVerity final : public DmTarget {
    bool valid_;
    bool valid_;
};
};


class DmTargetAndroidVerity final : public DmTarget {
  public:
    DmTargetAndroidVerity(uint64_t start, uint64_t length, const std::string& block_device,
                          const std::string& keyid)
        : DmTarget(start, length), keyid_(keyid), block_device_(block_device) {}

    std::string name() const override { return "android-verity"; }
    std::string GetParameterString() const override;

  private:
    std::string keyid_;
    std::string block_device_;
};

// This is the same as DmTargetVerity, but the table may be specified as a raw
// This is the same as DmTargetVerity, but the table may be specified as a raw
// string. This code exists only for fs_mgr_verity and should be avoided. Use
// string. This code exists only for fs_mgr_verity and should be avoided. Use
// DmTargetVerity for new code instead.
// DmTargetVerity for new code instead.
+12 −1
Original line number Original line Diff line number Diff line
@@ -40,6 +40,7 @@ using DmTable = ::android::dm::DmTable;
using DmTarget = ::android::dm::DmTarget;
using DmTarget = ::android::dm::DmTarget;
using DmTargetLinear = ::android::dm::DmTargetLinear;
using DmTargetLinear = ::android::dm::DmTargetLinear;
using DmTargetZero = ::android::dm::DmTargetZero;
using DmTargetZero = ::android::dm::DmTargetZero;
using DmTargetAndroidVerity = ::android::dm::DmTargetAndroidVerity;
using DmTargetTypeInfo = ::android::dm::DmTargetTypeInfo;
using DmTargetTypeInfo = ::android::dm::DmTargetTypeInfo;
using DmBlockDevice = ::android::dm::DeviceMapper::DmBlockDevice;
using DmBlockDevice = ::android::dm::DeviceMapper::DmBlockDevice;


@@ -96,6 +97,16 @@ class TargetParser final {
            }
            }
            return std::make_unique<DmTargetLinear>(start_sector, num_sectors, block_device,
            return std::make_unique<DmTargetLinear>(start_sector, num_sectors, block_device,
                                                    physical_sector);
                                                    physical_sector);
        } else if (target_type == "android-verity") {
            if (!HasArgs(2)) {
                std::cerr << "Expected \"android-verity\" <public-key-id> <block_device>"
                          << std::endl;
                return nullptr;
            }
            std::string keyid = NextArg();
            std::string block_device = NextArg();
            return std::make_unique<DmTargetAndroidVerity>(start_sector, num_sectors, keyid,
                                                           block_device);
        } else {
        } else {
            std::cerr << "Unrecognized target type: " << target_type << std::endl;
            std::cerr << "Unrecognized target type: " << target_type << std::endl;
            return nullptr;
            return nullptr;
@@ -132,11 +143,11 @@ static int DmCreateCmdHandler(int argc, char** argv) {
    while (arg_index < argc && argv[arg_index][0] == '-') {
    while (arg_index < argc && argv[arg_index][0] == '-') {
        if (strcmp(argv[arg_index], "-ro") == 0) {
        if (strcmp(argv[arg_index], "-ro") == 0) {
            table.set_readonly(true);
            table.set_readonly(true);
            arg_index++;
        } else {
        } else {
            std::cerr << "Unrecognized option: " << argv[arg_index] << std::endl;
            std::cerr << "Unrecognized option: " << argv[arg_index] << std::endl;
            return -EINVAL;
            return -EINVAL;
        }
        }
        arg_index++;
    }
    }


    // Parse everything else as target information.
    // Parse everything else as target information.