diff options
author | Eric Sandeen <sandeen@sandeen.net> | 2007-11-29 12:57:35 -0600 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2007-12-02 05:25:30 -0500 |
commit | 38361bbbb55735cf0f4ed6d56079c70fb3328036 (patch) | |
tree | c917454872b436f26c395eba648ee73608fe51ce /lib/blkid/devname.c | |
parent | 7e5a86a66044c4bf4021d1e2900a8748011f17b5 (diff) | |
download | e2fsprogs-38361bbbb55735cf0f4ed6d56079c70fb3328036.tar.gz |
e2fsprogs: fix blkid whole-disk scanning heuristics
The heuristics in blkid/devname.c probe_all() for scanning whole disks
with no partitions assume that a device name with no digit on the end
will always be present as a delineator, i.e.:
sda
sda1
sdb
sdc
In this case, when sdc is seen, it's the clue to go back and scan sdb.
However, for something like:
sda
sda1
sdb
loop0
this falls down, and sdb is never scanned.
(thanks to Karel Zak for pointing this out).
Addresses-Red-Hat-Bugzilla: #400321
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib/blkid/devname.c')
-rw-r--r-- | lib/blkid/devname.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/blkid/devname.c b/lib/blkid/devname.c index 13500768..fd646960 100644 --- a/lib/blkid/devname.c +++ b/lib/blkid/devname.c @@ -490,10 +490,11 @@ static int probe_all(blkid_cache cache, int only_if_new) DBG(DEBUG_DEVNAME, printf("read partition name %s\n", ptname)); - /* Skip whole disk devs unless they have no partitions - * If we don't have a partition on this dev, also + /* Skip whole disk devs unless they have no partitions. + * If base name of device has changed, also * check previous dev to see if it didn't have a partn. - * heuristic: partition name ends in a digit. + * heuristic: partition name ends in a digit, & partition + * names contain whole device name as substring. * * Skip extended partitions. * heuristic: size is 1 @@ -502,6 +503,8 @@ static int probe_all(blkid_cache cache, int only_if_new) */ lens[which] = strlen(ptname); + + /* ends in a digit, clearly a partition, so check */ if (isdigit(ptname[lens[which] - 1])) { DBG(DEBUG_DEVNAME, printf("partition dev %s, devno 0x%04X\n", @@ -510,10 +513,15 @@ static int probe_all(blkid_cache cache, int only_if_new) if (sz > 1) probe_one(cache, ptname, devs[which], 0, only_if_new); - lens[which] = 0; - lens[last] = 0; - } else if (lens[last] && strncmp(ptnames[last], ptname, - lens[last])) { + lens[which] = 0; /* mark as checked */ + } + + /* + * If last was not checked because it looked like a whole-disk + * dev, and the device's base name has changed, + * check last as well. + */ + if (lens[last] && strncmp(ptnames[last], ptname, lens[last])) { DBG(DEBUG_DEVNAME, printf("whole dev %s, devno 0x%04X\n", ptnames[last], (unsigned int) devs[last])); |