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

Commit f4cd54e5 authored by Yifan Hong's avatar Yifan Hong
Browse files

libsnapshot: MapSnapshot: use device string for inner device

Previously, the device path for the -inner device is used, which
may not be present. Use the major:minor instead.

Test: libsnapshot (not flaky)
Change-Id: I8b8cbe8af27a49a50876385bb0c0353ecf7ed1de
parent b120efd0
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -362,12 +362,18 @@ bool SnapshotManager::MapSnapshot(LockedFile* lock, const std::string& name,
    }

    if (linear_sectors) {
        std::string snap_dev;
        if (!dm.GetDeviceString(snap_name, &snap_dev)) {
            LOG(ERROR) << "Cannot determine major/minor for: " << snap_name;
            return false;
        }

        // Our stacking will looks like this:
        //     [linear, linear] ; to snapshot, and non-snapshot region of base device
        //     [snapshot-inner]
        //     [base device]   [cow]
        DmTable table;
        table.Emplace<DmTargetLinear>(0, snapshot_sectors, *dev_path, 0);
        table.Emplace<DmTargetLinear>(0, snapshot_sectors, snap_dev, 0);
        table.Emplace<DmTargetLinear>(snapshot_sectors, linear_sectors, base_device,
                                      snapshot_sectors);
        if (!dm.CreateDevice(name, table, dev_path, timeout_ms)) {