libzfs_jni_dataset.c revision fbfd10ff571cfd0139aa5127460f1b8a53dac971
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "libzfs_jni_util.h"
#include "libzfs_jni_dataset.h"
#include "libzfs_jni_property.h"
#include "libzfs_jni_pool.h"
#include <strings.h>
#define REGEX_ZFS_NAME "^((([^/]*)(/.+)?)[/@])?([^/]+)/*"
#define REGEX_ZFS_NAME_NGROUPS 6
#define REGEX_ZFS_NAME_POOL_GROUP 3
#define REGEX_ZFS_NAME_PARENT_GROUP 2
#define REGEX_ZFS_NAME_BASE_GROUP 5
/*
* 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_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(zfs_handle_t *);
/*
* 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(
}
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 {
result = -1;
} else {
char *msgid;
/* Override value set in populate_DeviceStatsBean */
}
if (result == 0) {
}
}
return (result != 0);
}
static int
{
}
static int
{
}
static int
{
}
static int
{
}
static int
{
}
static jobject
{
int result;
PoolBean_t bean_obj = {0};
/* Construct PoolBean */
if (result) {
/* Must not call any more Java methods to preserve exception */
return (NULL);
}
}
static jobject
{
int result;
FileSystemBean_t bean_obj = {0};
/* Construct FileSystemBean */
if (result) {
/* Must not call any more Java methods to preserve exception */
return (NULL);
}
}
static jobject
{
int result;
VolumeBean_t bean_obj = {0};
/* Construct VolumeBean */
if (result) {
/* Must not call any more Java methods to preserve exception */
return (NULL);
}
}
static jobject
{
int result;
FileSystemSnapshotBean_t bean_obj = {0};
/* Construct FileSystemSnapshotBean */
if (result) {
/* Must not call any more Java methods to preserve exception */
return (NULL);
}
}
static jobject
{
int result;
VolumeSnapshotBean_t bean_obj = {0};
/* 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
{
char parent[ZFS_MAXNAMELEN];
int isfs;
return (-1);
}
if (parent_zhp == NULL) {
return (-1);
}
return (isfs);
}
static int
{
}
static zfs_handle_t *
{
const char *name =
}
return (zhp);
}
/*
* Package-private functions
*/
/*
* 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 pool to zjni_ArrayList */
}
return (0);
}
{
/* Create an array list to hold the children */
zjni_DatasetSet_t list_obj = {0};
/* Retrieve parent */
}
}
return (array);
}
{
jint i;
/* Create a list to hold the children */
zjni_DatasetSet_t list_obj = {0};
for (i = 0; i < npaths; i++) {
/* Add all dependents of this Dataset to the list */
(void) zfs_iter_dependents(zhp,
/* Add this Dataset to the list (and close zhp) */
}
}
ZFSJNI_PACKAGE_DATA "Dataset");
}
return (array);
}
/*
* Gets a Dataset of the given name and type, or NULL if no such
* Dataset exists.
*/
{
/* Creates an object of the appropriate class */
}
return (device);
}