* [PATCH] dm: Get devices using name_to_dev_t
@ 2015-01-15 0:16 Dan Ehrenberg
2015-01-15 2:26 ` Mike Snitzer
0 siblings, 1 reply; 3+ messages in thread
From: Dan Ehrenberg @ 2015-01-15 0:16 UTC (permalink / raw)
To: dm-devel; +Cc: grundler, drewry, gwendal, Dan Ehrenberg
If a device is used as the root filesystem, it can't be built
off of devices which are within the root filesystem (just like
command line arguments to root=). For this reason, Linux has a
pseudo-filesystem for root= and md initialization based on the
function name_to_dev_t, which handles different ways of specifying
devices including PARTUUID and major:minor.
This patch applies name_to_dev_t to dm initialization. Rather
than assuming that all things which are not major:minor are paths
in an already-mounted filesystem, this patch first attempts
name_to_dev_t and tries the filesystem as a fallback.
Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org>
---
drivers/md/dm-table.c | 11 +++--------
include/linux/mount.h | 2 +-
init/do_mounts.c | 2 +-
3 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 3afae9e..03f65ed 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -18,6 +18,7 @@
#include <linux/mutex.h>
#include <linux/delay.h>
#include <linux/atomic.h>
+#include <linux/mount.h>
#define DM_MSG_PREFIX "table"
@@ -372,18 +373,12 @@ int dm_get_device(struct dm_target *ti, const char *path, fmode_t mode,
int r;
dev_t uninitialized_var(dev);
struct dm_dev_internal *dd;
- unsigned int major, minor;
struct dm_table *t = ti->table;
- char dummy;
BUG_ON(!t);
- if (sscanf(path, "%u:%u%c", &major, &minor, &dummy) == 2) {
- /* Extract the major/minor numbers */
- dev = MKDEV(major, minor);
- if (MAJOR(dev) != major || MINOR(dev) != minor)
- return -EOVERFLOW;
- } else {
+ dev = name_to_dev_t(path);
+ if (!dev) {
/* convert the path to a device */
struct block_device *bdev = lookup_bdev(path);
diff --git a/include/linux/mount.h b/include/linux/mount.h
index c2c561d..bca086d 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -92,6 +92,6 @@ extern struct vfsmount *vfs_kern_mount(struct file_system_type *type,
extern void mnt_set_expiry(struct vfsmount *mnt, struct list_head *expiry_list);
extern void mark_mounts_for_expiry(struct list_head *mounts);
-extern dev_t name_to_dev_t(char *name);
+extern dev_t name_to_dev_t(const char *name);
#endif /* _LINUX_MOUNT_H */
diff --git a/init/do_mounts.c b/init/do_mounts.c
index eb41008..0584e37 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -207,7 +207,7 @@ done:
* bangs.
*/
-dev_t name_to_dev_t(char *name)
+dev_t name_to_dev_t(const char *name)
{
char s[32];
char *p;
--
2.2.0.rc0.207.ga3a616c
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: dm: Get devices using name_to_dev_t
2015-01-15 0:16 [PATCH] dm: Get devices using name_to_dev_t Dan Ehrenberg
@ 2015-01-15 2:26 ` Mike Snitzer
2015-01-15 4:15 ` Daniel Ehrenberg
0 siblings, 1 reply; 3+ messages in thread
From: Mike Snitzer @ 2015-01-15 2:26 UTC (permalink / raw)
To: Dan Ehrenberg; +Cc: grundler, drewry, dm-devel, gwendal
On Wed, Jan 14 2015 at 7:16pm -0500,
Dan Ehrenberg <dehrenberg@chromium.org> wrote:
> If a device is used as the root filesystem, it can't be built
> off of devices which are within the root filesystem (just like
> command line arguments to root=). For this reason, Linux has a
> pseudo-filesystem for root= and md initialization based on the
> function name_to_dev_t, which handles different ways of specifying
> devices including PARTUUID and major:minor.
>
> This patch applies name_to_dev_t to dm initialization. Rather
> than assuming that all things which are not major:minor are paths
> in an already-mounted filesystem, this patch first attempts
> name_to_dev_t and tries the filesystem as a fallback.
What is all this talk of an already-mounted filesystem?
dm_get_device() currently assumes either a major:minor or path to the
block device is provided. Please be specific about what functionality
this change enables that you cannot do without.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: dm: Get devices using name_to_dev_t
2015-01-15 2:26 ` Mike Snitzer
@ 2015-01-15 4:15 ` Daniel Ehrenberg
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Ehrenberg @ 2015-01-15 4:15 UTC (permalink / raw)
To: Mike Snitzer; +Cc: Grant Grundler, drewry, Gwendal Grignou, dm-devel
[-- Attachment #1.1: Type: text/plain, Size: 1301 bytes --]
On Jan 14, 2015 6:26 PM, "Mike Snitzer" <snitzer@redhat.com> wrote:
>
> On Wed, Jan 14 2015 at 7:16pm -0500,
> Dan Ehrenberg <dehrenberg@chromium.org> wrote:
>
> > If a device is used as the root filesystem, it can't be built
> > off of devices which are within the root filesystem (just like
> > command line arguments to root=). For this reason, Linux has a
> > pseudo-filesystem for root= and md initialization based on the
> > function name_to_dev_t, which handles different ways of specifying
> > devices including PARTUUID and major:minor.
> >
> > This patch applies name_to_dev_t to dm initialization. Rather
> > than assuming that all things which are not major:minor are paths
> > in an already-mounted filesystem, this patch first attempts
> > name_to_dev_t and tries the filesystem as a fallback.
>
> What is all this talk of an already-mounted filesystem?
>
> dm_get_device() currently assumes either a major:minor or path to the
> block device is provided. Please be specific about what functionality
> this change enables that you cannot do without.
I want to run dm-verity on top of an ubiblock device. Ubiblock uses a
dynamic major number so I can't just refer to it as a major:minor. Because
it is the root filesystem I can't refer to it through the lookup_bdev path.
Thanks,
Dan
[-- Attachment #1.2: Type: text/html, Size: 1686 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-01-15 4:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-15 0:16 [PATCH] dm: Get devices using name_to_dev_t Dan Ehrenberg
2015-01-15 2:26 ` Mike Snitzer
2015-01-15 4:15 ` Daniel Ehrenberg
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.