Annotation of src/sys/dev/dm/dm_ioctl.c, revision 1.31

1.31    ! chs         1: /* $NetBSD: dm_ioctl.c,v 1.30 2015/05/10 14:08:54 christos Exp $      */
1.2       haad        2: 
                      3: /*
                      4:  * Copyright (c) 2008 The NetBSD Foundation, Inc.
                      5:  * All rights reserved.
                      6:  *
                      7:  * This code is derived from software contributed to The NetBSD Foundation
                      8:  * by Adam Hamsik.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  *
                     19:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     20:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     21:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     22:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     23:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     24:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     25:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     26:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     27:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     28:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     29:  * POSSIBILITY OF SUCH DAMAGE.
                     30:  */
                     31: 
                     32: /*
                     33:  * Locking is used to synchronise between ioctl calls and between dm_table's
                     34:  * users.
                     35:  *
                     36:  * ioctl locking:
                     37:  * Simple reference counting, to count users of device will be used routines
                     38:  * dm_dev_busy/dm_dev_unbusy are used for that.
                     39:  * dm_dev_lookup/dm_dev_rem call dm_dev_busy before return(caller is therefore
                     40:  * holder of reference_counter last).
                     41:  *
                     42:  * ioctl routines which change/remove dm_dev parameters must wait on
                     43:  * dm_dev::dev_cv and when last user will call dm_dev_unbusy they will wake
                     44:  * up them.
                     45:  *
                     46:  * table_head locking:
1.20      haad       47:  * To access table entries dm_table_* routines must be used.
1.2       haad       48:  *
                     49:  * dm_table_get_entry will increment table users reference
1.22      haad       50:  * counter. It will return active or inactive table depends
1.2       haad       51:  * on uint8_t argument.
                     52:  *
                     53:  * dm_table_release must be called for every table_entry from
                     54:  * dm_table_get_entry. Between these to calls tables can'tbe switched
1.20      haad       55:  * or destroyed.
1.2       haad       56:  *
                     57:  * dm_table_head_init initialize talbe_entries SLISTS and io_cv.
                     58:  *
                     59:  * dm_table_head_destroy destroy cv.
                     60:  *
                     61:  * There are two types of users for dm_table_head first type will
                     62:  * only read list and try to do anything with it e.g. dmstrategy,
                     63:  * dm_table_size etc. There is another user for table_head which wants
                     64:  * to change table lists e.g. dm_dev_resume_ioctl, dm_dev_remove_ioctl,
                     65:  * dm_table_clear_ioctl.
1.20      haad       66:  *
1.2       haad       67:  * NOTE: It is not allowed to call dm_table_destroy, dm_table_switch_tables
                     68:  *       with hold table reference counter. Table reference counter is hold
                     69:  *       after calling dm_table_get_entry routine. After calling this
                     70:  *       function user must call dm_table_release before any writer table
                     71:  *       operation.
                     72:  *
                     73:  * Example: dm_table_get_entry
                     74:  *          dm_table_destroy/dm_table_switch_tables
                     75:  * This exaple will lead to deadlock situation because after dm_table_get_entry
                     76:  * table reference counter is != 0 and dm_table_destroy have to wait on cv until
                     77:  * reference counter is 0.
                     78:  *
                     79:  */
                     80: 
                     81: #include <sys/types.h>
                     82: #include <sys/param.h>
                     83: 
1.19      haad       84: #include <sys/device.h>
1.6       haad       85: #include <sys/disk.h>
1.2       haad       86: #include <sys/disklabel.h>
                     87: #include <sys/kmem.h>
                     88: #include <sys/malloc.h>
                     89: #include <sys/vnode.h>
                     90: 
                     91: #include <machine/int_fmtio.h>
                     92: 
                     93: #include "netbsd-dm.h"
                     94: #include "dm.h"
                     95: 
1.23      haad       96: static uint32_t sc_minor_num;
1.10      haad       97: extern const struct dkdriver dmdkdriver;
1.24      haad       98: uint32_t dm_dev_counter;
1.2       haad       99: 
1.19      haad      100: /* Generic cf_data for device-mapper driver */
                    101: static struct cfdata dm_cfdata = {
                    102:        .cf_name = "dm",
                    103:        .cf_atname = "dm",
                    104:        .cf_fstate = FSTATE_STAR,
                    105:        .cf_unit = 0
                    106: };
1.2       haad      107: #define DM_REMOVE_FLAG(flag, name) do {                                        \
                    108:                prop_dictionary_get_uint32(dm_dict,DM_IOCTL_FLAGS,&flag); \
                    109:                flag &= ~name;                                          \
                    110:                prop_dictionary_set_uint32(dm_dict,DM_IOCTL_FLAGS,flag); \
1.20      haad      111: } while (/*CONSTCOND*/0)
1.2       haad      112: 
                    113: #define DM_ADD_FLAG(flag, name) do {                                   \
                    114:                prop_dictionary_get_uint32(dm_dict,DM_IOCTL_FLAGS,&flag); \
                    115:                flag |= name;                                           \
                    116:                prop_dictionary_set_uint32(dm_dict,DM_IOCTL_FLAGS,flag); \
