summaryrefslogtreecommitdiff
path: root/sys/dev/dm/dm_target_linear.c
diff options
context:
space:
mode:
authorhaad <haad@NetBSD.org>2009-12-01 23:12:09 +0000
committerhaad <haad@NetBSD.org>2009-12-01 23:12:09 +0000
commitf26bfe28da955f176f43dabbb209af4234115b39 (patch)
tree6c52caca3665579f2502051c2ca0afbbf44a561a /sys/dev/dm/dm_target_linear.c
parentcfa2bb1730d4cd54aa2b79d4913c5a8921e97e71 (diff)
Revert my commit which have added knowledge about dm targets to libdevmapper,
this breaks abstraction. Because only lvmtools/lvmlib and device-mapper can have knowledge about target mapping and libdevmapper only passes requests from lvmtools to kernel and back. Bump major library and driver version. Requested by: yamt@
Diffstat (limited to 'sys/dev/dm/dm_target_linear.c')
-rw-r--r--sys/dev/dm/dm_target_linear.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/sys/dev/dm/dm_target_linear.c b/sys/dev/dm/dm_target_linear.c
index fb59c9332e5..62429a94843 100644
--- a/sys/dev/dm/dm_target_linear.c
+++ b/sys/dev/dm/dm_target_linear.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_target_linear.c,v 1.7 2009/09/09 22:38:49 haad Exp $ */
+/* $NetBSD: dm_target_linear.c,v 1.8 2009/12/01 23:12:10 haad Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -43,7 +43,6 @@
#include <machine/int_fmtio.h>
-#include "netbsd-dm.h"
#include "dm.h"
/*
@@ -55,38 +54,42 @@
* @argv[1] is physical data offset.
*/
int
-dm_target_linear_init(dm_dev_t *dmv, void **target_config, prop_dictionary_t dict)
+dm_target_linear_init(dm_dev_t *dmv, void **target_config, char *params)
{
dm_target_linear_config_t *tlc;
dm_pdev_t *dmp;
- const char *device;
- uint64_t offset;
-
- if (prop_dictionary_get_cstring_nocopy(dict, DM_TARGET_LINEAR_DEVICE,
- &device) == false)
- return EINVAL;
-
- if (prop_dictionary_get_uint64(dict, DM_TARGET_LINEAR_OFFSET,
- &offset) == false)
+ char **ap, *argv[3];
+
+ if(params == NULL)
return EINVAL;
+
+ /*
+ * Parse a string, containing tokens delimited by white space,
+ * into an argument vector
+ */
+ for (ap = argv; ap < &argv[2] &&
+ (*ap = strsep(&params, " \t")) != NULL;) {
+ if (**ap != '\0')
+ ap++;
+ }
+ aprint_debug("Linear target init function called %s--%s!!\n",
+ argv[0], argv[1]);
+
/* Insert dmp to global pdev list */
- if ((dmp = dm_pdev_insert(device)) == NULL)
+ if ((dmp = dm_pdev_insert(argv[0])) == NULL)
return ENOENT;
- aprint_debug("Linear target init function called %s--%"PRIu64"!!\n",
- device, offset);
-
if ((tlc = kmem_alloc(sizeof(dm_target_linear_config_t), KM_SLEEP))
== NULL)
- return 1;
+ return ENOMEM;
tlc->pdev = dmp;
tlc->offset = 0; /* default settings */
/* Check user input if it is not leave offset as 0. */
- tlc->offset = offset;
+ tlc->offset = atoi(argv[1]);
*target_config = tlc;
@@ -105,17 +108,17 @@ dm_target_linear_status(void *target_config)
{
dm_target_linear_config_t *tlc;
char *params;
- tlc = target_config;
-
+ tlc = target_config;
+
aprint_debug("Linear target status function called\n");
- if ((params = kmem_alloc(DM_MAX_PARAMS_SIZE, KM_SLEEP)) == NULL)
+ if ((params = kmem_alloc(DM_MAX_PARAMS_SIZE, KM_NOSLEEP)) == NULL)
return NULL;
aprint_normal("%s %"PRIu64, tlc->pdev->name, tlc->offset);
- snprintf(params, DM_MAX_PARAMS_SIZE,"%s %"PRIu64,
- tlc->pdev->name, tlc->offset);
-
+ snprintf(params, DM_MAX_PARAMS_SIZE,"%s %"PRIu64,
+ tlc->pdev->name, tlc->offset);
+
return params;
}