Karel Zak wrote: > On Mon, Jun 01, 2020 at 01:35:44AM +0200, Stanislav Brabec wrote: >> Device mapper devices don't provide start sector. > for which type of the device/mapping? I'd like to reproduce this > issue. kpartx-style partition on multipath. >> It causes "blockdev --report" error: >> blockdev: /dev/dm-9: failed to read partition start from sysfs: No such >> file or directory >> >> There is no reliable way to detect a geometry in this case. >> Report N/A instead. > I guess the "start" file missing in the sysfs/ in this case, right? Yes. Actually, debugging shows: sysfs_blkdev_get_wholedisk(): This function has a special code for device mapper: If /sys/dev/block/{major}:{minor}/partition does not exist, check for /sys/dev/block/{major}:{minor}/dm/uuid, parse the result and attempt to check the structure. (Split by "-", check, whether string starts by "part".) It starts with "part1" => Device mapper is detected. => Partition is detected. The code returns to report_device(), and because partition is detected, it unconditionally attempts to read "start" file from "/sys/dev/block/254:9". This fails. >> if (ul_path_read_u64(pc, &start, "start") != 0) >> - err(EXIT_FAILURE, >> - _("%s: failed to read partition start from sysfs"), >> - device); >> + /* TRANSLATORS: Start sector not available. Max. 10 >> letters. */ >> + sprintf(start_str, "%10s", _("N/A")); >> } >> ul_unref_path(pc); >> } >> + if (start_str[0] == 0) >> + sprintf(start_str, "%10ju", start); > > Maybe we ca use ul_path_read_buffer() rather than ul_path_read_u64() to keep > it as string and to avoid sprintf(). This was in the original code, but your proposal makes a perfect sense. %10ju is just a space padded original string. -- Best Regards / S pozdravem, Stanislav Brabec software developer --------------------------------------------------------------------- SUSE LINUX, s. r. o. e-mail: sbrabec@xxxxxxxx Křižíkova 148/34 (Corso IIa) tel: +420 284 084 060 186 00 Praha 8-Karlín fax: +420 284 084 001 Czech Republic http://www.suse.cz/ PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76