1.20      haad      117: } while (/*CONSTCOND*/0)
1.2       haad      118: 
                    119: static int dm_dbg_print_flags(int);
                    120: 
                    121: /*
                    122:  * Print flags sent to the kernel from libevmapper.
                    123:  */
                    124: static int
                    125: dm_dbg_print_flags(int flags)
                    126: {
1.20      haad      127:        aprint_debug("dbg_print --- %d\n", flags);
                    128: 
1.2       haad      129:        if (flags & DM_READONLY_FLAG)
                    130:                aprint_debug("dbg_flags: DM_READONLY_FLAG set In/Out\n");
                    131: 
                    132:        if (flags & DM_SUSPEND_FLAG)
                    133:                aprint_debug("dbg_flags: DM_SUSPEND_FLAG set In/Out \n");
                    134: 
                    135:        if (flags & DM_PERSISTENT_DEV_FLAG)
                    136:                aprint_debug("db_flags: DM_PERSISTENT_DEV_FLAG set In\n");
                    137: 
                    138:        if (flags & DM_STATUS_TABLE_FLAG)
                    139:                aprint_debug("dbg_flags: DM_STATUS_TABLE_FLAG set In\n");
                    140: 
                    141:        if (flags & DM_ACTIVE_PRESENT_FLAG)
                    142:                aprint_debug("dbg_flags: DM_ACTIVE_PRESENT_FLAG set Out\n");
                    143: 
                    144:        if (flags & DM_INACTIVE_PRESENT_FLAG)
                    145:                aprint_debug("dbg_flags: DM_INACTIVE_PRESENT_FLAG set Out\n");
                    146: 
                    147:        if (flags & DM_BUFFER_FULL_FLAG)
                    148:                aprint_debug("dbg_flags: DM_BUFFER_FULL_FLAG set Out\n");
                    149: 
                    150:        if (flags & DM_SKIP_BDGET_FLAG)
                    151:                aprint_debug("dbg_flags: DM_SKIP_BDGET_FLAG set In\n");
                    152: 
                    153:        if (flags & DM_SKIP_LOCKFS_FLAG)
                    154:                aprint_debug("dbg_flags: DM_SKIP_LOCKFS_FLAG set In\n");
                    155: 
                    156:        if (flags & DM_NOFLUSH_FLAG)
                    157:                aprint_debug("dbg_flags: DM_NOFLUSH_FLAG set In\n");
1.20      haad      158: 
1.2       haad      159:        return 0;
                    160: }
                    161: /*
                    162:  * Get version ioctl call I do it as default therefore this
                    163:  * function is unused now.
                    164:  */
                    165: int
                    166: dm_get_version_ioctl(prop_dictionary_t dm_dict)
                    167: {
1.20      haad      168: 
1.2       haad      169:        return 0;
                    170: }
                    171: /*
                    172:  * Get list of all available targets from global
                    173:  * target list and sent them back to libdevmapper.
                    174:  */
                    175: int
                    176: dm_list_versions_ioctl(prop_dictionary_t dm_dict)
                    177: {
                    178:        prop_array_t target_list;
                    179:        uint32_t flags;
                    180: 
                    181:        flags = 0;
                    182: 
                    183:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
1.20      haad      184: 
1.2       haad      185:        dm_dbg_print_flags(flags);
                    186:        target_list = dm_target_prop_list();
                    187: 
                    188:        prop_dictionary_set(dm_dict, DM_IOCTL_CMD_DATA, target_list);
1.20      haad      189:        prop_object_release(target_list);
1.2       haad      190: 
                    191:        return 0;
                    192: }
                    193: /*
                    194:  * Create in-kernel entry for device. Device attributes such as name, uuid are
                    195:  * taken from proplib dictionary.
                    196:  *
                    197:  */
                    198: int
                    199: dm_dev_create_ioctl(prop_dictionary_t dm_dict)
                    200: {
                    201:        dm_dev_t *dmv;
                    202:        const char *name, *uuid;
1.29      justin    203:        int r;
                    204:        uint32_t flags;
1.19      haad      205:        device_t devt;
1.20      haad      206: 
1.2       haad      207:        r = 0;
                    208:        flags = 0;
1.20      haad      209:        name = NULL;
1.2       haad      210:        uuid = NULL;
                    211: 
                    212:        /* Get needed values from dictionary. */
                    213:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
                    214:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
                    215:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
1.20      haad      216: 
1.2       haad      217:        dm_dbg_print_flags(flags);
                    218: 
                    219:        /* Lookup name and uuid if device already exist quit. */
                    220:        if ((dmv = dm_dev_lookup(name, uuid, -1)) != NULL) {
1.20      haad      221:                DM_ADD_FLAG(flags, DM_EXISTS_FLAG);     /* Device already exists */
1.2       haad      222:                dm_dev_unbusy(dmv);
                    223:                return EEXIST;
                    224:        }
1.19      haad      225:        if ((devt = config_attach_pseudo(&dm_cfdata)) == NULL) {
                    226:                aprint_error("Unable to attach pseudo device dm/%s\n", name);
                    227:                return (ENOMEM);
                    228:        }
1.2       haad      229:        if ((dmv = dm_dev_alloc()) == NULL)
                    230:                return ENOMEM;
1.19      haad      231: 
1.2       haad      232:        if (uuid)
                    233:                strncpy(dmv->uuid, uuid, DM_UUID_LEN);
1.20      haad      234:        else
1.2       haad      235:                dmv->uuid[0] = '\0';
1.20      haad      236: 
1.2       haad      237:        if (name)
                    238:                strlcpy(dmv->name, name, DM_NAME_LEN);
                    239: 
1.23      haad      240:        dmv->minor = (uint64_t)atomic_inc_32_nv(&sc_minor_num);
1.20      haad      241:        dmv->flags = 0;         /* device flags are set when needed */
1.2       haad      242:        dmv->ref_cnt = 0;
                    243:        dmv->event_nr = 0;
                    244:        dmv->dev_type = 0;
1.19      haad      245:        dmv->devt = devt;
1.20      haad      246: 
1.19      haad      247:        dm_table_head_init(&dmv->table_head);
                    248: 
1.2       haad      249:        mutex_init(&dmv->dev_mtx, MUTEX_DEFAULT, IPL_NONE);
1.18      haad      250:        mutex_init(&dmv->diskp_mtx, MUTEX_DEFAULT, IPL_NONE);
1.2       haad      251:        cv_init(&dmv->dev_cv, "dm_dev");
                    252: 
                    253:        if (flags & DM_READONLY_FLAG)
                    254:                dmv->flags |= DM_READONLY_FLAG;
                    255: 
                    256:        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor);
