vitastor-disk: Accept symlinks to whole disks in prepare #134
@@ -347,13 +347,16 @@ std::vector<vitastor_dev_info_t> disk_tool_t::collect_devices(const std::vector<
|
||||
{
|
||||
std::vector<vitastor_dev_info_t> devinfo;
|
||||
std::set<std::string> seen;
|
||||
for (auto & dev: devices)
|
||||
for (auto & orig_dev: devices)
|
||||
{
|
||||
// Resolve symlinks like /dev/disk/by-id/*, /sys/block/ only has real device names
|
||||
std::string dev = realpath_str(orig_dev);
|
||||
if (seen.find(dev) != seen.end())
|
||||
|
vitalif marked this conversation as resolved
Outdated
|
||||
{
|
||||
fprintf(stderr, "%s is specified multiple times, ignoring\n", dev.c_str());
|
||||
fprintf(stderr, "%s is specified multiple times, ignoring\n", orig_dev.c_str());
|
||||
continue;
|
||||
}
|
||||
seen.insert(dev);
|
||||
// Check if the device is a whole disk
|
||||
if (dev.substr(0, 5) != "/dev/")
|
||||
{
|
||||
|
||||
@@ -15,6 +15,13 @@ trap "kill -9 $(jobs -p) || true; sudo losetup -d $LOOP1 $LOOP2"' || true' EXIT
|
||||
# also test prepare --hybrid :)
|
||||
# non-vitastor random type UUID to prevent udev activation
|
||||
mount | grep '/dev type devtmpfs' || sudo mount udev /dev/ -t devtmpfs
|
||||
# prepare should resolve symlinks (like /dev/disk/by-id/*), take each disk only once
|
||||
# and complain about a path which doesn't resolve
|
||||
ln -s $LOOP1 ./testdata/bin/test_osd1_link1
|
||||
ln -s $LOOP1 ./testdata/bin/test_osd1_link2
|
||||
sudo -E build/src/disk_tool/vitastor-disk-test prepare --dry-run --json ./testdata/bin/test_osd1_link1 ./testdata/bin/test_osd1_link2 \
|
||||
./testdata/bin/test_osd1_nolink 2>./testdata/prepare_err.txt | jq -e '[ .devices[].device_path ] == [ "'$LOOP1'" ]'
|
||||
grep 'test_osd1_nolink does not start with /dev/, ignoring' ./testdata/prepare_err.txt
|
||||
sudo -E build/src/disk_tool/vitastor-disk-test prepare $OFFSET_ARGS --no_init 1 --meta_reserve 1x,1M \
|
||||
--block_size 131072 --osd_num 987654 --part_type_uuid 0df42ae0-3695-4395-a957-7d5ff3645c56 \
|
||||
--hybrid --fast-devices $LOOP2 $LOOP1
|
||||
|
||||
Reference in New Issue
Block a user
тут бы добавить ошибку при == "" - раньше на косой симлинк оно бы по крайней мере ругнулось, что он не в /dev/