summaryrefslogtreecommitdiff
path: root/fastboot/device/utility.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fastboot/device/utility.cpp')
-rw-r--r--fastboot/device/utility.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/fastboot/device/utility.cpp b/fastboot/device/utility.cpp
index 7c6ac8993..07ad9028c 100644
--- a/fastboot/device/utility.cpp
+++ b/fastboot/device/utility.cpp
@@ -77,7 +77,8 @@ bool OpenLogicalPartition(FastbootDevice* device, const std::string& partition_n
} // namespace
-bool OpenPartition(FastbootDevice* device, const std::string& name, PartitionHandle* handle) {
+bool OpenPartition(FastbootDevice* device, const std::string& name, PartitionHandle* handle,
+ bool read) {
// We prioritize logical partitions over physical ones, and do this
// consistently for other partition operations (like getvar:partition-size).
if (LogicalPartitionExists(device, name)) {
@@ -89,7 +90,9 @@ bool OpenPartition(FastbootDevice* device, const std::string& name, PartitionHan
return false;
}
- unique_fd fd(TEMP_FAILURE_RETRY(open(handle->path().c_str(), O_WRONLY | O_EXCL)));
+ int flags = (read ? O_RDONLY : O_WRONLY);
+ flags |= (O_EXCL | O_CLOEXEC | O_BINARY);
+ unique_fd fd(TEMP_FAILURE_RETRY(open(handle->path().c_str(), flags)));
if (fd < 0) {
PLOG(ERROR) << "Failed to open block device: " << handle->path();
return false;
@@ -201,12 +204,7 @@ std::vector<std::string> ListPartitions(FastbootDevice* device) {
}
bool GetDeviceLockStatus() {
- std::string cmdline;
- // Return lock status true if unable to read kernel command line.
- if (!android::base::ReadFileToString("/proc/cmdline", &cmdline)) {
- return true;
- }
- return cmdline.find("androidboot.verifiedbootstate=orange") == std::string::npos;
+ return android::base::GetProperty("ro.boot.verifiedbootstate", "") != "orange";
}
bool UpdateAllPartitionMetadata(FastbootDevice* device, const std::string& super_name,