1.6       haad      257: 
1.10      haad      258:        disk_init(dmv->diskp, dmv->name, &dmdkdriver);
                    259:        disk_attach(dmv->diskp);
1.13      haad      260: 
                    261:        dmv->diskp->dk_info = NULL;
1.20      haad      262: 
                    263:        if ((r = dm_dev_insert(dmv)) != 0)
1.2       haad      264:                dm_dev_free(dmv);
1.20      haad      265: 
1.2       haad      266:        DM_ADD_FLAG(flags, DM_EXISTS_FLAG);
                    267:        DM_REMOVE_FLAG(flags, DM_INACTIVE_PRESENT_FLAG);
1.6       haad      268: 
                    269:        /* Increment device counter After creating device */
1.24      haad      270:        atomic_inc_32(&dm_dev_counter);
1.20      haad      271: 
1.2       haad      272:        return r;
                    273: }
                    274: /*
                    275:  * Get list of created device-mapper devices fromglobal list and
                    276:  * send it to kernel.
                    277:  *
                    278:  * Output dictionary:
                    279:  *
                    280:  * <key>cmd_data</key>
                    281:  *  <array>
                    282:  *   <dict>
                    283:  *    <key>name<key>
                    284:  *    <string>...</string>
                    285:  *
                    286:  *    <key>dev</key>
                    287:  *    <integer>...</integer>
                    288:  *   </dict>
                    289:  *  </array>
1.20      haad      290:  *
1.2       haad      291:  */
                    292: int
                    293: dm_dev_list_ioctl(prop_dictionary_t dm_dict)
                    294: {
                    295:        prop_array_t dev_list;
                    296: 
                    297:        uint32_t flags;
1.20      haad      298: 
1.2       haad      299:        flags = 0;
1.20      haad      300: 
1.2       haad      301:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
1.20      haad      302: 
1.2       haad      303:        dm_dbg_print_flags(flags);
1.20      haad      304: 
1.2       haad      305:        dev_list = dm_dev_prop_list();
                    306: 
                    307:        prop_dictionary_set(dm_dict, DM_IOCTL_CMD_DATA, dev_list);
                    308:        prop_object_release(dev_list);
1.20      haad      309: 
1.2       haad      310:        return 0;
                    311: }
                    312: /*
                    313:  * Rename selected devices old name is in struct dm_ioctl.
                    314:  * newname is taken from dictionary
                    315:  *
                    316:  * <key>cmd_data</key>
                    317:  *  <array>
                    318:  *   <string>...</string>
                    319:  *  </array>
                    320:  */
                    321: int
                    322: dm_dev_rename_ioctl(prop_dictionary_t dm_dict)
                    323: {
                    324:        prop_array_t cmd_array;
                    325:        dm_dev_t *dmv;
1.20      haad      326: 
1.2       haad      327:        const char *name, *uuid, *n_name;
                    328:        uint32_t flags, minor;
                    329: 
                    330:        name = NULL;
                    331:        uuid = NULL;
                    332:        minor = 0;
1.20      haad      333: 
1.2       haad      334:        /* Get needed values from dictionary. */
                    335:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
                    336:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
                    337:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
                    338:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);
                    339: 
                    340:        dm_dbg_print_flags(flags);
1.20      haad      341: 
1.2       haad      342:        cmd_array = prop_dictionary_get(dm_dict, DM_IOCTL_CMD_DATA);
                    343: 
                    344:        prop_array_get_cstring_nocopy(cmd_array, 0, &n_name);
1.20      haad      345: 
1.2       haad      346:        if (strlen(n_name) + 1 > DM_NAME_LEN)
                    347:                return EINVAL;
1.20      haad      348: 
1.2       haad      349:        if ((dmv = dm_dev_rem(name, uuid, minor)) == NULL) {
                    350:                DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG);
                    351:                return ENOENT;
                    352:        }
                    353:        /* change device name */
1.20      haad      354:        /*
                    355:         * XXX How to deal with this change, name only used in
                    356:         * dm_dev_routines, should I add dm_dev_change_name which will run
                    357:         * under the dm_dev_list mutex ?
1.2       haad      358:         */
                    359:        strlcpy(dmv->name, n_name, DM_NAME_LEN);
1.20      haad      360: 
1.2       haad      361:        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_OPEN, dmv->table_head.io_cnt);
                    362:        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor);
                    363:        prop_dictionary_set_cstring(dm_dict, DM_IOCTL_UUID, dmv->uuid);
                    364: 
                    365:        dm_dev_insert(dmv);
