vitastor-disk: Accept symlinks to whole disks in prepare #134
Reference in New Issue
Block a user
No description provided.
Delete Branch "koolkhel/vitastor:disk-prepare-symlinks"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
vitastor-disk preparelooked up/sys/block/<name>by the device path as given, so a symlink to a whole disk, like/dev/disk/by-id/*or/dev/disk/by-path/*, was refused as "probably a partition".collect_devices()now resolves each path once withrealpath_str()and uses the real device name after that.One disk can now be given under several names, and the
seenset meant to catch duplicates was never filled, so a disk given twice was taken twice. It is now filled with the resolved names.What else changes:
realpath_str()it goes through the old checks and is reported like before ("does not start with /dev/" or "does not exist"). The test passes such a path and checks the message./devthat points to a whole disk is accepted too. The test uses that.Tested:
test_resize_auto.shandOLD=1 test_resize_auto.shpass on loop devices. The added check (two symlinks to one loop device must give exactly that device) fails without the fix: both links are refused and prepare ends with "No suitable devices found".Not tested: device-mapper names.
/dev/mapper/*resolves to/dev/dm-Nand is then handled like/dev/dm-Ngiven directly.Contributor Name
Yury Luneff (MIND Software LLC, https://mindsw.io)
CLA
@@ -352,1 +352,3 @@if (seen.find(dev) != seen.end())// Resolve symlinks like /dev/disk/by-id/*, /sys/block/ only has real device namesstd::string dev = realpath_str(orig_dev, false);if (dev == "")тут бы добавить ошибку при == "" - раньше на косой симлинк оно бы по крайней мере ругнулось, что он не в /dev/