dm: Fix "table" output format of dm-linear and dm-stripe

The existing "table" output showing device file path of pdev is
not compatible with dm in Linux kernel (and also DragonFlyBSD).
It should be showing "major:minor" instead.

taken-from: DragonFlyBSD
This commit is contained in:
tkusumi 2019-12-20 16:16:36 +00:00
parent 1d3f9bf21d
commit aecedc2e33
4 changed files with 14 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dm.h,v 1.48 2019/12/16 15:59:04 tkusumi Exp $ */
/* $NetBSD: dm.h,v 1.49 2019/12/20 16:16:36 tkusumi Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -103,6 +103,7 @@ typedef struct dm_table_head {
*/
typedef struct dm_pdev {
char name[MAX_DEV_NAME];
char udev_name[MAX_DEV_NAME];
struct vnode *pdev_vnode;
uint64_t pdev_numsec;

View File

@ -1,4 +1,4 @@
/* $NetBSD: dm_pdev.c,v 1.21 2019/12/15 14:39:42 tkusumi Exp $ */
/* $NetBSD: dm_pdev.c,v 1.22 2019/12/20 16:16:36 tkusumi Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.21 2019/12/15 14:39:42 tkusumi Exp $");
__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.22 2019/12/20 16:16:36 tkusumi Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -127,6 +127,10 @@ dm_pdev_insert(const char *dev_name)
getdisksize(dmp->pdev_vnode, &dmp->pdev_numsec, &dmp->pdev_secsize);
dmp->ref_cnt = 1;
snprintf(dmp->udev_name, sizeof(dmp->udev_name), "%d:%d",
major(dmp->pdev_vnode->v_rdev), minor(dmp->pdev_vnode->v_rdev));
aprint_debug("%s: %s %s\n", __func__, dev_name, dmp->udev_name);
SLIST_INSERT_HEAD(&dm_pdev_list, dmp, next_pdev);
mutex_exit(&dm_pdev_mutex);

View File

@ -1,4 +1,4 @@
/* $NetBSD: dm_target_linear.c,v 1.33 2019/12/18 14:31:35 tkusumi Exp $ */
/* $NetBSD: dm_target_linear.c,v 1.34 2019/12/20 16:16:36 tkusumi Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.33 2019/12/18 14:31:35 tkusumi Exp $");
__KERNEL_RCSID(0, "$NetBSD: dm_target_linear.c,v 1.34 2019/12/20 16:16:36 tkusumi Exp $");
/*
* This file implements initial version of device-mapper dklinear target.
@ -96,7 +96,7 @@ dm_target_linear_table(void *target_config)
params = kmem_alloc(DM_MAX_PARAMS_SIZE, KM_SLEEP);
snprintf(params, DM_MAX_PARAMS_SIZE, "%s %" PRIu64,
tlc->pdev->name, tlc->offset);
tlc->pdev->udev_name, tlc->offset);
return params;
}

View File

@ -1,4 +1,4 @@
/*$NetBSD: dm_target_stripe.c,v 1.40 2019/12/18 14:31:35 tkusumi Exp $*/
/*$NetBSD: dm_target_stripe.c,v 1.41 2019/12/20 16:16:36 tkusumi Exp $*/
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.40 2019/12/18 14:31:35 tkusumi Exp $");
__KERNEL_RCSID(0, "$NetBSD: dm_target_stripe.c,v 1.41 2019/12/20 16:16:36 tkusumi Exp $");
/*
* This file implements initial version of device-mapper stripe target.
@ -197,7 +197,7 @@ dm_target_stripe_table(void *target_config)
TAILQ_FOREACH(tlc, &tsc->stripe_devs, entries) {
snprintf(tmp, DM_MAX_PARAMS_SIZE, " %s %" PRIu64,
tlc->pdev->name, tlc->offset);
tlc->pdev->udev_name, tlc->offset);
strcat(params, tmp);
}