1.20      haad      366: 
1.2       haad      367:        return 0;
                    368: }
                    369: /*
                    370:  * Remove device from global list I have to remove active
                    371:  * and inactive tables first.
                    372:  */
                    373: int
                    374: dm_dev_remove_ioctl(prop_dictionary_t dm_dict)
                    375: {
                    376:        dm_dev_t *dmv;
                    377:        const char *name, *uuid;
                    378:        uint32_t flags, minor;
1.19      haad      379:        device_t devt;
1.20      haad      380: 
1.2       haad      381:        flags = 0;
                    382:        name = NULL;
                    383:        uuid = NULL;
1.20      haad      384: 
1.2       haad      385:        /* Get needed values from dictionary. */
                    386:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
                    387:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
                    388:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
                    389:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);
1.20      haad      390: 
1.2       haad      391:        dm_dbg_print_flags(flags);
1.19      haad      392: 
1.20      haad      393:        /*
                    394:         * This seems as hack to me, probably use routine dm_dev_get_devt to
                    395:         * atomicaly get devt from device.
                    396:         */
1.19      haad      397:        if ((dmv = dm_dev_lookup(name, uuid, minor)) == NULL) {
1.2       haad      398:                DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG);
                    399:                return ENOENT;
                    400:        }
1.19      haad      401:        devt = dmv->devt;
1.2       haad      402: 
1.19      haad      403:        dm_dev_unbusy(dmv);
1.20      haad      404: 
                    405:        /*
                    406:         * This will call dm_detach routine which will actually removes
                    407:         * device.
                    408:         */
1.19      haad      409:        return config_detach(devt, DETACH_QUIET);
1.2       haad      410: }
                    411: /*
                    412:  * Return actual state of device to libdevmapper.
                    413:  */
                    414: int
                    415: dm_dev_status_ioctl(prop_dictionary_t dm_dict)
                    416: {
                    417:        dm_dev_t *dmv;
                    418:        const char *name, *uuid;
                    419:        uint32_t flags, j, minor;
1.20      haad      420: 
1.2       haad      421:        name = NULL;
                    422:        uuid = NULL;
                    423:        flags = 0;
                    424:        j = 0;
1.20      haad      425: 
1.2       haad      426:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
                    427:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
                    428:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
                    429:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);
1.20      haad      430: 
1.2       haad      431:        if ((dmv = dm_dev_lookup(name, uuid, minor)) == NULL) {
                    432:                DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG);
                    433:                return ENOENT;
                    434:        }
1.20      haad      435:        dm_dbg_print_flags(dmv->flags);
1.2       haad      436: 
                    437:        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_OPEN, dmv->table_head.io_cnt);
                    438:        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor);
                    439:        prop_dictionary_set_cstring(dm_dict, DM_IOCTL_UUID, dmv->uuid);
                    440: 
                    441:        if (dmv->flags & DM_SUSPEND_FLAG)
                    442:                DM_ADD_FLAG(flags, DM_SUSPEND_FLAG);
                    443: 
1.20      haad      444:        /*
                    445:         * Add status flags for tables I have to check both active and
                    446:         * inactive tables.
                    447:         */
1.2       haad      448:        if ((j = dm_table_get_target_count(&dmv->table_head, DM_TABLE_ACTIVE))) {
                    449:                DM_ADD_FLAG(flags, DM_ACTIVE_PRESENT_FLAG);
                    450:        } else
                    451:                DM_REMOVE_FLAG(flags, DM_ACTIVE_PRESENT_FLAG);
1.20      haad      452: 
1.2       haad      453:        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_TARGET_COUNT, j);
1.20      haad      454: 
1.2       haad      455:        if (dm_table_get_target_count(&dmv->table_head, DM_TABLE_INACTIVE))
                    456:                DM_ADD_FLAG(flags, DM_INACTIVE_PRESENT_FLAG);
                    457:        else
                    458:                DM_REMOVE_FLAG(flags, DM_INACTIVE_PRESENT_FLAG);
                    459: 
                    460:        dm_dev_unbusy(dmv);
1.20      haad      461: 
1.2       haad      462:        return 0;
                    463: }
                    464: /*
                    465:  * Set only flag to suggest that device is suspended. This call is
                    466:  * not supported in NetBSD.
                    467:  *
                    468:  */
                    469: int
                    470: dm_dev_suspend_ioctl(prop_dictionary_t dm_dict)
                    471: {
                    472:        dm_dev_t *dmv;
                    473:        const char *name, *uuid;
                    474:        uint32_t flags, minor;
1.20      haad      475: 
1.2       haad      476:        name = NULL;
                    477:        uuid = NULL;
                    478:        flags = 0;
1.20      haad      479: 
1.2       haad      480:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
                    481:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
                    482:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
                    483:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);
1.20      haad      484: 
                    485:        if ((dmv = dm_dev_lookup(name, uuid, minor)) == NULL) {
1.2       haad      486:                DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG);
                    487:                return ENOENT;
                    488:        }
                    489:        atomic_or_32(&dmv->flags, DM_SUSPEND_FLAG);
1.20      haad      490: 
1.2       haad      491:        dm_dbg_print_flags(dmv->flags);
1.20      haad      492: 
1.2       haad      493:        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_OPEN, dmv->table_head.io_cnt);
                    494:        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_FLAGS, dmv->flags);
                    495:        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor);
1.20      haad      496: 
1.2       haad      497:        dm_dev_unbusy(dmv);
1.20      haad      498: 
1.2       haad      499:        /* Add flags to dictionary flag after dmv -> dict copy */
1.20      haad      500:        DM_ADD_FLAG(flags, DM_EXISTS_FLAG);
                    501: 
