Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/dm Adapt to proplib API chanages.



details:   https://anonhg.NetBSD.org/src/rev/66d4b3288097
branches:  trunk
changeset: 935675:66d4b3288097
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Jul 08 15:07:13 2020 +0000

description:
Adapt to proplib API chanages.

diffstat:

 sys/dev/dm/device-mapper.c |   4 +-
 sys/dev/dm/dm_dev.c        |   6 +-
 sys/dev/dm/dm_ioctl.c      |  78 +++++++++++++++++++++++++--------------------
 sys/dev/dm/dm_target.c     |   6 +-
 4 files changed, 52 insertions(+), 42 deletions(-)

diffs (truncated from 304 to 300 lines):

diff -r caab450780b0 -r 66d4b3288097 sys/dev/dm/device-mapper.c
--- a/sys/dev/dm/device-mapper.c        Wed Jul 08 13:41:53 2020 +0000
+++ b/sys/dev/dm/device-mapper.c        Wed Jul 08 15:07:13 2020 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: device-mapper.c,v 1.60 2020/01/16 07:18:08 maya Exp $ */
+/*        $NetBSD: device-mapper.c,v 1.61 2020/07/08 15:07:13 thorpej Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -402,7 +402,7 @@
                return EINVAL;
 
        for (i = 0; cmd_fn[i].cmd != NULL; i++)
-               if (prop_string_equals_cstring(command, cmd_fn[i].cmd))
+               if (prop_string_equals_string(command, cmd_fn[i].cmd))
                        break;
 
        if (!cmd_fn[i].allowed &&
diff -r caab450780b0 -r 66d4b3288097 sys/dev/dm/dm_dev.c
--- a/sys/dev/dm/dm_dev.c       Wed Jul 08 13:41:53 2020 +0000
+++ b/sys/dev/dm/dm_dev.c       Wed Jul 08 15:07:13 2020 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_dev.c,v 1.17 2019/12/31 10:30:30 tkusumi Exp $      */
+/*        $NetBSD: dm_dev.c,v 1.18 2020/07/08 15:07:13 thorpej 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_dev.c,v 1.17 2019/12/31 10:30:30 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_dev.c,v 1.18 2020/07/08 15:07:13 thorpej Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -381,7 +381,7 @@
        TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist) {
                dev_dict = prop_dictionary_create();
 
-               prop_dictionary_set_cstring(dev_dict, DM_DEV_NAME, dmv->name);
+               prop_dictionary_set_string(dev_dict, DM_DEV_NAME, dmv->name);
                prop_dictionary_set_uint32(dev_dict, DM_DEV_DEV, dmv->minor);
 
                prop_array_add(dev_array, dev_dict);
diff -r caab450780b0 -r 66d4b3288097 sys/dev/dm/dm_ioctl.c
--- a/sys/dev/dm/dm_ioctl.c     Wed Jul 08 13:41:53 2020 +0000
+++ b/sys/dev/dm/dm_ioctl.c     Wed Jul 08 15:07:13 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_ioctl.c,v 1.49 2019/12/23 16:17:35 tkusumi Exp $      */
+/* $NetBSD: dm_ioctl.c,v 1.50 2020/07/08 15:07:13 thorpej 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_ioctl.c,v 1.49 2019/12/23 16:17:35 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.50 2020/07/08 15:07:13 thorpej Exp $");
 
 /*
  * Locking is used to synchronise between ioctl calls and between dm_table's
@@ -202,8 +202,8 @@
        uuid = NULL;
 
        /* Get needed values from dictionary. */
-       prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
-       prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
+       prop_dictionary_get_string(dm_dict, DM_IOCTL_NAME, &name);
+       prop_dictionary_get_string(dm_dict, DM_IOCTL_UUID, &uuid);
        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
 
        dm_dbg_print_flags(flags);
@@ -323,8 +323,8 @@
        minor = 0;
 
        /* Get needed values from dictionary. */
-       prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
-       prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
+       prop_dictionary_get_string(dm_dict, DM_IOCTL_NAME, &name);
+       prop_dictionary_get_string(dm_dict, DM_IOCTL_UUID, &uuid);
        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);
 
