diff options
author | Theodore Ts'o <tytso@mit.edu> | 2008-08-26 08:13:56 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-08-26 23:53:22 -0400 |
commit | f4e89bcdf2870820ff262e3aed04cbb5374d7fdd (patch) | |
tree | 27ff73aadba70831e3c01f7a49863dabc6650c10 /lib/blkid/devname.c | |
parent | 5dd77dbe5a0ac6d78c1c6441fae4087be56d9088 (diff) | |
download | e2fsprogs-f4e89bcdf2870820ff262e3aed04cbb5374d7fdd.tar.gz |
libblkid: Optimize devicemapper support
This commit works by removing all calls from libdevmapper altogether,
and using the standard support for "normal" non-dm devices.
It depends on dm devices being placed in /dev/mapper (but the previous
code had this dependency anyway), and /proc/partitions containing dm
devices.
We don't actually rip out the libdevmapper code in this commit, but
just disable it via #undef HAVE_DEVMAPPER, just so it's easier to
review and understand the fundamental code changes. A subsequent
commit will remove the libdevmapper code, as well as unexport
the blkid_devdirs string array.
Thanks to Karel Zak for inspiring me to look at the dm code in blkid,
so I could realize how much it deserved to ripped out by its roots. :-)
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, 17 insertions, 5 deletions
diff --git a/lib/blkid/devname.c b/lib/blkid/devname.c index 86fd44cb..ec3cff3a 100644 --- a/lib/blkid/devname.c +++ b/lib/blkid/devname.c @@ -38,6 +38,8 @@ #include "blkidP.h" +#undef HAVE_DEVMAPPER + #ifdef HAVE_DEVMAPPER #include <libdevmapper.h> #endif @@ -122,6 +124,9 @@ blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags) static int dm_device_is_leaf(const dev_t dev); #endif +/* Directories where we will try to search for device names */ +static const char *dirlist[] = { "/dev", "/devfs", "/devices", NULL }; + /* * Probe a single block device to add to the device cache. */ @@ -159,7 +164,7 @@ static void probe_one(blkid_cache cache, const char *ptname, * the stat information doesn't check out, use blkid_devno_to_devname() * to find it via an exhaustive search for the device major/minor. */ - for (dir = blkid_devdirs; *dir; dir++) { + for (dir = dirlist; *dir; dir++) { struct stat st; char device[256]; @@ -174,6 +179,9 @@ static void probe_one(blkid_cache cache, const char *ptname, break; } } + /* Do a short-cut scan of /dev/mapper first */ + if (!devname) + blkid__scan_dir("/dev/mapper", devno, 0, &devname); if (!devname) { devname = blkid_devno_to_devname(devno); if (!devname) @@ -183,10 +191,14 @@ static void probe_one(blkid_cache cache, const char *ptname, free(devname); set_pri: - if (!pri && !strncmp(ptname, "md", 2)) - pri = BLKID_PRI_MD; - if (dev) - dev->bid_pri = pri; + if (dev) { + if (pri) + dev->bid_pri = pri; + else if (!strncmp(dev->bid_name, "/dev/mapper/", 11)) + dev->bid_pri = BLKID_PRI_DM; + else if (!strncmp(ptname, "md", 2)) + dev->bid_pri = BLKID_PRI_MD; + } return; } |