2 * Copyright (c) 2001-2002 International Business Machines Corp.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
9 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
10 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
11 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
12 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
13 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
14 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
15 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
16 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
17 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
18 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 jmethodID MID_String_getBytes = 0;
33 /* User Class and Fields */
35 jfieldID user_ptsField = 0;
36 jfieldID user_kasField = 0;
37 jfieldID user_nameField = 0;
38 jfieldID user_cachedInfoField = 0;
40 jfieldID user_nameUidField = 0;
41 jfieldID user_ownerUidField = 0;
42 jfieldID user_creatorUidField = 0;
43 jfieldID user_listStatusField = 0;
44 jfieldID user_listGroupsOwnedField = 0;
45 jfieldID user_listMembershipField = 0;
46 jfieldID user_groupCreationQuotaField = 0;
47 jfieldID user_groupMembershipCountField = 0;
48 jfieldID user_ownerField = 0;
49 jfieldID user_creatorField = 0;
51 jfieldID user_adminSettingField = 0;
52 jfieldID user_tgsSettingField = 0;
53 jfieldID user_encSettingField = 0;
54 jfieldID user_cpwSettingField = 0;
55 jfieldID user_rpwSettingField = 0;
56 jfieldID user_userExpirationField = 0;
57 jfieldID user_lastModTimeField = 0;
58 jfieldID user_lastModNameField = 0;
59 jfieldID user_lastChangePasswordTimeField = 0;
60 jfieldID user_maxTicketLifetimeField = 0;
61 jfieldID user_keyVersionField = 0;
62 jfieldID user_encryptionKeyField = 0;
63 jfieldID user_keyCheckSumField = 0;
64 jfieldID user_daysToPasswordExpireField = 0;
65 jfieldID user_failLoginCountField = 0;
66 jfieldID user_lockTimeField = 0;
67 jfieldID user_lockedUntilField = 0;
69 /* Group Class and Fields */
71 jfieldID group_nameField = 0;
72 jfieldID group_cachedInfoField = 0;
73 jfieldID group_nameUidField = 0;
74 jfieldID group_ownerUidField = 0;
75 jfieldID group_creatorUidField = 0;
76 jfieldID group_listStatusField = 0;
77 jfieldID group_listGroupsOwnedField = 0;
78 jfieldID group_listMembershipField = 0;
79 jfieldID group_listAddField = 0;
80 jfieldID group_listDeleteField = 0;
81 jfieldID group_membershipCountField = 0;
82 jfieldID group_ownerField = 0;
83 jfieldID group_creatorField = 0;
85 /* Server Class and Fields */
87 jfieldID server_nameField = 0;
88 jfieldID server_cachedInfoField = 0;
89 jfieldID server_databaseField = 0;
90 jfieldID server_fileServerField = 0;
91 jfieldID server_badDatabaseField = 0;
92 jfieldID server_badFileServerField = 0;
93 jfieldID server_IPAddressField = 0;
95 /* Executable Time Class and Fields */
96 jclass exectimeCls = 0;
97 jfieldID exectime_HourField = 0;
98 jfieldID exectime_MinField = 0;
99 jfieldID exectime_SecField = 0;
100 jfieldID exectime_DayField = 0;
101 jfieldID exectime_NowField = 0;
102 jfieldID exectime_NeverField = 0;
104 /* Partition Class and Fields */
105 jclass partitionCls = 0;
106 jfieldID partition_nameField = 0;
107 jfieldID partition_cachedInfoField = 0;
108 jfieldID partition_idField = 0;
109 jfieldID partition_deviceNameField = 0;
110 jfieldID partition_lockFileDescriptorField = 0;
111 jfieldID partition_totalSpaceField = 0;
112 jfieldID partition_totalFreeSpaceField = 0;
114 /* Volume Class and Fields */
115 jclass volumeCls = 0;
116 jfieldID volume_nameField = 0;
117 jfieldID volume_cachedInfoField = 0;
118 jfieldID volume_idField = 0;
119 jfieldID volume_readWriteIdField = 0;
120 jfieldID volume_readOnlyIdField = 0;
121 jfieldID volume_backupIdField = 0;
122 jfieldID volume_creationDateField = 0;
123 jfieldID volume_lastAccessDateField = 0;
124 jfieldID volume_lastUpdateDateField = 0;
125 jfieldID volume_lastBackupDateField = 0;
126 jfieldID volume_copyCreationDateField = 0;
127 jfieldID volume_accessesSinceMidnightField = 0;
128 jfieldID volume_fileCountField = 0;
129 jfieldID volume_maxQuotaField = 0;
130 jfieldID volume_currentSizeField = 0;
131 jfieldID volume_statusField = 0;
132 jfieldID volume_dispositionField = 0;
133 jfieldID volume_typeField = 0;
135 /* Key Class and Fields */
137 jfieldID key_cachedInfoField = 0;
138 jfieldID key_versionField = 0;
139 jfieldID key_encryptionKeyField = 0;
140 jfieldID key_lastModDateField = 0;
141 jfieldID key_lastModMsField = 0;
142 jfieldID key_checkSumField = 0;
144 /* Process Class and Fields */
145 jclass processCls = 0;
146 jfieldID process_cachedInfoField = 0;
147 jfieldID process_nameField = 0;
148 jfieldID process_typeField = 0;
149 jfieldID process_stateField = 0;
150 jfieldID process_goalField = 0;
151 jfieldID process_startTimeField = 0;
152 jfieldID process_numberStartsField = 0;
153 jfieldID process_exitTimeField = 0;
154 jfieldID process_exitErrorTimeField = 0;
155 jfieldID process_errorCodeField = 0;
156 jfieldID process_errorSignalField = 0;
157 jfieldID process_stateOkField = 0;
158 jfieldID process_stateTooManyErrorsField = 0;
159 jfieldID process_stateBadFileAccessField = 0;
161 #endif /* !LIBJUAFS */
164 * Throws an exception up to the Java layer, using ast as the error code
165 * for the exception. See Exceptions.h for the available
169 throwException(JNIEnv * env, jclass * excCls, char *excClsName,
170 jmethodID * initID, int code)
175 (*env)->NewGlobalRef(env, (*env)->FindClass(env, excClsName));
178 "ERROR: Internal::throwException()\n Cannot find class: %s\n",
182 *initID = (*env)->GetMethodID(env, *excCls, "<init>", "(I)V");
185 "ERROR: Internal::throwException()\n Cannot find construction method: %s\n",
191 exc = (*env)->NewObject(env, *excCls, *initID, code);
194 "ERROR: Internal::throwException()\n Cannot construct new exception object: %s\n",
198 (*env)->Throw(env, exc);
202 * Throws an exception up to the Java layer, constructing it with msg.
203 * This function should only be used when a valid AFS error number/code
204 * is unavailable and it is necessary to interrupt the Java call with an
205 * exception. See Exceptions.h for the available exceptions.
208 throwMessageException(JNIEnv * env, char *msg)
210 jclass excCls = (*env)->FindClass(env, afsExceptionName);
213 "ERROR: Internal::throwMessageException()\n Cannot find class: %s\n",
217 (*env)->ThrowNew(env, excCls, msg);
221 * Throws an exception up to the Java layer, using ast as the error code
222 * for the exception. See Exceptions.h for the available
226 throwAFSException(JNIEnv * env, int code)
228 jclass afsExceptionCls;
229 jmethodID afsExceptionInit;
232 afsExceptionCls = (*env)->FindClass(env, afsExceptionName);
233 if (!afsExceptionCls) {
235 "ERROR: Internal::throwAFSException()\n Cannot find class: %s\n",
241 (*env)->GetMethodID(env, afsExceptionCls, "<init>", "(I)V");
242 if (!afsExceptionInit) {
244 "ERROR: Internal::throwAFSException()\n Cannot find construction method: %s\n",
249 exc = (*env)->NewObject(env, afsExceptionCls, afsExceptionInit, code);
253 "ERROR: Internal::throwAFSException()\n Cannot construct new exception object: %s\n",
257 (*env)->Throw(env, exc);
261 * Throws an exception up to the Java layer, using ast as the error code
262 * for the exception. See Exceptions.h for the available
266 throwAFSFileException(JNIEnv * env, int code, char *msg)
268 jclass afsFileExceptionCls;
269 jmethodID afsFileExceptionInit;
272 afsFileExceptionCls = (*env)->FindClass(env, afsFileExceptionName);
273 if (!afsFileExceptionCls) {
275 "ERROR: Internal::throwAFSFileException()\n Cannot find class: %s\n",
276 afsFileExceptionName);
280 afsFileExceptionInit =
281 (*env)->GetMethodID(env, afsFileExceptionCls, "<init>",
282 "(Ljava/lang/String;I)V");
284 if (!afsFileExceptionInit) {
286 "ERROR: Internal::throwAFSFileException()\n Cannot find construction method: %s\n",
287 afsFileExceptionName);
292 (*env)->NewObject(env, afsFileExceptionCls, afsFileExceptionInit, msg,
296 "ERROR: Internal::throwAFSFileException()\n Cannot construct new exception object: %s\n",
297 afsFileExceptionName);
300 (*env)->Throw(env, exc);
304 * Throws an exception up to the Java layer, using ast as the error code
305 * for the exception. See Exceptions.h for the available
309 throwAFSSecurityException(JNIEnv * env, int code)
311 jclass afsSecurityExceptionCls;
312 jmethodID afsSecurityExceptionInit;
315 afsSecurityExceptionCls =
316 (*env)->FindClass(env, afsSecurityExceptionName);
317 if (!afsSecurityExceptionCls) {
319 "ERROR: Internal::throwAFSSecurityException()\n Cannot find class: %s\n",
320 afsSecurityExceptionName);
324 afsSecurityExceptionInit =
325 (*env)->GetMethodID(env, afsSecurityExceptionCls, "<init>", "(I)V");
326 if (!afsSecurityExceptionInit) {
328 "ERROR: Internal::throwAFSSecurityException()\n Cannot find construction method: %s\n",
329 afsSecurityExceptionName);
334 (*env)->NewObject(env, afsSecurityExceptionCls,
335 afsSecurityExceptionInit, code);
339 "ERROR: Internal::throwAFSSecurityException()\n Cannot construct new exception object: %s\n",
340 afsSecurityExceptionName);
343 (*env)->Throw(env, exc);
347 setError(JNIEnv * env, jobject * obj, int code)
350 jclass cls = (*env)->GetObjectClass(env, *obj);
352 fid = (*env)->GetFieldID(env, cls, "errno", "I");
354 (*env)->SetIntField(env, *obj, fid, code);
362 setString(JNIEnv * env, jobject * obj, char *field, char *string)
368 cls = (*env)->GetObjectClass(env, *obj);
369 /*fprintf(stderr, "setString: env=0x%x, obj=0x%x, cls=0x%x\n", env, obj, cls); */
371 fid = (*env)->GetFieldID(env, cls, field, "Ljava/lang/String;");
372 /*fprintf(stderr, "setString: field=%s, fid=0x%x\n", field, fid); */
374 jstr = (*env)->NewStringUTF(env, (string));
375 /*fprintf(stderr, "jstr = 0x%x\n", jstr); */
376 (*env)->SetObjectField(env, *obj, fid, jstr);
384 * Translates a jstring to a locale-specific native C string.
385 * Use in place of "GetStringUTFChars()" for internationalization
388 * Make sure to "free()" any strings created by this function.
390 * A NULL (zero) return indicates a critical error has occurred and
391 * relies on the caller of this function to throw a Java exception.
393 * This function does not throw any Java exceptions.
395 * env the Java environment
396 * jstr the Java string (UTF) to translate
398 * @returns native C string with the appropriate locale-specific
402 getNativeString(JNIEnv * env, const jstring jstr)
404 jbyteArray bytes = 0;
408 if ((*env)->EnsureLocalCapacity(env, 2) < 0) {
409 // Out of memory error
410 fprintf(stderr, "Internal::getNativeString(): ");
412 "EnsureLocalCapacity() failed: Most likely out of memory\n");
416 if (!MID_String_getBytes) {
417 jclass stringClass = (*env)->FindClass(env, "java/lang/String");
419 fprintf(stderr, "Internal::getNativeString(): ");
421 "Could not locate Java class: java.lang.String.\n");
425 MID_String_getBytes =
426 (*env)->GetMethodID(env, stringClass, "getBytes", "()[B");
427 if (!MID_String_getBytes) {
428 fprintf(stderr, "Internal::getNativeString(): ");
430 "Could not get Java method id for java.lang.String method \"getBytes()\".\n");
435 bytes = (*env)->CallObjectMethod(env, jstr, MID_String_getBytes);
437 fprintf(stderr, "Internal::getNativeString(): ");
439 "CallObjectMethod() failed for java.lang.String.getBytes().\n");
440 fprintf(stderr, "\tMID_String_getBytes = %d\n", MID_String_getBytes);
444 len = (*env)->GetArrayLength(env, bytes);
445 result = (char *)malloc(len + 1);
448 fprintf(stderr, "Internal::getNativeString(): ");
449 fprintf(stderr, "Could not allocate memory for byte array.\n");
450 (*env)->DeleteLocalRef(env, bytes);
453 (*env)->GetByteArrayRegion(env, bytes, 0, len, (jbyte *) result);
454 result[len] = '\0'; // NULL-terminate
456 (*env)->DeleteLocalRef(env, bytes);
463 * Opens an AFS file, with the specified name, using the specified flags
464 * with in the specified mode (permission mode).
466 * env the Java environment
467 * fileNameUTF name of file to be opened
468 * flags open mode: O_CREAT, O_APPEND
469 * mode UNIX permission mode mask
472 * @returns file descriptor
475 openAFSFile(JNIEnv * env, jstring filenameUTF, int flags, int mode, int *err)
482 filename = getNativeString(env, filenameUTF);
483 if (filename == NULL) {
484 fprintf(stderr, "Internal::openAFSFile(): failed to get filename\n");
488 fd = uafs_open(filename, flags, mode);
492 fprintf(stderr, "Internal::openAFSFile(): errno=%d\n", errno);
493 fprintf(stderr, "Internal::openAFSFile(): fd=%d\n", fd);
496 fprintf(stderr, "Internal::openAFSFile(): failed to open filename\n");
497 fprintf(stderr, "Internal::openAFSFile(): fd=%d\n", fd);
504 * Reads the "CacheConfig" file for user space configuration.
505 * By default, this file resides in "/usr/afswsp/etc/CacheConfig",
506 * however if the environment variable "LIBJAFS_CACHE_CONFIG" is
507 * set this function will use that value instead.
509 * The CacheConfig file contains several cache tuning parameters
510 * as well as a few parameters that define the runtime environment
511 * for the user space client, including: mount point location,
512 * configuration directory (where to find ThisCell and CellServDB),
513 * cache directory, debug and verbose options, and log file location.
516 readCacheParms(char *afsMountPoint, char *afsConfDir, char *afsCacheDir,
517 int *cacheBlocks, int *cacheFiles, int *cacheStatEntries,
518 int *dCacheSize, int *vCacheSize, int *chunkSize,
519 int *closeSynch, int *debug, int *nDaemons, int *cacheFlags,
526 char cacheConfigFile[100];
528 p = (char *)getenv("LIBJAFS_CACHE_CONFIG");
530 strcpy(cacheConfigFile, p);
532 strcpy(cacheConfigFile, "/usr/afswsp/etc/CacheConfig");
535 f = fopen(cacheConfigFile, "r");
537 fprintf(stderr, "Could not open cache config file: %s\n",
546 p = (char *)strchr(line, '\n');
549 if (strncmp(line, "#", 1) == 0)
550 continue; /* comment */
552 p = (char *)strchr(line, ' ');
559 if (strncmp(line, "MountPoint", len1) == 0)
560 strcpy(afsMountPoint, p);
561 else if (strncmp(line, "ConfDir", len1) == 0)
562 strcpy(afsConfDir, p);
563 else if (strncmp(line, "CacheDir", len1) == 0)
564 strcpy(afsCacheDir, p);
565 else if (strncmp(line, "CacheBlocks", len1) == 0)
566 *cacheBlocks = atoi(p);
567 else if (strncmp(line, "CacheFiles", len1) == 0)
568 *cacheFiles = atoi(p);
569 else if (strncmp(line, "CacheStatEntries", len1) == 0)
570 *cacheStatEntries = atoi(p);
571 else if (strncmp(line, "DCacheSize", len1) == 0)
572 *dCacheSize = atoi(p);
573 else if (strncmp(line, "VCacheSize", len1) == 0)
574 *vCacheSize = atoi(p);
575 else if (strncmp(line, "ChunkSize", len1) == 0)
576 *chunkSize = atoi(p);
577 else if (strncmp(line, "CloseSynch", len1) == 0)
578 *closeSynch = atoi(p);
579 else if (strncmp(line, "Debug", len1) == 0)
581 else if (strncmp(line, "NDaemons", len1) == 0)
583 else if (strncmp(line, "CacheFlags", len1) == 0)
584 *cacheFlags = atoi(p);
585 else if (strncmp(line, "LogFile", len1) == 0)
594 * Makes a kas identity given the full name of a kas user. If the
595 * name contains a period, everything after the first period is
596 * considered to be the instance of that name, otherwise
597 * the instance is the empty string. The memory for who
598 * that's passed in should be fully allocated in advance.
601 internal_makeKasIdentity(const char *fullName, kas_identity_p who)
605 if ((period = (char *)strchr(fullName, '.')) != NULL) {
606 strncpy(who->principal, fullName, period - fullName);
607 who->principal[period - fullName] = '\0';
608 strncpy(who->instance, period + 1,
609 strlen(fullName) - (period - fullName));
611 strcpy(who->principal, fullName);
612 strcpy(who->instance, "");
617 * Given a Java environment and an instance of a user, gets the object and
618 * field information for the user object from the Java environment.
621 internal_getUserClass(JNIEnv * env, jobject user)
625 (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, user));
627 throwAFSException(env, JAFSADMCLASSNOTFOUND);
630 user_ptsField = (*env)->GetFieldID(env, userCls, "pts", "Z");
631 user_kasField = (*env)->GetFieldID(env, userCls, "kas", "Z");
633 (*env)->GetFieldID(env, userCls, "name", "Ljava/lang/String;");
634 user_cachedInfoField =
635 (*env)->GetFieldID(env, userCls, "cachedInfo", "Z");
637 user_nameUidField = (*env)->GetFieldID(env, userCls, "nameUID", "I");
639 (*env)->GetFieldID(env, userCls, "ownerUID", "I");
640 user_creatorUidField =
641 (*env)->GetFieldID(env, userCls, "creatorUID", "I");
642 user_listStatusField =
643 (*env)->GetFieldID(env, userCls, "listStatus", "I");
644 user_listGroupsOwnedField =
645 (*env)->GetFieldID(env, userCls, "listGroupsOwned", "I");
646 user_listMembershipField =
647 (*env)->GetFieldID(env, userCls, "listMembership", "I");
648 user_groupCreationQuotaField =
649 (*env)->GetFieldID(env, userCls, "groupCreationQuota", "I");
650 user_groupMembershipCountField =
651 (*env)->GetFieldID(env, userCls, "groupMembershipCount", "I");
653 (*env)->GetFieldID(env, userCls, "owner", "Ljava/lang/String;");
655 (*env)->GetFieldID(env, userCls, "creator", "Ljava/lang/String;");
657 user_adminSettingField =
658 (*env)->GetFieldID(env, userCls, "adminSetting", "I");
659 user_tgsSettingField =
660 (*env)->GetFieldID(env, userCls, "tgsSetting", "I");
661 user_encSettingField =
662 (*env)->GetFieldID(env, userCls, "encSetting", "I");
663 user_cpwSettingField =
664 (*env)->GetFieldID(env, userCls, "cpwSetting", "I");
665 user_rpwSettingField =
666 (*env)->GetFieldID(env, userCls, "rpwSetting", "I");
667 user_userExpirationField =
668 (*env)->GetFieldID(env, userCls, "userExpiration", "I");
669 user_lastModTimeField =
670 (*env)->GetFieldID(env, userCls, "lastModTime", "I");
671 user_lastModNameField =
672 (*env)->GetFieldID(env, userCls, "lastModName",
673 "Ljava/lang/String;");
674 user_lastChangePasswordTimeField =
675 (*env)->GetFieldID(env, userCls, "lastChangePasswordTime", "I");
676 user_maxTicketLifetimeField =
677 (*env)->GetFieldID(env, userCls, "maxTicketLifetime", "I");
678 user_keyVersionField =
679 (*env)->GetFieldID(env, userCls, "keyVersion", "I");
680 user_encryptionKeyField =
681 (*env)->GetFieldID(env, userCls, "encryptionKey",
682 "Ljava/lang/String;");
683 user_keyCheckSumField =
684 (*env)->GetFieldID(env, userCls, "keyCheckSum", "J");
685 user_daysToPasswordExpireField =
686 (*env)->GetFieldID(env, userCls, "daysToPasswordExpire", "I");
687 user_failLoginCountField =
688 (*env)->GetFieldID(env, userCls, "failLoginCount", "I");
690 (*env)->GetFieldID(env, userCls, "lockTime", "I");
691 user_lockedUntilField =
692 (*env)->GetFieldID(env, userCls, "lockedUntil", "I");
693 if (!user_ptsField || !user_kasField || !user_nameField
694 || !user_cachedInfoField || !user_nameUidField
695 || !user_ownerUidField || !user_creatorUidField
696 || !user_listStatusField || !user_listGroupsOwnedField
697 || !user_listMembershipField || !user_groupCreationQuotaField
698 || !user_groupMembershipCountField || !user_ownerField
699 || !user_creatorField || !user_adminSettingField
700 || !user_tgsSettingField || !user_encSettingField
701 || !user_cpwSettingField || !user_rpwSettingField
702 || !user_userExpirationField || !user_lastModTimeField
703 || !user_lastModNameField || !user_lastChangePasswordTimeField
704 || !user_maxTicketLifetimeField || !user_keyVersionField
705 || !user_encryptionKeyField || !user_keyCheckSumField
706 || !user_daysToPasswordExpireField || !user_failLoginCountField
707 || !user_lockTimeField || !user_lockedUntilField) {
709 throwAFSException(env, JAFSADMFIELDNOTFOUND);
716 * Given a Java environment and an instance of a group, gets the object and
717 * field information for the group object from the Java environment.
720 internal_getGroupClass(JNIEnv * env, jobject group)
724 (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, group));
726 throwAFSException(env, JAFSADMCLASSNOTFOUND);
730 (*env)->GetFieldID(env, groupCls, "name", "Ljava/lang/String;");
731 group_cachedInfoField =
732 (*env)->GetFieldID(env, groupCls, "cachedInfo", "Z");
734 (*env)->GetFieldID(env, groupCls, "nameUID", "I");
735 group_ownerUidField =
736 (*env)->GetFieldID(env, groupCls, "ownerUID", "I");
737 group_creatorUidField =
738 (*env)->GetFieldID(env, groupCls, "creatorUID", "I");
739 group_listStatusField =
740 (*env)->GetFieldID(env, groupCls, "listStatus", "I");
741 group_listGroupsOwnedField =
742 (*env)->GetFieldID(env, groupCls, "listGroupsOwned", "I");
743 group_listMembershipField =
744 (*env)->GetFieldID(env, groupCls, "listMembership", "I");
746 (*env)->GetFieldID(env, groupCls, "listAdd", "I");
747 group_listDeleteField =
748 (*env)->GetFieldID(env, groupCls, "listDelete", "I");
749 group_membershipCountField =
750 (*env)->GetFieldID(env, groupCls, "membershipCount", "I");
752 (*env)->GetFieldID(env, groupCls, "owner", "Ljava/lang/String;");
754 (*env)->GetFieldID(env, groupCls, "creator",
755 "Ljava/lang/String;");
756 if (!group_nameField || !group_cachedInfoField || !group_nameUidField
757 || !group_ownerUidField || !group_creatorUidField
758 || !group_listStatusField || !group_listGroupsOwnedField
759 || !group_listMembershipField || !group_listAddField
760 || !group_listDeleteField || !group_membershipCountField
761 || !group_ownerField || !group_creatorField) {
763 throwAFSException(env, JAFSADMFIELDNOTFOUND);
770 * Given a Java environment and an instance of a server, gets the object and
771 * field information for the server object from the Java environment.
774 internal_getServerClass(JNIEnv * env, jobject server)
776 if (serverCls == 0) {
778 (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, server));
780 throwAFSException(env, JAFSADMCLASSNOTFOUND);
784 (*env)->GetFieldID(env, serverCls, "name", "Ljava/lang/String;");
785 server_cachedInfoField =
786 (*env)->GetFieldID(env, serverCls, "cachedInfo", "Z");
787 server_databaseField =
788 (*env)->GetFieldID(env, serverCls, "database", "Z");
789 server_fileServerField =
790 (*env)->GetFieldID(env, serverCls, "fileServer", "Z");
791 server_badDatabaseField =
792 (*env)->GetFieldID(env, serverCls, "badDatabase", "Z");
793 server_badFileServerField =
794 (*env)->GetFieldID(env, serverCls, "badFileServer", "Z");
795 server_IPAddressField =
796 (*env)->GetFieldID(env, serverCls, "ipAddresses",
797 "[Ljava/lang/String;");
798 if (!server_nameField || !server_cachedInfoField
799 || !server_databaseField || !server_fileServerField
800 || !server_badDatabaseField || !server_badFileServerField
801 || !server_IPAddressField) {
803 throwAFSException(env, JAFSADMFIELDNOTFOUND);
811 * Given a Java environment and an instance of an executableTime, gets the
812 * object and field information for the executableTime object from the
816 internal_getExecTimeClass(JNIEnv * env, jobject exectime)
818 if (exectimeCls == 0) {
820 (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, exectime));
822 throwAFSException(env, JAFSADMCLASSNOTFOUND);
826 (*env)->GetFieldID(env, exectimeCls, "hour", "S");
828 (*env)->GetFieldID(env, exectimeCls, "minute", "S");
830 (*env)->GetFieldID(env, exectimeCls, "second", "S");
831 exectime_DayField = (*env)->GetFieldID(env, exectimeCls, "day", "S");
832 exectime_NowField = (*env)->GetFieldID(env, exectimeCls, "now", "Z");
833 exectime_NeverField =
834 (*env)->GetFieldID(env, exectimeCls, "never", "Z");
835 if (!exectime_HourField || !exectime_MinField || !exectime_SecField
836 || !exectime_DayField || !exectime_NowField
837 || !exectime_NeverField) {
839 throwAFSException(env, JAFSADMFIELDNOTFOUND);
847 * Given a Java environment and an instance of a partition, gets the object and
848 * field information for the partition object from the Java environment.
851 internal_getPartitionClass(JNIEnv * env, jobject partition)
853 if (partitionCls == 0) {
855 (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, partition));
857 throwAFSException(env, JAFSADMCLASSNOTFOUND);
860 partition_nameField =
861 (*env)->GetFieldID(env, partitionCls, "name",
862 "Ljava/lang/String;");
863 partition_deviceNameField =
864 (*env)->GetFieldID(env, partitionCls, "deviceName",
865 "Ljava/lang/String;");
866 partition_idField = (*env)->GetFieldID(env, partitionCls, "id", "I");
867 partition_cachedInfoField =
868 (*env)->GetFieldID(env, partitionCls, "cachedInfo", "Z");
869 partition_lockFileDescriptorField =
870 (*env)->GetFieldID(env, partitionCls, "lockFileDescriptor", "I");
871 partition_totalSpaceField =
872 (*env)->GetFieldID(env, partitionCls, "totalSpace", "I");
873 partition_totalFreeSpaceField =
874 (*env)->GetFieldID(env, partitionCls, "totalFreeSpace", "I");
875 if (!partition_nameField || !partition_cachedInfoField
876 || !partition_idField || !partition_deviceNameField
877 || !partition_lockFileDescriptorField
878 || !partition_totalSpaceField || !partition_totalFreeSpaceField) {
880 throwAFSException(env, JAFSADMFIELDNOTFOUND);
888 * Given a Java environment and an instance of a volume, gets the object and
889 * field information for the volume object from the Java environment.
892 internal_getVolumeClass(JNIEnv * env, jobject volume)
894 if (volumeCls == 0) {
896 (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, volume));
898 throwAFSException(env, JAFSADMCLASSNOTFOUND);
902 (*env)->GetFieldID(env, volumeCls, "name", "Ljava/lang/String;");
903 volume_cachedInfoField =
904 (*env)->GetFieldID(env, volumeCls, "cachedInfo", "Z");
905 volume_idField = (*env)->GetFieldID(env, volumeCls, "id", "I");
906 volume_readWriteIdField =
907 (*env)->GetFieldID(env, volumeCls, "readWriteID", "I");
908 volume_readOnlyIdField =
909 (*env)->GetFieldID(env, volumeCls, "readOnlyID", "I");
910 volume_backupIdField =
911 (*env)->GetFieldID(env, volumeCls, "backupID", "I");
912 volume_creationDateField =
913 (*env)->GetFieldID(env, volumeCls, "creationDate", "J");
914 volume_lastAccessDateField =
915 (*env)->GetFieldID(env, volumeCls, "lastAccessDate", "J");
916 volume_lastUpdateDateField =
917 (*env)->GetFieldID(env, volumeCls, "lastUpdateDate", "J");
918 volume_lastBackupDateField =
919 (*env)->GetFieldID(env, volumeCls, "lastBackupDate", "J");
920 volume_copyCreationDateField =
921 (*env)->GetFieldID(env, volumeCls, "copyCreationDate", "J");
922 volume_accessesSinceMidnightField =
923 (*env)->GetFieldID(env, volumeCls, "accessesSinceMidnight", "I");
924 volume_fileCountField =
925 (*env)->GetFieldID(env, volumeCls, "fileCount", "I");
926 volume_maxQuotaField =
927 (*env)->GetFieldID(env, volumeCls, "maxQuota", "I");
928 volume_currentSizeField =
929 (*env)->GetFieldID(env, volumeCls, "currentSize", "I");
931 (*env)->GetFieldID(env, volumeCls, "status", "I");
932 volume_dispositionField =
933 (*env)->GetFieldID(env, volumeCls, "disposition", "I");
934 volume_typeField = (*env)->GetFieldID(env, volumeCls, "type", "I");
935 if (!volume_nameField || !volume_cachedInfoField || !volume_idField
936 || !volume_readWriteIdField || !volume_readOnlyIdField
937 || !volume_backupIdField || !volume_creationDateField
938 || !volume_lastAccessDateField || !volume_lastUpdateDateField
939 || !volume_lastBackupDateField || !volume_copyCreationDateField
940 || !volume_accessesSinceMidnightField || !volume_fileCountField
941 || !volume_maxQuotaField || !volume_currentSizeField
942 || !volume_statusField || !volume_dispositionField
943 || !volume_typeField) {
945 throwAFSException(env, JAFSADMFIELDNOTFOUND);
953 * Given a Java environment and an instance of a key, gets the object and
954 * field information for the key object from the Java environment.
957 internal_getKeyClass(JNIEnv * env, jobject key)
960 keyCls = (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, key));
962 throwAFSException(env, JAFSADMCLASSNOTFOUND);
965 key_encryptionKeyField =
966 (*env)->GetFieldID(env, keyCls, "encryptionKey",
967 "Ljava/lang/String;");
968 key_cachedInfoField =
969 (*env)->GetFieldID(env, keyCls, "cachedInfo", "Z");
970 key_versionField = (*env)->GetFieldID(env, keyCls, "version", "I");
971 key_lastModDateField =
972 (*env)->GetFieldID(env, keyCls, "lastModDate", "I");
974 (*env)->GetFieldID(env, keyCls, "lastModMs", "I");
975 key_checkSumField = (*env)->GetFieldID(env, keyCls, "checkSum", "J");
976 if (!key_cachedInfoField || !key_versionField
977 || !key_encryptionKeyField || !key_lastModDateField
978 || !key_lastModMsField || !key_checkSumField) {
980 throwAFSException(env, JAFSADMFIELDNOTFOUND);
988 * Given a Java environment and an instance of a process, gets the object and
989 * field information for the process object from the Java environment.
992 internal_getProcessClass(JNIEnv * env, jobject process)
994 if (processCls == 0) {
996 (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, process));
998 throwAFSException(env, JAFSADMCLASSNOTFOUND);
1001 process_cachedInfoField =
1002 (*env)->GetFieldID(env, processCls, "cachedInfo", "Z");
1004 (*env)->GetFieldID(env, processCls, "name", "Ljava/lang/String;");
1005 process_typeField = (*env)->GetFieldID(env, processCls, "type", "I");
1006 process_stateField =
1007 (*env)->GetFieldID(env, processCls, "state", "I");
1008 process_goalField = (*env)->GetFieldID(env, processCls, "goal", "I");
1009 process_startTimeField =
1010 (*env)->GetFieldID(env, processCls, "startTime", "J");
1011 process_numberStartsField =
1012 (*env)->GetFieldID(env, processCls, "numberStarts", "J");
1013 process_exitTimeField =
1014 (*env)->GetFieldID(env, processCls, "exitTime", "J");
1015 process_exitErrorTimeField =
1016 (*env)->GetFieldID(env, processCls, "exitErrorTime", "J");
1017 process_errorCodeField =
1018 (*env)->GetFieldID(env, processCls, "errorCode", "J");
1019 process_errorSignalField =
1020 (*env)->GetFieldID(env, processCls, "errorSignal", "J");
1021 process_stateOkField =
1022 (*env)->GetFieldID(env, processCls, "stateOk", "Z");
1023 process_stateTooManyErrorsField =
1024 (*env)->GetFieldID(env, processCls, "stateTooManyErrors", "Z");
1025 process_stateBadFileAccessField =
1026 (*env)->GetFieldID(env, processCls, "stateBadFileAccess", "Z");
1027 if (!process_cachedInfoField || !process_nameField
1028 || !process_typeField || !process_stateField || !process_goalField
1029 || !process_startTimeField || !process_numberStartsField
1030 || !process_exitTimeField || !process_exitErrorTimeField
1031 || !process_errorCodeField || !process_errorSignalField
1032 || !process_stateOkField || !process_stateTooManyErrorsField
1033 || !process_stateBadFileAccessField) {
1035 throwAFSException(env, JAFSADMFIELDNOTFOUND);
1042 #endif /* LIBJUAFS */