Util-Linux Archive on lore.kernel.org
 help / color / Atom feed
From: Stanislav Brabec <sbrabec@suse.cz>
To: Karel Zak <kzak@redhat.com>
Cc: util-linux@vger.kernel.org, Martin Wilck <martin.wilck@suse.com>
Subject: Re: [PATCH] blockdev: Don't fail on missing start sector
Date: Tue, 2 Jun 2020 03:52:11 +0200
Message-ID: <8803c12f-98b5-8d63-5408-09b61d736b2a@suse.cz> (raw)
In-Reply-To: <20200601081349.uirtbn2u2bfztnq4@ws.net.home>

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?

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@suse.com
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

  reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-31 23:35 Stanislav Brabec
2020-06-01  8:13 ` Karel Zak
2020-06-02  1:52   ` Stanislav Brabec [this message]
2020-06-03 15:16 ` Karel Zak
2020-06-05  8:06   ` Karel Zak
2020-06-13 20:52     ` Stanislav Brabec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8803c12f-98b5-8d63-5408-09b61d736b2a@suse.cz \
    --to=sbrabec@suse.cz \
    --cc=kzak@redhat.com \
    --cc=martin.wilck@suse.com \
    --cc=util-linux@vger.kernel.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Util-Linux Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/util-linux/0 util-linux/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 util-linux util-linux/ https://lore.kernel.org/util-linux \
	public-inbox-index util-linux

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git