From: Karel Zak Date: Tue, 5 May 2009 19:40:19 +0000 (+0200) Subject: blkid: use /dev/mapper/ rather than /dev/dm- X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e1ae8abce67829ba07ec8de1c4daef152d92846;p=util-linux blkid: use /dev/mapper/ rather than /dev/dm- The libblkid (since v1.41.1) returns private device-mapper names (e.g. /dev/dm-0). It's because the probe_one() function scans /dev before /dev/mapper. brw-rw---- 1 root disk 253, 0 2009-04-27 13:41 /dev/dm-0 brw-rw---- 1 root disk 253, 0 2009-04-27 13:41 /dev/mapper/TestVolGroup-TestLogVolume Old version: # blkid -t LABEL="TEST-LABEL" -o device /dev/dm-0 Fixed version: # blkid -t LABEL="TEST-LABEL" -o device /dev/mapper/TestVolGroup-TestLogVolume Addresses-Red-Hat-Bug: #497259 Signed-off-by: Karel Zak --- diff --git a/libs/blkid/src/devname.c b/libs/blkid/src/devname.c index 8c9c3954..d2f53330 100644 --- a/libs/blkid/src/devname.c +++ b/libs/blkid/src/devname.c @@ -179,6 +179,15 @@ static void probe_one(blkid_cache cache, const char *ptname, if (dev && dev->bid_devno == devno) goto set_pri; + /* Try to translate private device-mapper dm- names + * to standard /dev/mapper/. + */ + if (!strncmp(ptname, "dm-", 3) && isdigit(ptname[3])) { + blkid__scan_dir("/dev/mapper", devno, 0, &devname); + if (devname) + goto get_dev; + } + /* * Take a quick look at /dev/ptname for the device number. We check * all of the likely device directories. If we don't find it, or if @@ -197,7 +206,7 @@ static void probe_one(blkid_cache cache, const char *ptname, if (stat(device, &st) == 0 && S_ISBLK(st.st_mode) && st.st_rdev == devno) { devname = blkid_strdup(device); - break; + goto get_dev; } } /* Do a short-cut scan of /dev/mapper first */ @@ -208,6 +217,8 @@ static void probe_one(blkid_cache cache, const char *ptname, if (!devname) return; } + +get_dev: dev = blkid_get_dev(cache, devname, BLKID_DEV_NORMAL); free(devname);