1.2       haad      502:        return 0;
                    503: }
                    504: /*
                    505:  * Simulate Linux behaviour better and switch tables here and not in
1.20      haad      506:  * dm_table_load_ioctl.
1.2       haad      507:  */
                    508: int
                    509: dm_dev_resume_ioctl(prop_dictionary_t dm_dict)
                    510: {
                    511:        dm_dev_t *dmv;
                    512:        const char *name, *uuid;
                    513:        uint32_t flags, minor;
                    514: 
                    515:        name = NULL;
                    516:        uuid = NULL;
                    517:        flags = 0;
1.20      haad      518: 
                    519:        /*
                    520:         * char *xml; xml = prop_dictionary_externalize(dm_dict);
                    521:         * printf("%s\n",xml);
                    522:         */
                    523: 
1.2       haad      524:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
                    525:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
                    526:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
                    527:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);
1.20      haad      528: 
1.2       haad      529:        /* Remove device from global device list */
1.20      haad      530:        if ((dmv = dm_dev_lookup(name, uuid, minor)) == NULL) {
1.2       haad      531:                DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG);
                    532:                return ENOENT;
                    533:        }
                    534:        atomic_and_32(&dmv->flags, ~(DM_SUSPEND_FLAG | DM_INACTIVE_PRESENT_FLAG));
                    535:        atomic_or_32(&dmv->flags, DM_ACTIVE_PRESENT_FLAG);
1.20      haad      536: 
1.2       haad      537:        dm_table_switch_tables(&dmv->table_head);
1.20      haad      538: 
                    539:        DM_ADD_FLAG(flags, DM_EXISTS_FLAG);
1.2       haad      540: 
1.13      haad      541:        dmgetproperties(dmv->diskp, &dmv->table_head);
1.20      haad      542: 
1.2       haad      543:        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_OPEN, dmv->table_head.io_cnt);
1.16      haad      544:        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_FLAGS, flags);
1.2       haad      545:        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor);
                    546: 
                    547:        dm_dev_unbusy(dmv);
                    548: 
                    549:        /* Destroy inactive table after resume. */
                    550:        dm_table_destroy(&dmv->table_head, DM_TABLE_INACTIVE);
1.20      haad      551: 
1.2       haad      552:        return 0;
                    553: }
                    554: /*
                    555:  * Table management routines
                    556:  * lvm2tools doens't send name/uuid to kernel with table
                    557:  * for lookup I have to use minor number.
                    558:  */
                    559: 
                    560: /*
                    561:  * Remove inactive table from device. Routines which work's with inactive tables
                    562:  * doesn't need to synchronise with dmstrategy. They can synchronise themselves with mutex?.
                    563:  *
                    564:  */
                    565: int
                    566: dm_table_clear_ioctl(prop_dictionary_t dm_dict)
                    567: {
                    568:        dm_dev_t *dmv;
                    569:        const char *name, *uuid;
                    570:        uint32_t flags, minor;
                    571: 
1.20      haad      572:        dmv = NULL;
1.2       haad      573:        name = NULL;
                    574:        uuid = NULL;
                    575:        flags = 0;
                    576:        minor = 0;
1.20      haad      577: 
1.2       haad      578:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
                    579:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
                    580:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
                    581:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);
1.20      haad      582: 
1.2       haad      583:        aprint_debug("Clearing inactive table from device: %s--%s\n",
                    584:            name, uuid);
1.20      haad      585: 
                    586:        if ((dmv = dm_dev_lookup(name, uuid, minor)) == NULL) {
1.2       haad      587:                DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG);
                    588:                return ENOENT;
                    589:        }
                    590:        /* Select unused table */
                    591:        dm_table_destroy(&dmv->table_head, DM_TABLE_INACTIVE);
                    592: 
                    593:        atomic_and_32(&dmv->flags, ~DM_INACTIVE_PRESENT_FLAG);
                    594: 
                    595:        dm_dev_unbusy(dmv);
1.20      haad      596: 
1.2       haad      597:        return 0;
                    598: }
                    599: /*
                    600:  * Get list of physical devices for active table.
                    601:  * Get dev_t from pdev vnode and insert it into cmd_array.
                    602:  *
                    603:  * XXX. This function is called from lvm2tools to get information
1.20      haad      604:  *      about physical devices, too e.g. during vgcreate.
1.2       haad      605:  */
                    606: int
                    607: dm_table_deps_ioctl(prop_dictionary_t dm_dict)
                    608: {
                    609:        dm_dev_t *dmv;
                    610:        dm_table_t *tbl;
                    611:        dm_table_entry_t *table_en;
                    612: 
                    613:        prop_array_t cmd_array;
                    614:        const char *name, *uuid;
                    615:        uint32_t flags, minor;
1.17      haad      616: 
                    617:        int table_type;
1.2       haad      618: 
                    619:        name = NULL;
                    620:        uuid = NULL;
1.20      haad      621:        dmv = NULL;
1.2       haad      622:        flags = 0;
1.20      haad      623: 
1.2       haad      624:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
                    625:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
                    626:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
                    627:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);
                    628: 
                    629:        /* create array for dev_t's */
                    630:        cmd_array = prop_array_create();
                    631: 
1.20      haad      632:        if ((dmv = dm_dev_lookup(name, uuid, minor)) == NULL) {
1.2       haad      633:                DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG);
                    634:                return ENOENT;
                    635:        }
                    636:        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor);
                    637:        prop_dictionary_set_cstring(dm_dict, DM_IOCTL_NAME, dmv->name);
                    638:        prop_dictionary_set_cstring(dm_dict, DM_IOCTL_UUID, dmv->uuid);
