Commit 76a5f0eb authored by Timothy Loh's avatar Timothy Loh Committed by Chromium LUCI CQ

Ignore failed mounts in CrosUsbDetector

This CL updates the CrosUsbDetector to ignore failed mount events.
Currently USB drives with filesystems we can't mount are not able to be
shared with VMs as it attempts and fails to unmount disks which were
never successfully mounted in the first place.

Bug: 1146325
Change-Id: I56001e5039d609a5eac1c037c83f9cf474e7ff20
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2583600Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Commit-Queue: Timothy Loh <timloh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835907}
parent bda65559
......@@ -505,7 +505,8 @@ void CrosUsbDetector::OnMountEvent(
disks::DiskMountManager::MountEvent event,
MountError error_code,
const disks::DiskMountManager::MountPointInfo& mount_info) {
if (mount_info.mount_type != MOUNT_TYPE_DEVICE) {
if (mount_info.mount_type != MOUNT_TYPE_DEVICE ||
error_code != MOUNT_ERROR_NONE) {
return;
}
......
......@@ -246,13 +246,14 @@ class CrosUsbDetectorTest : public BrowserWithTestWindowTest {
NotifyMountEvent(name, chromeos::disks::DiskMountManager::MOUNTING);
}
void NotifyMountEvent(const std::string& name,
chromeos::disks::DiskMountManager::MountEvent event) {
void NotifyMountEvent(
const std::string& name,
chromeos::disks::DiskMountManager::MountEvent event,
chromeos::MountError mount_error = chromeos::MOUNT_ERROR_NONE) {
chromeos::disks::DiskMountManager::MountPointInfo info(
"/dev/" + name, "/mount/" + name, chromeos::MOUNT_TYPE_DEVICE,
chromeos::disks::MOUNT_CONDITION_NONE);
mock_disk_mount_manager_->NotifyMountEvent(
event, chromeos::MOUNT_ERROR_NONE, info);
mock_disk_mount_manager_->NotifyMountEvent(event, mount_error, info);
}
protected:
......@@ -998,7 +999,9 @@ TEST_F(CrosUsbDetectorTest, AttachUnmountFilesystemSuccess) {
base::RunLoop().RunUntilIdle();
AddDisk("disk1", 3, 4, true);
AddDisk("disk2", 3, 4, false);
AddDisk("disk2", 3, 4, /*mounted=*/false);
NotifyMountEvent("disk2", chromeos::disks::DiskMountManager::MOUNTING,
chromeos::MOUNT_ERROR_INTERNAL);
AddDisk("disk3", 3, 5, true);
AddDisk("disk4", 3, 4, true);
AddDisk("disk5", 2, 4, true);
......@@ -1095,11 +1098,18 @@ TEST_F(CrosUsbDetectorTest, ReassignPromptForStorageDevice) {
auto device_info = GetSingleDeviceInfo();
EXPECT_FALSE(cros_usb_detector_->SharingRequiresReassignPrompt(device_info));
AddDisk("disk1", 1, 5, true);
AddDisk("disk_error", 1, 5, /*mounted=*/false);
NotifyMountEvent("disk_error", chromeos::disks::DiskMountManager::MOUNTING,
chromeos::MOUNT_ERROR_INTERNAL);
device_info = GetSingleDeviceInfo();
EXPECT_FALSE(cros_usb_detector_->SharingRequiresReassignPrompt(device_info));
AddDisk("disk_success", 1, 5, true);
device_info = GetSingleDeviceInfo();
EXPECT_TRUE(cros_usb_detector_->SharingRequiresReassignPrompt(device_info));
NotifyMountEvent("disk1", chromeos::disks::DiskMountManager::UNMOUNTING);
NotifyMountEvent("disk_success",
chromeos::disks::DiskMountManager::UNMOUNTING);
device_info = GetSingleDeviceInfo();
EXPECT_FALSE(cros_usb_detector_->SharingRequiresReassignPrompt(device_info));
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment