From: Will Drewry <wad@chromium.org>
To: dm-devel@redhat.com, linux-kernel@vger.kernel.org
Cc: agk@redhat.com, snitzer@redhat.com, Will Drewry <wad@chromium.org>
Subject: [PATCH v3 3/3] dm: lookup devices by path with name_to_dev_t
Date: Wed, 19 May 2010 13:38:24 -0500 [thread overview]
Message-ID: <1274294304-30606-3-git-send-email-wad@chromium.org> (raw)
In-Reply-To: <1274294304-30606-1-git-send-email-wad@chromium.org>
Replace major:minor parsing with name_to_dev_t. This
maintains the current functionality (as the code was the same),
but adds support for the hexadecimal dev as well as device lookup
before the root filesystem is available. The latter is the motivation
for this change.
It still falls back to lookup_bdev() for cases where the inode
on disk provides more information than the name (and the path exceeds
the length handled by name_to_dev_t).
Signed-off-by: Will Drewry <wad@chromium.org>
---
drivers/md/dm-table.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
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))
--
1.7.0.4
next prev parent reply other threads:[~2010-05-19 18:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-19 18:38 [PATCH v3 1/3] dm: allow a dm-fs-style device to be shared via dm-ioctl Will Drewry
2010-05-19 18:38 ` [PATCH v3 2/3] init: boot to device-mapper targets without an initr* Will Drewry
2010-05-19 18:38 ` Will Drewry [this message]
2010-05-24 11:38 ` [dm-devel] [PATCH v3 3/3] dm: lookup devices by path with name_to_dev_t Alasdair G Kergon
2010-05-24 11:57 ` Alasdair G Kergon
2010-05-24 14:44 ` Will Drewry
2010-05-24 15:07 ` Alasdair G Kergon
2010-05-24 16:35 ` Will Drewry
2010-05-24 23:35 ` Mike Snitzer
2010-05-24 23:55 ` Mike Snitzer
2010-05-25 15:58 ` Will Drewry
2010-05-24 16:33 ` [PATCH 1/2] dm: ensure dm_table_complete() completes a table for use Will Drewry
2010-05-24 16:33 ` [PATCH 2/2] dm: export a table+mapped device to the ioctl interface Will Drewry
2010-06-08 3:25 ` [PATCH v4 1/3] dm: ensure dm_table_complete() completes a table for use Will Drewry
2010-06-08 3:25 ` [PATCH v4 2/3] dm: export a table+mapped device to the ioctl interface Will Drewry
2010-06-08 3:25 ` [PATCH v4 3/3] init: add support to directly boot to a mapped device Will Drewry
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=1274294304-30606-3-git-send-email-wad@chromium.org \
--to=wad@chromium.org \
--cc=agk@redhat.com \
--cc=dm-devel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=snitzer@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®