/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2015 by Delphix. All rights reserved.
*/
#include "libzfs_jni_util.h"
#include "libzfs_jni_dataset.h"
#include "libzfs_jni_property.h"
#include "libzfs_jni_pool.h"
#include <strings.h>
/*
* Types
*/
typedef struct DatasetBean {
typedef struct FileSystemBean {
typedef struct PoolBean {
} PoolBean_t;
typedef struct VolumeBean {
} VolumeBean_t;
typedef struct SnapshotBean {
typedef struct FileSystemSnapshotBean {
typedef struct VolumeSnapshotBean {
/*
* Function prototypes
*/
static int populate_PoolBean(
static int populate_FileSystemBean(
static int populate_VolumeBean(
static int populate_FileSystemSnapshotBean(
static int populate_VolumeSnapshotBean(
static int is_fs_snapshot(zfs_handle_t *);
static int is_pool_name(const char *);
/*
* Static functions
*/
/* Create a DatasetBean */
static void
{
}
}
/* Create a PoolBean */
static void
{
}
}
/* Create a FileSystemBean */
static void
{
ZFSJNI_PACKAGE_DATA "FileSystemBean");
}
}
/* Create a VolumeBean */
static void
{
ZFSJNI_PACKAGE_DATA "VolumeBean");
}
}
/* Create a SnapshotBean */
static void
{
ZFSJNI_PACKAGE_DATA "SnapshotBean");
}
}
/* Create a FileSystemSnapshotBean */
static void
{
ZFSJNI_PACKAGE_DATA "FileSystemSnapshotBean");
}
}
/* Create a VolumeSnapshotBean */
static void
{
ZFSJNI_PACKAGE_DATA "VolumeSnapshotBean");
}
}
static int
{
/*
* zhp->zfs_name has the format
* <pool>[[/<container...>]/<dataset>[@<snapshot>]]
*/
return (-1);
}
/* Set names */
}
(*env)->CallVoidMethod(
(*env)->CallVoidMethod(
(*env)->CallVoidMethod(
}
return (0);
}
static int
{
if (result != 0) {
/* Must not call any more Java methods to preserve exception */
return (-1);
}
if (properties == NULL) {
/* Must not call any more Java methods to preserve exception */
return (-1);
}
(*env)->CallVoidMethod(
return (0);
}
static int
{
int result = 0;
result = -1;
} else {
char *msgid;
/* Override value set in populate_DeviceStatsBean */
/*
* If a root file system does not exist for this pool, the pool
* is likely faulted, so just set its name in the Java object.
* Otherwise, populate all fields of the Java object.
*/
(char *)zpool_get_name(zphp),
(DatasetBean_t *)bean);
} else {
}
}
return (result != 0);
}
static int
{
}
static int
{
}
static int
{
}
static int
{
}
static int
{
}
static jobject
{
int result;
/* Construct PoolBean */
if (result) {
/* Must not call any more Java methods to preserve exception */
return (NULL);
}
}
static jobject
{
int result;
/* Construct FileSystemBean */
if (result) {
/* Must not call any more Java methods to preserve exception */
return (NULL);
}
}
static jobject
{
int result;
/* Construct VolumeBean */
if (result) {
/* Must not call any more Java methods to preserve exception */
return (NULL);
}
}
static jobject
{
int result;
/* Construct FileSystemSnapshotBean */
if (result) {
/* Must not call any more Java methods to preserve exception */
return (NULL);
}
}
static jobject
{
int result;
/* Construct VolumeSnapshotBean */
if (result) {
/* Must not call any more Java methods to preserve exception */
return (NULL);
}
}
static jobject
{
switch (zfs_get_type(zhp)) {
case ZFS_TYPE_FILESYSTEM:
break;
case ZFS_TYPE_VOLUME:
break;
case ZFS_TYPE_SNAPSHOT:
break;
}
return (object);
}
/*
* Determines whether the given snapshot is a snapshot of a file
* system or of a volume.
*
* Returns:
*
* 0 if it is a volume snapshot
* 1 if it is a file system snapshot
* -1 on error
*/
static int
{
int isfs;
return (-1);
}
if (parent_zhp == NULL) {
return (-1);
}
return (isfs);
}
static int
{
}
/*
* Package-private functions
*/
/*
* Callback function for zpool_iter(). Creates a Pool and adds it to
* the given zjni_ArrayList.
*/
int
{
/* Get root fs for this pool -- may be NULL if pool is faulted */
/* Must not call any more Java methods to preserve exception */
return (-1);
}
/* Add pool to zjni_ArrayList */
return (0);
}
/*
* Callback function for zfs_iter_children(). Creates the appropriate
* Dataset and adds it to the given zjni_ArrayList. Per the contract
* with zfs_iter_children(), calls zfs_close() on the given
* zfs_handle_t.
*/
int
{
/* Only add allowed types */
/*
* Must not call any more Java methods to preserve
* exception
*/
return (-1);
}
/* Add Dataset to zjni_ArrayList */
} else {
}
return (0);
}
{
const char *name =
/* Create an array list to hold the children */
/* Retrieve parent dataset */
&data);
error = 0;
}
} else
/* Parent is not a dataset -- see if it's a faulted pool */
if ((parent_typemask & ZFS_TYPE_FILESYSTEM) &&
is_pool_name(name)) {
/* A faulted pool has no datasets */
error = 0;
}
}
if (!error) {
}
}
return (array);
}
{
jint i;
/* Create a list to hold the children */
for (i = 0; i < npaths; i++) {
const char *path =
/* Add all dependents of this Dataset to list */
/* Add this Dataset to list (and close zhp) */
} else if (is_pool_name(path)) {
/*
* Path is not a dataset -
* see if it's a faulted pool
*/
path);
/*
* Add this Pool to list (and
* close zphp)
*/
(void) zjni_create_add_Pool(zphp,
}
}
}
}
ZFSJNI_PACKAGE_DATA "Dataset");
}
return (array);
}
/*
* Gets a Dataset of the given name and type, or NULL if no such
* Dataset exists.
*/
{
}
/* Creates a Dataset object of the appropriate class */
}
}
return (device);
}