@@ -332,7 +332,7 @@
 
        cmd_array = prop_dictionary_get(dm_dict, DM_IOCTL_CMD_DATA);
 
-       prop_array_get_cstring_nocopy(cmd_array, 0, &n_name);
+       prop_array_get_string(cmd_array, 0, &n_name);
 
        if (strlen(n_name) + 1 > DM_NAME_LEN)
                return EINVAL;
@@ -351,7 +351,7 @@
 
        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_OPEN, dmv->table_head.io_cnt);
        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor);
-       prop_dictionary_set_cstring(dm_dict, DM_IOCTL_UUID, dmv->uuid);
+       prop_dictionary_set_string(dm_dict, DM_IOCTL_UUID, dmv->uuid);
 
        dm_dev_insert(dmv);
 
@@ -375,8 +375,8 @@
        uuid = NULL;
 
        /* Get needed values from dictionary. */
-       prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
-       prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
+       prop_dictionary_get_string(dm_dict, DM_IOCTL_NAME, &name);
+       prop_dictionary_get_string(dm_dict, DM_IOCTL_UUID, &uuid);
        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);
 
@@ -415,8 +415,8 @@
        uuid = NULL;
        flags = 0;
 
-       prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
-       prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
+       prop_dictionary_get_string(dm_dict, DM_IOCTL_NAME, &name);
+       prop_dictionary_get_string(dm_dict, DM_IOCTL_UUID, &uuid);
        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);
 
@@ -428,7 +428,7 @@
 
        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_OPEN, dmv->table_head.io_cnt);
        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor);
-       prop_dictionary_set_cstring(dm_dict, DM_IOCTL_UUID, dmv->uuid);
+       prop_dictionary_set_string(dm_dict, DM_IOCTL_UUID, dmv->uuid);
 
        if (dmv->flags & DM_SUSPEND_FLAG)
                DM_ADD_FLAG(flags, DM_SUSPEND_FLAG);
@@ -469,8 +469,8 @@
        uuid = NULL;
        flags = 0;
 
-       prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
-       prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
+       prop_dictionary_get_string(dm_dict, DM_IOCTL_NAME, &name);
+       prop_dictionary_get_string(dm_dict, DM_IOCTL_UUID, &uuid);
        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);
 
@@ -514,8 +514,8 @@
         * printf("%s\n",xml);
         */
 
-       prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
-       prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
+       prop_dictionary_get_string(dm_dict, DM_IOCTL_NAME, &name);
+       prop_dictionary_get_string(dm_dict, DM_IOCTL_UUID, &uuid);
        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);
 
@@ -570,8 +570,8 @@
        flags = 0;
        minor = 0;
 
-       prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
-       prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
+       prop_dictionary_get_string(dm_dict, DM_IOCTL_NAME, &name);
+       prop_dictionary_get_string(dm_dict, DM_IOCTL_UUID, &uuid);
        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);
 
@@ -615,8 +615,8 @@
        uuid = NULL;
        flags = 0;
 
-       prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
-       prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
+       prop_dictionary_get_string(dm_dict, DM_IOCTL_NAME, &name);
+       prop_dictionary_get_string(dm_dict, DM_IOCTL_UUID, &uuid);
        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);
 
@@ -628,8 +628,8 @@
                return ENOENT;
        }
        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor);
-       prop_dictionary_set_cstring(dm_dict, DM_IOCTL_NAME, dmv->name);
-       prop_dictionary_set_cstring(dm_dict, DM_IOCTL_UUID, dmv->uuid);
+       prop_dictionary_set_string(dm_dict, DM_IOCTL_NAME, dmv->name);
+       prop_dictionary_set_string(dm_dict, DM_IOCTL_UUID, dmv->uuid);
 
        aprint_debug("Getting table deps for device: %s\n", dmv->name);
 
@@ -720,8 +720,8 @@
         * printf("%s\n",xml);
         */
 
-       prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
-       prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
+       prop_dictionary_get_string(dm_dict, DM_IOCTL_NAME, &name);
+       prop_dictionary_get_string(dm_dict, DM_IOCTL_UUID, &uuid);
        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);
 