1.20      haad      639: 
1.2       haad      640:        aprint_debug("Getting table deps for device: %s\n", dmv->name);
                    641: 
1.20      haad      642:        /*
                    643:         * if DM_QUERY_INACTIVE_TABLE_FLAG is passed we need to query
                    644:         * INACTIVE TABLE
                    645:         */
1.17      haad      646:        if (flags & DM_QUERY_INACTIVE_TABLE_FLAG)
                    647:                table_type = DM_TABLE_INACTIVE;
                    648:        else
                    649:                table_type = DM_TABLE_ACTIVE;
1.20      haad      650: 
1.17      haad      651:        tbl = dm_table_get_entry(&dmv->table_head, table_type);
1.2       haad      652: 
                    653:        SLIST_FOREACH(table_en, tbl, next)
1.20      haad      654:            table_en->target->deps(table_en, cmd_array);
1.2       haad      655: 
1.17      haad      656:        dm_table_release(&dmv->table_head, table_type);
1.2       haad      657:        dm_dev_unbusy(dmv);
1.20      haad      658: 
1.2       haad      659:        prop_dictionary_set(dm_dict, DM_IOCTL_CMD_DATA, cmd_array);
                    660:        prop_object_release(cmd_array);
1.20      haad      661: 
1.2       haad      662:        return 0;
                    663: }
                    664: /*
                    665:  * Load new table/tables to device.
                    666:  * Call apropriate target init routine open all physical pdev's and
                    667:  * link them to device. For other targets mirror, strip, snapshot
                    668:  * etc. also add dependency devices to upcalls list.
                    669:  *
                    670:  * Load table to inactive slot table are switched in dm_device_resume_ioctl.
                    671:  * This simulates Linux behaviour better there should not be any difference.
                    672:  *
                    673:  */
                    674: int
                    675: dm_table_load_ioctl(prop_dictionary_t dm_dict)
                    676: {
                    677:        dm_dev_t *dmv;
                    678:        dm_table_entry_t *table_en, *last_table;
1.20      haad      679:        dm_table_t *tbl;
1.2       haad      680:        dm_target_t *target;
                    681: 
                    682:        prop_object_iterator_t iter;
                    683:        prop_array_t cmd_array;
1.15      haad      684:        prop_dictionary_t target_dict;
1.20      haad      685: 
1.2       haad      686:        const char *name, *uuid, *type;
                    687: 
                    688:        uint32_t flags, ret, minor;
                    689: 
1.15      haad      690:        char *str;
                    691: 
1.2       haad      692:        ret = 0;
                    693:        flags = 0;
                    694:        name = NULL;
                    695:        uuid = NULL;
                    696:        dmv = NULL;
                    697:        last_table = NULL;
1.15      haad      698:        str = NULL;
1.2       haad      699: 
1.20      haad      700:        /*
                    701:         * char *xml; xml = prop_dictionary_externalize(dm_dict);
                    702:         * printf("%s\n",xml);
                    703:         */
                    704: 
1.2       haad      705:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
                    706:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
                    707:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
                    708:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);
1.20      haad      709: 
1.2       haad      710:        cmd_array = prop_dictionary_get(dm_dict, DM_IOCTL_CMD_DATA);
                    711:        iter = prop_array_iterator(cmd_array);
1.20      haad      712:        dm_dbg_print_flags(flags);
                    713: 
                    714:        if ((dmv = dm_dev_lookup(name, uuid, minor)) == NULL) {
1.2       haad      715:                DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG);
1.28      mlelstv   716:                prop_object_iterator_release(iter);
1.2       haad      717:                return ENOENT;
                    718:        }
1.7       haad      719:        aprint_debug("Loading table to device: %s--%d\n", name,
                    720:            dmv->table_head.cur_active_table);
1.20      haad      721: 
1.2       haad      722:        /*
                    723:         * I have to check if this table slot is not used by another table list.
                    724:         * if it is used I should free them.
                    725:         */
                    726:        if (dmv->flags & DM_INACTIVE_PRESENT_FLAG)
                    727:                dm_table_destroy(&dmv->table_head, DM_TABLE_INACTIVE);
                    728: 
                    729:        dm_dbg_print_flags(dmv->flags);
                    730:        tbl = dm_table_get_entry(&dmv->table_head, DM_TABLE_INACTIVE);
1.20      haad      731: 
1.2       haad      732:        aprint_debug("dmv->name = %s\n", dmv->name);
1.20      haad      733: 
1.2       haad      734:        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor);
                    735: 
