Hide special partitions on Chrome OS recovery media.
This CL changes cros-disks to use partition type UUIDs, instead of
filesystem labels, to identify and hide the following special partitions
on Chrome OS recovery media:
- EFI system partition
- Chrome OS kernel
- Chrome OS root filesystem
- Chrome OS firmware
- Chrome OS reserved
BUG=chromium:260961
TEST=Tested the following:
1. Build and run unit tests.
2. Run platform_CrosDisksFilesystem test.
3. Insert a Chrome OS recovery USB drive and verify that the special
partitions on the drive are not mounted by the Files app.
Change-Id: Idc6e120745fbd58373970645dd24481cc5411c5a
Reviewed-on: https://chromium-review.googlesource.com/186484
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
diff --git a/udev_device.cc b/udev_device.cc
index fa588aa..c80a2b7 100644
--- a/udev_device.cc
+++ b/udev_device.cc
@@ -46,6 +46,7 @@
const char kPropertyFilesystemUsage[] = "ID_FS_USAGE";
const char kPropertyMistSupportedDevice[] = "MIST_SUPPORTED_DEVICE";
const char kPropertyModel[] = "ID_MODEL";
+const char kPropertyPartitionEntryType[] = "ID_PART_ENTRY_TYPE";
const char kPropertyPartitionSize[] = "UDISKS_PARTITION_SIZE";
const char kPropertyPresentationHide[] = "UDISKS_PRESENTATION_HIDE";
const char kPropertyRotationRate[] = "ID_ATA_ROTATION_RATE_RPM";
@@ -55,8 +56,12 @@
const char kLoopDevicePathPrefix[] = "/sys/devices/virtual/block/loop";
const char kUSBDeviceInfoFile[] = "/opt/google/cros-disks/usb-device-info";
const char kUSBIdentifierDatabase[] = "/usr/share/misc/usb.ids";
-const char* kNonAutoMountableFilesystemLabels[] = {
- "C-ROOT", "C-STATE", NULL
+const char* kPartitionTypesToHide[] = {
+ "c12a7328-f81f-11d2-ba4b-00a0c93ec93b", // EFI system partition
+ "fe3a2a5d-4f32-41a7-b725-accc3285a309", // Chrome OS kernel
+ "3cb8e202-3b7e-47dd-8a3c-7ff2a13cfcec", // Chrome OS root filesystem
+ "cab6e88e-abf3-4102-a07a-d4bb9be3c1d3", // Chrome OS firmware
+ "2e0a753d-9e48-43b0-8337-b15192cb1b5e", // Chrome OS reserved
};
} // namespace
@@ -301,16 +306,12 @@
(GetPartitionCount() > 0))
return true;
- // TODO(benchan): Find a better way to filter out Chrome OS specific
- // partitions instead of excluding partitions with certain labels
- // (e.g. C-ROOT, C-STATE).
- string filesystem_label = GetPropertyFromBlkId(kPropertyBlkIdFilesystemLabel);
- if (!filesystem_label.empty()) {
- for (const char** label = kNonAutoMountableFilesystemLabels;
- *label; ++label) {
- if (strcmp(*label, filesystem_label.c_str()) == 0) {
+ // Hide special partitions based on partition type.
+ string partition_type = GetProperty(kPropertyPartitionEntryType);
+ if (!partition_type.empty()) {
+ for (size_t i = 0; i < arraysize(kPartitionTypesToHide); ++i) {
+ if (partition_type == kPartitionTypesToHide[i])
return true;
- }
}
}
return false;