@@ -753,9 +753,11 @@
 
        while ((target_dict = prop_object_iterator_next(iter)) != NULL) {
                int ret;
-               char *str = NULL;
+               const char *cp;
+               char *str;
+               size_t strsz;
 
-               prop_dictionary_get_cstring_nocopy(target_dict,
+               prop_dictionary_get_string(target_dict,
                    DM_TABLE_TYPE, &type);
                /*
                 * If we want to deny table with 2 or more different
@@ -786,8 +788,13 @@
                 * null and therefore it should be checked before we try to
                 * use it.
                 */
-               prop_dictionary_get_cstring(target_dict,
-                   DM_TABLE_PARAMS, (char **) &str);
+               cp = NULL;
+               prop_dictionary_get_string(target_dict,
+                   DM_TABLE_PARAMS, &cp);
+               if (cp == NULL)
+                       str = NULL;
+               else
+                       str = kmem_strdupsize(cp, &strsz, KM_SLEEP);
 
                if (SLIST_EMPTY(tbl) || last_table == NULL)
                        /* insert this table to head */
@@ -798,14 +805,17 @@
                if ((ret = dm_table_init(target, table_en, str)) != 0) {
                        dm_table_release(&dmv->table_head, DM_TABLE_INACTIVE);
                        dm_table_destroy(&dmv->table_head, DM_TABLE_INACTIVE);
-                       free(str, M_TEMP);
+
+                       if (str != NULL)
+                               kmem_free(str, strsz);
 
                        dm_dev_unbusy(dmv);
                        prop_object_iterator_release(iter);
                        return ret;
                }
                last_table = table_en;
-               free(str, M_TEMP);
+               if (str != NULL)
+                       kmem_free(str, strsz);
        }
        prop_object_iterator_release(iter);
 
@@ -948,7 +958,7 @@
                prop_dictionary_set_uint64(target_dict, DM_TABLE_LENGTH,
                    table_en->length);
 
-               prop_dictionary_set_cstring(target_dict, DM_TABLE_TYPE,
+               prop_dictionary_set_string(target_dict, DM_TABLE_TYPE,
                    table_en->target->name);
 
                /* dm_table_get_cur_actv.table ?? */
@@ -959,7 +969,7 @@
                 * Explicitly clear DM_TABLE_PARAMS to prevent dmsetup(8) from
                 * printing junk when DM_TABLE_PARAMS was never initialized.
                 */
-               prop_dictionary_set_cstring(target_dict, DM_TABLE_PARAMS, "");
+               prop_dictionary_set_string(target_dict, DM_TABLE_PARAMS, "");
 
                is_table = (flags & DM_STATUS_TABLE_FLAG) ? 1 : 0;
                if (is_table && table_en->target->table)
@@ -972,7 +982,7 @@
                        params = NULL;
 
                if (params != NULL) {
-                       prop_dictionary_set_cstring(target_dict,
+                       prop_dictionary_set_string(target_dict,
                            DM_TABLE_PARAMS, params);
                        kmem_free(params, DM_MAX_PARAMS_SIZE);
                }
diff -r caab450780b0 -r 66d4b3288097 sys/dev/dm/dm_target.c
--- a/sys/dev/dm/dm_target.c    Wed Jul 08 13:41:53 2020 +0000
+++ b/sys/dev/dm/dm_target.c    Wed Jul 08 15:07:13 2020 +0000
@@ -1,4 +1,4 @@
-/*        $NetBSD: dm_target.c,v 1.40 2020/01/21 16:27:53 tkusumi Exp $      */
+/*        $NetBSD: dm_target.c,v 1.41 2020/07/08 15:07:13 thorpej 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.c,v 1.40 2020/01/21 16:27:53 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_target.c,v 1.41 2020/07/08 15:07:13 thorpej Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -285,7 +285,7 @@
 
                target_dict = prop_dictionary_create();
                ver = prop_array_create();
-               prop_dictionary_set_cstring(target_dict, DM_TARGETS_NAME,



Home | Main Index | Thread Index | Old Index