1.20      haad      736:        while ((target_dict = prop_object_iterator_next(iter)) != NULL) {
1.2       haad      737: 
                    738:                prop_dictionary_get_cstring_nocopy(target_dict,
                    739:                    DM_TABLE_TYPE, &type);
                    740:                /*
                    741:                 * If we want to deny table with 2 or more different
                    742:                 * target we should do it here
                    743:                 */
1.7       haad      744:                if (((target = dm_target_lookup(type)) == NULL) &&
                    745:                    ((target = dm_target_autoload(type)) == NULL)) {
1.8       haad      746:                        dm_table_release(&dmv->table_head, DM_TABLE_INACTIVE);
1.7       haad      747:                        dm_dev_unbusy(dmv);
1.28      mlelstv   748:                        prop_object_iterator_release(iter);
1.2       haad      749:                        return ENOENT;
1.7       haad      750:                }
1.31    ! chs       751:                table_en = kmem_alloc(sizeof(dm_table_entry_t), KM_SLEEP);
1.2       haad      752:                prop_dictionary_get_uint64(target_dict, DM_TABLE_START,
                    753:                    &table_en->start);
                    754:                prop_dictionary_get_uint64(target_dict, DM_TABLE_LENGTH,
                    755:                    &table_en->length);
                    756: 
                    757:                table_en->target = target;
                    758:                table_en->dm_dev = dmv;
                    759:                table_en->target_config = NULL;
1.20      haad      760: 
1.2       haad      761:                /*
                    762:                 * There is a parameter string after dm_target_spec
                    763:                 * structure which  points to /dev/wd0a 284 part of
                    764:                 * table. String str points to this text. This can be
                    765:                 * null and therefore it should be checked before we try to
                    766:                 * use it.
                    767:                 */
1.15      haad      768:                prop_dictionary_get_cstring(target_dict,
1.20      haad      769:                    DM_TABLE_PARAMS, (char **) &str);
                    770: 
1.30      christos  771:                if (SLIST_EMPTY(tbl) || last_table == NULL)
1.2       haad      772:                        /* insert this table to head */
                    773:                        SLIST_INSERT_HEAD(tbl, table_en, next);
                    774:                else
                    775:                        SLIST_INSERT_AFTER(last_table, table_en, next);
1.20      haad      776: 
1.2       haad      777:                /*
                    778:                 * Params string is different for every target,
                    779:                 * therfore I have to pass it to target init
                    780:                 * routine and parse parameters there.
                    781:                 */
1.20      haad      782: 
1.2       haad      783:                if ((ret = target->init(dmv, &table_en->target_config,
1.15      haad      784:                            str)) != 0) {
1.2       haad      785: 
1.4       haad      786:                        dm_table_release(&dmv->table_head, DM_TABLE_INACTIVE);
1.2       haad      787:                        dm_table_destroy(&dmv->table_head, DM_TABLE_INACTIVE);
1.15      haad      788:                        free(str, M_TEMP);
                    789: 
1.4       haad      790:                        dm_dev_unbusy(dmv);
1.26      ahoka     791:                        dm_target_unbusy(target);
1.28      mlelstv   792:                        prop_object_iterator_release(iter);
1.2       haad      793:                        return ret;
                    794:                }
                    795:                last_table = table_en;
1.15      haad      796:                free(str, M_TEMP);
1.2       haad      797:        }
                    798:        prop_object_iterator_release(iter);
1.20      haad      799: 
1.2       haad      800:        DM_ADD_FLAG(flags, DM_INACTIVE_PRESENT_FLAG);
                    801:        atomic_or_32(&dmv->flags, DM_INACTIVE_PRESENT_FLAG);
1.20      haad      802: 
1.2       haad      803:        dm_table_release(&dmv->table_head, DM_TABLE_INACTIVE);
                    804:        dm_dev_unbusy(dmv);
                    805:        return 0;
                    806: }
                    807: /*
                    808:  * Get description of all tables loaded to device from kernel
                    809:  * and send it to libdevmapper.
                    810:  *
                    811:  * Output dictionary for every table:
                    812:  *
                    813:  * <key>cmd_data</key>
                    814:  * <array>
                    815:  *   <dict>
                    816:  *    <key>type<key>
                    817:  *    <string>...</string>
                    818:  *
                    819:  *    <key>start</key>
                    820:  *    <integer>...</integer>
                    821:  *
                    822:  *    <key>length</key>
                    823:  *    <integer>...</integer>
                    824:  *
                    825:  *    <key>params</key>
                    826:  *    <string>...</string>
                    827:  *   </dict>
                    828:  * </array>
                    829:  *
                    830:  */
                    831: int
                    832: dm_table_status_ioctl(prop_dictionary_t dm_dict)
                    833: {
                    834:        dm_dev_t *dmv;
                    835:        dm_table_t *tbl;
                    836:        dm_table_entry_t *table_en;
                    837: 
                    838:        prop_array_t cmd_array;
                    839:        prop_dictionary_t target_dict;
1.20      haad      840: 
1.29      justin    841:        uint32_t minor, flags;
1.20      haad      842: 
1.2       haad      843:        const char *name, *uuid;
                    844:        char *params;
1.17      haad      845:        int table_type;
1.20      haad      846: 
1.2       haad      847:        dmv = NULL;
                    848:        uuid = NULL;
                    849:        name = NULL;
                    850:        params = NULL;
                    851:        flags = 0;
                    852: 
                    853:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
                    854:        prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
                    855:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
                    856:        prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);
                    857: 
                    858:        cmd_array = prop_array_create();
1.20      haad      859: 
                    860:        if ((dmv = dm_dev_lookup(name, uuid, minor)) == NULL) {
1.2       haad      861:                DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG);
                    862:                return ENOENT;
                    863:        }
1.20      haad      864:        /*
                    865:         * if DM_QUERY_INACTIVE_TABLE_FLAG is passed we need to query
                    866:         * INACTIVE TABLE
                    867:         */
1.17      haad      868:        if (flags & DM_QUERY_INACTIVE_TABLE_FLAG)
                    869:                table_type = DM_TABLE_INACTIVE;
                    870:        else
                    871:                table_type = DM_TABLE_ACTIVE;
