usr/src/lib/libzfs_jni/common/libzfs_jni_property.c
author ahrens
Mon, 31 Oct 2005 11:33:35 -0800
changeset 789 b348f31ed315
child 1066 7ebdc59e2074
permissions -rw-r--r--
PSARC 2002/240 ZFS 6338653 Integrate ZFS PSARC 2004/652 - DKIOCFLUSH 5096886 Write caching disks need mechanism to flush cache to physical media
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     1
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     2
 * CDDL HEADER START
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     3
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     5
 * Common Development and Distribution License, Version 1.0 only
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     6
 * (the "License").  You may not use this file except in compliance
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     7
 * with the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     8
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     9
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    10
 * or http://www.opensolaris.org/os/licensing.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    11
 * See the License for the specific language governing permissions
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    12
 * and limitations under the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    13
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    14
 * When distributing Covered Code, include this CDDL HEADER in each
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    15
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    16
 * If applicable, add the following below this CDDL HEADER, with the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    17
 * fields enclosed by brackets "[]" replaced with your own identifying
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    18
 * information: Portions Copyright [yyyy] [name of copyright owner]
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    19
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    20
 * CDDL HEADER END
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    21
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    22
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    23
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    24
 * Use is subject to license terms.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    25
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    26
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    27
#pragma ident	"%Z%%M%	%I%	%E% SMI"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    28
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    29
#include "libzfs_jni_property.h"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    30
#include "libzfs_jni_util.h"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    31
#include <strings.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    32
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    33
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    34
 * Function prototypes
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    35
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    36
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    37
static jobject create_BooleanProperty(JNIEnv *, zfs_handle_t *, zfs_prop_t);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    38
static jobject create_ChecksumProperty(JNIEnv *, zfs_handle_t *);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    39
static jobject create_CompressionProperty(JNIEnv *, zfs_handle_t *);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    40
static jobject create_DateProperty(JNIEnv *, zfs_handle_t *, zfs_prop_t);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    41
static jobject create_LongProperty(JNIEnv *, zfs_handle_t *, zfs_prop_t);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    42
static jobject create_RecordSizeProperty(JNIEnv *, zfs_handle_t *);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    43
static jobject create_StringProperty(JNIEnv *, zfs_handle_t *, zfs_prop_t);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    44
static jobject str_to_checksum(JNIEnv *, char *);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    45
static jobject str_to_compression(JNIEnv *, char *);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    46
static jobject create_default_BooleanProperty(JNIEnv *, zfs_prop_t);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    47
static jobject create_default_LongProperty(JNIEnv *, zfs_prop_t);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    48
static jobject create_default_StringProperty(JNIEnv *, zfs_prop_t);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    49
static jobject create_default_MountPointProperty(JNIEnv *);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    50
static jobject create_default_ShareNFSProperty(JNIEnv *);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    51
static jobject create_default_ChecksumProperty(JNIEnv *);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    52
static jobject create_default_CompressionProperty(JNIEnv *);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    53
static jobject create_default_RecordSizeProperty(JNIEnv *);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    54
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    55
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    56
 * Static data
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    57
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    58
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    59
zfs_prop_t props_boolean[] = {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    60
	ZFS_PROP_ATIME,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    61
	ZFS_PROP_DEVICES,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    62
	ZFS_PROP_EXEC,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    63
	ZFS_PROP_MOUNTED,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    64
	ZFS_PROP_READONLY,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    65
	ZFS_PROP_SETUID,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    66
	ZFS_PROP_ZONED,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    67
	ZFS_PROP_INVAL
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    68
};
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    69
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    70
zfs_prop_t props_long[] = {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    71
	ZFS_PROP_AVAILABLE,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    72
	ZFS_PROP_QUOTA,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    73
	/*	ZFS_PROP_RATIO, */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    74
	ZFS_PROP_REFERENCED,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    75
	ZFS_PROP_RESERVATION,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    76
	ZFS_PROP_USED,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    77
	ZFS_PROP_VOLSIZE,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    78
	ZFS_PROP_INVAL
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    79
};
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    80
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    81
zfs_prop_t props_string[] = {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    82
	ZFS_PROP_ORIGIN,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    83
	/*	ZFS_PROP_TYPE, */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    84
	ZFS_PROP_INVAL
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    85
};
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    86
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    87
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    88
 * Static functions
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    89
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    90
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    91
static jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    92
create_BooleanProperty(JNIEnv *env, zfs_handle_t *zhp, zfs_prop_t prop)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    93
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    94
	jobject propertyObject = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    95
	char source[ZFS_MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    96
	uint64_t value;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    97
	zfs_source_t srctype;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    98
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    99
	int result = zfs_prop_get_numeric(zhp, prop, &value,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   100
	    &srctype, source, sizeof (source));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   101
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   102
	if (result == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   103
		jclass class_BooleanProperty = (*env)->FindClass(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   104
		    ZFSJNI_PACKAGE_DATA "BooleanProperty");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   105
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   106
		jstring propName = (*env)->NewStringUTF(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   107
		    env, zfs_prop_to_name(prop));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   108
		jobject propValue = zjni_int_to_boolean(env, value);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   109
		jboolean readOnly = zfs_prop_readonly(prop) ?
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   110
		    JNI_TRUE : JNI_FALSE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   111
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   112
		jmethodID constructor_BooleanProperty;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   113
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   114
		if (srctype == ZFS_SRC_INHERITED) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   115
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   116
			jstring propSource = (*env)->NewStringUTF(env, source);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   117
			constructor_BooleanProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   118
			    env, class_BooleanProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   119
			    "(Ljava/lang/String;Ljava/lang/Boolean;ZL"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   120
			    "java/lang/String;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   121
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   122
			propertyObject = (*env)->NewObject(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   123
			    env, class_BooleanProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   124
			    constructor_BooleanProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   125
			    propName, propValue, readOnly, propSource);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   126
		} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   127
			jobject lineage = zjni_get_lineage(env, srctype);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   128
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   129
			constructor_BooleanProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   130
			    env, class_BooleanProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   131
			    "(Ljava/lang/String;Ljava/lang/Boolean;ZL"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   132
			    ZFSJNI_PACKAGE_DATA "Property$Lineage;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   133
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   134
			propertyObject = (*env)->NewObject(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   135
			    env, class_BooleanProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   136
			    constructor_BooleanProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   137
			    propName, propValue, readOnly, lineage);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   138
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   139
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   140
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   141
	return (propertyObject);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   142
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   143
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   144
static jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   145
create_ChecksumProperty(JNIEnv *env, zfs_handle_t *zhp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   146
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   147
	jobject propertyObject = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   148
	char propbuf[ZFS_MAXPROPLEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   149
	char source[ZFS_MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   150
	zfs_source_t srctype;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   151
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   152
	int result = zfs_prop_get(zhp, ZFS_PROP_CHECKSUM,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   153
	    propbuf, sizeof (propbuf), &srctype, source, sizeof (source), 1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   154
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   155
	if (result == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   156
		jobject propValue = str_to_checksum(env, propbuf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   157
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   158
		if (propValue != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   159
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   160
			jclass class_ChecksumProperty = (*env)->FindClass(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   161
			    ZFSJNI_PACKAGE_DATA "ChecksumProperty");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   162
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   163
			jmethodID constructor_ChecksumProperty;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   164
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   165
			if (srctype == ZFS_SRC_INHERITED) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   166
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   167
				jstring propSource = (*env)->NewStringUTF(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   168
				    source);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   169
				constructor_ChecksumProperty =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   170
				    (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   171
					env, class_ChecksumProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   172
					"(L" ZFSJNI_PACKAGE_DATA
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   173
					"ChecksumProperty$Checksum;Ljava/lang/"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   174
					"String;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   175
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   176
				propertyObject = (*env)->NewObject(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   177
				    class_ChecksumProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   178
				    constructor_ChecksumProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   179
				    propValue, propSource);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   180
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   181
			} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   182
				jobject lineage =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   183
				    zjni_get_lineage(env, srctype);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   184
				constructor_ChecksumProperty =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   185
				    (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   186
					env, class_ChecksumProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   187
					"(L" ZFSJNI_PACKAGE_DATA
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   188
					"ChecksumProperty$Checksum;L"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   189
					ZFSJNI_PACKAGE_DATA
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   190
					"Property$Lineage;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   191
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   192
				propertyObject = (*env)->NewObject(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   193
				    class_ChecksumProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   194
				    constructor_ChecksumProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   195
				    propValue, lineage);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   196
			}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   197
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   198
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   199
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   200
	return (propertyObject);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   201
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   202
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   203
static jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   204
create_CompressionProperty(JNIEnv *env, zfs_handle_t *zhp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   205
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   206
	jobject propertyObject = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   207
	char propbuf[ZFS_MAXPROPLEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   208
	char source[ZFS_MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   209
	zfs_source_t srctype;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   210
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   211
	int result = zfs_prop_get(zhp, ZFS_PROP_COMPRESSION,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   212
	    propbuf, sizeof (propbuf), &srctype, source, sizeof (source), 1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   213
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   214
	if (result == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   215
		jobject propValue = str_to_compression(env, propbuf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   216
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   217
		if (propValue != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   218
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   219
			jclass class_CompressionProperty =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   220
			    (*env)->FindClass(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   221
				ZFSJNI_PACKAGE_DATA "CompressionProperty");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   222
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   223
			jmethodID constructor_CompressionProperty;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   224
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   225
			if (srctype == ZFS_SRC_INHERITED) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   226
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   227
				jstring propSource = (*env)->NewStringUTF(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   228
				    source);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   229
				constructor_CompressionProperty =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   230
				    (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   231
					env, class_CompressionProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   232
					"<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   233
					"(L" ZFSJNI_PACKAGE_DATA
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   234
					"CompressionProperty$Compression;Ljava/"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   235
					"lang/String;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   236
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   237
				propertyObject = (*env)->NewObject(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   238
				    class_CompressionProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   239
				    constructor_CompressionProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   240
				    propValue, propSource);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   241
			} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   242
				jobject lineage = zjni_get_lineage(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   243
				    srctype);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   244
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   245
				constructor_CompressionProperty =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   246
				    (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   247
					env, class_CompressionProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   248
					"<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   249
					"(L" ZFSJNI_PACKAGE_DATA
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   250
					"CompressionProperty$Compression;L"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   251
					ZFSJNI_PACKAGE_DATA
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   252
					"Property$Lineage;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   253
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   254
				propertyObject = (*env)->NewObject(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   255
				    class_CompressionProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   256
				    constructor_CompressionProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   257
				    propValue, lineage);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   258
			}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   259
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   260
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   261
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   262
	return (propertyObject);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   263
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   264
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   265
static jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   266
create_DateProperty(JNIEnv *env, zfs_handle_t *zhp, zfs_prop_t prop)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   267
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   268
	jobject propertyObject = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   269
	char propbuf[ZFS_MAXPROPLEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   270
	char source[ZFS_MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   271
	zfs_source_t srctype;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   272
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   273
	int result = zfs_prop_get(zhp, prop, propbuf, sizeof (propbuf),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   274
	    &srctype, source, sizeof (source), 1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   275
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   276
	if (result == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   277
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   278
		jobject propValue = zjni_str_to_date(env, propbuf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   279
		if (propValue != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   280
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   281
			jclass class_DateProperty = (*env)->FindClass(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   282
			    ZFSJNI_PACKAGE_DATA "DateProperty");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   283
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   284
			jstring propName = (*env)->NewStringUTF(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   285
			    env, zfs_prop_to_name(prop));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   286
			jboolean readOnly =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   287
			    zfs_prop_readonly(prop) ? JNI_TRUE : JNI_FALSE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   288
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   289
			jmethodID constructor_DateProperty;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   290
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   291
			if (srctype == ZFS_SRC_INHERITED) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   292
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   293
				jstring propSource = (*env)->NewStringUTF(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   294
				    source);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   295
				constructor_DateProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   296
				    env, class_DateProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   297
				    "(Ljava/lang/String;Ljava/util/Date;ZL"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   298
				    "java/lang/String;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   299
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   300
				propertyObject = (*env)->NewObject(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   301
				    env, class_DateProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   302
				    constructor_DateProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   303
				    propName, propValue, readOnly, propSource);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   304
			} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   305
				jobject lineage = zjni_get_lineage(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   306
				    srctype);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   307
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   308
				constructor_DateProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   309
				    env, class_DateProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   310
				    "(Ljava/lang/String;Ljava/util/Date;ZL"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   311
				    ZFSJNI_PACKAGE_DATA "Property$Lineage;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   312
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   313
				propertyObject = (*env)->NewObject(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   314
				    env, class_DateProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   315
				    constructor_DateProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   316
				    propName, propValue, readOnly, lineage);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   317
			}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   318
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   319
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   320
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   321
	return (propertyObject);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   322
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   323
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   324
static jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   325
create_LongProperty(JNIEnv *env, zfs_handle_t *zhp, zfs_prop_t prop)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   326
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   327
	jobject propertyObject = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   328
	char propbuf[ZFS_MAXPROPLEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   329
	char source[ZFS_MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   330
	zfs_source_t srctype;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   331
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   332
	int result = zfs_prop_get(zhp, prop, propbuf, sizeof (propbuf),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   333
	    &srctype, source, sizeof (source), 1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   334
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   335
	if (result == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   336
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   337
		jobject propValue = zjni_str_to_long(env, propbuf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   338
		if (propValue != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   339
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   340
			jclass class_LongProperty = (*env)->FindClass(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   341
			    ZFSJNI_PACKAGE_DATA "LongProperty");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   342
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   343
			jstring propName = (*env)->NewStringUTF(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   344
			    env, zfs_prop_to_name(prop));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   345
			jboolean readOnly =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   346
			    zfs_prop_readonly(prop) ? JNI_TRUE : JNI_FALSE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   347
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   348
			jmethodID constructor_LongProperty;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   349
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   350
			if (srctype == ZFS_SRC_INHERITED) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   351
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   352
				jstring propSource =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   353
				    (*env)->NewStringUTF(env, source);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   354
				constructor_LongProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   355
				    env, class_LongProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   356
				    "(Ljava/lang/String;Ljava/lang/Long;ZL"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   357
				    "java/lang/String;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   358
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   359
				propertyObject = (*env)->NewObject(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   360
				    env, class_LongProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   361
				    constructor_LongProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   362
				    propName, propValue, readOnly, propSource);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   363
			} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   364
				jobject lineage = zjni_get_lineage(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   365
				    srctype);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   366
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   367
				constructor_LongProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   368
				    env, class_LongProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   369
				    "(Ljava/lang/String;Ljava/lang/Long;ZL"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   370
				    ZFSJNI_PACKAGE_DATA "Property$Lineage;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   371
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   372
				propertyObject = (*env)->NewObject(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   373
				    env, class_LongProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   374
				    constructor_LongProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   375
				    propName, propValue, readOnly, lineage);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   376
			}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   377
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   378
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   379
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   380
	return (propertyObject);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   381
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   382
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   383
static jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   384
create_RecordSizeProperty(JNIEnv *env, zfs_handle_t *zhp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   385
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   386
	jobject propertyObject = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   387
	char propbuf[ZFS_MAXPROPLEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   388
	char source[ZFS_MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   389
	zfs_source_t srctype;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   390
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   391
	int result = zfs_prop_get(zhp, ZFS_PROP_RECORDSIZE,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   392
	    propbuf, sizeof (propbuf), &srctype, source, sizeof (source), 1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   393
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   394
	if (result == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   395
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   396
		jobject propValue = zjni_str_to_long(env, propbuf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   397
		if (propValue != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   398
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   399
			jclass class_RecordSizeProperty = (*env)->FindClass(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   400
			    ZFSJNI_PACKAGE_DATA "RecordSizeProperty");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   401
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   402
			jmethodID constructor_RecordSizeProperty;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   403
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   404
			if (srctype == ZFS_SRC_INHERITED) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   405
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   406
				jstring propSource =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   407
				    (*env)->NewStringUTF(env, source);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   408
				constructor_RecordSizeProperty =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   409
				    (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   410
					env, class_RecordSizeProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   411
					"(Ljava/lang/Long;Ljava/lang/"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   412
					"String;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   413
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   414
				propertyObject = (*env)->NewObject(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   415
				    class_RecordSizeProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   416
				    constructor_RecordSizeProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   417
				    propValue, propSource);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   418
			} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   419
				jobject lineage =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   420
				    zjni_get_lineage(env, srctype);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   421
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   422
				constructor_RecordSizeProperty =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   423
				    (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   424
					env, class_RecordSizeProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   425
					"(Ljava/lang/Long;L"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   426
					ZFSJNI_PACKAGE_DATA
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   427
					"Property$Lineage;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   428
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   429
				propertyObject = (*env)->NewObject(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   430
				    class_RecordSizeProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   431
				    constructor_RecordSizeProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   432
				    propValue, lineage);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   433
			}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   434
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   435
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   436
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   437
	return (propertyObject);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   438
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   439
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   440
static jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   441
create_StringProperty(JNIEnv *env, zfs_handle_t *zhp, zfs_prop_t prop)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   442
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   443
	jobject propertyObject = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   444
	char propbuf[ZFS_MAXPROPLEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   445
	char source[ZFS_MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   446
	zfs_source_t srctype;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   447
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   448
	int result = zfs_prop_get(zhp, prop, propbuf, sizeof (propbuf),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   449
	    &srctype, source, sizeof (source), 1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   450
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   451
	if (result == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   452
		jmethodID constructor_StringProperty;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   453
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   454
		jclass class_StringProperty =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   455
		    (*env)->FindClass(env, ZFSJNI_PACKAGE_DATA
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   456
			"StringProperty");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   457
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   458
		jstring propName =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   459
		    (*env)->NewStringUTF(env, zfs_prop_to_name(prop));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   460
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   461
		jobject propValue = (*env)->NewStringUTF(env, propbuf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   462
		jboolean readOnly = zfs_prop_readonly(prop) ?
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   463
		    JNI_TRUE : JNI_FALSE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   464
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   465
		if (srctype == ZFS_SRC_INHERITED) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   466
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   467
			jstring propSource = (*env)->NewStringUTF(env, source);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   468
			constructor_StringProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   469
			    env, class_StringProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   470
			    "(Ljava/lang/String;Ljava/lang/String;ZL"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   471
			    "java/lang/String;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   472
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   473
			propertyObject = (*env)->NewObject(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   474
			    env, class_StringProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   475
			    constructor_StringProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   476
			    propName, propValue, readOnly, propSource);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   477
		} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   478
			jobject lineage = zjni_get_lineage(env, srctype);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   479
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   480
			constructor_StringProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   481
			    env, class_StringProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   482
			    "(Ljava/lang/String;Ljava/lang/String;ZL"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   483
			    ZFSJNI_PACKAGE_DATA "Property$Lineage;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   484
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   485
			propertyObject = (*env)->NewObject(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   486
			    env, class_StringProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   487
			    constructor_StringProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   488
			    propName, propValue, readOnly, lineage);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   489
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   490
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   491
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   492
	return (propertyObject);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   493
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   494
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   495
static jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   496
create_MountPointProperty(JNIEnv *env, zfs_handle_t *zhp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   497
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   498
	jobject propertyObject = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   499
	char propbuf[ZFS_MAXPROPLEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   500
	char source[ZFS_MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   501
	zfs_source_t srctype;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   502
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   503
	int result = zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   504
	    propbuf, sizeof (propbuf), &srctype, source, sizeof (source), 1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   505
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   506
	if (result == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   507
		jmethodID constructor_MountPointProperty;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   508
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   509
		jclass class_MountPointProperty = (*env)->FindClass(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   510
		    env, ZFSJNI_PACKAGE_DATA "MountPointProperty");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   511
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   512
		jobject propValue = (*env)->NewStringUTF(env, propbuf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   513
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   514
		if (srctype == ZFS_SRC_INHERITED) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   515
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   516
			jstring propSource = (*env)->NewStringUTF(env, source);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   517
			constructor_MountPointProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   518
			    env, class_MountPointProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   519
			    "(Ljava/lang/String;Ljava/lang/String;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   520
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   521
			propertyObject = (*env)->NewObject(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   522
			    class_MountPointProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   523
			    constructor_MountPointProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   524
			    propValue, propSource);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   525
		} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   526
			jobject lineage = zjni_get_lineage(env, srctype);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   527
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   528
			constructor_MountPointProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   529
			    env, class_MountPointProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   530
			    "(Ljava/lang/String;L"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   531
			    ZFSJNI_PACKAGE_DATA "Property$Lineage;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   532
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   533
			propertyObject = (*env)->NewObject(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   534
			    class_MountPointProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   535
			    constructor_MountPointProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   536
			    propValue, lineage);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   537
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   538
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   539
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   540
	return (propertyObject);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   541
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   542
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   543
static jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   544
create_ShareNFSProperty(JNIEnv *env, zfs_handle_t *zhp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   545
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   546
	jobject propertyObject = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   547
	char propbuf[ZFS_MAXPROPLEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   548
	char source[ZFS_MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   549
	zfs_source_t srctype;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   550
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   551
	int result = zfs_prop_get(zhp, ZFS_PROP_SHARENFS,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   552
	    propbuf, sizeof (propbuf), &srctype, source, sizeof (source), 1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   553
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   554
	if (result == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   555
		jmethodID constructor_ShareNFSProperty;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   556
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   557
		jclass class_ShareNFSProperty = (*env)->FindClass(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   558
		    env, ZFSJNI_PACKAGE_DATA "ShareNFSProperty");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   559
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   560
		jobject propValue = (*env)->NewStringUTF(env, propbuf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   561
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   562
		if (srctype == ZFS_SRC_INHERITED) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   563
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   564
			jstring propSource = (*env)->NewStringUTF(env, source);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   565
			constructor_ShareNFSProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   566
			    env, class_ShareNFSProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   567
			    "(Ljava/lang/String;Ljava/lang/String;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   568
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   569
			propertyObject = (*env)->NewObject(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   570
			    env, class_ShareNFSProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   571
			    constructor_ShareNFSProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   572
			    propValue, propSource);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   573
		} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   574
			jobject lineage = zjni_get_lineage(env, srctype);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   575
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   576
			constructor_ShareNFSProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   577
			    env, class_ShareNFSProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   578
			    "(Ljava/lang/String;L"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   579
			    ZFSJNI_PACKAGE_DATA "Property$Lineage;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   580
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   581
			propertyObject = (*env)->NewObject(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   582
			    env, class_ShareNFSProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   583
			    constructor_ShareNFSProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   584
			    propValue, lineage);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   585
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   586
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   587
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   588
	return (propertyObject);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   589
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   590
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   591
static jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   592
str_to_checksum(JNIEnv *env, char *str)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   593
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   594
	jclass class_Checksum = (*env)->FindClass(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   595
	    env, ZFSJNI_PACKAGE_DATA "ChecksumProperty$Checksum");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   596
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   597
	jmethodID method_valueOf = (*env)->GetStaticMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   598
	    env, class_Checksum, "valueOf",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   599
	    "(Ljava/lang/String;)L"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   600
	    ZFSJNI_PACKAGE_DATA "ChecksumProperty$Checksum;");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   601
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   602
	jstring utf = (*env)->NewStringUTF(env, str);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   603
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   604
	return (*env)->CallStaticObjectMethod(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   605
	    env, class_Checksum, method_valueOf, utf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   606
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   607
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   608
static jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   609
str_to_compression(JNIEnv *env, char *str)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   610
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   611
	jclass class_Compression = (*env)->FindClass(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   612
	    env, ZFSJNI_PACKAGE_DATA "CompressionProperty$Compression");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   613
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   614
	jmethodID method_valueOf = (*env)->GetStaticMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   615
	    env, class_Compression, "valueOf",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   616
	    "(Ljava/lang/String;)L"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   617
	    ZFSJNI_PACKAGE_DATA "CompressionProperty$Compression;");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   618
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   619
	jstring utf = (*env)->NewStringUTF(env, str);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   620
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   621
	return (*env)->CallStaticObjectMethod(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   622
	    env, class_Compression, method_valueOf, utf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   623
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   624
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   625
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   626
 * Package-private functions
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   627
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   628
jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   629
zjni_get_default_property(JNIEnv *env, zfs_prop_t prop)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   630
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   631
	int i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   632
	for (i = 0; props_boolean[i] != ZFS_PROP_INVAL; i++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   633
		if (prop == props_boolean[i]) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   634
			return (create_default_BooleanProperty(env, prop));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   635
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   636
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   637
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   638
	for (i = 0; props_long[i] != ZFS_PROP_INVAL; i++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   639
		if (prop == props_long[i]) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   640
			return (create_default_LongProperty(env, prop));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   641
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   642
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   643
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   644
	for (i = 0; props_string[i] != ZFS_PROP_INVAL; i++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   645
		if (prop == props_string[i]) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   646
			return (create_default_StringProperty(env, prop));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   647
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   648
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   649
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   650
	if (prop == ZFS_PROP_MOUNTPOINT) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   651
		return (create_default_MountPointProperty(env));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   652
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   653
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   654
	if (prop == ZFS_PROP_SHARENFS) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   655
		return (create_default_ShareNFSProperty(env));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   656
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   657
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   658
	if (prop == ZFS_PROP_CHECKSUM) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   659
		return (create_default_ChecksumProperty(env));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   660
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   661
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   662
	if (prop == ZFS_PROP_COMPRESSION) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   663
		return (create_default_CompressionProperty(env));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   664
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   665
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   666
	if (prop == ZFS_PROP_RECORDSIZE) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   667
		return (create_default_RecordSizeProperty(env));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   668
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   669
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   670
	return (NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   671
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   672
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   673
zfs_prop_t
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   674
zjni_get_property_from_name(const char *name)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   675
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   676
	zfs_prop_t prop;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   677
	for (prop = 0; prop < ZFS_NPROP_VISIBLE; prop++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   678
		if (strcasecmp(name, zfs_prop_to_name(prop)) == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   679
			return (prop);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   680
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   681
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   682
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   683
	return (ZFS_PROP_INVAL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   684
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   685
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   686
jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   687
zjni_get_lineage(JNIEnv *env, zfs_source_t srctype)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   688
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   689
	char *field;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   690
	jclass class_Lineage;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   691
	jfieldID id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   692
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   693
	switch (srctype) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   694
	case ZFS_SRC_NONE:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   695
		field = "ZFS_PROP_LINEAGE_NOTINHERITABLE";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   696
		break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   697
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   698
	case ZFS_SRC_DEFAULT:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   699
		field = "ZFS_PROP_LINEAGE_DEFAULT";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   700
		break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   701
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   702
	case ZFS_SRC_LOCAL:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   703
		field = "ZFS_PROP_LINEAGE_LOCAL";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   704
		break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   705
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   706
	case ZFS_SRC_TEMPORARY:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   707
		field = "ZFS_PROP_LINEAGE_TEMPORARY";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   708
		break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   709
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   710
	default:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   711
	case ZFS_SRC_INHERITED:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   712
		field = "ZFS_PROP_LINEAGE_INHERITED";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   713
		break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   714
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   715
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   716
	class_Lineage = (*env)->FindClass(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   717
	    env, ZFSJNI_PACKAGE_DATA "Property$Lineage");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   718
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   719
	id = (*env)->GetStaticFieldID(env, class_Lineage,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   720
	    field, "L" ZFSJNI_PACKAGE_DATA "Property$Lineage;");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   721
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   722
	return (*env)->GetStaticObjectField(env, class_Lineage, id);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   723
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   724
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   725
jobjectArray
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   726
zjni_get_Dataset_properties(JNIEnv *env, zfs_handle_t *zhp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   727
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   728
	jobject prop;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   729
	int i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   730
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   731
	/* Create an array list for the properties */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   732
	zjni_ArrayList_t proplist_obj = {0};
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   733
	zjni_ArrayList_t *proplist = &proplist_obj;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   734
	zjni_new_ArrayList(env, proplist);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   735
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   736
	for (i = 0; props_boolean[i] != ZFS_PROP_INVAL; i++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   737
		/* Create property and add to list */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   738
		prop = create_BooleanProperty(env, zhp, props_boolean[i]);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   739
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   740
		/* Does this property apply to this object? */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   741
		if (prop != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   742
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   743
			(*env)->CallBooleanMethod(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   744
			    env, ((zjni_Object_t *)proplist)->object,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   745
			    ((zjni_Collection_t *)proplist)->method_add, prop);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   746
		} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   747
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   748
			if ((*env)->ExceptionOccurred(env) != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   749
				return (NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   750
			}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   751
#ifdef	DEBUG
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   752
			(void) fprintf(stderr, "Property %s is not appropriate "
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   753
			    "for %s\n", zfs_prop_to_name(props_boolean[i]),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   754
			    zfs_get_name(zhp));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   755
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   756
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   757
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   758
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   759
	for (i = 0; props_long[i] != ZFS_PROP_INVAL; i++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   760
		/* Create property and add to list */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   761
		prop = create_LongProperty(env, zhp, props_long[i]);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   762
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   763
		/* Does this property apply to this object? */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   764
		if (prop != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   765
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   766
			(*env)->CallBooleanMethod(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   767
			    env, ((zjni_Object_t *)proplist)->object,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   768
			    ((zjni_Collection_t *)proplist)->method_add, prop);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   769
		} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   770
			if ((*env)->ExceptionOccurred(env) != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   771
				return (NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   772
			}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   773
#ifdef	DEBUG
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   774
			(void) fprintf(stderr, "Property %s is not appropriate "
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   775
			    "for %s\n", zfs_prop_to_name(props_long[i]),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   776
			    zfs_get_name(zhp));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   777
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   778
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   779
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   780
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   781
	for (i = 0; props_string[i] != ZFS_PROP_INVAL; i++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   782
		/* Create property and add to list */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   783
		prop = create_StringProperty(env, zhp, props_string[i]);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   784
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   785
		/* Does this property apply to this object? */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   786
		if (prop != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   787
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   788
			(*env)->CallBooleanMethod(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   789
			    env, ((zjni_Object_t *)proplist)->object,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   790
			    ((zjni_Collection_t *)proplist)->method_add, prop);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   791
		} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   792
			if ((*env)->ExceptionOccurred(env) != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   793
				return (NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   794
			}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   795
#ifdef	DEBUG
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   796
			(void) fprintf(stderr, "Property %s is not appropriate "
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   797
			    "for %s\n", zfs_prop_to_name(props_string[i]),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   798
			    zfs_get_name(zhp));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   799
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   800
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   801
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   802
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   803
	prop = create_MountPointProperty(env, zhp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   804
	/* Does this property apply to this object? */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   805
	if (prop != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   806
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   807
		(*env)->CallBooleanMethod(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   808
		    ((zjni_Object_t *)proplist)->object,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   809
		    ((zjni_Collection_t *)proplist)->method_add, prop);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   810
	} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   811
		if ((*env)->ExceptionOccurred(env) != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   812
			return (NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   813
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   814
#ifdef	DEBUG
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   815
		(void) fprintf(stderr, "Property %s is not appropriate "
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   816
		    "for %s\n", zfs_prop_to_name(ZFS_PROP_MOUNTPOINT),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   817
		    zfs_get_name(zhp));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   818
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   819
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   820
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   821
	prop = create_ShareNFSProperty(env, zhp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   822
	/* Does this property apply to this object? */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   823
	if (prop != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   824
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   825
		(*env)->CallBooleanMethod(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   826
		    ((zjni_Object_t *)proplist)->object,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   827
		    ((zjni_Collection_t *)proplist)->method_add, prop);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   828
	} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   829
		if ((*env)->ExceptionOccurred(env) != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   830
			return (NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   831
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   832
#ifdef	DEBUG
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   833
		(void) fprintf(stderr, "Property %s is not appropriate "
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   834
		    "for %s\n", zfs_prop_to_name(ZFS_PROP_SHARENFS),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   835
		    zfs_get_name(zhp));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   836
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   837
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   838
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   839
	prop = create_ChecksumProperty(env, zhp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   840
	/* Does this property apply to this object? */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   841
	if (prop != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   842
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   843
		(*env)->CallBooleanMethod(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   844
		    ((zjni_Object_t *)proplist)->object,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   845
		    ((zjni_Collection_t *)proplist)->method_add, prop);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   846
	} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   847
		if ((*env)->ExceptionOccurred(env) != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   848
			return (NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   849
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   850
#ifdef	DEBUG
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   851
		(void) fprintf(stderr, "Property %s is not appropriate "
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   852
		    "for %s\n", zfs_prop_to_name(ZFS_PROP_CHECKSUM),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   853
		    zfs_get_name(zhp));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   854
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   855
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   856
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   857
	prop = create_CompressionProperty(env, zhp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   858
	/* Does this property apply to this object? */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   859
	if (prop != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   860
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   861
		(*env)->CallBooleanMethod(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   862
		    ((zjni_Object_t *)proplist)->object,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   863
		    ((zjni_Collection_t *)proplist)->method_add, prop);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   864
	} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   865
		if ((*env)->ExceptionOccurred(env) != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   866
			return (NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   867
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   868
#ifdef	DEBUG
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   869
		(void) fprintf(stderr, "Property %s is not appropriate "
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   870
		    "for %s\n", zfs_prop_to_name(ZFS_PROP_COMPRESSION),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   871
		    zfs_get_name(zhp));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   872
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   873
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   874
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   875
	prop = create_RecordSizeProperty(env, zhp);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   876
	/* Does this property apply to this object? */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   877
	if (prop != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   878
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   879
		(*env)->CallBooleanMethod(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   880
		    ((zjni_Object_t *)proplist)->object,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   881
		    ((zjni_Collection_t *)proplist)->method_add, prop);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   882
	} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   883
		if ((*env)->ExceptionOccurred(env) != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   884
			return (NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   885
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   886
#ifdef	DEBUG
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   887
		(void) fprintf(stderr, "Property %s is not appropriate "
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   888
		    "for %s\n", zfs_prop_to_name(ZFS_PROP_RECORDSIZE),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   889
		    zfs_get_name(zhp));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   890
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   891
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   892
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   893
	prop = create_DateProperty(env, zhp, ZFS_PROP_CREATION);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   894
	/* Does this property apply to this object? */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   895
	if (prop != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   896
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   897
		(*env)->CallBooleanMethod(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   898
		    ((zjni_Object_t *)proplist)->object,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   899
		    ((zjni_Collection_t *)proplist)->method_add, prop);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   900
	} else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   901
		if ((*env)->ExceptionOccurred(env) != NULL) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   902
			return (NULL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   903
		}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   904
#ifdef	DEBUG
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   905
		(void) fprintf(stderr, "Property %s is not appropriate "
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   906
		    "for %s\n", zfs_prop_to_name(ZFS_PROP_CREATION),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   907
		    zfs_get_name(zhp));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   908
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   909
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   910
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   911
	return (zjni_Collection_to_array(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   912
	    env, (zjni_Collection_t *)proplist,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   913
	    ZFSJNI_PACKAGE_DATA "Property"));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   914
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   915
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   916
static jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   917
create_default_BooleanProperty(JNIEnv *env, zfs_prop_t prop)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   918
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   919
	jobject propertyObject = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   920
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   921
	if (!zfs_prop_readonly(prop)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   922
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   923
		jclass class_BooleanProperty = (*env)->FindClass(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   924
		    ZFSJNI_PACKAGE_DATA "BooleanProperty");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   925
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   926
		jmethodID constructor_BooleanProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   927
		    env, class_BooleanProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   928
		    "(Ljava/lang/String;Ljava/lang/Boolean;ZL"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   929
		    ZFSJNI_PACKAGE_DATA "Property$Lineage;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   930
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   931
		jstring propName =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   932
		    (*env)->NewStringUTF(env, zfs_prop_to_name(prop));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   933
		jobject propValue =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   934
		    zjni_int_to_boolean(env, zfs_prop_default_numeric(prop));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   935
		jboolean readOnly = zfs_prop_readonly(prop) ?
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   936
		    JNI_TRUE : JNI_FALSE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   937
		jobject lineage = zjni_get_lineage(env, ZFS_SRC_DEFAULT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   938
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   939
		propertyObject = (*env)->NewObject(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   940
		    env, class_BooleanProperty, constructor_BooleanProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   941
		    propName, propValue, readOnly, lineage);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   942
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   943
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   944
	return (propertyObject);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   945
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   946
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   947
static jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   948
create_default_LongProperty(JNIEnv *env, zfs_prop_t prop)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   949
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   950
	jobject propertyObject = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   951
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   952
	if (!zfs_prop_readonly(prop)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   953
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   954
		jclass class_LongProperty = (*env)->FindClass(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   955
		    ZFSJNI_PACKAGE_DATA "LongProperty");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   956
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   957
		jmethodID constructor_LongProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   958
		    env, class_LongProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   959
		    "(Ljava/lang/String;Ljava/lang/Long;ZL"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   960
		    ZFSJNI_PACKAGE_DATA "Property$Lineage;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   961
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   962
		jstring propName =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   963
		    (*env)->NewStringUTF(env, zfs_prop_to_name(prop));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   964
		jobject propValue =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   965
		    zjni_long_to_Long(env, zfs_prop_default_numeric(prop));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   966
		jboolean readOnly = zfs_prop_readonly(prop)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   967
		    ? JNI_TRUE : JNI_FALSE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   968
		jobject lineage = zjni_get_lineage(env, ZFS_SRC_DEFAULT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   969
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   970
		propertyObject = (*env)->NewObject(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   971
		    env, class_LongProperty, constructor_LongProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   972
		    propName, propValue, readOnly, lineage);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   973
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   974
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   975
	return (propertyObject);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   976
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   977
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   978
static jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   979
create_default_StringProperty(JNIEnv *env, zfs_prop_t prop)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   980
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   981
	jobject propertyObject = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   982
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   983
	if (zfs_prop_is_string(prop) && !zfs_prop_readonly(prop)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   984
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   985
		char propbuf[ZFS_MAXPROPLEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   986
		jclass class_StringProperty;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   987
		jmethodID constructor_StringProperty;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   988
		jstring propName;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   989
		jobject propValue;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   990
		jboolean readOnly;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   991
		jobject lineage;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   992
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   993
		zfs_prop_default_string(prop, propbuf, sizeof (propbuf));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   994
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   995
		class_StringProperty =
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   996
		    (*env)->FindClass(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   997
			ZFSJNI_PACKAGE_DATA "StringProperty");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   998
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   999
		constructor_StringProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1000
		    env, class_StringProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1001
		    "(Ljava/lang/String;Ljava/lang/String;ZL"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1002
		    ZFSJNI_PACKAGE_DATA "Property$Lineage;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1003
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1004
		propName = (*env)->NewStringUTF(env, zfs_prop_to_name(prop));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1005
		propValue = (*env)->NewStringUTF(env, propbuf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1006
		readOnly = zfs_prop_readonly(prop) ? JNI_TRUE : JNI_FALSE;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1007
		lineage = zjni_get_lineage(env, ZFS_SRC_DEFAULT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1008
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1009
		propertyObject = (*env)->NewObject(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1010
		    env, class_StringProperty, constructor_StringProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1011
		    propName, propValue, readOnly, lineage);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1012
	}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1013
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1014
	return (propertyObject);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1015
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1016
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1017
static jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1018
create_default_MountPointProperty(JNIEnv *env)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1019
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1020
	jobject propertyObject = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1021
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1022
	char propbuf[ZFS_MAXPROPLEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1023
	jclass class_MountPointProperty;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1024
	jmethodID constructor_MountPointProperty;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1025
	jobject propValue;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1026
	jobject lineage;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1027
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1028
	zfs_prop_default_string(ZFS_PROP_MOUNTPOINT, propbuf, sizeof (propbuf));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1029
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1030
	class_MountPointProperty = (*env)->FindClass(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1031
	    env, ZFSJNI_PACKAGE_DATA "MountPointProperty");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1032
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1033
	propValue = (*env)->NewStringUTF(env, propbuf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1034
	lineage = zjni_get_lineage(env, ZFS_SRC_DEFAULT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1035
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1036
	constructor_MountPointProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1037
	    env, class_MountPointProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1038
	    "(Ljava/lang/String;L"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1039
	    ZFSJNI_PACKAGE_DATA "Property$Lineage;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1040
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1041
	propertyObject = (*env)->NewObject(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1042
	    env, class_MountPointProperty, constructor_MountPointProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1043
	    propValue, lineage);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1044
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1045
	return (propertyObject);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1046
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1047
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1048
static jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1049
create_default_ShareNFSProperty(JNIEnv *env)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1050
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1051
	jobject propertyObject = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1052
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1053
	char propbuf[ZFS_MAXPROPLEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1054
	jclass class_ShareNFSProperty;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1055
	jmethodID constructor_ShareNFSProperty;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1056
	jobject propValue;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1057
	jobject lineage;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1058
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1059
	zfs_prop_default_string(ZFS_PROP_SHARENFS, propbuf, sizeof (propbuf));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1060
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1061
	class_ShareNFSProperty = (*env)->FindClass(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1062
	    env, ZFSJNI_PACKAGE_DATA "ShareNFSProperty");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1063
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1064
	propValue = (*env)->NewStringUTF(env, propbuf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1065
	lineage = zjni_get_lineage(env, ZFS_SRC_DEFAULT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1066
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1067
	constructor_ShareNFSProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1068
	    env, class_ShareNFSProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1069
	    "(Ljava/lang/String;L"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1070
	    ZFSJNI_PACKAGE_DATA "Property$Lineage;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1071
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1072
	propertyObject = (*env)->NewObject(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1073
	    env, class_ShareNFSProperty, constructor_ShareNFSProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1074
	    propValue, lineage);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1075
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1076
	return (propertyObject);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1077
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1078
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1079
static jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1080
create_default_ChecksumProperty(JNIEnv *env)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1081
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1082
	jobject propertyObject = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1083
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1084
	char propbuf[ZFS_MAXPROPLEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1085
	jclass class_ChecksumProperty;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1086
	jmethodID constructor_ChecksumProperty;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1087
	jobject propValue;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1088
	jobject lineage;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1089
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1090
	zfs_prop_default_string(ZFS_PROP_CHECKSUM, propbuf, sizeof (propbuf));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1091
	propValue = str_to_checksum(env, propbuf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1092
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1093
	class_ChecksumProperty = (*env)->FindClass(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1094
	    env, ZFSJNI_PACKAGE_DATA "ChecksumProperty");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1095
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1096
	lineage = zjni_get_lineage(env, ZFS_SRC_DEFAULT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1097
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1098
	constructor_ChecksumProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1099
	    env, class_ChecksumProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1100
	    "(L" ZFSJNI_PACKAGE_DATA "ChecksumProperty$Checksum;L"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1101
	    ZFSJNI_PACKAGE_DATA "Property$Lineage;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1102
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1103
	propertyObject = (*env)->NewObject(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1104
	    class_ChecksumProperty, constructor_ChecksumProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1105
	    propValue, lineage);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1106
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1107
	return (propertyObject);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1108
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1109
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1110
static jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1111
create_default_CompressionProperty(JNIEnv *env)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1112
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1113
	jobject propertyObject = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1114
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1115
	char propbuf[ZFS_MAXPROPLEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1116
	jclass class_CompressionProperty;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1117
	jmethodID constructor_CompressionProperty;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1118
	jobject propValue;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1119
	jobject lineage;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1120
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1121
	zfs_prop_default_string(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1122
	    ZFS_PROP_COMPRESSION, propbuf, sizeof (propbuf));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1123
	propValue = str_to_compression(env, propbuf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1124
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1125
	class_CompressionProperty = (*env)->FindClass(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1126
	    env, ZFSJNI_PACKAGE_DATA "CompressionProperty");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1127
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1128
	lineage = zjni_get_lineage(env, ZFS_SRC_DEFAULT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1129
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1130
	constructor_CompressionProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1131
	    env, class_CompressionProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1132
	    "(L" ZFSJNI_PACKAGE_DATA "CompressionProperty$Compression;L"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1133
	    ZFSJNI_PACKAGE_DATA "Property$Lineage;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1134
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1135
	propertyObject = (*env)->NewObject(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1136
	    class_CompressionProperty, constructor_CompressionProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1137
	    propValue, lineage);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1138
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1139
	return (propertyObject);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1140
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1141
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1142
static jobject
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1143
create_default_RecordSizeProperty(JNIEnv *env)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1144
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1145
	jclass class_RecordSizeProperty = (*env)->FindClass(env,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1146
	    ZFSJNI_PACKAGE_DATA "RecordSizeProperty");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1147
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1148
	jmethodID constructor_RecordSizeProperty = (*env)->GetMethodID(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1149
	    env, class_RecordSizeProperty, "<init>",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1150
	    "(Ljava/lang/Long;L"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1151
	    ZFSJNI_PACKAGE_DATA "Property$Lineage;)V");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1152
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1153
	jobject propValue = zjni_long_to_Long(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1154
	    env, zfs_prop_default_numeric(ZFS_PROP_RECORDSIZE));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1155
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1156
	jobject lineage = zjni_get_lineage(env, ZFS_SRC_DEFAULT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1157
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1158
	jobject propertyObject = (*env)->NewObject(
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1159
	    env, class_RecordSizeProperty, constructor_RecordSizeProperty,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1160
	    propValue, lineage);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1161
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1162
	return (propertyObject);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
  1163
}