2010-01-04 03:12:22 +03:00
|
|
|
/* $NetBSD: dm_dev.c,v 1.8 2010/01/04 00:19:08 haad Exp $ */
|
2008-12-19 18:24:03 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Adam Hamsik.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
|
2009-03-06 19:17:29 +03:00
|
|
|
#include <sys/disk.h>
|
2008-12-19 18:24:03 +03:00
|
|
|
#include <sys/disklabel.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/ioccom.h>
|
|
|
|
#include <sys/kmem.h>
|
|
|
|
|
|
|
|
#include "netbsd-dm.h"
|
|
|
|
#include "dm.h"
|
|
|
|
|
2010-01-04 03:12:22 +03:00
|
|
|
static dm_dev_t *dm_dev_lookup_name(const char *);
|
|
|
|
static dm_dev_t *dm_dev_lookup_uuid(const char *);
|
|
|
|
static dm_dev_t *dm_dev_lookup_minor(int);
|
2008-12-19 18:24:03 +03:00
|
|
|
|
|
|
|
static struct dm_dev_head dm_dev_list =
|
|
|
|
TAILQ_HEAD_INITIALIZER(dm_dev_list);
|
|
|
|
|
|
|
|
kmutex_t dm_dev_mutex;
|
|
|
|
|
2009-12-30 02:37:47 +03:00
|
|
|
/* dm_dev_mutex must be holdby caller before using disable_dev. */
|
2008-12-19 18:24:03 +03:00
|
|
|
__inline static void
|
2010-01-04 03:12:22 +03:00
|
|
|
disable_dev(dm_dev_t * dmv)
|
2008-12-19 18:24:03 +03:00
|
|
|
{
|
2010-01-04 03:12:22 +03:00
|
|
|
TAILQ_REMOVE(&dm_dev_list, dmv, next_devlist);
|
|
|
|
mutex_enter(&dmv->dev_mtx);
|
|
|
|
mutex_exit(&dm_dev_mutex);
|
|
|
|
while (dmv->ref_cnt != 0)
|
|
|
|
cv_wait(&dmv->dev_cv, &dmv->dev_mtx);
|
|
|
|
mutex_exit(&dmv->dev_mtx);
|
|
|
|
}
|
2008-12-19 18:24:03 +03:00
|
|
|
/*
|
2010-01-04 03:12:22 +03:00
|
|
|
* Generic function used to lookup dm_dev_t. Calling with dm_dev_name
|
2008-12-19 18:24:03 +03:00
|
|
|
* and dm_dev_uuid NULL is allowed.
|
|
|
|
*/
|
2010-01-04 03:12:22 +03:00
|
|
|
dm_dev_t *
|
2008-12-19 18:24:03 +03:00
|
|
|
dm_dev_lookup(const char *dm_dev_name, const char *dm_dev_uuid,
|
2010-01-04 03:12:22 +03:00
|
|
|
int dm_dev_minor)
|
2008-12-19 18:24:03 +03:00
|
|
|
{
|
|
|
|
dm_dev_t *dmv;
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
dmv = NULL;
|
|
|
|
mutex_enter(&dm_dev_mutex);
|
2010-01-04 03:12:22 +03:00
|
|
|
|
|
|
|
/* KASSERT(dm_dev_name != NULL && dm_dev_uuid != NULL && dm_dev_minor
|
|
|
|
* > 0); */
|
2008-12-19 18:24:03 +03:00
|
|
|
if (dm_dev_minor > 0)
|
2010-01-04 03:12:22 +03:00
|
|
|
if ((dmv = dm_dev_lookup_minor(dm_dev_minor)) != NULL) {
|
2008-12-19 18:24:03 +03:00
|
|
|
dm_dev_busy(dmv);
|
|
|
|
mutex_exit(&dm_dev_mutex);
|
|
|
|
return dmv;
|
|
|
|
}
|
2010-01-04 03:12:22 +03:00
|
|
|
if (dm_dev_name != NULL)
|
|
|
|
if ((dmv = dm_dev_lookup_name(dm_dev_name)) != NULL) {
|
2008-12-19 18:24:03 +03:00
|
|
|
dm_dev_busy(dmv);
|
|
|
|
mutex_exit(&dm_dev_mutex);
|
2010-01-04 03:12:22 +03:00
|
|
|
return dmv;
|
2008-12-19 18:24:03 +03:00
|
|
|
}
|
|
|
|
if (dm_dev_uuid != NULL)
|
2010-01-04 03:12:22 +03:00
|
|
|
if ((dmv = dm_dev_lookup_uuid(dm_dev_uuid)) != NULL) {
|
2008-12-19 18:24:03 +03:00
|
|
|
dm_dev_busy(dmv);
|
|
|
|
mutex_exit(&dm_dev_mutex);
|
|
|
|
return dmv;
|
|
|
|
}
|
2010-01-04 03:12:22 +03:00
|
|
|
mutex_exit(&dm_dev_mutex);
|
|
|
|
return NULL;
|
2008-12-19 18:24:03 +03:00
|
|
|
}
|
|
|
|
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
/*
|
|
|
|
* Lookup device with its minor number.
|
|
|
|
*/
|
2010-01-04 03:12:22 +03:00
|
|
|
static dm_dev_t *
|
2008-12-19 18:24:03 +03:00
|
|
|
dm_dev_lookup_minor(int dm_dev_minor)
|
|
|
|
{
|
|
|
|
dm_dev_t *dmv;
|
2010-01-04 03:12:22 +03:00
|
|
|
|
|
|
|
TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist) {
|
2008-12-19 18:24:03 +03:00
|
|
|
if (dm_dev_minor == dmv->minor)
|
|
|
|
return dmv;
|
|
|
|
}
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Lookup device with it's device name.
|
|
|
|
*/
|
2010-01-04 03:12:22 +03:00
|
|
|
static dm_dev_t *
|
2008-12-19 18:24:03 +03:00
|
|
|
dm_dev_lookup_name(const char *dm_dev_name)
|
|
|
|
{
|
|
|
|
dm_dev_t *dmv;
|
2010-01-04 03:12:22 +03:00
|
|
|
int dlen;
|
|
|
|
int slen;
|
2008-12-19 18:24:03 +03:00
|
|
|
|
|
|
|
slen = strlen(dm_dev_name);
|
|
|
|
|
|
|
|
if (slen == 0)
|
|
|
|
return NULL;
|
2010-01-04 03:12:22 +03:00
|
|
|
|
|
|
|
TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist) {
|
2008-12-19 18:24:03 +03:00
|
|
|
|
|
|
|
dlen = strlen(dmv->name);
|
2010-01-04 03:12:22 +03:00
|
|
|
|
|
|
|
if (slen != dlen)
|
2008-12-19 18:24:03 +03:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (strncmp(dm_dev_name, dmv->name, slen) == 0)
|
|
|
|
return dmv;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Lookup device with it's device uuid. Used mostly by LVM2tools.
|
|
|
|
*/
|
2010-01-04 03:12:22 +03:00
|
|
|
static dm_dev_t *
|
2008-12-19 18:24:03 +03:00
|
|
|
dm_dev_lookup_uuid(const char *dm_dev_uuid)
|
|
|
|
{
|
|
|
|
dm_dev_t *dmv;
|
|
|
|
size_t len;
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
len = 0;
|
|
|
|
len = strlen(dm_dev_uuid);
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
if (len == 0)
|
|
|
|
return NULL;
|
|
|
|
|
2010-01-04 03:12:22 +03:00
|
|
|
TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist) {
|
2008-12-19 18:24:03 +03:00
|
|
|
|
|
|
|
if (strlen(dmv->uuid) != len)
|
|
|
|
continue;
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
if (strncmp(dm_dev_uuid, dmv->uuid, strlen(dmv->uuid)) == 0)
|
|
|
|
return dmv;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Insert new device to the global list of devices.
|
|
|
|
*/
|
|
|
|
int
|
2010-01-04 03:12:22 +03:00
|
|
|
dm_dev_insert(dm_dev_t * dev)
|
2008-12-19 18:24:03 +03:00
|
|
|
{
|
|
|
|
dm_dev_t *dmv;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
dmv = NULL;
|
|
|
|
r = 0;
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
KASSERT(dev != NULL);
|
|
|
|
mutex_enter(&dm_dev_mutex);
|
|
|
|
if (((dmv = dm_dev_lookup_uuid(dev->uuid)) == NULL) &&
|
|
|
|
((dmv = dm_dev_lookup_name(dev->name)) == NULL) &&
|
2010-01-04 03:12:22 +03:00
|
|
|
((dmv = dm_dev_lookup_minor(dev->minor)) == NULL)) {
|
2008-12-19 18:24:03 +03:00
|
|
|
|
|
|
|
TAILQ_INSERT_TAIL(&dm_dev_list, dev, next_devlist);
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
} else
|
|
|
|
r = EEXIST;
|
2010-01-04 03:12:22 +03:00
|
|
|
|
|
|
|
mutex_exit(&dm_dev_mutex);
|
2008-12-19 18:24:03 +03:00
|
|
|
return r;
|
|
|
|
}
|
2010-01-04 03:12:22 +03:00
|
|
|
#ifdef notyet
|
2008-12-19 18:24:03 +03:00
|
|
|
/*
|
|
|
|
* Lookup device with its minor number.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
dm_dev_test_minor(int dm_dev_minor)
|
|
|
|
{
|
|
|
|
dm_dev_t *dmv;
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
mutex_enter(&dm_dev_mutex);
|
2010-01-04 03:12:22 +03:00
|
|
|
TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist) {
|
|
|
|
if (dm_dev_minor == dmv->minor) {
|
2008-12-19 18:24:03 +03:00
|
|
|
mutex_exit(&dm_dev_mutex);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mutex_exit(&dm_dev_mutex);
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-12-30 02:37:47 +03:00
|
|
|
/*
|
|
|
|
* dm_dev_lookup_devt look for selected device_t. We keep this routine
|
|
|
|
* outside of dm_dev_lookup because it is a temporally solution.
|
|
|
|
*
|
|
|
|
* TODO: This is a hack autoconf should be more flexible.
|
|
|
|
*/
|
|
|
|
dm_dev_t *
|
|
|
|
dm_dev_detach(device_t devt)
|
|
|
|
{
|
|
|
|
dm_dev_t *dmv;
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2009-12-30 02:37:47 +03:00
|
|
|
mutex_enter(&dm_dev_mutex);
|
2010-01-04 03:12:22 +03:00
|
|
|
TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist) {
|
|
|
|
if (devt == dmv->devt) {
|
2009-12-30 02:37:47 +03:00
|
|
|
disable_dev(dmv);
|
|
|
|
return dmv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mutex_exit(&dm_dev_mutex);
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2009-12-30 02:37:47 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
2010-01-04 03:12:22 +03:00
|
|
|
/*
|
|
|
|
* Remove device selected with dm_dev from global list of devices.
|
2008-12-19 18:24:03 +03:00
|
|
|
*/
|
2010-01-04 03:12:22 +03:00
|
|
|
dm_dev_t *
|
2008-12-19 18:24:03 +03:00
|
|
|
dm_dev_rem(const char *dm_dev_name, const char *dm_dev_uuid,
|
2010-01-04 03:12:22 +03:00
|
|
|
int dm_dev_minor)
|
|
|
|
{
|
2008-12-19 18:24:03 +03:00
|
|
|
dm_dev_t *dmv;
|
|
|
|
dmv = NULL;
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
mutex_enter(&dm_dev_mutex);
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
if (dm_dev_minor > 0)
|
2010-01-04 03:12:22 +03:00
|
|
|
if ((dmv = dm_dev_lookup_minor(dm_dev_minor)) != NULL) {
|
2008-12-19 18:24:03 +03:00
|
|
|
disable_dev(dmv);
|
|
|
|
return dmv;
|
|
|
|
}
|
2010-01-04 03:12:22 +03:00
|
|
|
if (dm_dev_name != NULL)
|
|
|
|
if ((dmv = dm_dev_lookup_name(dm_dev_name)) != NULL) {
|
2008-12-19 18:24:03 +03:00
|
|
|
disable_dev(dmv);
|
|
|
|
return dmv;
|
|
|
|
}
|
|
|
|
if (dm_dev_uuid != NULL)
|
2010-01-04 03:12:22 +03:00
|
|
|
if ((dmv = dm_dev_lookup_name(dm_dev_uuid)) != NULL) {
|
2008-12-19 18:24:03 +03:00
|
|
|
disable_dev(dmv);
|
|
|
|
return dmv;
|
|
|
|
}
|
|
|
|
mutex_exit(&dm_dev_mutex);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Destroy all devices created in device-mapper. Remove all tables
|
2010-01-04 03:12:22 +03:00
|
|
|
* free all allocated memmory.
|
2008-12-19 18:24:03 +03:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
dm_dev_destroy(void)
|
|
|
|
{
|
|
|
|
dm_dev_t *dmv;
|
|
|
|
mutex_enter(&dm_dev_mutex);
|
|
|
|
|
2010-01-04 03:12:22 +03:00
|
|
|
while (TAILQ_FIRST(&dm_dev_list) != NULL) {
|
2008-12-19 18:24:03 +03:00
|
|
|
|
|
|
|
dmv = TAILQ_FIRST(&dm_dev_list);
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
TAILQ_REMOVE(&dm_dev_list, TAILQ_FIRST(&dm_dev_list),
|
|
|
|
next_devlist);
|
|
|
|
|
|
|
|
mutex_enter(&dmv->dev_mtx);
|
|
|
|
|
|
|
|
while (dmv->ref_cnt != 0)
|
|
|
|
cv_wait(&dmv->dev_cv, &dmv->dev_mtx);
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
/* Destroy active table first. */
|
|
|
|
dm_table_destroy(&dmv->table_head, DM_TABLE_ACTIVE);
|
|
|
|
|
|
|
|
/* Destroy inactive table if exits, too. */
|
|
|
|
dm_table_destroy(&dmv->table_head, DM_TABLE_INACTIVE);
|
|
|
|
|
|
|
|
dm_table_head_destroy(&dmv->table_head);
|
|
|
|
|
|
|
|
mutex_exit(&dmv->dev_mtx);
|
|
|
|
mutex_destroy(&dmv->dev_mtx);
|
|
|
|
cv_destroy(&dmv->dev_cv);
|
2010-01-04 03:12:22 +03:00
|
|
|
|
|
|
|
(void) kmem_free(dmv, sizeof(dm_dev_t));
|
2008-12-19 18:24:03 +03:00
|
|
|
}
|
|
|
|
mutex_exit(&dm_dev_mutex);
|
|
|
|
|
|
|
|
mutex_destroy(&dm_dev_mutex);
|
2010-01-04 03:12:22 +03:00
|
|
|
return 0;
|
2008-12-19 18:24:03 +03:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Allocate new device entry.
|
|
|
|
*/
|
2010-01-04 03:12:22 +03:00
|
|
|
dm_dev_t *
|
2009-03-18 13:22:21 +03:00
|
|
|
dm_dev_alloc(void)
|
2008-12-19 18:24:03 +03:00
|
|
|
{
|
|
|
|
dm_dev_t *dmv;
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2009-09-10 02:38:49 +04:00
|
|
|
dmv = kmem_zalloc(sizeof(dm_dev_t), KM_SLEEP);
|
2010-01-04 03:12:22 +03:00
|
|
|
|
|
|
|
if (dmv != NULL)
|
2009-09-10 02:38:49 +04:00
|
|
|
dmv->diskp = kmem_zalloc(sizeof(struct disk), KM_SLEEP);
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
return dmv;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Freed device entry.
|
|
|
|
*/
|
|
|
|
int
|
2010-01-04 03:12:22 +03:00
|
|
|
dm_dev_free(dm_dev_t * dmv)
|
2008-12-19 18:24:03 +03:00
|
|
|
{
|
|
|
|
KASSERT(dmv != NULL);
|
2009-03-06 19:17:29 +03:00
|
|
|
|
2009-04-13 22:51:54 +04:00
|
|
|
mutex_destroy(&dmv->dev_mtx);
|
2009-12-30 02:37:47 +03:00
|
|
|
mutex_destroy(&dmv->diskp_mtx);
|
2009-04-13 22:51:54 +04:00
|
|
|
cv_destroy(&dmv->dev_cv);
|
|
|
|
|
2010-01-04 03:12:22 +03:00
|
|
|
if (dmv->diskp != NULL)
|
|
|
|
(void) kmem_free(dmv->diskp, sizeof(struct disk));
|
|
|
|
|
|
|
|
(void) kmem_free(dmv, sizeof(dm_dev_t));
|
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-01-04 03:12:22 +03:00
|
|
|
dm_dev_busy(dm_dev_t * dmv)
|
2008-12-19 18:24:03 +03:00
|
|
|
{
|
|
|
|
mutex_enter(&dmv->dev_mtx);
|
|
|
|
dmv->ref_cnt++;
|
|
|
|
mutex_exit(&dmv->dev_mtx);
|
2010-01-04 03:12:22 +03:00
|
|
|
}
|
2008-12-19 18:24:03 +03:00
|
|
|
|
|
|
|
void
|
2010-01-04 03:12:22 +03:00
|
|
|
dm_dev_unbusy(dm_dev_t * dmv)
|
2008-12-19 18:24:03 +03:00
|
|
|
{
|
|
|
|
KASSERT(dmv->ref_cnt != 0);
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
mutex_enter(&dmv->dev_mtx);
|
|
|
|
if (--dmv->ref_cnt == 0)
|
|
|
|
cv_broadcast(&dmv->dev_cv);
|
|
|
|
mutex_exit(&dmv->dev_mtx);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Return prop_array of dm_targer_list dictionaries.
|
|
|
|
*/
|
|
|
|
prop_array_t
|
|
|
|
dm_dev_prop_list(void)
|
|
|
|
{
|
|
|
|
dm_dev_t *dmv;
|
|
|
|
prop_array_t dev_array;
|
|
|
|
prop_dictionary_t dev_dict;
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
dev_array = prop_array_create();
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
mutex_enter(&dm_dev_mutex);
|
2010-01-04 03:12:22 +03:00
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
TAILQ_FOREACH(dmv, &dm_dev_list, next_devlist) {
|
2010-01-04 03:12:22 +03:00
|
|
|
dev_dict = prop_dictionary_create();
|
|
|
|
|
2008-12-19 18:24:03 +03:00
|
|
|
prop_dictionary_set_cstring(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);
|
|
|
|
prop_object_release(dev_dict);
|
|
|
|
}
|
|
|
|
|
2010-01-04 03:12:22 +03:00
|
|
|
mutex_exit(&dm_dev_mutex);
|
2008-12-19 18:24:03 +03:00
|
|
|
return dev_array;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Initialize global device mutex.
|
|
|
|
*/
|
|
|
|
int
|
2009-03-18 13:22:21 +03:00
|
|
|
dm_dev_init(void)
|
2008-12-19 18:24:03 +03:00
|
|
|
{
|
2010-01-04 03:12:22 +03:00
|
|
|
TAILQ_INIT(&dm_dev_list); /* initialize global dev list */
|
2008-12-19 18:24:03 +03:00
|
|
|
mutex_init(&dm_dev_mutex, MUTEX_DEFAULT, IPL_NONE);
|
|
|
|
return 0;
|
|
|
|
}
|