All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: ext4 development <linux-ext4@vger.kernel.org>
Cc: Theodore Tso <tytso@mit.edu>
Subject: [PATCH] e2fsprogs: fix blkid whole-disk scanning heuristics
Date: Thu, 29 Nov 2007 12:57:35 -0600	[thread overview]
Message-ID: <474F0B9F.5070902@sandeen.net> (raw)

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).

I believe the following patch will fix this up, but when messing
with partition scanning, I don't mind a second opinion.  :)

Thanks,

-Eric

---

Addresses-Red-Hat-Bugzilla: #400321
Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Index: e2fsprogs-1.40.2/lib/blkid/devname.c
===================================================================
--- e2fsprogs-1.40.2.orig/lib/blkid/devname.c
+++ e2fsprogs-1.40.2/lib/blkid/devname.c
@@ -490,10 +490,11 @@ static int probe_all(blkid_cache cache, 
 
 		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, 
 		 */
 
 		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, 
 			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]));

                 reply	other threads:[~2007-11-29 19:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=474F0B9F.5070902@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.