fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER START
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The contents of this file are subject to the terms of the
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley * Common Development and Distribution License (the "License").
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley * You may not use this file except in compliance with the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fa9e4066f08beec538e775443c5be79dd423fcabahrens * or http://www.opensolaris.org/os/licensing.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * See the License for the specific language governing permissions
fa9e4066f08beec538e775443c5be79dd423fcabahrens * and limitations under the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * When distributing Covered Code, include this CDDL HEADER in each
fa9e4066f08beec538e775443c5be79dd423fcabahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If applicable, add the following below this CDDL HEADER, with the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fields enclosed by brackets "[]" replaced with your own identifying
fa9e4066f08beec538e775443c5be79dd423fcabahrens * information: Portions Copyright [yyyy] [name of copyright owner]
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER END
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
99653d4ee642c6528e88224f12409a5f23060994eschrock#include "libzfs_jni_util.h"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include "libzfs_jni_pool.h"
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <strings.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Types
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
c8e9ed14d97e244b9753db14caf8481f181f5750talleytypedef struct ImportablePoolBean {
c8e9ed14d97e244b9753db14caf8481f181f5750talley zjni_Object_t super;
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley PoolStatsBean_t interface_PoolStats;
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley jmethodID method_setName;
c8e9ed14d97e244b9753db14caf8481f181f5750talley jmethodID method_setId;
c8e9ed14d97e244b9753db14caf8481f181f5750talley} ImportablePoolBean_t;
c8e9ed14d97e244b9753db14caf8481f181f5750talley
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef struct VirtualDeviceBean {
fa9e4066f08beec538e775443c5be79dd423fcabahrens zjni_Object_t super;
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley DeviceStatsBean_t interface_DeviceStats;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens jmethodID method_setPoolName;
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley jmethodID method_setParentIndex;
fa9e4066f08beec538e775443c5be79dd423fcabahrens jmethodID method_setIndex;
fa9e4066f08beec538e775443c5be79dd423fcabahrens} VirtualDeviceBean_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talleytypedef struct LeafVirtualDeviceBean {
fa9e4066f08beec538e775443c5be79dd423fcabahrens VirtualDeviceBean_t super;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley jmethodID method_setName;
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley} LeafVirtualDeviceBean_t;
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talleytypedef struct DiskVirtualDeviceBean {
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley LeafVirtualDeviceBean_t super;
fa9e4066f08beec538e775443c5be79dd423fcabahrens} DiskVirtualDeviceBean_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talleytypedef struct SliceVirtualDeviceBean {
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley LeafVirtualDeviceBean_t super;
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley} SliceVirtualDeviceBean_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talleytypedef struct FileVirtualDeviceBean {
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley LeafVirtualDeviceBean_t super;
fa9e4066f08beec538e775443c5be79dd423fcabahrens} FileVirtualDeviceBean_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef struct RAIDVirtualDeviceBean {
fa9e4066f08beec538e775443c5be79dd423fcabahrens VirtualDeviceBean_t super;
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl jmethodID method_setParity;
fa9e4066f08beec538e775443c5be79dd423fcabahrens} RAIDVirtualDeviceBean_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef struct MirrorVirtualDeviceBean {
fa9e4066f08beec538e775443c5be79dd423fcabahrens VirtualDeviceBean_t super;
fa9e4066f08beec538e775443c5be79dd423fcabahrens} MirrorVirtualDeviceBean_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley/*
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley * Data
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley */
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley/* vdev_state_t to DeviceStats$DeviceState map */
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleystatic zjni_field_mapping_t vdev_state_map[] = {
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { VDEV_STATE_CANT_OPEN, "VDEV_STATE_CANT_OPEN" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { VDEV_STATE_CLOSED, "VDEV_STATE_CLOSED" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { VDEV_STATE_DEGRADED, "VDEV_STATE_DEGRADED" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { VDEV_STATE_HEALTHY, "VDEV_STATE_HEALTHY" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { VDEV_STATE_OFFLINE, "VDEV_STATE_OFFLINE" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { VDEV_STATE_UNKNOWN, "VDEV_STATE_UNKNOWN" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { -1, NULL },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley};
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley/* vdev_aux_t to DeviceStats$DeviceStatus map */
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleystatic zjni_field_mapping_t vdev_aux_map[] = {
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { VDEV_AUX_NONE, "VDEV_AUX_NONE" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { VDEV_AUX_OPEN_FAILED, "VDEV_AUX_OPEN_FAILED" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { VDEV_AUX_CORRUPT_DATA, "VDEV_AUX_CORRUPT_DATA" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { VDEV_AUX_NO_REPLICAS, "VDEV_AUX_NO_REPLICAS" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { VDEV_AUX_BAD_GUID_SUM, "VDEV_AUX_BAD_GUID_SUM" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { VDEV_AUX_TOO_SMALL, "VDEV_AUX_TOO_SMALL" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { VDEV_AUX_BAD_LABEL, "VDEV_AUX_BAD_LABEL" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { -1, NULL },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley};
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley/* zpool_state_t to PoolStats$PoolState map */
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleystatic zjni_field_mapping_t pool_state_map[] = {
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { POOL_STATE_ACTIVE, "POOL_STATE_ACTIVE" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { POOL_STATE_EXPORTED, "POOL_STATE_EXPORTED" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { POOL_STATE_DESTROYED, "POOL_STATE_DESTROYED" },
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian { POOL_STATE_SPARE, "POOL_STATE_SPARE" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { POOL_STATE_UNINITIALIZED, "POOL_STATE_UNINITIALIZED" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { POOL_STATE_UNAVAIL, "POOL_STATE_UNAVAIL" },
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian { POOL_STATE_POTENTIALLY_ACTIVE, "POOL_STATE_POTENTIALLY_ACTIVE" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { -1, NULL },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley};
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley/* zpool_status_t to PoolStats$PoolStatus map */
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleystatic zjni_field_mapping_t zpool_status_map[] = {
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian { ZPOOL_STATUS_CORRUPT_CACHE, "ZPOOL_STATUS_CORRUPT_CACHE" },
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian { ZPOOL_STATUS_MISSING_DEV_R, "ZPOOL_STATUS_MISSING_DEV_R" },
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian { ZPOOL_STATUS_MISSING_DEV_NR, "ZPOOL_STATUS_MISSING_DEV_NR" },
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian { ZPOOL_STATUS_CORRUPT_LABEL_R, "ZPOOL_STATUS_CORRUPT_LABEL_R" },
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian { ZPOOL_STATUS_CORRUPT_LABEL_NR, "ZPOOL_STATUS_CORRUPT_LABEL_NR" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { ZPOOL_STATUS_BAD_GUID_SUM, "ZPOOL_STATUS_BAD_GUID_SUM" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { ZPOOL_STATUS_CORRUPT_POOL, "ZPOOL_STATUS_CORRUPT_POOL" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { ZPOOL_STATUS_CORRUPT_DATA, "ZPOOL_STATUS_CORRUPT_DATA" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { ZPOOL_STATUS_FAILING_DEV, "ZPOOL_STATUS_FAILING_DEV" },
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian { ZPOOL_STATUS_VERSION_NEWER, "ZPOOL_STATUS_VERSION_NEWER" },
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian { ZPOOL_STATUS_HOSTID_MISMATCH, "ZPOOL_STATUS_HOSTID_MISMATCH" },
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian { ZPOOL_STATUS_FAULTED_DEV_R, "ZPOOL_STATUS_FAULTED_DEV_R" },
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian { ZPOOL_STATUS_FAULTED_DEV_NR, "ZPOOL_STATUS_FAULTED_DEV_NR" },
b87f3af36bb994656da117319f5129ddfd05ed21perrin { ZPOOL_STATUS_BAD_LOG, "ZPOOL_STATUS_BAD_LOG" },
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian { ZPOOL_STATUS_VERSION_OLDER, "ZPOOL_STATUS_VERSION_OLDER" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { ZPOOL_STATUS_RESILVERING, "ZPOOL_STATUS_RESILVERING" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { ZPOOL_STATUS_OFFLINE_DEV, "ZPOOL_STATUS_OFFLINE_DEV" },
c25309d42d46e04be84e0dbadaf3c9ab3369ad05George Wilson { ZPOOL_STATUS_REMOVED_DEV, "ZPOOL_STATUS_REMOVED_DEV" },
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley { ZPOOL_STATUS_OK, "ZPOOL_STATUS_OK" },
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian { -1, NULL }
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley};
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Function prototypes
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
c8e9ed14d97e244b9753db14caf8481f181f5750talleystatic void new_ImportablePoolBean(JNIEnv *, ImportablePoolBean_t *);
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic void new_VirtualDevice(JNIEnv *, VirtualDeviceBean_t *);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talleystatic void new_LeafVirtualDevice(JNIEnv *, LeafVirtualDeviceBean_t *);
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic void new_DiskVirtualDeviceBean(JNIEnv *, DiskVirtualDeviceBean_t *);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talleystatic void new_SliceVirtualDeviceBean(JNIEnv *, SliceVirtualDeviceBean_t *);
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic void new_FileVirtualDeviceBean(JNIEnv *, FileVirtualDeviceBean_t *);
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic void new_RAIDVirtualDeviceBean(JNIEnv *, RAIDVirtualDeviceBean_t *);
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic void new_MirrorVirtualDeviceBean(JNIEnv *, MirrorVirtualDeviceBean_t *);
c8e9ed14d97e244b9753db14caf8481f181f5750talleystatic int populate_ImportablePoolBean(
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley JNIEnv *, ImportablePoolBean_t *, nvlist_t *);
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalleystatic int populate_VirtualDeviceBean(JNIEnv *, zpool_handle_t *,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *, uint64_t *p_vdev_id, VirtualDeviceBean_t *);
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalleystatic int populate_LeafVirtualDeviceBean(JNIEnv *, zpool_handle_t *,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *, uint64_t *p_vdev_id, LeafVirtualDeviceBean_t *);
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalleystatic int populate_DiskVirtualDeviceBean(JNIEnv *, zpool_handle_t *,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *, uint64_t *p_vdev_id, DiskVirtualDeviceBean_t *);
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalleystatic int populate_SliceVirtualDeviceBean(JNIEnv *, zpool_handle_t *,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *, uint64_t *p_vdev_id, SliceVirtualDeviceBean_t *);
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalleystatic int populate_FileVirtualDeviceBean(JNIEnv *, zpool_handle_t *,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *, uint64_t *p_vdev_id, FileVirtualDeviceBean_t *);
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalleystatic int populate_RAIDVirtualDeviceBean(JNIEnv *, zpool_handle_t *,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *, uint64_t *p_vdev_id, RAIDVirtualDeviceBean_t *);
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalleystatic int populate_MirrorVirtualDeviceBean(JNIEnv *, zpool_handle_t *,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *, uint64_t *p_vdev_id, MirrorVirtualDeviceBean_t *);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleystatic jobject create_ImportablePoolBean(JNIEnv *, nvlist_t *);
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic jobject create_DiskVirtualDeviceBean(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley JNIEnv *, zpool_handle_t *, nvlist_t *, uint64_t *p_vdev_id);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talleystatic jobject create_SliceVirtualDeviceBean(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley JNIEnv *, zpool_handle_t *, nvlist_t *, uint64_t *p_vdev_id);
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic jobject create_FileVirtualDeviceBean(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley JNIEnv *, zpool_handle_t *, nvlist_t *, uint64_t *p_vdev_id);
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic jobject create_RAIDVirtualDeviceBean(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley JNIEnv *, zpool_handle_t *, nvlist_t *, uint64_t *p_vdev_id);
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic jobject create_MirrorVirtualDeviceBean(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley JNIEnv *, zpool_handle_t *, nvlist_t *, uint64_t *p_vdev_id);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleystatic char *find_field(const zjni_field_mapping_t *, int);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleystatic jobject zjni_vdev_state_to_obj(JNIEnv *, vdev_state_t);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleystatic jobject zjni_vdev_aux_to_obj(JNIEnv *, vdev_aux_t);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Static functions
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
c8e9ed14d97e244b9753db14caf8481f181f5750talley/* Create a ImportablePoolBean */
c8e9ed14d97e244b9753db14caf8481f181f5750talleystatic void
c8e9ed14d97e244b9753db14caf8481f181f5750talleynew_ImportablePoolBean(JNIEnv *env, ImportablePoolBean_t *bean)
c8e9ed14d97e244b9753db14caf8481f181f5750talley{
c8e9ed14d97e244b9753db14caf8481f181f5750talley zjni_Object_t *object = (zjni_Object_t *)bean;
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley if (object->object == NULL) {
c8e9ed14d97e244b9753db14caf8481f181f5750talley object->class =
c8e9ed14d97e244b9753db14caf8481f181f5750talley (*env)->FindClass(env,
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl ZFSJNI_PACKAGE_DATA "ImportablePoolBean");
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley object->constructor =
c8e9ed14d97e244b9753db14caf8481f181f5750talley (*env)->GetMethodID(env, object->class, "<init>", "()V");
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley object->object =
c8e9ed14d97e244b9753db14caf8481f181f5750talley (*env)->NewObject(env, object->class, object->constructor);
c8e9ed14d97e244b9753db14caf8481f181f5750talley }
c8e9ed14d97e244b9753db14caf8481f181f5750talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley new_PoolStats(env, &(bean->interface_PoolStats), object);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley bean->method_setName = (*env)->GetMethodID(
c8e9ed14d97e244b9753db14caf8481f181f5750talley env, object->class, "setName", "(Ljava/lang/String;)V");
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley bean->method_setId = (*env)->GetMethodID(
c8e9ed14d97e244b9753db14caf8481f181f5750talley env, object->class, "setId", "(J)V");
c8e9ed14d97e244b9753db14caf8481f181f5750talley}
c8e9ed14d97e244b9753db14caf8481f181f5750talley
fa9e4066f08beec538e775443c5be79dd423fcabahrens/* Create a VirtualDeviceBean */
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic void
fa9e4066f08beec538e775443c5be79dd423fcabahrensnew_VirtualDevice(JNIEnv *env, VirtualDeviceBean_t *bean)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
fa9e4066f08beec538e775443c5be79dd423fcabahrens zjni_Object_t *object = (zjni_Object_t *)bean;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (object->object == NULL) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens object->class =
fa9e4066f08beec538e775443c5be79dd423fcabahrens (*env)->FindClass(env,
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl ZFSJNI_PACKAGE_DATA "VirtualDeviceBean");
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens object->constructor =
fa9e4066f08beec538e775443c5be79dd423fcabahrens (*env)->GetMethodID(env, object->class, "<init>", "()V");
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens object->object =
fa9e4066f08beec538e775443c5be79dd423fcabahrens (*env)->NewObject(env, object->class, object->constructor);
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley new_DeviceStats(env, &(bean->interface_DeviceStats), object);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fa9e4066f08beec538e775443c5be79dd423fcabahrens bean->method_setPoolName = (*env)->GetMethodID(
fa9e4066f08beec538e775443c5be79dd423fcabahrens env, object->class, "setPoolName", "(Ljava/lang/String;)V");
fa9e4066f08beec538e775443c5be79dd423fcabahrens
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley bean->method_setParentIndex = (*env)->GetMethodID(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley env, object->class, "setParentIndex", "(Ljava/lang/Long;)V");
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley
fa9e4066f08beec538e775443c5be79dd423fcabahrens bean->method_setIndex = (*env)->GetMethodID(
fa9e4066f08beec538e775443c5be79dd423fcabahrens env, object->class, "setIndex", "(J)V");
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley/* Create a LeafVirtualDeviceBean */
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talleystatic void
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talleynew_LeafVirtualDevice(JNIEnv *env, LeafVirtualDeviceBean_t *bean)
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley{
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley zjni_Object_t *object = (zjni_Object_t *)bean;
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley if (object->object == NULL) {
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley object->class =
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley (*env)->FindClass(env,
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl ZFSJNI_PACKAGE_DATA "LeafVirtualDeviceBean");
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley object->constructor =
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley (*env)->GetMethodID(env, object->class, "<init>", "()V");
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley object->object =
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley (*env)->NewObject(env, object->class, object->constructor);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley }
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley new_VirtualDevice(env, (VirtualDeviceBean_t *)bean);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley bean->method_setName = (*env)->GetMethodID(
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley env, object->class, "setName", "(Ljava/lang/String;)V");
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley}
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
fa9e4066f08beec538e775443c5be79dd423fcabahrens/* Create a DiskVirtualDeviceBean */
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic void
fa9e4066f08beec538e775443c5be79dd423fcabahrensnew_DiskVirtualDeviceBean(JNIEnv *env, DiskVirtualDeviceBean_t *bean)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
fa9e4066f08beec538e775443c5be79dd423fcabahrens zjni_Object_t *object = (zjni_Object_t *)bean;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (object->object == NULL) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens object->class = (*env)->FindClass(
fa9e4066f08beec538e775443c5be79dd423fcabahrens env, ZFSJNI_PACKAGE_DATA "DiskVirtualDeviceBean");
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens object->constructor =
fa9e4066f08beec538e775443c5be79dd423fcabahrens (*env)->GetMethodID(env, object->class, "<init>", "()V");
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens object->object =
fa9e4066f08beec538e775443c5be79dd423fcabahrens (*env)->NewObject(env, object->class, object->constructor);
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley new_LeafVirtualDevice(env, (LeafVirtualDeviceBean_t *)bean);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley/* Create a SliceVirtualDeviceBean */
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talleystatic void
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talleynew_SliceVirtualDeviceBean(JNIEnv *env, SliceVirtualDeviceBean_t *bean)
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley{
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley zjni_Object_t *object = (zjni_Object_t *)bean;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley if (object->object == NULL) {
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley object->class = (*env)->FindClass(
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley env, ZFSJNI_PACKAGE_DATA "SliceVirtualDeviceBean");
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley object->constructor =
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley (*env)->GetMethodID(env, object->class, "<init>", "()V");
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley object->object =
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley (*env)->NewObject(env, object->class, object->constructor);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley }
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley new_LeafVirtualDevice(env, (LeafVirtualDeviceBean_t *)bean);
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/* Create a FileVirtualDeviceBean */
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic void
fa9e4066f08beec538e775443c5be79dd423fcabahrensnew_FileVirtualDeviceBean(JNIEnv *env, FileVirtualDeviceBean_t *bean)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
fa9e4066f08beec538e775443c5be79dd423fcabahrens zjni_Object_t *object = (zjni_Object_t *)bean;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (object->object == NULL) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens object->class = (*env)->FindClass(
fa9e4066f08beec538e775443c5be79dd423fcabahrens env, ZFSJNI_PACKAGE_DATA "FileVirtualDeviceBean");
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens object->constructor =
fa9e4066f08beec538e775443c5be79dd423fcabahrens (*env)->GetMethodID(env, object->class, "<init>", "()V");
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens object->object =
fa9e4066f08beec538e775443c5be79dd423fcabahrens (*env)->NewObject(env, object->class, object->constructor);
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley new_LeafVirtualDevice(env, (LeafVirtualDeviceBean_t *)bean);
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/* Create a RAIDVirtualDeviceBean */
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic void
fa9e4066f08beec538e775443c5be79dd423fcabahrensnew_RAIDVirtualDeviceBean(JNIEnv *env, RAIDVirtualDeviceBean_t *bean)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
fa9e4066f08beec538e775443c5be79dd423fcabahrens zjni_Object_t *object = (zjni_Object_t *)bean;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (object->object == NULL) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens object->class = (*env)->FindClass(
fa9e4066f08beec538e775443c5be79dd423fcabahrens env, ZFSJNI_PACKAGE_DATA "RAIDVirtualDeviceBean");
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens object->constructor =
fa9e4066f08beec538e775443c5be79dd423fcabahrens (*env)->GetMethodID(env, object->class, "<init>", "()V");
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens object->object =
fa9e4066f08beec538e775443c5be79dd423fcabahrens (*env)->NewObject(env, object->class, object->constructor);
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens new_VirtualDevice(env, (VirtualDeviceBean_t *)bean);
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl bean->method_setParity = (*env)->GetMethodID(
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl env, object->class, "setParity", "(J)V");
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/* Create a MirrorVirtualDeviceBean */
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic void
fa9e4066f08beec538e775443c5be79dd423fcabahrensnew_MirrorVirtualDeviceBean(JNIEnv *env, MirrorVirtualDeviceBean_t *bean)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
fa9e4066f08beec538e775443c5be79dd423fcabahrens zjni_Object_t *object = (zjni_Object_t *)bean;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (object->object == NULL) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens object->class = (*env)->FindClass(
fa9e4066f08beec538e775443c5be79dd423fcabahrens env, ZFSJNI_PACKAGE_DATA "MirrorVirtualDeviceBean");
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens object->constructor =
fa9e4066f08beec538e775443c5be79dd423fcabahrens (*env)->GetMethodID(env, object->class, "<init>", "()V");
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens object->object =
fa9e4066f08beec538e775443c5be79dd423fcabahrens (*env)->NewObject(env, object->class, object->constructor);
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens new_VirtualDevice(env, (VirtualDeviceBean_t *)bean);
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
c8e9ed14d97e244b9753db14caf8481f181f5750talleystatic int
c8e9ed14d97e244b9753db14caf8481f181f5750talleypopulate_ImportablePoolBean(JNIEnv *env, ImportablePoolBean_t *bean,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley nvlist_t *config)
c8e9ed14d97e244b9753db14caf8481f181f5750talley{
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley char *c;
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley char *name;
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley uint64_t guid;
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley uint64_t state;
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian uint64_t version;
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley nvlist_t *devices;
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley zjni_Object_t *object = (zjni_Object_t *)bean;
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley PoolStatsBean_t *pool_stats = &(bean->interface_PoolStats);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley DeviceStatsBean_t *dev_stats = (DeviceStatsBean_t *)pool_stats;
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley if (nvlist_lookup_string(config, ZPOOL_CONFIG_POOL_NAME, &name) ||
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID, &guid) ||
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_STATE, &state) ||
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION, &version) ||
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, &devices) ||
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley populate_DeviceStatsBean(env, devices, dev_stats, object)) {
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley return (-1);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley }
c8e9ed14d97e244b9753db14caf8481f181f5750talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley (*env)->CallVoidMethod(env, object->object,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setName, (*env)->NewStringUTF(env, name));
c8e9ed14d97e244b9753db14caf8481f181f5750talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley (*env)->CallVoidMethod(env, object->object,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setId, (jlong)guid);
c8e9ed14d97e244b9753db14caf8481f181f5750talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley (*env)->CallVoidMethod(env, object->object,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley pool_stats->method_setPoolState,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley zjni_pool_state_to_obj(env, (pool_state_t)state));
c8e9ed14d97e244b9753db14caf8481f181f5750talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley (*env)->CallVoidMethod(env, object->object,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley pool_stats->method_setPoolStatus,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley zjni_pool_status_to_obj(env, zpool_import_status(config, &c)));
c8e9ed14d97e244b9753db14caf8481f181f5750talley
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian (*env)->CallVoidMethod(env, object->object,
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian pool_stats->method_setPoolVersion, (jlong)version);
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian
c8e9ed14d97e244b9753db14caf8481f181f5750talley return (0);
c8e9ed14d97e244b9753db14caf8481f181f5750talley}
c8e9ed14d97e244b9753db14caf8481f181f5750talley
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic int
fa9e4066f08beec538e775443c5be79dd423fcabahrenspopulate_VirtualDeviceBean(JNIEnv *env, zpool_handle_t *zhp,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *vdev, uint64_t *p_vdev_id, VirtualDeviceBean_t *bean)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
fa9e4066f08beec538e775443c5be79dd423fcabahrens int result;
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t vdev_id;
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley jstring poolUTF;
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fa9e4066f08beec538e775443c5be79dd423fcabahrens zjni_Object_t *object = (zjni_Object_t *)bean;
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley DeviceStatsBean_t *stats = &(bean->interface_DeviceStats);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley result = populate_DeviceStatsBean(env, vdev, stats, object);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley if (result != 0) {
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley return (1);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Set pool name */
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley poolUTF = (*env)->NewStringUTF(env, zpool_get_name(zhp));
fa9e4066f08beec538e775443c5be79dd423fcabahrens (*env)->CallVoidMethod(
fa9e4066f08beec538e775443c5be79dd423fcabahrens env, object->object, bean->method_setPoolName, poolUTF);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley /* Set parent vdev index */
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley (*env)->CallVoidMethod(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley env, object->object, bean->method_setParentIndex,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley p_vdev_id == NULL ? NULL :
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley zjni_long_to_Long(env, *p_vdev_id));
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Get index */
fa9e4066f08beec538e775443c5be79dd423fcabahrens result = nvlist_lookup_uint64(vdev, ZPOOL_CONFIG_GUID, &vdev_id);
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (result != 0) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens zjni_throw_exception(env,
fa9e4066f08beec538e775443c5be79dd423fcabahrens "could not retrieve virtual device ID (pool %s)",
fa9e4066f08beec538e775443c5be79dd423fcabahrens zpool_get_name(zhp));
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley return (1);
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley (*env)->CallVoidMethod(
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley env, object->object, bean->method_setIndex, (jlong)vdev_id);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley return (0);
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talleystatic int
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talleypopulate_LeafVirtualDeviceBean(JNIEnv *env, zpool_handle_t *zhp,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *vdev, uint64_t *p_vdev_id, LeafVirtualDeviceBean_t *bean)
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley{
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley return (populate_VirtualDeviceBean(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley env, zhp, vdev, p_vdev_id, (VirtualDeviceBean_t *)bean));
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley}
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic int
fa9e4066f08beec538e775443c5be79dd423fcabahrenspopulate_DiskVirtualDeviceBean(JNIEnv *env, zpool_handle_t *zhp,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *vdev, uint64_t *p_vdev_id, DiskVirtualDeviceBean_t *bean)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
fa9e4066f08beec538e775443c5be79dd423fcabahrens char *path;
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley int result = populate_LeafVirtualDeviceBean(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley env, zhp, vdev, p_vdev_id, (LeafVirtualDeviceBean_t *)bean);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (result) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Must not call any more Java methods to preserve exception */
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (-1);
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Set path */
fa9e4066f08beec538e775443c5be79dd423fcabahrens result = nvlist_lookup_string(vdev, ZPOOL_CONFIG_PATH, &path);
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (result != 0) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens zjni_throw_exception(env,
d7d4af51b4d115490d97f0b89993fdbaaf441c94mmusante "could not retrieve path from disk virtual device "
d7d4af51b4d115490d97f0b89993fdbaaf441c94mmusante "(pool %s)", zpool_get_name(zhp));
fa9e4066f08beec538e775443c5be79dd423fcabahrens } else {
fa9e4066f08beec538e775443c5be79dd423fcabahrens
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley regex_t re;
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley regmatch_t matches[2];
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley jstring pathUTF = NULL;
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley /* Strip off slice portion of name, if applicable */
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley if (regcomp(&re, "^(/dev/dsk/.*)s[0-9]+$", REG_EXTENDED) == 0) {
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley if (regexec(&re, path, 2, matches, 0) == 0) {
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley regmatch_t *match = matches + 1;
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley if (match->rm_so != -1 && match->rm_eo != -1) {
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley char *tmp = strdup(path);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley if (tmp != NULL) {
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley char *end = tmp + match->rm_eo;
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley *end = '\0';
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley pathUTF = (*env)->NewStringUTF(
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley env, tmp);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley free(tmp);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley }
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley }
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley }
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley regfree(&re);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley }
3fdda4994a108ded4ec1a2b544804f191a4ec83aJohn Harres if (regcomp(&re, "^(/dev/dsk/.*)s[0-9]+/old$", REG_EXTENDED) ==
3fdda4994a108ded4ec1a2b544804f191a4ec83aJohn Harres 0) {
3fdda4994a108ded4ec1a2b544804f191a4ec83aJohn Harres if (regexec(&re, path, 2, matches, 0) == 0) {
3fdda4994a108ded4ec1a2b544804f191a4ec83aJohn Harres regmatch_t *match = matches + 1;
3fdda4994a108ded4ec1a2b544804f191a4ec83aJohn Harres if (match->rm_so != -1 && match->rm_eo != -1) {
3fdda4994a108ded4ec1a2b544804f191a4ec83aJohn Harres char *tmp = strdup(path);
3fdda4994a108ded4ec1a2b544804f191a4ec83aJohn Harres if (tmp != NULL) {
3fdda4994a108ded4ec1a2b544804f191a4ec83aJohn Harres (void) strcpy(tmp +
3fdda4994a108ded4ec1a2b544804f191a4ec83aJohn Harres match->rm_eo, "/old");
3fdda4994a108ded4ec1a2b544804f191a4ec83aJohn Harres pathUTF = (*env)->NewStringUTF(
3fdda4994a108ded4ec1a2b544804f191a4ec83aJohn Harres env, tmp);
3fdda4994a108ded4ec1a2b544804f191a4ec83aJohn Harres free(tmp);
3fdda4994a108ded4ec1a2b544804f191a4ec83aJohn Harres }
3fdda4994a108ded4ec1a2b544804f191a4ec83aJohn Harres }
3fdda4994a108ded4ec1a2b544804f191a4ec83aJohn Harres }
3fdda4994a108ded4ec1a2b544804f191a4ec83aJohn Harres regfree(&re);
3fdda4994a108ded4ec1a2b544804f191a4ec83aJohn Harres }
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley if (pathUTF == NULL) {
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl pathUTF = (*env)->NewStringUTF(env, path);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley }
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley (*env)->CallVoidMethod(env, ((zjni_Object_t *)bean)->object,
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley ((LeafVirtualDeviceBean_t *)bean)->method_setName, pathUTF);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley }
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley return (result != 0);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley}
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talleystatic int
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talleypopulate_SliceVirtualDeviceBean(JNIEnv *env, zpool_handle_t *zhp,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *vdev, uint64_t *p_vdev_id, SliceVirtualDeviceBean_t *bean)
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley{
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley char *path;
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley int result = populate_LeafVirtualDeviceBean(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley env, zhp, vdev, p_vdev_id, (LeafVirtualDeviceBean_t *)bean);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley if (result) {
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley /* Must not call any more Java methods to preserve exception */
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley return (-1);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley }
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley /* Set path */
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley result = nvlist_lookup_string(vdev, ZPOOL_CONFIG_PATH, &path);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley if (result != 0) {
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley zjni_throw_exception(env,
d7d4af51b4d115490d97f0b89993fdbaaf441c94mmusante "could not retrieve path from slice virtual device (pool "
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley "%s)", zpool_get_name(zhp));
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley } else {
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
fa9e4066f08beec538e775443c5be79dd423fcabahrens jstring pathUTF = (*env)->NewStringUTF(env, path);
fa9e4066f08beec538e775443c5be79dd423fcabahrens (*env)->CallVoidMethod(env, ((zjni_Object_t *)bean)->object,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley ((LeafVirtualDeviceBean_t *)bean)->method_setName,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley pathUTF);
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (result != 0);
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic int
fa9e4066f08beec538e775443c5be79dd423fcabahrenspopulate_FileVirtualDeviceBean(JNIEnv *env, zpool_handle_t *zhp,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *vdev, uint64_t *p_vdev_id, FileVirtualDeviceBean_t *bean)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
fa9e4066f08beec538e775443c5be79dd423fcabahrens char *path;
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley int result = populate_LeafVirtualDeviceBean(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley env, zhp, vdev, p_vdev_id, (LeafVirtualDeviceBean_t *)bean);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (result) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Must not call any more Java methods to preserve exception */
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (-1);
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Set path */
fa9e4066f08beec538e775443c5be79dd423fcabahrens result = nvlist_lookup_string(vdev, ZPOOL_CONFIG_PATH, &path);
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (result != 0) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens zjni_throw_exception(env,
d7d4af51b4d115490d97f0b89993fdbaaf441c94mmusante "could not retrieve path from disk virtual device "
d7d4af51b4d115490d97f0b89993fdbaaf441c94mmusante "(pool %s)", zpool_get_name(zhp));
fa9e4066f08beec538e775443c5be79dd423fcabahrens } else {
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens jstring pathUTF = (*env)->NewStringUTF(env, path);
fa9e4066f08beec538e775443c5be79dd423fcabahrens (*env)->CallVoidMethod(env, ((zjni_Object_t *)bean)->object,
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley ((LeafVirtualDeviceBean_t *)bean)->method_setName, pathUTF);
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (result != 0);
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic int
fa9e4066f08beec538e775443c5be79dd423fcabahrenspopulate_RAIDVirtualDeviceBean(JNIEnv *env, zpool_handle_t *zhp,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *vdev, uint64_t *p_vdev_id, RAIDVirtualDeviceBean_t *bean)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley return (populate_VirtualDeviceBean(env, zhp, vdev, p_vdev_id,
fa9e4066f08beec538e775443c5be79dd423fcabahrens (VirtualDeviceBean_t *)bean));
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic int
fa9e4066f08beec538e775443c5be79dd423fcabahrenspopulate_MirrorVirtualDeviceBean(JNIEnv *env, zpool_handle_t *zhp,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *vdev, uint64_t *p_vdev_id, MirrorVirtualDeviceBean_t *bean)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley return (populate_VirtualDeviceBean(env, zhp, vdev, p_vdev_id,
fa9e4066f08beec538e775443c5be79dd423fcabahrens (VirtualDeviceBean_t *)bean));
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
c8e9ed14d97e244b9753db14caf8481f181f5750talleystatic jobject
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleycreate_ImportablePoolBean(JNIEnv *env, nvlist_t *config)
c8e9ed14d97e244b9753db14caf8481f181f5750talley{
c8e9ed14d97e244b9753db14caf8481f181f5750talley int result;
c8e9ed14d97e244b9753db14caf8481f181f5750talley ImportablePoolBean_t bean_obj = {0};
c8e9ed14d97e244b9753db14caf8481f181f5750talley ImportablePoolBean_t *bean = &bean_obj;
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley /* Construct ImportablePoolBean */
c8e9ed14d97e244b9753db14caf8481f181f5750talley new_ImportablePoolBean(env, bean);
c8e9ed14d97e244b9753db14caf8481f181f5750talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley result = populate_ImportablePoolBean(env, bean, config);
c8e9ed14d97e244b9753db14caf8481f181f5750talley if (result) {
c8e9ed14d97e244b9753db14caf8481f181f5750talley /* Must not call any more Java methods to preserve exception */
c8e9ed14d97e244b9753db14caf8481f181f5750talley return (NULL);
c8e9ed14d97e244b9753db14caf8481f181f5750talley }
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley return (((zjni_Object_t *)bean)->object);
c8e9ed14d97e244b9753db14caf8481f181f5750talley}
c8e9ed14d97e244b9753db14caf8481f181f5750talley
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic jobject
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalleycreate_DiskVirtualDeviceBean(JNIEnv *env, zpool_handle_t *zhp,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *vdev, uint64_t *p_vdev_id)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
fa9e4066f08beec538e775443c5be79dd423fcabahrens int result;
fa9e4066f08beec538e775443c5be79dd423fcabahrens DiskVirtualDeviceBean_t bean_obj = {0};
fa9e4066f08beec538e775443c5be79dd423fcabahrens DiskVirtualDeviceBean_t *bean = &bean_obj;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Construct DiskVirtualDeviceBean */
fa9e4066f08beec538e775443c5be79dd423fcabahrens new_DiskVirtualDeviceBean(env, bean);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley result = populate_DiskVirtualDeviceBean(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley env, zhp, vdev, p_vdev_id, bean);
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (result) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Must not call any more Java methods to preserve exception */
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (NULL);
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (((zjni_Object_t *)bean)->object);
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talleystatic jobject
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalleycreate_SliceVirtualDeviceBean(JNIEnv *env, zpool_handle_t *zhp,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *vdev, uint64_t *p_vdev_id)
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley{
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley int result;
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley SliceVirtualDeviceBean_t bean_obj = {0};
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley SliceVirtualDeviceBean_t *bean = &bean_obj;
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley /* Construct SliceVirtualDeviceBean */
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley new_SliceVirtualDeviceBean(env, bean);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley result = populate_SliceVirtualDeviceBean(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley env, zhp, vdev, p_vdev_id, bean);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley if (result) {
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley /* Must not call any more Java methods to preserve exception */
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley return (NULL);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley }
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley return (((zjni_Object_t *)bean)->object);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley}
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic jobject
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalleycreate_FileVirtualDeviceBean(JNIEnv *env, zpool_handle_t *zhp,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *vdev, uint64_t *p_vdev_id)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
fa9e4066f08beec538e775443c5be79dd423fcabahrens int result;
fa9e4066f08beec538e775443c5be79dd423fcabahrens FileVirtualDeviceBean_t bean_obj = {0};
fa9e4066f08beec538e775443c5be79dd423fcabahrens FileVirtualDeviceBean_t *bean = &bean_obj;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Construct FileVirtualDeviceBean */
fa9e4066f08beec538e775443c5be79dd423fcabahrens new_FileVirtualDeviceBean(env, bean);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley result = populate_FileVirtualDeviceBean(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley env, zhp, vdev, p_vdev_id, bean);
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (result) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Must not call any more Java methods to preserve exception */
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (NULL);
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (((zjni_Object_t *)bean)->object);
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic jobject
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalleycreate_RAIDVirtualDeviceBean(JNIEnv *env, zpool_handle_t *zhp,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *vdev, uint64_t *p_vdev_id)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
fa9e4066f08beec538e775443c5be79dd423fcabahrens int result;
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl uint64_t parity;
fa9e4066f08beec538e775443c5be79dd423fcabahrens RAIDVirtualDeviceBean_t bean_obj = {0};
fa9e4066f08beec538e775443c5be79dd423fcabahrens RAIDVirtualDeviceBean_t *bean = &bean_obj;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens ((zjni_Object_t *)bean)->object = NULL;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Construct RAIDVirtualDeviceBean */
fa9e4066f08beec538e775443c5be79dd423fcabahrens new_RAIDVirtualDeviceBean(env, bean);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl /* Set parity bit */
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl result = nvlist_lookup_uint64(vdev, ZPOOL_CONFIG_NPARITY,
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl &parity);
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl if (result) {
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl /* Default to RAID-Z1 in case of error */
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl parity = 1;
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl }
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl (*env)->CallVoidMethod(
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl env, ((zjni_Object_t *)bean)->object, bean->method_setParity,
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl (jlong)parity);
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley result = populate_RAIDVirtualDeviceBean(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley env, zhp, vdev, p_vdev_id, bean);
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (result) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Must not call any more Java methods to preserve exception */
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (NULL);
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (((zjni_Object_t *)bean)->object);
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrensstatic jobject
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalleycreate_MirrorVirtualDeviceBean(JNIEnv *env, zpool_handle_t *zhp,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *vdev, uint64_t *p_vdev_id)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
fa9e4066f08beec538e775443c5be79dd423fcabahrens int result;
fa9e4066f08beec538e775443c5be79dd423fcabahrens MirrorVirtualDeviceBean_t bean_obj = {0};
fa9e4066f08beec538e775443c5be79dd423fcabahrens MirrorVirtualDeviceBean_t *bean = &bean_obj;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Construct MirrorVirtualDeviceBean */
fa9e4066f08beec538e775443c5be79dd423fcabahrens new_MirrorVirtualDeviceBean(env, bean);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley result = populate_MirrorVirtualDeviceBean(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley env, zhp, vdev, p_vdev_id, bean);
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (result) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Must not call any more Java methods to preserve exception */
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (NULL);
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (((zjni_Object_t *)bean)->object);
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleystatic char *
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleyfind_field(const zjni_field_mapping_t *mapping, int value) {
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley int i;
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley for (i = 0; mapping[i].name != NULL; i++) {
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley if (value == mapping[i].value) {
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley return (mapping[i].name);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley }
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley }
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley return (NULL);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley}
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley/*
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley * Converts a vdev_state_t to a Java DeviceStats$DeviceState object.
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley */
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleystatic jobject
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleyzjni_vdev_state_to_obj(JNIEnv *env, vdev_state_t state)
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley{
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley return (zjni_int_to_enum(env, state,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley ZFSJNI_PACKAGE_DATA "DeviceStats$DeviceState",
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley "VDEV_STATE_UNKNOWN", vdev_state_map));
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley}
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley/*
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley * Converts a vdev_aux_t to a Java DeviceStats$DeviceStatus object.
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley */
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleystatic jobject
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleyzjni_vdev_aux_to_obj(JNIEnv *env, vdev_aux_t aux)
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley{
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley return (zjni_int_to_enum(env, aux,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley ZFSJNI_PACKAGE_DATA "DeviceStats$DeviceStatus",
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley "VDEV_AUX_NONE", vdev_aux_map));
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley}
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Package-private functions
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley/* Create a DeviceStatsBean */
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleyvoid
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleynew_DeviceStats(JNIEnv *env, DeviceStatsBean_t *bean, zjni_Object_t *object)
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley{
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setSize = (*env)->GetMethodID(
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley env, object->class, "setSize", "(J)V");
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley bean->method_setReplacementSize = (*env)->GetMethodID(
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley env, object->class, "setReplacementSize", "(J)V");
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setUsed = (*env)->GetMethodID(
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley env, object->class, "setUsed", "(J)V");
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setReadBytes = (*env)->GetMethodID(
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley env, object->class, "setReadBytes", "(J)V");
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setWriteBytes = (*env)->GetMethodID(
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley env, object->class, "setWriteBytes", "(J)V");
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setReadOperations = (*env)->GetMethodID(
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley env, object->class, "setReadOperations", "(J)V");
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setWriteOperations = (*env)->GetMethodID(
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley env, object->class, "setWriteOperations", "(J)V");
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setReadErrors = (*env)->GetMethodID(
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley env, object->class, "setReadErrors", "(J)V");
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setWriteErrors = (*env)->GetMethodID(
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley env, object->class, "setWriteErrors", "(J)V");
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setChecksumErrors = (*env)->GetMethodID(
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley env, object->class, "setChecksumErrors", "(J)V");
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setDeviceState = (*env)->GetMethodID(
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley env, object->class, "setDeviceState",
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley "(L" ZFSJNI_PACKAGE_DATA "DeviceStats$DeviceState;)V");
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setDeviceStatus = (*env)->GetMethodID(
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley env, object->class, "setDeviceStatus",
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley "(L" ZFSJNI_PACKAGE_DATA "DeviceStats$DeviceStatus;)V");
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley}
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley/* Create a PoolStatsBean */
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleyvoid
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleynew_PoolStats(JNIEnv *env, PoolStatsBean_t *bean, zjni_Object_t *object)
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley{
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley new_DeviceStats(env, (DeviceStatsBean_t *)bean, object);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setPoolState = (*env)->GetMethodID(
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley env, object->class, "setPoolState",
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley "(L" ZFSJNI_PACKAGE_DATA "PoolStats$PoolState;)V");
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setPoolStatus = (*env)->GetMethodID(
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley env, object->class, "setPoolStatus",
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley "(L" ZFSJNI_PACKAGE_DATA "PoolStats$PoolStatus;)V");
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian bean->method_setPoolVersion = (*env)->GetMethodID(
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian env, object->class, "setPoolVersion", "(J)V");
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley}
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Gets the root vdev (an nvlist_t *) for the given pool.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrensnvlist_t *
fa9e4066f08beec538e775443c5be79dd423fcabahrenszjni_get_root_vdev(zpool_handle_t *zhp)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
fa9e4066f08beec538e775443c5be79dd423fcabahrens nvlist_t *root = NULL;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (zhp != NULL) {
088e9d477eee66081e407fbc5a33c4da25f66f6aeschrock nvlist_t *attrs = zpool_get_config(zhp, NULL);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (attrs != NULL) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens int result = nvlist_lookup_nvlist(
fa9e4066f08beec538e775443c5be79dd423fcabahrens attrs, ZPOOL_CONFIG_VDEV_TREE, &root);
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (result != 0) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens root = NULL;
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (root);
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Gets the vdev (an nvlist_t *) with the given vdev_id, below the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * given vdev. If the given vdev is NULL, all vdevs within the given
fa9e4066f08beec538e775443c5be79dd423fcabahrens * pool are searched.
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley *
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley * If p_vdev_id is not NULL, it will be set to the ID of the parent
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley * vdev, if any, or to vdev_id_to_find if the searched-for vdev is a
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley * toplevel vdev.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrensnvlist_t *
fa9e4066f08beec538e775443c5be79dd423fcabahrenszjni_get_vdev(zpool_handle_t *zhp, nvlist_t *vdev_parent,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley uint64_t vdev_id_to_find, uint64_t *p_vdev_id)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
fa9e4066f08beec538e775443c5be79dd423fcabahrens int result;
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley uint64_t id = vdev_id_to_find;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Was a vdev specified? */
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (vdev_parent == NULL) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* No -- retrieve the top-level pool vdev */
fa9e4066f08beec538e775443c5be79dd423fcabahrens vdev_parent = zjni_get_root_vdev(zhp);
fa9e4066f08beec538e775443c5be79dd423fcabahrens } else {
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Get index of this vdev and compare with vdev_id_to_find */
fa9e4066f08beec538e775443c5be79dd423fcabahrens result = nvlist_lookup_uint64(
fa9e4066f08beec538e775443c5be79dd423fcabahrens vdev_parent, ZPOOL_CONFIG_GUID, &id);
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (result == 0 && id == vdev_id_to_find) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (vdev_parent);
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (vdev_parent != NULL) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens nvlist_t **children;
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint_t nelem = 0;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Get the vdevs under this vdev */
fa9e4066f08beec538e775443c5be79dd423fcabahrens result = nvlist_lookup_nvlist_array(
fa9e4066f08beec538e775443c5be79dd423fcabahrens vdev_parent, ZPOOL_CONFIG_CHILDREN, &children, &nelem);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (result == 0) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens int i;
fa9e4066f08beec538e775443c5be79dd423fcabahrens nvlist_t *child;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* For each vdev child... */
fa9e4066f08beec538e775443c5be79dd423fcabahrens for (i = 0; i < nelem; i++) {
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley if (p_vdev_id != NULL) {
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley /* Save parent vdev id */
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley *p_vdev_id = id;
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley }
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley
fa9e4066f08beec538e775443c5be79dd423fcabahrens child = zjni_get_vdev(zhp, children[i],
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley vdev_id_to_find, p_vdev_id);
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (child != NULL) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (child);
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (NULL);
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrensjobject
fa9e4066f08beec538e775443c5be79dd423fcabahrenszjni_get_VirtualDevice_from_vdev(JNIEnv *env, zpool_handle_t *zhp,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *vdev, uint64_t *p_vdev_id)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
fa9e4066f08beec538e775443c5be79dd423fcabahrens jobject obj = NULL;
fa9e4066f08beec538e775443c5be79dd423fcabahrens char *type = NULL;
fa9e4066f08beec538e775443c5be79dd423fcabahrens int result = nvlist_lookup_string(vdev, ZPOOL_CONFIG_TYPE, &type);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (result == 0) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (strcmp(type, VDEV_TYPE_DISK) == 0) {
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley uint64_t wholedisk;
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley if (nvlist_lookup_uint64(vdev, ZPOOL_CONFIG_WHOLE_DISK,
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley &wholedisk) == 0 && wholedisk) {
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley obj = create_DiskVirtualDeviceBean(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley env, zhp, vdev, p_vdev_id);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley } else {
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley obj = create_SliceVirtualDeviceBean(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley env, zhp, vdev, p_vdev_id);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley }
fa9e4066f08beec538e775443c5be79dd423fcabahrens } else if (strcmp(type, VDEV_TYPE_FILE) == 0) {
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley obj = create_FileVirtualDeviceBean(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley env, zhp, vdev, p_vdev_id);
fa9e4066f08beec538e775443c5be79dd423fcabahrens } else if (strcmp(type, VDEV_TYPE_RAIDZ) == 0) {
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley obj = create_RAIDVirtualDeviceBean(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley env, zhp, vdev, p_vdev_id);
fa9e4066f08beec538e775443c5be79dd423fcabahrens } else if (strcmp(type, VDEV_TYPE_MIRROR) == 0) {
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley obj = create_MirrorVirtualDeviceBean(
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley env, zhp, vdev, p_vdev_id);
c8e9ed14d97e244b9753db14caf8481f181f5750talley } else if (strcmp(type, VDEV_TYPE_REPLACING) == 0) {
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley /* Get the vdevs under this vdev */
c8e9ed14d97e244b9753db14caf8481f181f5750talley nvlist_t **children;
c8e9ed14d97e244b9753db14caf8481f181f5750talley uint_t nelem = 0;
c8e9ed14d97e244b9753db14caf8481f181f5750talley int result = nvlist_lookup_nvlist_array(
c8e9ed14d97e244b9753db14caf8481f181f5750talley vdev, ZPOOL_CONFIG_CHILDREN, &children, &nelem);
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley if (result == 0 && nelem > 0) {
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley /* Get last vdev child (replacement device) */
c8e9ed14d97e244b9753db14caf8481f181f5750talley nvlist_t *child = children[nelem - 1];
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley obj = zjni_get_VirtualDevice_from_vdev(env,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley zhp, child, p_vdev_id);
c8e9ed14d97e244b9753db14caf8481f181f5750talley }
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (obj);
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrensjobject
fa9e4066f08beec538e775443c5be79dd423fcabahrenszjni_get_VirtualDevices_from_vdev(JNIEnv *env, zpool_handle_t *zhp,
bfe5f5a4bed2da6ba708c3b046a37de8b4568d4ftalley nvlist_t *vdev_parent, uint64_t *p_vdev_id)
fa9e4066f08beec538e775443c5be79dd423fcabahrens{
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Create an array list for the vdevs */
fa9e4066f08beec538e775443c5be79dd423fcabahrens zjni_ArrayList_t list_class = {0};
fa9e4066f08beec538e775443c5be79dd423fcabahrens zjni_ArrayList_t *list_class_p = &list_class;
fa9e4066f08beec538e775443c5be79dd423fcabahrens zjni_new_ArrayList(env, list_class_p);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Was a vdev specified? */
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (vdev_parent == NULL) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* No -- retrieve the top-level pool vdev */
fa9e4066f08beec538e775443c5be79dd423fcabahrens vdev_parent = zjni_get_root_vdev(zhp);
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (vdev_parent != NULL) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Get the vdevs under this vdev */
fa9e4066f08beec538e775443c5be79dd423fcabahrens nvlist_t **children;
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint_t nelem = 0;
fa9e4066f08beec538e775443c5be79dd423fcabahrens int result = nvlist_lookup_nvlist_array(
fa9e4066f08beec538e775443c5be79dd423fcabahrens vdev_parent, ZPOOL_CONFIG_CHILDREN, &children, &nelem);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens if (result == 0) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* For each vdev child... */
fa9e4066f08beec538e775443c5be79dd423fcabahrens int i;
fa9e4066f08beec538e775443c5be79dd423fcabahrens for (i = 0; i < nelem; i++) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens nvlist_t *child = children[i];
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Create a Java object from this vdev */
fa9e4066f08beec538e775443c5be79dd423fcabahrens jobject obj =
fa9e4066f08beec538e775443c5be79dd423fcabahrens zjni_get_VirtualDevice_from_vdev(env,
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl zhp, child, p_vdev_id);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
c8e9ed14d97e244b9753db14caf8481f181f5750talley if ((*env)->ExceptionOccurred(env) != NULL) {
fa9e4066f08beec538e775443c5be79dd423fcabahrens /*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Must not call any more Java methods
fa9e4066f08beec538e775443c5be79dd423fcabahrens * to preserve exception
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (NULL);
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
c8e9ed14d97e244b9753db14caf8481f181f5750talley if (obj != NULL) {
c8e9ed14d97e244b9753db14caf8481f181f5750talley /* Add child to child vdev list */
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl (*env)->CallBooleanMethod(env,
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl ((zjni_Object_t *)
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl list_class_p)->object,
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl ((zjni_Collection_t *)
1e995cfce563729fbd612e2ee27dbbab4f50dbaarl list_class_p)->method_add, obj);
c8e9ed14d97e244b9753db14caf8481f181f5750talley }
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens }
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (zjni_Collection_to_array(
fa9e4066f08beec538e775443c5be79dd423fcabahrens env, (zjni_Collection_t *)list_class_p,
fa9e4066f08beec538e775443c5be79dd423fcabahrens ZFSJNI_PACKAGE_DATA "VirtualDevice"));
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talleyint
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleyzjni_create_add_ImportablePool(nvlist_t *config, void *data) {
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley JNIEnv *env = ((zjni_ArrayCallbackData_t *)data)->env;
c8e9ed14d97e244b9753db14caf8481f181f5750talley zjni_Collection_t *list = ((zjni_ArrayCallbackData_t *)data)->list;
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley /* Construct ImportablePool object */
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley jobject bean = create_ImportablePoolBean(env, config);
c8e9ed14d97e244b9753db14caf8481f181f5750talley if (bean == NULL) {
c8e9ed14d97e244b9753db14caf8481f181f5750talley return (-1);
c8e9ed14d97e244b9753db14caf8481f181f5750talley }
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley /* Add bean to list */
c8e9ed14d97e244b9753db14caf8481f181f5750talley (*env)->CallBooleanMethod(env, ((zjni_Object_t *)list)->object,
c8e9ed14d97e244b9753db14caf8481f181f5750talley ((zjni_Collection_t *)list)->method_add, bean);
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley return (0);
c8e9ed14d97e244b9753db14caf8481f181f5750talley}
c8e9ed14d97e244b9753db14caf8481f181f5750talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleyint
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleypopulate_DeviceStatsBean(JNIEnv *env, nvlist_t *vdev,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley DeviceStatsBean_t *bean, zjni_Object_t *object)
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley{
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley uint_t c;
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley vdev_stat_t *vs;
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley int result = nvlist_lookup_uint64_array(
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling vdev, ZPOOL_CONFIG_VDEV_STATS, (uint64_t **)&vs, &c);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley if (result != 0) {
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley zjni_throw_exception(env,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley "could not retrieve virtual device statistics");
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley return (1);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley }
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley (*env)->CallVoidMethod(env, object->object,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setUsed, (jlong)vs->vs_alloc);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley (*env)->CallVoidMethod(env, object->object,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setSize, (jlong)vs->vs_space);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley (*env)->CallVoidMethod(env, object->object,
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley bean->method_setReplacementSize, (jlong)vs->vs_rsize);
a1a659ae4f0ae792e70c00834f74ae0d472c2b05talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley (*env)->CallVoidMethod(env, object->object,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setReadBytes, (jlong)vs->vs_bytes[ZIO_TYPE_READ]);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley (*env)->CallVoidMethod(env, object->object,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setWriteBytes, (jlong)vs->vs_bytes[ZIO_TYPE_WRITE]);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley (*env)->CallVoidMethod(env, object->object,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setReadOperations, (jlong)vs->vs_ops[ZIO_TYPE_READ]);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley (*env)->CallVoidMethod(env, object->object,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setWriteOperations, (jlong)vs->vs_ops[ZIO_TYPE_WRITE]);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley (*env)->CallVoidMethod(env, object->object,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setReadErrors, (jlong)vs->vs_read_errors);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley (*env)->CallVoidMethod(env, object->object,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setWriteErrors, (jlong)vs->vs_write_errors);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley (*env)->CallVoidMethod(env, object->object,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setChecksumErrors, (jlong)vs->vs_checksum_errors);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley (*env)->CallVoidMethod(env, object->object,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setDeviceState,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley zjni_vdev_state_to_obj(env, vs->vs_state));
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley (*env)->CallVoidMethod(env, object->object,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley bean->method_setDeviceStatus,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley zjni_vdev_aux_to_obj(env, vs->vs_aux));
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley return (0);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley}
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley/*
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley * Converts a pool_state_t to a Java PoolStats$PoolState object.
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley */
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleyjobject
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleyzjni_pool_state_to_obj(JNIEnv *env, pool_state_t state)
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley{
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley return (zjni_int_to_enum(env, state,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley ZFSJNI_PACKAGE_DATA "PoolStats$PoolState",
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley "POOL_STATE_ACTIVE", pool_state_map));
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley}
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley/*
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley * Converts a zpool_status_t to a Java PoolStats$PoolStatus object.
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley */
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleyjobject
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleyzjni_pool_status_to_obj(JNIEnv *env, zpool_status_t status)
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley{
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley return (zjni_int_to_enum(env, status,
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley ZFSJNI_PACKAGE_DATA "PoolStats$PoolStatus",
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley "ZPOOL_STATUS_OK", zpool_status_map));
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley}
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley/*
c8e9ed14d97e244b9753db14caf8481f181f5750talley * Extern functions
c8e9ed14d97e244b9753db14caf8481f181f5750talley */
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley/*
c8e9ed14d97e244b9753db14caf8481f181f5750talley * Iterates through each importable pool on the system. For each
c8e9ed14d97e244b9753db14caf8481f181f5750talley * importable pool, runs the given function with the given void as the
c8e9ed14d97e244b9753db14caf8481f181f5750talley * last arg.
c8e9ed14d97e244b9753db14caf8481f181f5750talley */
c8e9ed14d97e244b9753db14caf8481f181f5750talleyint
c8e9ed14d97e244b9753db14caf8481f181f5750talleyzjni_ipool_iter(int argc, char **argv, zjni_ipool_iter_f func, void *data)
c8e9ed14d97e244b9753db14caf8481f181f5750talley{
24e697d414a4df0377b91a2875f029e7b5f97247ck nvlist_t *pools = zpool_find_import(g_zfs, argc, argv);
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley if (pools != NULL) {
c8e9ed14d97e244b9753db14caf8481f181f5750talley nvpair_t *elem = NULL;
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley while ((elem = nvlist_next_nvpair(pools, elem)) != NULL) {
c8e9ed14d97e244b9753db14caf8481f181f5750talley nvlist_t *config;
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley if (nvpair_value_nvlist(elem, &config) != 0 ||
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley func(config, data)) {
c8e9ed14d97e244b9753db14caf8481f181f5750talley return (-1);
c8e9ed14d97e244b9753db14caf8481f181f5750talley }
c8e9ed14d97e244b9753db14caf8481f181f5750talley }
c8e9ed14d97e244b9753db14caf8481f181f5750talley }
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talley return (0);
c8e9ed14d97e244b9753db14caf8481f181f5750talley}
c8e9ed14d97e244b9753db14caf8481f181f5750talley
c8e9ed14d97e244b9753db14caf8481f181f5750talleychar *
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleyzjni_vdev_state_to_str(vdev_state_t state) {
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley return (find_field(vdev_state_map, state));
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley}
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleychar *
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleyzjni_vdev_aux_to_str(vdev_aux_t aux) {
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley return (find_field(vdev_aux_map, aux));
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley}
c8e9ed14d97e244b9753db14caf8481f181f5750talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleychar *
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleyzjni_pool_state_to_str(pool_state_t state) {
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley return (find_field(pool_state_map, state));
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley}
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleychar *
fbfd10ff571cfd0139aa5127460f1b8a53dac971talleyzjni_pool_status_to_str(zpool_status_t status) {
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley return (find_field(zpool_status_map, status));
c8e9ed14d97e244b9753db14caf8481f181f5750talley}