diff mbox

[v3,3/3] dm: lookup devices by path with name_to_dev_t

Message ID 1274294304-30606-3-git-send-email-wad@chromium.org (mailing list archive)
State Deferred, archived
Delegated to: Alasdair Kergon
Headers show

Commit Message

Will Drewry May 19, 2010, 6:38 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index ef6a3ab..589e86a 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -11,6 +11,7 @@ 
 #include <linux/vmalloc.h>
 #include <linux/blkdev.h>
 #include <linux/namei.h>
+#include <linux/mount.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
 #include <linux/slab.h>
@@ -434,17 +435,16 @@  static int __table_get_device(struct dm_table *t, struct dm_target *ti,
 	int r;
 	dev_t uninitialized_var(dev);
 	struct dm_dev_internal *dd;
-	unsigned int major, minor;
+	char base_path[32];  /* size from name_to_dev_t */
 
 	BUG_ON(!t);
 
-	if (sscanf(path, "%u:%u", &major, &minor) == 2) {
-		/* Extract the major/minor numbers */
-		dev = MKDEV(major, minor);
-		if (MAJOR(dev) != major || MINOR(dev) != minor)
-			return -EOVERFLOW;
-	} else {
-		/* convert the path to a device */
+	/* stage the shorter path for name_to_dev_t. */
+	strncpy(base_path, path, sizeof(base_path));
+
+	/* lookup by major:minor or registered device name */
+	if (!(dev = name_to_dev_t(base_path))) {
+		/* convert the path to a device by finding its inode */
 		struct block_device *bdev = lookup_bdev(path);
 
 		if (IS_ERR(bdev))