Merge "fastboot: Query the name of the super partition."
diff --git a/adb/daemon/remount_service.cpp b/adb/daemon/remount_service.cpp
index 2dcfb53..b72ed16 100644
--- a/adb/daemon/remount_service.cpp
+++ b/adb/daemon/remount_service.cpp
@@ -97,8 +97,12 @@
}
}
+bool dev_is_overlayfs(const std::string& dev) {
+ return (dev == "overlay") || (dev == "overlayfs");
+}
+
bool make_block_device_writable(const std::string& dev) {
- if ((dev == "overlay") || (dev == "overlayfs")) return true;
+ if (dev_is_overlayfs(dev)) return true;
int fd = unix_open(dev.c_str(), O_RDONLY | O_CLOEXEC);
if (fd == -1) {
return false;
@@ -161,6 +165,10 @@
return true;
}
bool is_root = strcmp(dir, "/") == 0;
+ if (is_root && dev_is_overlayfs(find_mount("/system", false))) {
+ dir = "/system";
+ is_root = false;
+ }
std::string dev = find_mount(dir, is_root);
if (is_root && dev.empty()) {
// The fstab entry will be /system if the device switched roots during
diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp
index fc3a05c..e89c91c 100644
--- a/fs_mgr/fs_mgr_fstab.cpp
+++ b/fs_mgr/fs_mgr_fstab.cpp
@@ -403,10 +403,13 @@
static bool is_dt_fstab_compatible() {
std::string dt_value;
std::string file_name = get_android_dt_dir() + "/fstab/compatible";
- if (read_dt_file(file_name, &dt_value)) {
- if (dt_value == "android,fstab") {
- return true;
- }
+
+ if (read_dt_file(file_name, &dt_value) && dt_value == "android,fstab") {
+ // If there's no status property or its set to "ok" or "okay", then we use the DT fstab.
+ std::string status_value;
+ std::string status_file_name = get_android_dt_dir() + "/fstab/status";
+ return !read_dt_file(status_file_name, &status_value) || status_value == "ok" ||
+ status_value == "okay";
}
return false;
diff --git a/fs_mgr/liblp/writer.cpp b/fs_mgr/liblp/writer.cpp
index c740bd4..f4c9b99 100644
--- a/fs_mgr/liblp/writer.cpp
+++ b/fs_mgr/liblp/writer.cpp
@@ -82,12 +82,8 @@
// Perform sanity checks so we don't accidentally overwrite valid metadata
// with potentially invalid metadata, or random partition data with metadata.
-static bool ValidateAndSerializeMetadata(int fd, const LpMetadata& metadata, std::string* blob) {
- uint64_t blockdevice_size;
- if (!GetDescriptorSize(fd, &blockdevice_size)) {
- return false;
- }
-
+static bool ValidateAndSerializeMetadata(const IPartitionOpener& opener, const LpMetadata& metadata,
+ std::string* blob) {
const LpMetadataHeader& header = metadata.header;
const LpMetadataGeometry& geometry = metadata.geometry;
@@ -104,7 +100,7 @@
// metadata.
uint64_t reserved_size = LP_METADATA_GEOMETRY_SIZE +
uint64_t(geometry.metadata_max_size) * geometry.metadata_slot_count;
- uint64_t total_reserved = reserved_size * 2;
+ uint64_t total_reserved = LP_PARTITION_RESERVED_BYTES + reserved_size * 2;
const LpMetadataBlockDevice* super_device = GetMetadataSuperBlockDevice(metadata);
if (!super_device) {
@@ -112,15 +108,27 @@
return false;
}
- if (total_reserved > blockdevice_size ||
- total_reserved > super_device->first_logical_sector * LP_SECTOR_SIZE) {
+ if (total_reserved > super_device->first_logical_sector * LP_SECTOR_SIZE) {
LERROR << "Not enough space to store all logical partition metadata slots.";
return false;
}
- if (blockdevice_size != super_device->size) {
- LERROR << "Block device size " << blockdevice_size
- << " does not match metadata requested size " << super_device->size;
- return false;
+ for (const auto& block_device : metadata.block_devices) {
+ std::string partition_name = GetBlockDevicePartitionName(block_device);
+ if ((block_device.first_logical_sector + 1) * LP_SECTOR_SIZE > block_device.size) {
+ LERROR << "Block device " << partition_name << " has invalid first sector "
+ << block_device.first_logical_sector << " for size " << block_device.size;
+ return false;
+ }
+ BlockDeviceInfo info;
+ if (!opener.GetInfo(partition_name, &info)) {
+ PERROR << partition_name << ": ioctl";
+ return false;
+ }
+ if (info.size != block_device.size) {
+ LERROR << "Block device " << partition_name << " size mismatch (expected"
+ << block_device.size << ", got " << info.size << ")";
+ return false;
+ }
}
// Make sure all partition entries reference valid extents.
@@ -230,7 +238,7 @@
// basic checks that the geometry and tables are coherent, and will fit
// on the given block device.
std::string metadata_blob;
- if (!ValidateAndSerializeMetadata(fd, metadata, &metadata_blob)) {
+ if (!ValidateAndSerializeMetadata(opener, metadata, &metadata_blob)) {
return false;
}
@@ -295,7 +303,7 @@
// basic checks that the geometry and tables are coherent, and will fit
// on the given block device.
std::string blob;
- if (!ValidateAndSerializeMetadata(fd, metadata, &blob)) {
+ if (!ValidateAndSerializeMetadata(opener, metadata, &blob)) {
return false;
}
@@ -327,7 +335,7 @@
// synchronize the backup copy. This guarantees that a partial write
// still leaves one copy intact.
std::string old_blob;
- if (!ValidateAndSerializeMetadata(fd, *primary.get(), &old_blob)) {
+ if (!ValidateAndSerializeMetadata(opener, *primary.get(), &old_blob)) {
LERROR << "Error serializing primary metadata to repair corrupted backup";
return false;
}
@@ -339,7 +347,7 @@
// The backup copy is coherent, and the primary is not. Sync it for
// safety.
std::string old_blob;
- if (!ValidateAndSerializeMetadata(fd, *backup.get(), &old_blob)) {
+ if (!ValidateAndSerializeMetadata(opener, *backup.get(), &old_blob)) {
LERROR << "Error serializing primary metadata to repair corrupted backup";
return false;
}
diff --git a/fs_mgr/tests/adb-remount-test.sh b/fs_mgr/tests/adb-remount-test.sh
index 6b908d3..98c0879 100755
--- a/fs_mgr/tests/adb-remount-test.sh
+++ b/fs_mgr/tests/adb-remount-test.sh
@@ -274,9 +274,8 @@
echo "${D}" | grep "^overlay .* /system\$" >/dev/null ||
die "overlay takeover after remount"
!(adb_sh grep "^overlay " /proc/mounts </dev/null | grep " overlay ro,") &&
- !(adb_sh grep " rw," /proc/mounts </dev/null |
- skip_administrative_mounts) ||
- die "remount overlayfs missed a spot"
+ !(adb_sh grep " rw," /proc/mounts </dev/null | skip_administrative_mounts) ||
+ die "remount overlayfs missed a spot (ro)"
adb_su "sed -n '1,/overlay \\/system/p' /proc/mounts" </dev/null |
skip_administrative_mounts |
diff --git a/run-as/.clang-format b/run-as/.clang-format
new file mode 120000
index 0000000..fd0645f
--- /dev/null
+++ b/run-as/.clang-format
@@ -0,0 +1 @@
+../.clang-format-2
\ No newline at end of file
diff --git a/run-as/run-as.cpp b/run-as/run-as.cpp
index ac470d4..971b9f4 100644
--- a/run-as/run-as.cpp
+++ b/run-as/run-as.cpp
@@ -144,7 +144,7 @@
// Some devices can disable running run-as, such as Chrome OS when running in
// non-developer mode.
if (android::base::GetBoolProperty("ro.boot.disable_runas", false)) {
- error(1, 0, "run-as is disabled from the kernel commandline");
+ error(1, 0, "run-as is disabled from the kernel commandline");
}
char* pkgname = argv[1];