1.20      haad      872: 
1.2       haad      873:        if (dm_table_get_target_count(&dmv->table_head, DM_TABLE_ACTIVE))
                    874:                DM_ADD_FLAG(flags, DM_ACTIVE_PRESENT_FLAG);
                    875:        else {
                    876:                DM_REMOVE_FLAG(flags, DM_ACTIVE_PRESENT_FLAG);
1.20      haad      877: 
1.2       haad      878:                if (dm_table_get_target_count(&dmv->table_head, DM_TABLE_INACTIVE))
                    879:                        DM_ADD_FLAG(flags, DM_INACTIVE_PRESENT_FLAG);
                    880:                else {
                    881:                        DM_REMOVE_FLAG(flags, DM_INACTIVE_PRESENT_FLAG);
                    882:                }
                    883:        }
1.20      haad      884: 
1.2       haad      885:        if (dmv->flags & DM_SUSPEND_FLAG)
                    886:                DM_ADD_FLAG(flags, DM_SUSPEND_FLAG);
1.20      haad      887: 
1.2       haad      888:        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor);
1.20      haad      889: 
1.2       haad      890:        aprint_debug("Status of device tables: %s--%d\n",
                    891:            name, dmv->table_head.cur_active_table);
1.20      haad      892: 
1.17      haad      893:        tbl = dm_table_get_entry(&dmv->table_head, table_type);
1.20      haad      894: 
                    895:        SLIST_FOREACH(table_en, tbl, next) {
1.2       haad      896:                target_dict = prop_dictionary_create();
                    897:                aprint_debug("%016" PRIu64 ", length %016" PRIu64
                    898:                    ", target %s\n", table_en->start, table_en->length,
                    899:                    table_en->target->name);
                    900: 
                    901:                prop_dictionary_set_uint64(target_dict, DM_TABLE_START,
                    902:                    table_en->start);
                    903:                prop_dictionary_set_uint64(target_dict, DM_TABLE_LENGTH,
                    904:                    table_en->length);
                    905: 
                    906:                prop_dictionary_set_cstring(target_dict, DM_TABLE_TYPE,
                    907:                    table_en->target->name);
                    908: 
                    909:                /* dm_table_get_cur_actv.table ?? */
                    910:                prop_dictionary_set_int32(target_dict, DM_TABLE_STAT,
                    911:                    dmv->table_head.cur_active_table);
                    912: 
1.25      joerg     913:                if (flags & DM_STATUS_TABLE_FLAG) {
1.2       haad      914:                        params = table_en->target->status
                    915:                            (table_en->target_config);
                    916: 
1.20      haad      917:                        if (params != NULL) {
1.2       haad      918:                                prop_dictionary_set_cstring(target_dict,
                    919:                                    DM_TABLE_PARAMS, params);
1.20      haad      920: 
1.14      haad      921:                                kmem_free(params, DM_MAX_PARAMS_SIZE);
1.2       haad      922:                        }
                    923:                }
                    924:                prop_array_add(cmd_array, target_dict);
                    925:                prop_object_release(target_dict);
                    926:        }
                    927: 
1.17      haad      928:        dm_table_release(&dmv->table_head, table_type);
1.2       haad      929:        dm_dev_unbusy(dmv);
1.17      haad      930: 
                    931:        prop_dictionary_set_uint32(dm_dict, DM_IOCTL_FLAGS, flags);
1.2       haad      932:        prop_dictionary_set(dm_dict, DM_IOCTL_CMD_DATA, cmd_array);
                    933:        prop_object_release(cmd_array);
1.20      haad      934: 
1.2       haad      935:        return 0;
                    936: }
                    937: 
                    938: 
                    939: /*
                    940:  * For every call I have to set kernel driver version.
                    941:  * Because I can have commands supported only in other
1.20      haad      942:  * newer/later version. This routine is called for every
1.2       haad      943:  * ioctl command.
                    944:  */
                    945: int
                    946: dm_check_version(prop_dictionary_t dm_dict)
                    947: {
                    948:        size_t i;
1.29      justin    949:        uint32_t dm_version[3];
1.2       haad      950:        prop_array_t ver;
1.20      haad      951: 
1.2       haad      952:        ver = prop_dictionary_get(dm_dict, DM_IOCTL_VERSION);
1.20      haad      953: 
                    954:        for (i = 0; i < 3; i++)
1.2       haad      955:                prop_array_get_uint32(ver, i, &dm_version[i]);
                    956: 
1.20      haad      957:        if (DM_VERSION_MAJOR != dm_version[0] || DM_VERSION_MINOR < dm_version[1]) {
1.2       haad      958:                aprint_debug("libdevmapper/kernel version mismatch "
                    959:                    "kernel: %d.%d.%d libdevmapper: %d.%d.%d\n",
                    960:                    DM_VERSION_MAJOR, DM_VERSION_MINOR, DM_VERSION_PATCHLEVEL,
                    961:                    dm_version[0], dm_version[1], dm_version[2]);
1.20      haad      962: 
1.2       haad      963:                return EIO;
                    964:        }
                    965:        prop_array_set_uint32(ver, 0, DM_VERSION_MAJOR);
                    966:        prop_array_set_uint32(ver, 1, DM_VERSION_MINOR);
                    967:        prop_array_set_uint32(ver, 2, DM_VERSION_PATCHLEVEL);
                    968: 
1.17      haad      969:        prop_dictionary_set(dm_dict, DM_IOCTL_VERSION, ver);
1.20      haad      970: 
1.2       haad      971:        return 0;
                    972: }

CVSweb <webmaster@jp.NetBSD.org>