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.
31 // user class and fields //
33 jfieldID user_ptsField = 0;
34 jfieldID user_kasField = 0;
35 jfieldID user_nameField = 0;
36 //jfieldID user_cellHandleField = 0;
37 jfieldID user_cachedInfoField = 0;
39 jfieldID user_nameUidField = 0;
40 jfieldID user_ownerUidField = 0;
41 jfieldID user_creatorUidField = 0;
42 jfieldID user_listStatusField = 0;
43 jfieldID user_listGroupsOwnedField = 0;
44 jfieldID user_listMembershipField = 0;
45 jfieldID user_groupCreationQuotaField = 0;
46 jfieldID user_groupMembershipCountField = 0;
47 jfieldID user_ownerField = 0;
48 jfieldID user_creatorField = 0;
50 jfieldID user_adminSettingField = 0;
51 jfieldID user_tgsSettingField = 0;
52 jfieldID user_encSettingField = 0;
53 jfieldID user_cpwSettingField = 0;
54 jfieldID user_rpwSettingField = 0;
55 jfieldID user_userExpirationField = 0;
56 jfieldID user_lastModTimeField = 0;
57 jfieldID user_lastModNameField = 0;
58 jfieldID user_lastChangePasswordTimeField = 0;
59 jfieldID user_maxTicketLifetimeField = 0;
60 jfieldID user_keyVersionField = 0;
61 jfieldID user_encryptionKeyField = 0;
62 jfieldID user_keyCheckSumField = 0;
63 jfieldID user_daysToPasswordExpireField = 0;
64 jfieldID user_failLoginCountField = 0;
65 jfieldID user_lockTimeField = 0;
66 jfieldID user_lockedUntilField = 0;
68 // group class and fields //
70 jfieldID group_nameField = 0;
71 //jfieldID group_cellHandleField = 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_cellHandleField = 0;
89 jfieldID server_cachedInfoField = 0;
90 jfieldID server_databaseField = 0;
91 jfieldID server_fileServerField = 0;
92 jfieldID server_badDatabaseField = 0;
93 jfieldID server_badFileServerField = 0;
94 jfieldID server_IPAddressField = 0;
96 // executable time class and fields //
97 jclass exectimeCls = 0;
98 jfieldID exectime_HourField = 0;
99 jfieldID exectime_MinField = 0;
100 jfieldID exectime_SecField = 0;
101 jfieldID exectime_DayField = 0;
102 jfieldID exectime_NowField = 0;
103 jfieldID exectime_NeverField = 0;
105 // partition class and fields //
106 jclass partitionCls = 0;
107 jfieldID partition_nameField = 0;
108 jfieldID partition_cachedInfoField = 0;
109 jfieldID partition_idField = 0;
110 jfieldID partition_deviceNameField = 0;
111 jfieldID partition_lockFileDescriptorField = 0;
112 jfieldID partition_totalSpaceField = 0;
113 jfieldID partition_totalFreeSpaceField = 0;
115 // volume class and fields //
116 jclass volumeCls = 0;
117 jfieldID volume_nameField = 0;
118 jfieldID volume_cachedInfoField = 0;
119 jfieldID volume_idField = 0;
120 jfieldID volume_readWriteIdField = 0;
121 jfieldID volume_readOnlyIdField = 0;
122 jfieldID volume_backupIdField = 0;
123 jfieldID volume_creationDateField = 0;
124 jfieldID volume_lastAccessDateField = 0;
125 jfieldID volume_lastUpdateDateField = 0;
126 jfieldID volume_lastBackupDateField = 0;
127 jfieldID volume_copyCreationDateField = 0;
128 jfieldID volume_accessesSinceMidnightField = 0;
129 jfieldID volume_fileCountField = 0;
130 jfieldID volume_maxQuotaField = 0;
131 jfieldID volume_currentSizeField = 0;
132 jfieldID volume_statusField = 0;
133 jfieldID volume_dispositionField = 0;
134 jfieldID volume_typeField = 0;
136 // key class and fields //
138 jfieldID key_cachedInfoField = 0;
139 jfieldID key_versionField = 0;
140 jfieldID key_encryptionKeyField = 0;
141 jfieldID key_lastModDateField = 0;
142 jfieldID key_lastModMsField = 0;
143 jfieldID key_checkSumField = 0;
145 // process class and fields //
146 jclass processCls = 0;
147 jfieldID process_cachedInfoField = 0;
148 jfieldID process_nameField = 0;
149 //jfieldID process_serverHandleField = 0;
150 jfieldID process_typeField = 0;
151 jfieldID process_stateField = 0;
152 jfieldID process_goalField = 0;
153 jfieldID process_startTimeField = 0;
154 jfieldID process_numberStartsField = 0;
155 jfieldID process_exitTimeField = 0;
156 jfieldID process_exitErrorTimeField = 0;
157 jfieldID process_errorCodeField = 0;
158 jfieldID process_errorSignalField = 0;
159 jfieldID process_stateOkField = 0;
160 jfieldID process_stateTooManyErrorsField = 0;
161 jfieldID process_stateBadFileAccessField = 0;
162 #endif /* !LIBJUAFS */
165 * Throws an exception up to the Java layer, using ast as the error code
166 * for the exception. See Exceptions.h for the available
170 (JNIEnv *env, jclass *excCls, char *excClsName, jmethodID *initID, int code)
174 *excCls = (*env)->NewGlobalRef(env, (*env)->FindClass(env, excClsName ));
176 fprintf(stderr, "ERROR: Internal::throwException()\n Cannot find class: %s\n", excClsName);
179 *initID = (*env)->GetMethodID( env, *excCls, "<init>", "(I)V" );
181 fprintf(stderr, "ERROR: Internal::throwException()\n Cannot find construction method: %s\n",
187 exc = (*env)->NewObject( env, *excCls, *initID, code );
189 fprintf(stderr, "ERROR: Internal::throwException()\n Cannot construct new exception object: %s\n",
193 (*env)->Throw(env, exc);
197 * Throws an exception up to the Java layer, constructing it with msg.
198 * This function should only be used when a valid AFS error number/code
199 * is unavailable and it is necessary to interrupt the Java call with an
200 * exception. See Exceptions.h for the available exceptions.
202 void throwMessageException( JNIEnv *env, char *msg )
204 jclass excCls = (*env)->FindClass(env, afsExceptionName);
206 fprintf(stderr, "ERROR: Internal::throwMessageException()\n Cannot find class: %s\n", afsExceptionName);
209 (*env)->ThrowNew(env, excCls, msg);
213 * Throws an exception up to the Java layer, using ast as the error code
214 * for the exception. See Exceptions.h for the available
217 void throwAFSException( JNIEnv *env, int code )
219 jclass afsExceptionCls;
220 jmethodID afsExceptionInit;
223 afsExceptionCls = (*env)->FindClass(env, afsExceptionName);
224 if( !afsExceptionCls ) {
225 fprintf(stderr, "ERROR: Internal::throwAFSException()\n Cannot find class: %s\n", afsExceptionName);
229 afsExceptionInit = (*env)->GetMethodID( env, afsExceptionCls,
231 if( !afsExceptionInit ) {
232 fprintf(stderr, "ERROR: Internal::throwAFSException()\n Cannot find construction method: %s\n",
237 exc = (*env)->NewObject( env, afsExceptionCls, afsExceptionInit, code );
240 fprintf(stderr, "ERROR: Internal::throwAFSException()\n Cannot construct new exception object: %s\n",
244 (*env)->Throw(env, exc);
248 * Throws an exception up to the Java layer, using ast as the error code
249 * for the exception. See Exceptions.h for the available
252 void throwAFSFileException( JNIEnv *env, int code, char *msg )
254 jclass afsFileExceptionCls;
255 jmethodID afsFileExceptionInit;
258 afsFileExceptionCls = (*env)->FindClass(env, afsFileExceptionName);
259 if( !afsFileExceptionCls ) {
260 fprintf(stderr, "ERROR: Internal::throwAFSFileException()\n Cannot find class: %s\n", afsFileExceptionName);
264 afsFileExceptionInit = (*env)->GetMethodID( env, afsFileExceptionCls,
265 "<init>", "(Ljava/lang/String;I)V" );
266 if( !afsFileExceptionInit ) {
267 fprintf(stderr, "ERROR: Internal::throwAFSFileException()\n Cannot find construction method: %s\n",
268 afsFileExceptionName);
272 exc = (*env)->NewObject( env, afsFileExceptionCls,
273 afsFileExceptionInit, msg, code );
275 fprintf(stderr, "ERROR: Internal::throwAFSFileException()\n Cannot construct new exception object: %s\n",
276 afsFileExceptionName);
279 (*env)->Throw(env, exc);
283 * Throws an exception up to the Java layer, using ast as the error code
284 * for the exception. See Exceptions.h for the available
287 void throwAFSSecurityException( JNIEnv *env, int code )
289 jclass afsSecurityExceptionCls;
290 jmethodID afsSecurityExceptionInit;
293 afsSecurityExceptionCls = (*env)->FindClass(env, afsSecurityExceptionName);
294 if( !afsSecurityExceptionCls ) {
295 fprintf(stderr, "ERROR: Internal::throwAFSSecurityException()\n Cannot find class: %s\n", afsSecurityExceptionName);
299 afsSecurityExceptionInit = (*env)->GetMethodID( env, afsSecurityExceptionCls,
301 if( !afsSecurityExceptionInit ) {
302 fprintf(stderr, "ERROR: Internal::throwAFSSecurityException()\n Cannot find construction method: %s\n",
303 afsSecurityExceptionName);
307 exc = (*env)->NewObject( env, afsSecurityExceptionCls,
308 afsSecurityExceptionInit, code );
310 fprintf(stderr, "ERROR: Internal::throwAFSSecurityException()\n Cannot construct new exception object: %s\n",
311 afsSecurityExceptionName);
314 (*env)->Throw(env, exc);
317 int setError(JNIEnv *env, jobject *obj, int code)
320 jclass cls = (*env)->GetObjectClass(env, *obj);
322 fid = (*env)->GetFieldID(env, cls, "errno", "I");
325 (*env)->SetIntField(env, *obj, fid, code);
335 * Opens an AFS file, with the specified name, using the specified flags
336 * with in the specified mode (permission mode).
338 * env the Java environment
339 * fileNameUTF name of file to be opened
340 * flags open mode: O_CREAT, O_APPEND
341 * mode UNIX permission mode mask
344 * @returns file descriptor
347 (JNIEnv *env, jstring fileNameUTF, int flags, int mode, int *err)
354 fileName=(char*) (*env)->GetStringUTFChars(env, fileNameUTF, 0);
355 if(fileName == NULL) {
356 fprintf(stderr, "Internal::openAFSFile(): failed to get fileName\n");
360 fd = uafs_open(fileName, flags, mode);
363 fprintf(stderr, "Internal::openAFSFile(): errno=%d\n", errno);
364 fprintf(stderr, "Internal::openAFSFile(): fd=%d\n", fd);
366 (*env)->ReleaseStringUTFChars(env, fileNameUTF, fileName);
368 fprintf(stderr, "Internal::openAFSFile(): failed to open fileName\n");
369 fprintf(stderr, "Internal::openAFSFile(): fd=%d\n", fd);
375 int readCacheParms(char *afsMountPoint, char *afsConfDir, char *afsCacheDir,
376 int *cacheBlocks, int *cacheFiles, int *cacheStatEntries,
377 int *dCacheSize, int *vCacheSize, int *chunkSize,
378 int *closeSynch, int *debug, int *nDaemons, int *cacheFlags,
385 char cacheConfigFile[100];
387 p = (char *)getenv("LIBJAFS_CACHE_CONFIG");
389 strcpy(cacheConfigFile, p);
391 strcpy(cacheConfigFile, "/usr/afswsp/etc/CacheConfig");
394 f = fopen(cacheConfigFile, "r");
396 fprintf(stderr, "Could not open cache config file: %s\n",
404 p = (char *)strchr(line, '\n');
406 if (strncmp(line, "#", 1) == 0) continue; /* comment */
408 p = (char *)strchr(line, ' ');
411 p++; len2 = strlen(p);
413 if (strncmp(line, "MountPoint", len1) == 0)
414 strcpy(afsMountPoint, p);
415 else if (strncmp(line, "ConfDir", len1) == 0)
416 strcpy(afsConfDir, p);
417 else if (strncmp(line, "CacheDir", len1) == 0)
418 strcpy(afsCacheDir, p);
419 else if (strncmp(line, "CacheBlocks", len1) == 0)
420 *cacheBlocks = atoi(p);
421 else if (strncmp(line, "CacheFiles", len1) == 0)
422 *cacheFiles = atoi(p);
423 else if (strncmp(line, "CacheStatEntries", len1) == 0)
424 *cacheStatEntries = atoi(p);
425 else if (strncmp(line, "DCacheSize", len1) == 0)
426 *dCacheSize = atoi(p);
427 else if (strncmp(line, "VCacheSize", len1) == 0)
428 *vCacheSize = atoi(p);
429 else if (strncmp(line, "ChunkSize", len1) == 0)
430 *chunkSize = atoi(p);
431 else if (strncmp(line, "CloseSynch", len1) == 0)
432 *closeSynch = atoi(p);
433 else if (strncmp(line, "Debug", len1) == 0)
435 else if (strncmp(line, "NDaemons", len1) == 0)
437 else if (strncmp(line, "CacheFlags", len1) == 0)
438 *cacheFlags = atoi(p);
439 else if (strncmp(line, "LogFile", len1) == 0)
445 int setString(JNIEnv *env, jobject *obj, char *field, char *string)
451 cls = (*env)->GetObjectClass(env, *obj);
452 /*fprintf(stderr, "setString: env=0x%x, obj=0x%x, cls=0x%x\n", env, obj, cls);*/
454 fid = (*env)->GetFieldID(env, cls, field, "Ljava/lang/String;");
455 /*fprintf(stderr, "setString: field=%s, fid=0x%x\n", field, fid);*/
457 jstr = (*env)->NewStringUTF(env, (string));
458 /*fprintf(stderr, "jstr = 0x%x\n", jstr);*/
459 (*env)->SetObjectField(env, *obj, fid, jstr);
469 * Makes a kas identity given the full name of a kas user. If the
470 * name contains a period, everything after the first period is
471 * considered to be the instance of that name, otherwise
472 * the instance is the empty string. The memory for who
473 * that's passed in should be fully allocated in advance.
475 void internal_makeKasIdentity( const char *fullName,
476 kas_identity_p who ) {
480 if( (period = (char *) strchr( fullName, '.' )) != NULL ) {
481 strncpy( who->principal, fullName, period - fullName );
482 who->principal[period - fullName] = '\0';
483 strncpy( who->instance, period + 1,
484 strlen(fullName) - (period - fullName) );
486 strcpy( who->principal, fullName);
487 strcpy( who->instance, "" );
493 * Given a Java environment and an instance of a user, gets the object and
494 * field information for the user object from the Java environment.
496 void internal_getUserClass( JNIEnv *env, jobject user ) {
498 userCls = (*env)->NewGlobalRef( env, (*env)->GetObjectClass(env, user) );
500 throwAFSException( env, JAFSADMCLASSNOTFOUND );
503 user_ptsField = (*env)->GetFieldID( env, userCls, "pts", "Z" );
504 user_kasField = (*env)->GetFieldID( env, userCls, "kas", "Z" );
505 user_nameField = (*env)->GetFieldID( env, userCls, "name",
506 "Ljava/lang/String;" );
507 user_cachedInfoField = (*env)->GetFieldID( env, userCls, "cachedInfo",
510 user_nameUidField = (*env)->GetFieldID( env, userCls, "nameUID", "I" );
511 user_ownerUidField = (*env)->GetFieldID( env, userCls, "ownerUID", "I" );
512 user_creatorUidField = (*env)->GetFieldID( env, userCls, "creatorUID",
514 user_listStatusField = (*env)->GetFieldID( env, userCls, "listStatus",
516 user_listGroupsOwnedField = (*env)->GetFieldID( env, userCls,
517 "listGroupsOwned", "I" );
518 user_listMembershipField = (*env)->GetFieldID( env, userCls,
519 "listMembership", "I" );
520 user_groupCreationQuotaField = (*env)->GetFieldID( env, userCls,
521 "groupCreationQuota",
523 user_groupMembershipCountField = (*env)->GetFieldID( env, userCls,
524 "groupMembershipCount",
526 user_ownerField = (*env)->GetFieldID( env, userCls, "owner",
527 "Ljava/lang/String;" );
528 user_creatorField = (*env)->GetFieldID( env, userCls, "creator",
529 "Ljava/lang/String;" );
531 user_adminSettingField = (*env)->GetFieldID( env, userCls, "adminSetting",
533 user_tgsSettingField = (*env)->GetFieldID( env, userCls, "tgsSetting",
535 user_encSettingField = (*env)->GetFieldID( env, userCls, "encSetting",
537 user_cpwSettingField = (*env)->GetFieldID( env, userCls, "cpwSetting",
539 user_rpwSettingField = (*env)->GetFieldID( env, userCls, "rpwSetting",
541 user_userExpirationField = (*env)->GetFieldID( env, userCls,
542 "userExpiration", "I" );
543 user_lastModTimeField = (*env)->GetFieldID( env, userCls, "lastModTime",
545 user_lastModNameField = (*env)->GetFieldID( env, userCls, "lastModName",
546 "Ljava/lang/String;" );
547 user_lastChangePasswordTimeField = (*env)->GetFieldID( env, userCls,
548 "lastChangePasswordTime",
550 user_maxTicketLifetimeField = (*env)->GetFieldID( env, userCls,
553 user_keyVersionField = (*env)->GetFieldID( env, userCls, "keyVersion",
555 user_encryptionKeyField = (*env)->GetFieldID( env, userCls,
557 "Ljava/lang/String;" );
558 user_keyCheckSumField = (*env)->GetFieldID( env, userCls, "keyCheckSum",
560 user_daysToPasswordExpireField = (*env)->GetFieldID( env, userCls,
561 "daysToPasswordExpire",
563 user_failLoginCountField = (*env)->GetFieldID( env, userCls,
564 "failLoginCount", "I" );
565 user_lockTimeField = (*env)->GetFieldID( env, userCls, "lockTime", "I" );
566 user_lockedUntilField = (*env)->GetFieldID( env, userCls, "lockedUntil",
568 if( !user_ptsField || !user_kasField || !user_nameField ||
569 !user_cachedInfoField || !user_nameUidField || !user_ownerUidField ||
570 !user_creatorUidField || !user_listStatusField ||
571 !user_listGroupsOwnedField || !user_listMembershipField ||
572 !user_groupCreationQuotaField || !user_groupMembershipCountField ||
573 !user_ownerField || !user_creatorField || !user_adminSettingField ||
574 !user_tgsSettingField || !user_encSettingField ||
575 !user_cpwSettingField || !user_rpwSettingField ||
576 !user_userExpirationField || !user_lastModTimeField ||
577 !user_lastModNameField || !user_lastChangePasswordTimeField ||
578 !user_maxTicketLifetimeField || !user_keyVersionField ||
579 !user_encryptionKeyField || !user_keyCheckSumField ||
580 !user_daysToPasswordExpireField || !user_failLoginCountField ||
581 !user_lockTimeField || !user_lockedUntilField ) {
583 throwAFSException( env, JAFSADMFIELDNOTFOUND );
591 * Given a Java environment and an instance of a group, gets the object and
592 * field information for the group object from the Java environment.
594 void internal_getGroupClass( JNIEnv *env, jobject group ) {
595 if( groupCls == 0 ) {
596 groupCls = (*env)->NewGlobalRef( env, (*env)->GetObjectClass(env, group) );
598 throwAFSException( env, JAFSADMCLASSNOTFOUND );
601 group_nameField = (*env)->GetFieldID( env, groupCls, "name",
602 "Ljava/lang/String;" );
603 group_cachedInfoField = (*env)->GetFieldID( env, groupCls, "cachedInfo",
605 group_nameUidField = (*env)->GetFieldID( env, groupCls, "nameUID", "I" );
606 group_ownerUidField = (*env)->GetFieldID( env, groupCls, "ownerUID", "I" );
607 group_creatorUidField = (*env)->GetFieldID( env, groupCls, "creatorUID",
609 group_listStatusField = (*env)->GetFieldID( env, groupCls, "listStatus",
611 group_listGroupsOwnedField = (*env)->GetFieldID( env, groupCls,
612 "listGroupsOwned", "I" );
613 group_listMembershipField = (*env)->GetFieldID( env, groupCls,
614 "listMembership", "I" );
615 group_listAddField = (*env)->GetFieldID( env, groupCls, "listAdd", "I" );
616 group_listDeleteField = (*env)->GetFieldID( env, groupCls, "listDelete",
618 group_membershipCountField = (*env)->GetFieldID( env, groupCls,
619 "membershipCount", "I" );
620 group_ownerField = (*env)->GetFieldID( env, groupCls, "owner",
621 "Ljava/lang/String;" );
622 group_creatorField = (*env)->GetFieldID( env, groupCls, "creator",
623 "Ljava/lang/String;" );
624 if( !group_nameField || !group_cachedInfoField || !group_nameUidField ||
625 !group_ownerUidField || !group_creatorUidField ||
626 !group_listStatusField || !group_listGroupsOwnedField ||
627 !group_listMembershipField || !group_listAddField ||
628 !group_listDeleteField || !group_membershipCountField ||
629 !group_ownerField || !group_creatorField ) {
631 throwAFSException( env, JAFSADMFIELDNOTFOUND );
639 * Given a Java environment and an instance of a server, gets the object and
640 * field information for the server object from the Java environment.
642 void internal_getServerClass( JNIEnv *env, jobject server ) {
643 if( serverCls == 0 ) {
644 serverCls = (*env)->NewGlobalRef( env,
645 (*env)->GetObjectClass(env, server) );
647 throwAFSException( env, JAFSADMCLASSNOTFOUND );
650 server_nameField = (*env)->GetFieldID( env, serverCls, "name",
651 "Ljava/lang/String;" );
652 server_cachedInfoField = (*env)->GetFieldID( env, serverCls, "cachedInfo",
654 server_databaseField = (*env)->GetFieldID( env, serverCls, "database",
656 server_fileServerField = (*env)->GetFieldID( env, serverCls, "fileServer",
658 server_badDatabaseField = (*env)->GetFieldID( env, serverCls,
659 "badDatabase", "Z" );
660 server_badFileServerField = (*env)->GetFieldID( env, serverCls,
661 "badFileServer", "Z" );
662 server_IPAddressField = (*env)->GetFieldID( env, serverCls, "ipAddresses",
663 "[Ljava/lang/String;" );
664 if( !server_nameField || !server_cachedInfoField || !server_databaseField
665 || !server_fileServerField || !server_badDatabaseField ||
666 !server_badFileServerField || !server_IPAddressField ) {
668 throwAFSException( env, JAFSADMFIELDNOTFOUND );
676 * Given a Java environment and an instance of an executableTime, gets the
677 * object and field information for the executableTime object from the
680 void internal_getExecTimeClass( JNIEnv *env, jobject exectime ) {
681 if( exectimeCls == 0 ) {
682 exectimeCls = (*env)->NewGlobalRef( env,
683 (*env)->GetObjectClass(env, exectime) );
685 throwAFSException( env, JAFSADMCLASSNOTFOUND );
688 exectime_HourField = (*env)->GetFieldID( env, exectimeCls, "hour", "S" );
689 exectime_MinField = (*env)->GetFieldID( env, exectimeCls, "minute",
691 exectime_SecField = (*env)->GetFieldID( env, exectimeCls, "second",
693 exectime_DayField = (*env)->GetFieldID( env, exectimeCls, "day", "S" );
694 exectime_NowField = (*env)->GetFieldID( env, exectimeCls, "now", "Z" );
695 exectime_NeverField = (*env)->GetFieldID( env, exectimeCls, "never", "Z" );
696 if( !exectime_HourField || !exectime_MinField || !exectime_SecField ||
697 !exectime_DayField || !exectime_NowField || !exectime_NeverField ) {
699 throwAFSException( env, JAFSADMFIELDNOTFOUND );
707 * Given a Java environment and an instance of a partition, gets the object and
708 * field information for the partition object from the Java environment.
710 void internal_getPartitionClass( JNIEnv *env, jobject partition ) {
711 if( partitionCls == 0 ) {
712 partitionCls = (*env)->NewGlobalRef( env,
713 (*env)->GetObjectClass(env, partition) );
714 if( !partitionCls ) {
715 throwAFSException( env, JAFSADMCLASSNOTFOUND );
718 partition_nameField = (*env)->GetFieldID( env, partitionCls, "name",
719 "Ljava/lang/String;" );
720 partition_deviceNameField = (*env)->GetFieldID( env, partitionCls,
722 "Ljava/lang/String;" );
723 partition_idField = (*env)->GetFieldID( env, partitionCls, "id", "I" );
724 partition_cachedInfoField = (*env)->GetFieldID( env, partitionCls,
726 partition_lockFileDescriptorField = (*env)->GetFieldID( env, partitionCls,
727 "lockFileDescriptor",
729 partition_totalSpaceField = (*env)->GetFieldID( env, partitionCls,
731 partition_totalFreeSpaceField = (*env)->GetFieldID( env, partitionCls,
732 "totalFreeSpace", "I");
733 if( !partition_nameField || !partition_cachedInfoField ||
734 !partition_idField || !partition_deviceNameField ||
735 !partition_lockFileDescriptorField || !partition_totalSpaceField ||
736 !partition_totalFreeSpaceField ) {
738 throwAFSException( env, JAFSADMFIELDNOTFOUND );
746 * Given a Java environment and an instance of a volume, gets the object and
747 * field information for the volume object from the Java environment.
749 void internal_getVolumeClass( JNIEnv *env, jobject volume ) {
750 if( volumeCls == 0 ) {
751 volumeCls = (*env)->NewGlobalRef( env,
752 (*env)->GetObjectClass(env, volume) );
754 throwAFSException( env, JAFSADMCLASSNOTFOUND );
757 volume_nameField = (*env)->GetFieldID( env, volumeCls, "name",
758 "Ljava/lang/String;" );
759 volume_cachedInfoField = (*env)->GetFieldID( env, volumeCls, "cachedInfo",
761 volume_idField = (*env)->GetFieldID( env, volumeCls, "id", "I" );
762 volume_readWriteIdField = (*env)->GetFieldID( env, volumeCls,
763 "readWriteID", "I" );
764 volume_readOnlyIdField = (*env)->GetFieldID( env, volumeCls, "readOnlyID",
766 volume_backupIdField = (*env)->GetFieldID( env, volumeCls, "backupID",
768 volume_creationDateField = (*env)->GetFieldID( env, volumeCls,
769 "creationDate", "J" );
770 volume_lastAccessDateField = (*env)->GetFieldID( env, volumeCls,
771 "lastAccessDate", "J" );
772 volume_lastUpdateDateField = (*env)->GetFieldID( env, volumeCls,
773 "lastUpdateDate", "J" );
774 volume_lastBackupDateField = (*env)->GetFieldID( env, volumeCls,
775 "lastBackupDate", "J" );
776 volume_copyCreationDateField = (*env)->GetFieldID( env, volumeCls,
779 volume_accessesSinceMidnightField = (*env)->GetFieldID( env, volumeCls,
780 "accessesSinceMidnight",
782 volume_fileCountField = (*env)->GetFieldID( env, volumeCls, "fileCount",
784 volume_maxQuotaField = (*env)->GetFieldID( env, volumeCls, "maxQuota",
786 volume_currentSizeField = (*env)->GetFieldID( env, volumeCls,
787 "currentSize", "I" );
788 volume_statusField = (*env)->GetFieldID( env, volumeCls, "status", "I" );
789 volume_dispositionField = (*env)->GetFieldID( env, volumeCls,
790 "disposition", "I" );
791 volume_typeField = (*env)->GetFieldID( env, volumeCls, "type", "I" );
792 if( !volume_nameField || !volume_cachedInfoField || !volume_idField ||
793 !volume_readWriteIdField || !volume_readOnlyIdField ||
794 !volume_backupIdField || !volume_creationDateField ||
795 !volume_lastAccessDateField || !volume_lastUpdateDateField ||
796 !volume_lastBackupDateField || !volume_copyCreationDateField ||
797 !volume_accessesSinceMidnightField || !volume_fileCountField ||
798 !volume_maxQuotaField || !volume_currentSizeField ||
799 !volume_statusField || !volume_dispositionField ||
800 !volume_typeField ) {
802 throwAFSException( env, JAFSADMFIELDNOTFOUND );
810 * Given a Java environment and an instance of a key, gets the object and
811 * field information for the key object from the Java environment.
813 void internal_getKeyClass( JNIEnv *env, jobject key ) {
815 keyCls = (*env)->NewGlobalRef( env, (*env)->GetObjectClass(env, key) );
817 throwAFSException( env, JAFSADMCLASSNOTFOUND );
820 key_encryptionKeyField = (*env)->GetFieldID( env, keyCls,
822 "Ljava/lang/String;" );
823 key_cachedInfoField = (*env)->GetFieldID( env, keyCls, "cachedInfo", "Z" );
824 key_versionField = (*env)->GetFieldID( env, keyCls, "version", "I" );
825 key_lastModDateField = (*env)->GetFieldID( env, keyCls, "lastModDate",
827 key_lastModMsField = (*env)->GetFieldID( env, keyCls, "lastModMs", "I" );
828 key_checkSumField = (*env)->GetFieldID( env, keyCls, "checkSum", "J" );
829 if( !key_cachedInfoField || !key_versionField || !key_encryptionKeyField
830 || !key_lastModDateField || !key_lastModMsField ||
831 !key_checkSumField ) {
833 throwAFSException( env, JAFSADMFIELDNOTFOUND );
841 * Given a Java environment and an instance of a process, gets the object and
842 * field information for the process object from the Java environment.
844 void internal_getProcessClass( JNIEnv *env, jobject process ) {
845 if( processCls == 0 ) {
846 processCls = (*env)->NewGlobalRef( env,
847 (*env)->GetObjectClass(env, process) );
849 throwAFSException( env, JAFSADMCLASSNOTFOUND );
852 process_cachedInfoField = (*env)->GetFieldID( env, processCls,
854 process_nameField = (*env)->GetFieldID( env, processCls, "name",
855 "Ljava/lang/String;" );
856 process_typeField = (*env)->GetFieldID( env, processCls, "type", "I" );
857 process_stateField = (*env)->GetFieldID( env, processCls, "state", "I" );
858 process_goalField = (*env)->GetFieldID( env, processCls, "goal", "I" );
859 process_startTimeField = (*env)->GetFieldID( env, processCls, "startTime",
861 process_numberStartsField = (*env)->GetFieldID( env, processCls,
862 "numberStarts", "J" );
863 process_exitTimeField = (*env)->GetFieldID( env, processCls, "exitTime",
865 process_exitErrorTimeField = (*env)->GetFieldID( env, processCls,
866 "exitErrorTime", "J" );
867 process_errorCodeField = (*env)->GetFieldID( env, processCls, "errorCode",
869 process_errorSignalField = (*env)->GetFieldID( env, processCls,
870 "errorSignal", "J" );
871 process_stateOkField = (*env)->GetFieldID( env, processCls, "stateOk",
873 process_stateTooManyErrorsField = (*env)->GetFieldID( env, processCls,
874 "stateTooManyErrors",
876 process_stateBadFileAccessField = (*env)->GetFieldID( env, processCls,
877 "stateBadFileAccess",
879 if( !process_cachedInfoField || !process_nameField || !process_typeField
880 || !process_stateField || !process_goalField ||
881 !process_startTimeField || !process_numberStartsField ||
882 !process_exitTimeField || !process_exitErrorTimeField ||
883 !process_errorCodeField || !process_errorSignalField ||
884 !process_stateOkField || !process_stateTooManyErrorsField ||
885 !process_stateBadFileAccessField ) {
887 throwAFSException( env, JAFSADMFIELDNOTFOUND );
894 #endif /* LIBJUAFS */