libzfs_jni_pool.c revision fa9e4066f08beec538e775443c5be79dd423fcab
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "libzfs_jni_pool.h"
#include "libzfs_jni_util.h"
#include <strings.h>
/*
* Types
*/
typedef struct VirtualDeviceBean {
typedef struct DiskVirtualDeviceBean {
typedef struct FileVirtualDeviceBean {
typedef struct RAIDVirtualDeviceBean {
typedef struct MirrorVirtualDeviceBean {
/*
* Function prototypes
*/
static int populate_VirtualDeviceBean(
static int populate_DiskVirtualDeviceBean(
static int populate_FileVirtualDeviceBean(
static int populate_RAIDVirtualDeviceBean(
static int populate_MirrorVirtualDeviceBean(
static jobject create_DiskVirtualDeviceBean(
static jobject create_FileVirtualDeviceBean(
static jobject create_RAIDVirtualDeviceBean(
/*
* Static functions
*/
/* Create a VirtualDeviceBean */
static void
{
ZFSJNI_PACKAGE_DATA "VirtualDeviceBean");
}
}
/* Create a DiskVirtualDeviceBean */
static void
{
}
}
/* Create a FileVirtualDeviceBean */
static void
{
}
}
/* Create a RAIDVirtualDeviceBean */
static void
{
}
}
/* Create a MirrorVirtualDeviceBean */
static void
{
}
}
static int
{
int result;
/* Set pool name */
(*env)->CallVoidMethod(
/* Get index */
if (result != 0) {
"could not retrieve virtual device ID (pool %s)",
} else {
(*env)->CallVoidMethod(
/* Set used space */
(*env)->CallVoidMethod(
/* Set available space */
(*env)->CallVoidMethod(
}
return (result != 0);
}
static int
{
char *path;
int result = populate_VirtualDeviceBean(
if (result) {
/* Must not call any more Java methods to preserve exception */
return (-1);
}
/* Set path */
if (result != 0) {
"could not retrive path from disk virtual device (pool %s)",
} else {
}
return (result != 0);
}
static int
{
char *path;
int result = populate_VirtualDeviceBean(
if (result) {
/* Must not call any more Java methods to preserve exception */
return (-1);
}
/* Set path */
if (result != 0) {
"could not retrive path from disk virtual device (pool %s)",
} else {
}
return (result != 0);
}
static int
{
(VirtualDeviceBean_t *)bean));
}
static int
{
(VirtualDeviceBean_t *)bean));
}
static jobject
{
int result;
DiskVirtualDeviceBean_t bean_obj = {0};
/* Construct DiskVirtualDeviceBean */
if (result) {
/* Must not call any more Java methods to preserve exception */
return (NULL);
}
}
static jobject
{
int result;
FileVirtualDeviceBean_t bean_obj = {0};
/* Construct FileVirtualDeviceBean */
if (result) {
/* Must not call any more Java methods to preserve exception */
return (NULL);
}
}
static jobject
{
int result;
RAIDVirtualDeviceBean_t bean_obj = {0};
/* Construct RAIDVirtualDeviceBean */
if (result) {
/* Must not call any more Java methods to preserve exception */
return (NULL);
}
}
static jobject
{
int result;
/* Construct MirrorVirtualDeviceBean */
if (result) {
/* Must not call any more Java methods to preserve exception */
return (NULL);
}
}
/*
* Package-private functions
*/
/*
* Gets the root vdev (an nvlist_t *) for the given pool.
*/
nvlist_t *
{
int result = nvlist_lookup_nvlist(
if (result != 0) {
}
/* nvlist_print(stderr, vdev_parent); */
}
}
return (root);
}
/*
* Gets the vdev (an nvlist_t *) with the given vdev_id, below the
* given vdev. If the given vdev is NULL, all vdevs within the given
* pool are searched.
*/
nvlist_t *
{
int result;
/* Was a vdev specified? */
if (vdev_parent == NULL) {
/* No -- retrieve the top-level pool vdev */
} else {
/* Get index of this vdev and compare with vdev_id_to_find */
return (vdev_parent);
}
}
if (vdev_parent != NULL) {
/* Get the vdevs under this vdev */
if (result == 0) {
int i;
/* For each vdev child... */
for (i = 0; i < nelem; i++) {
return (child);
}
}
}
}
return (NULL);
}
{
if (result == 0) {
vdev);
}
}
return (obj);
}
{
/* Create an array list for the vdevs */
zjni_ArrayList_t list_class = {0};
/* Was a vdev specified? */
if (vdev_parent == NULL) {
/* No -- retrieve the top-level pool vdev */
}
/* nvlist_print(stderr, vdev_parent); */
if (vdev_parent != NULL) {
/* Get the vdevs under this vdev */
int result = nvlist_lookup_nvlist_array(
if (result == 0) {
/* For each vdev child... */
int i;
for (i = 0; i < nelem; i++) {
/* Create a Java object from this vdev */
/*
* Must not call any more Java methods
* to preserve exception
*/
return (NULL);
}
/* Add child to child vdev list */
((zjni_Collection_t *)list_class_p)->
method_add, obj);
}
}
}
return (zjni_Collection_to_array(
ZFSJNI_PACKAGE_DATA "VirtualDevice"));
}