dm: Make numsec/secsize arguments in dm_table_disksize() optional

This commit is contained in:
tkusumi 2019-12-22 13:16:09 +00:00
parent 520cf6d5ea
commit 9c30b6c561
2 changed files with 11 additions and 11 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: device-mapper.c,v 1.58 2019/12/22 12:28:54 tkusumi Exp $ */
/* $NetBSD: device-mapper.c,v 1.59 2019/12/22 13:16:09 tkusumi Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@ -431,7 +431,6 @@ disk_ioctl_switch(dev_t dev, unsigned long cmd, void *data)
case DIOCGWEDGEINFO:
{
struct dkwedge_info *dkw = (void *) data;
unsigned int secsize;
if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL)
return ENODEV;
@ -443,7 +442,7 @@ disk_ioctl_switch(dev_t dev, unsigned long cmd, void *data)
strlcpy(dkw->dkw_parent, dmv->name, 16);
dkw->dkw_offset = 0;
dm_table_disksize(&dmv->table_head, &dkw->dkw_size, &secsize);
dm_table_disksize(&dmv->table_head, &dkw->dkw_size, NULL);
strcpy(dkw->dkw_ptype, DKW_PTYPE_FFS);
dm_dev_unbusy(dmv);
@ -494,7 +493,6 @@ disk_ioctl_switch(dev_t dev, unsigned long cmd, void *data)
}
case DIOCGSECTORSIZE:
{
uint64_t numsec;
unsigned int secsize, *valp = data;
if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL)
@ -502,7 +500,7 @@ disk_ioctl_switch(dev_t dev, unsigned long cmd, void *data)
aprint_debug("DIOCGSECTORSIZE ioctl called\n");
dm_table_disksize(&dmv->table_head, &numsec, &secsize);
dm_table_disksize(&dmv->table_head, NULL, &secsize);
*valp = secsize;
dm_dev_unbusy(dmv);
@ -512,14 +510,13 @@ disk_ioctl_switch(dev_t dev, unsigned long cmd, void *data)
{
off_t *valp = data;
uint64_t numsec;
unsigned int secsize;
if ((dmv = dm_dev_lookup(NULL, NULL, minor(dev))) == NULL)
return ENODEV;
aprint_debug("DIOCGMEDIASIZE ioctl called\n");
dm_table_disksize(&dmv->table_head, &numsec, &secsize);
dm_table_disksize(&dmv->table_head, &numsec, NULL);
*valp = numsec;
dm_dev_unbusy(dmv);

View File

@ -1,4 +1,4 @@
/* $NetBSD: dm_table.c,v 1.17 2019/12/21 11:59:03 tkusumi Exp $ */
/* $NetBSD: dm_table.c,v 1.18 2019/12/22 13:16:09 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_table.c,v 1.17 2019/12/21 11:59:03 tkusumi Exp $");
__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.18 2019/12/22 13:16:09 tkusumi Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -262,8 +262,11 @@ dm_table_disksize(dm_table_head_t *head, uint64_t *numsecp,
if (secsize < tsecsize)
secsize = tsecsize;
}
*numsecp = secsize > 0 ? dbtob(length) / secsize : 0;
*secsizep = secsize;
if (numsecp)
*numsecp = secsize > 0 ? dbtob(length) / secsize : 0;
if (secsizep)
*secsizep = secsize;
dm_table_unbusy(head);
}