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.
23 #include "org_openafs_jafs_Cell.h"
26 #include <afs_kasAdmin.h>
27 #include <afs_ptsAdmin.h>
28 #include <afs_clientAdmin.h>
32 #include <afs_AdminPtsErrors.h>
33 #include <afs_AdminClientErrors.h>
34 #include <afs_AdminCommonErrors.h>
36 //// definitions in Internal.c //////////////////
38 extern jclass userCls
;
39 //extern jfieldID user_cellHandleField;
40 extern jfieldID user_nameField
;
41 extern jfieldID user_cachedInfoField
;
43 extern jclass groupCls
;
44 //extern jfieldID group_cellHandleField;
45 extern jfieldID group_nameField
;
46 extern jfieldID group_cachedInfoField
;
48 extern jclass serverCls
;
49 //extern jfieldID server_cellHandleField;
50 extern jfieldID server_cachedInfoField
;
52 //////////////////////////////////////////////////////////
54 ///// definition in jafs_User.c /////////////////
56 extern void getUserInfoChar (JNIEnv
*env
, void *cellHandle
, const char *name
,
59 ///////////////////////////////////////////////////
61 ///// definition in jafs_Group.c /////////////////
63 extern void getGroupInfoChar (JNIEnv
*env
, void *cellHandle
, const char *name
,
66 ///////////////////////////////////////////////////
68 ///// definition in jafs_Server.c /////////////////
70 extern void fillServerInfo (JNIEnv
*env
, void *cellHandle
, jobject server
,
71 afs_serverEntry_t servEntry
);
73 ///////////////////////////////////////////////////
76 * Returns the total number of KAS users belonging to the cell denoted
79 * env the Java environment
80 * cls the current Java class
81 * cellHandle the handle of the cell to which the users belong
82 * returns total count of KAS users
84 JNIEXPORT jint JNICALL
85 Java_org_openafs_jafs_Cell_getKasUserCount (JNIEnv
*env
, jclass cls
,
93 if( !kas_PrincipalGetBegin( (void *) cellHandle
, NULL
,
94 &iterationId
, &ast
) ) {
95 throwAFSException( env
, ast
);
99 while ( kas_PrincipalGetNext( iterationId
, &who
, &ast
) ) i
++;
101 if( ast
!= ADMITERATORDONE
) {
102 throwAFSException( env
, ast
);
111 * Begin the process of getting the kas users that belong to the cell.
112 * Returns an iteration ID to be used by subsequent calls to
113 * getKasUsersNextString (or getKasUsersNext)
114 * and getKasUsersDone.
116 * env the Java environment
117 * cls the current Java class
118 * cellHandle the handle of the cell to which the users belong
119 * returns an iteration ID
121 JNIEXPORT jlong JNICALL
122 Java_org_openafs_jafs_Cell_getKasUsersBegin (JNIEnv
*env
, jclass cls
,
128 if( !kas_PrincipalGetBegin( (void *) cellHandle
, NULL
, &iterationId
,
130 throwAFSException( env
, ast
);
134 return (jlong
) iterationId
;
139 * Begin the process of getting the KAS users, starting at
140 * startIndex, that belong to the cell.
141 * Returns an iteration ID to be used by subsequent calls to
142 * getKasUsersNextString (or getKasUsersNext)
143 * and getKasUsersDone.
145 * env the Java environment
146 * cls the current Java class
147 * cellHandle the handle of the cell to which the users belong
148 * startIndex the starting base-zero index
149 * returns an iteration ID
151 JNIEXPORT jlong JNICALL
152 Java_org_openafs_jafs_Cell_getKasUsersBeginAt (JNIEnv
*env
, jclass cls
,
161 if( !kas_PrincipalGetBegin( (void *) cellHandle
, NULL
,
162 &iterationId
, &ast
) ) {
163 throwAFSException( env
, ast
);
167 for ( i
= 1; i
< startIndex
; i
++) {
168 if( !kas_PrincipalGetNext( (void *) iterationId
, &who
, &ast
) ) {
169 if( ast
== ADMITERATORDONE
) {
172 throwAFSException( env
, ast
);
178 return (jlong
) iterationId
;
183 * Returns the next kas user of the cell. Returns null if there
184 * are no more users. Appends instance names to principal names as follows:
187 * env the Java environment
188 * cls the current Java class
189 * iterationId the iteration ID of this iteration
190 * returns the name of the next user of the cell
192 JNIEXPORT jstring JNICALL
193 Java_org_openafs_jafs_Cell_getKasUsersNextString (JNIEnv
*env
, jclass cls
,
200 if( !kas_PrincipalGetNext( (void *) iterationId
, &who
, &ast
) ) {
201 if( ast
== ADMITERATORDONE
) {
205 throwAFSException( env
, ast
);
210 if( strcmp( who
.instance
, "" ) ) {
211 char *fullName
= malloc( sizeof(char)*( strlen( who
.principal
) +
212 strlen( who
.instance
) + 2 ) );
214 throwAFSException( env
, JAFSADMNOMEM
);
218 strcat( fullName
, who
.principal
);
219 strcat( fullName
, "." );
220 strcat( fullName
, who
.instance
);
221 juser
= (*env
)->NewStringUTF(env
, fullName
);
224 juser
= (*env
)->NewStringUTF(env
, who
.principal
);
232 * Fills the next kas user object of the cell. Returns 0 if there
233 * are no more users, != 0 otherwise.
235 * env the Java environment
236 * cls the current Java class
237 * cellHandle the handle of the cell to which the users belong
238 * iterationId the iteration ID of this iteration
239 * juserObject a User object to be populated with the values of
241 * returns 0 if there are no more users, != 0 otherwise
243 JNIEXPORT jint JNICALL
244 Java_org_openafs_jafs_Cell_getKasUsersNext (JNIEnv
*env
, jclass cls
,
247 jobject juserObject
) {
252 char *fullName
= NULL
;
255 if( !kas_PrincipalGetNext( (void *) iterationId
, &who
, &ast
) ) {
256 if( ast
== ADMITERATORDONE
) {
260 throwAFSException( env
, ast
);
265 // take care of the instance stuff(by concatenating with a period in between)
266 if( strcmp( who
.instance
, "" ) ) {
267 fullName
= malloc( sizeof(char)*( strlen( who
.principal
) +
268 strlen( who
.instance
) + 2 ) );
270 throwAFSException( env
, JAFSADMNOMEM
);
274 strcat( fullName
, who
.principal
);
275 strcat( fullName
, "." );
276 strcat( fullName
, who
.instance
);
277 juser
= (*env
)->NewStringUTF(env
, fullName
);
279 juser
= (*env
)->NewStringUTF(env
, who
.principal
);
283 internal_getUserClass( env
, juserObject
);
286 (*env
)->SetObjectField(env
, juserObject
, user_nameField
, juser
);
288 if( fullName
!= NULL
) {
289 getUserInfoChar( env
, (void *) cellHandle
, fullName
, juserObject
);
292 getUserInfoChar( env
, (void *) cellHandle
, who
.principal
, juserObject
);
294 (*env
)->SetBooleanField( env
, juserObject
, user_cachedInfoField
, TRUE
);
301 * Signals that the iteration is complete and will not be accessed anymore.
303 * env the Java environment
304 * cls the current Java class
305 * iterationId the iteration ID of this iteration
307 JNIEXPORT
void JNICALL
308 Java_org_openafs_jafs_Cell_getKasUsersDone (JNIEnv
*env
, jclass cls
,
313 if( !kas_PrincipalGetDone( (void *) iterationId
, &ast
) ) {
314 throwAFSException( env
, ast
);
321 * Returns the name of the cell.
323 * env the Java environment
324 * cls the current Java class
325 * cellHandle the handle of the cell to which the user belongs
326 * returns the name of the cell
328 JNIEXPORT jstring JNICALL
329 Java_org_openafs_jafs_Cell_getCellName (JNIEnv
*env
, jclass cls
,
336 if( !afsclient_CellNameGet( (void *) cellHandle
,
337 (const char **) &cellName
, &ast
) ) {
338 throwAFSException( env
, ast
);
342 jcellName
= (*env
)->NewStringUTF(env
, cellName
);
349 * Returns the total number of PTS users belonging to the cell denoted
352 * env the Java environment
353 * cls the current Java class
354 * cellHandle the handle of the cell to which the users belong
355 * returns total number of PTS users
357 JNIEXPORT jint JNICALL
358 Java_org_openafs_jafs_Cell_getPtsUserCount (JNIEnv
*env
, jclass cls
,
366 if( !pts_UserListBegin( (void *) cellHandle
, &iterationId
, &ast
) ) {
367 throwAFSException( env
, ast
);
371 userName
= malloc( sizeof(char)*PTS_MAX_NAME_LEN
);
374 throwAFSException( env
, JAFSADMNOMEM
);
378 while ( pts_UserListNext( (void *) iterationId
, userName
, &ast
) ) i
++;
382 if( ast
!= ADMITERATORDONE
) {
383 throwAFSException( env
, ast
);
391 * Returns the total number of PTS users, belonging to the cell denoted
392 * by cellHandle, that are not in KAS.
394 * env the Java environment
395 * cls the current Java class
396 * cellHandle the handle of the cell to which the users belong
397 * returns total number of users that are in PTS and not KAS
399 JNIEXPORT jint JNICALL
400 Java_org_openafs_jafs_Cell_getPtsOnlyUserCount (JNIEnv
*env
, jclass cls
,
405 kas_identity_p who
= (kas_identity_p
) malloc( sizeof(kas_identity_t
) );
406 kas_principalEntry_t kasEntry
;
411 throwAFSException( env
, JAFSADMNOMEM
);
415 if( !pts_UserListBegin( (void *) cellHandle
, &iterationId
, &ast
) ) {
417 throwAFSException( env
, ast
);
421 userName
= malloc( sizeof(char)*PTS_MAX_NAME_LEN
);
425 throwAFSException( env
, JAFSADMNOMEM
);
429 while ( pts_UserListNext( (void *) iterationId
, userName
, &ast
) ) {
430 if( strcmp( userName
, "anonymous" ) != 0 ) {
431 // make sure the name is within the allowed bounds
432 if( strlen( userName
) > KAS_MAX_NAME_LEN
) {
435 throwAFSException( env
, ADMPTSUSERNAMETOOLONG
);
439 // if there is a kas entry, recurse
440 internal_makeKasIdentity( userName
, who
);
441 if( !kas_PrincipalGet( (void *) cellHandle
, NULL
, who
,
442 &kasEntry
, &ast
) ) i
++;
449 if( ast
!= ADMITERATORDONE
) {
450 throwAFSException( env
, ast
);
458 * Begin the process of getting the pts users that belong to the cell.
459 * Returns an iteration ID to be used by subsequent calls to
460 * getPtsUsersNextString (or getPtsUsersNext)
461 * and getPtsUsersDone.
463 * env the Java environment
464 * cls the current Java class
465 * cellHandle the handle of the cell to which the users belong
466 * returns an iteration ID
468 JNIEXPORT jlong JNICALL
469 Java_org_openafs_jafs_Cell_getPtsUsersBegin (JNIEnv
*env
, jclass cls
,
475 if( !pts_UserListBegin( (void *) cellHandle
, &iterationId
, &ast
) ) {
476 throwAFSException( env
, ast
);
480 return (jlong
) iterationId
;
485 * Returns the next pts user of the cell. Returns null if
486 * there are no more users.
488 * env the Java environment
489 * cls the current Java class
490 * iterationId the iteration ID of this iteration
491 * returns the name of the next user of the cell
493 JNIEXPORT jstring JNICALL
494 Java_org_openafs_jafs_Cell_getPtsUsersNextString (JNIEnv
*env
, jclass cls
,
501 userName
= malloc( sizeof(char)*PTS_MAX_NAME_LEN
);
504 throwAFSException( env
, JAFSADMNOMEM
);
508 if( !pts_UserListNext( (void *) iterationId
, userName
, &ast
) ) {
510 if( ast
== ADMITERATORDONE
) {
513 throwAFSException( env
, ast
);
518 if( strcmp( userName
, "anonymous" ) == 0 ) {
520 return Java_org_openafs_jafs_Cell_getPtsUsersNextString( env
, cls
,
524 juser
= (*env
)->NewStringUTF(env
, userName
);
531 * Returns the next pts user (who is not a kas user) of the cell.
532 * Returns null if there are no more users.
534 * env the Java environment
535 * cls the current Java class
536 * iterationId the iteration ID of this iteration
537 * cellHandle the cell handle to which these users will belong
538 * returns the name of the next pts user (not kas user) of the cell
540 JNIEXPORT jstring JNICALL
541 Java_org_openafs_jafs_Cell_getPtsOnlyUsersNextString (JNIEnv
*env
,
546 kas_identity_p who
= (kas_identity_p
) malloc( sizeof(kas_identity_t
) );
547 kas_principalEntry_t kasEntry
;
553 throwAFSException( env
, JAFSADMNOMEM
);
557 userName
= malloc( sizeof(char)*PTS_MAX_NAME_LEN
);
561 throwAFSException( env
, JAFSADMNOMEM
);
567 if( !pts_UserListNext( (void *) iterationId
, userName
, &ast
) ) {
570 if( ast
== ADMITERATORDONE
) {
573 throwAFSException( env
, ast
);
578 if( strcmp( userName
, "anonymous" ) == 0 ) {
582 // make sure the name is within the allowed bounds
583 if( strlen( userName
) > KAS_MAX_NAME_LEN
) {
586 throwAFSException( env
, ADMPTSUSERNAMETOOLONG
);
590 // if there is a kas entry, recurse
591 internal_makeKasIdentity( userName
, who
);
592 if( kas_PrincipalGet( (void *) cellHandle
, NULL
, who
,
593 &kasEntry
, &ast
) ) {
597 juser
= (*env
)->NewStringUTF(env
, userName
);
607 * Fills the next pts user object of the cell. Returns 0 if there
608 * are no more users, != 0 otherwise.
610 * env the Java environment
611 * cls the current Java class
612 * cellHandle the handle of the cell to which the users belong
613 * iterationId the iteration ID of this iteration
614 * juserObject a User object to be populated with the values of
616 * returns 0 if there are no more users, != 0 otherwise
618 JNIEXPORT jint JNICALL
619 Java_org_openafs_jafs_Cell_getPtsUsersNext (JNIEnv
*env
, jclass cls
,
622 jobject juserObject
) {
628 userName
= malloc( sizeof(char)*PTS_MAX_NAME_LEN
);
631 throwAFSException( env
, JAFSADMNOMEM
);
635 if( !pts_UserListNext( (void *) iterationId
, userName
, &ast
) ) {
637 if( ast
== ADMITERATORDONE
) {
640 throwAFSException( env
, ast
);
645 if( strcmp( userName
, "anonymous" ) == 0 ) {
647 return Java_org_openafs_jafs_Cell_getPtsUsersNext( env
, cls
,
653 juser
= (*env
)->NewStringUTF(env
, userName
);
656 internal_getUserClass( env
, juserObject
);
659 (*env
)->SetObjectField(env
, juserObject
, user_nameField
, juser
);
661 getUserInfoChar( env
, (void *) cellHandle
, userName
, juserObject
);
662 (*env
)->SetBooleanField( env
, juserObject
, user_cachedInfoField
, TRUE
);
670 * Fills the next pts user (who does not have a kas entry) object of
671 * the cell. Returns 0 if there are no more users, != 0 otherwise.
673 * env the Java environment
674 * cls the current Java class
675 * cellHandle the handle of the cell to which the users belong
676 * iterationId the iteration ID of this iteration
677 * juserObject a User object to be populated with the values of
678 * the next pts (with no kas) user
679 * returns 0 if there are no more users, != 0 otherwise
681 JNIEXPORT jint JNICALL
682 Java_org_openafs_jafs_Cell_getPtsOnlyUsersNext (JNIEnv
*env
, jclass cls
,
685 jobject juserObject
) {
687 kas_identity_p who
= (kas_identity_p
) malloc( sizeof(kas_identity_t
) );
688 kas_principalEntry_t kasEntry
;
694 throwAFSException( env
, JAFSADMNOMEM
);
698 userName
= malloc( sizeof(char)*PTS_MAX_NAME_LEN
);
702 throwAFSException( env
, JAFSADMNOMEM
);
708 if( !pts_UserListNext( (void *) iterationId
, userName
, &ast
) ) {
711 if( ast
== ADMITERATORDONE
) {
714 throwAFSException( env
, ast
);
719 if( strcmp( userName
, "anonymous" ) == 0 ) {
723 // make sure the name is within the allowed bounds
724 if( strlen( userName
) > KAS_MAX_NAME_LEN
) {
727 throwAFSException( env
, ADMPTSUSERNAMETOOLONG
);
732 internal_getUserClass( env
, juserObject
);
736 // if there is a kas entry, recurse
737 internal_makeKasIdentity( userName
, who
);
738 if( kas_PrincipalGet( (void *) cellHandle
, NULL
, who
,
739 &kasEntry
, &ast
) ) {
743 juser
= (*env
)->NewStringUTF(env
, userName
);
745 (*env
)->SetObjectField(env
, juserObject
, user_nameField
, juser
);
746 getUserInfoChar( env
, (void *) cellHandle
, userName
, juserObject
);
747 (*env
)->SetBooleanField( env
, juserObject
, user_cachedInfoField
, TRUE
);
758 * Signals that the iteration is complete and will not be accessed anymore.
760 * env the Java environment
761 * cls the current Java class
762 * iterationId the iteration ID of this iteration
764 JNIEXPORT
void JNICALL
765 Java_org_openafs_jafs_Cell_getPtsUsersDone (JNIEnv
*env
, jclass cls
,
770 if( !pts_UserListDone( (void *) iterationId
, &ast
) ) {
771 throwAFSException( env
, ast
);
778 * Returns the total number of groups belonging to the cell denoted
781 * env the Java environment
782 * cls the current Java class
783 * cellHandle the handle of the cell to which the groups belong
784 * returns total number of groups
786 JNIEXPORT jint JNICALL
787 Java_org_openafs_jafs_Cell_getGroupCount (JNIEnv
*env
, jclass cls
,
795 if( !pts_GroupListBegin( (void *) cellHandle
, &iterationId
, &ast
) ) {
796 throwAFSException( env
, ast
);
800 groupName
= malloc( sizeof(char)*PTS_MAX_NAME_LEN
);
803 throwAFSException( env
, JAFSADMNOMEM
);
807 while ( pts_GroupListNext( (void *) iterationId
, groupName
, &ast
) ) i
++;
811 if( ast
!= ADMITERATORDONE
) {
812 throwAFSException( env
, ast
);
820 * Begin the process of getting the groups that belong to the cell. Returns
821 * an iteration ID to be used by subsequent calls to
822 * getGroupsNextString (or getGroupsNext) and
825 * env the Java environment
826 * cls the current Java class
827 * cellHandle the handle of the cell to which the groups belong
828 * returns an iteration ID
830 JNIEXPORT jlong JNICALL
831 Java_org_openafs_jafs_Cell_getGroupsBegin (JNIEnv
*env
, jclass cls
,
837 if( !pts_GroupListBegin( (void *) cellHandle
, &iterationId
, &ast
) ) {
838 throwAFSException( env
, ast
);
842 return (jlong
) iterationId
;
847 * Begin the process of getting the groups that belong to the cell, starting
848 * with element index startIndex. Returns an iteration ID to
849 * be used by subsequent calls to getGroupsNextString
850 * (or getGroupsNext) and getGroupsDone.
852 * env the Java environment
853 * cls the current Java class
854 * cellHandle the handle of the cell to which the groups belong
855 * startIndex the starting base-zero index
856 * returns an iteration ID
858 JNIEXPORT jlong JNICALL
859 Java_org_openafs_jafs_Cell_getGroupsBeginAt (JNIEnv
*env
, jclass cls
,
868 groupName
= malloc( sizeof(char)*PTS_MAX_NAME_LEN
);
870 if( !pts_GroupListBegin( (void *) cellHandle
, &iterationId
, &ast
) ) {
871 throwAFSException( env
, ast
);
875 for ( i
= 1; i
< startIndex
; i
++) {
876 if( !pts_GroupListNext( (void *) iterationId
, groupName
, &ast
) ) {
878 if( ast
== ADMITERATORDONE
) {
881 throwAFSException( env
, ast
);
888 return (jlong
) iterationId
;
893 * Returns the next group of the cell. Returns null if there
894 * are no more groups.
896 * env the Java environment
897 * cls the current Java class
898 * iterationId the iteration ID of this iteration
899 * returns the name of the next user of the cell
901 JNIEXPORT jstring JNICALL
902 Java_org_openafs_jafs_Cell_getGroupsNextString (JNIEnv
*env
, jclass cls
,
909 groupName
= malloc( sizeof(char)*PTS_MAX_NAME_LEN
);
912 throwAFSException( env
, JAFSADMNOMEM
);
916 if( !pts_GroupListNext( (void *) iterationId
, groupName
, &ast
) ) {
918 if( ast
== ADMITERATORDONE
) {
921 throwAFSException( env
, ast
);
926 jgroup
= (*env
)->NewStringUTF(env
, groupName
);
933 * Fills the next group object of the cell. Returns 0 if there
934 * are no more groups, != 0 otherwise.
936 * env the Java environment
937 * cls the current Java class
938 * cellHandle the handle of the cell to which the users belong
939 * iterationId the iteration ID of this iteration
940 * jgroupObject a Group object to be populated with the values of
942 * returns 0 if there are no more users, != 0 otherwise
944 JNIEXPORT jint JNICALL
945 Java_org_openafs_jafs_Cell_getGroupsNext (JNIEnv
*env
, jclass cls
,
948 jobject jgroupObject
) {
954 groupName
= malloc( sizeof(char)*PTS_MAX_NAME_LEN
);
957 throwAFSException( env
, JAFSADMNOMEM
);
961 if( !pts_GroupListNext( (void *) iterationId
, groupName
, &ast
) ) {
963 if( ast
== ADMITERATORDONE
) {
966 throwAFSException( env
, ast
);
971 jgroup
= (*env
)->NewStringUTF(env
, groupName
);
973 if( groupCls
== 0 ) {
974 internal_getGroupClass( env
, jgroupObject
);
977 (*env
)->SetObjectField(env
, jgroupObject
, group_nameField
, jgroup
);
978 getGroupInfoChar( env
, (void *)cellHandle
, groupName
, jgroupObject
);
979 (*env
)->SetBooleanField( env
, jgroupObject
, group_cachedInfoField
, TRUE
);
987 * Signals that the iteration is complete and will not be accessed anymore.
989 * env the Java environment
990 * cls the current Java class
991 * iterationId the iteration ID of this iteration
993 JNIEXPORT
void JNICALL
994 Java_org_openafs_jafs_Cell_getGroupsDone (JNIEnv
*env
, jclass cls
,
999 if( !pts_GroupListDone( (void *) iterationId
, &ast
) ) {
1000 throwAFSException( env
, ast
);
1007 * Gets the maximum group pts ID that's been used within a cell.
1008 * The next auto-assigned group ID will be one less (more negative)
1011 * env the Java environment
1012 * cls the current Java class
1013 * cellHandle the handle of the cell to which the group belongs
1014 * returns an integer reresenting the max group id in a cell
1016 JNIEXPORT jint JNICALL
1017 Java_org_openafs_jafs_Cell_getMaxGroupID (JNIEnv
*env
, jclass cls
,
1023 if( !pts_GroupMaxGet( (void *) cellHandle
, &maxID
, &ast
) ) {
1024 throwAFSException( env
, ast
);
1033 * Sets the maximum group pts ID that's been used within a cell. The next
1034 * auto-assigned group ID will be one less (more negative) than this value.
1036 * env the Java environment
1037 * cls the current Java class
1038 * cellHandle the handle of the cell to which the group belongs
1039 * maxID an integer reresenting the new max group id in a cell
1041 JNIEXPORT
void JNICALL
1042 Java_org_openafs_jafs_Cell_setMaxGroupID (JNIEnv
*env
, jclass cls
,
1043 jlong cellHandle
, jint maxID
) {
1047 if( !pts_GroupMaxSet( (void *) cellHandle
, (int) maxID
, &ast
) ) {
1048 throwAFSException( env
, ast
);
1055 * Gets the maximum user pts ID that's been used within a cell.
1056 * The next auto-assigned user ID will be one greater (more positive)
1059 * env the Java environment
1060 * cls the current Java class
1061 * cellHandle the handle of the cell to which the user belongs
1062 * returns an integer reresenting the max user id in a cell
1064 JNIEXPORT jint JNICALL
1065 Java_org_openafs_jafs_Cell_getMaxUserID (JNIEnv
*env
, jclass cls
,
1071 if( !pts_UserMaxGet( (void *) cellHandle
, &maxID
, &ast
) ) {
1072 throwAFSException( env
, ast
);
1081 * Sets the maximum user pts ID that's been used within a cell. The next
1082 * auto-assigned user ID will be one greater (more positive) than this value.
1084 * env the Java environment
1085 * cls the current Java class
1086 * cellHandle the handle of the cell to which the user belongs
1087 * maxID an integer reresenting the new max user id in a cell
1089 JNIEXPORT
void JNICALL
1090 Java_org_openafs_jafs_Cell_setMaxUserID (JNIEnv
*env
, jclass cls
,
1091 jlong cellHandle
, jint maxID
) {
1095 if( !pts_UserMaxSet( (void *) cellHandle
, (int) maxID
, &ast
) ) {
1096 throwAFSException( env
, ast
);
1103 * Returns the total number of servers belonging to the cell denoted
1106 * env the Java environment
1107 * cls the current Java class
1108 * cellHandle the handle of the cell to which the servers belong
1109 * returns total number of servers
1111 JNIEXPORT jint JNICALL
1112 Java_org_openafs_jafs_Cell_getServerCount (JNIEnv
*env
, jclass cls
,
1117 afs_serverEntry_t servEntry
;
1120 if( !afsclient_AFSServerGetBegin( (void *) cellHandle
,
1121 &iterationId
, &ast
) ) {
1122 throwAFSException( env
, ast
);
1126 while ( afsclient_AFSServerGetNext( (void *) iterationId
,
1127 &servEntry
, &ast
) ) i
++;
1129 if( ast
!= ADMITERATORDONE
) {
1130 throwAFSException( env
, ast
);
1138 * Begin the process of getting the servers in the cell. Returns
1139 * an iteration ID to be used by subsequent calls to
1140 * getServersNextString and getServersDone.
1142 * env the Java environment
1143 * cls the current Java class
1144 * cellHandle the handle of the cell to which the servers belong
1145 * returns an iteration ID
1147 JNIEXPORT jlong JNICALL
1148 Java_org_openafs_jafs_Cell_getServersBegin (JNIEnv
*env
, jclass cls
,
1154 if( !afsclient_AFSServerGetBegin( (void *) cellHandle
,
1155 &iterationId
, &ast
) ) {
1156 throwAFSException( env
, ast
);
1160 return (jlong
) iterationId
;
1165 * Returns the next server of the cell. Returns null if there
1166 * are no more servers.
1168 * env the Java environment
1169 * cls the current Java class
1170 * iterationId the iteration ID of this iteration
1171 * returns the name of the next server of the cell
1173 JNIEXPORT jstring JNICALL
1174 Java_org_openafs_jafs_Cell_getServersNextString (JNIEnv
*env
, jclass cls
,
1175 jlong iterationId
) {
1179 afs_serverEntry_t servEntry
;
1181 if( !afsclient_AFSServerGetNext( (void *) iterationId
, &servEntry
, &ast
) ) {
1182 if( ast
== ADMITERATORDONE
) {
1185 throwAFSException( env
, ast
);
1190 jserver
= (*env
)->NewStringUTF(env
, "not_implemented"); /* psomogyi 20050514 */
1196 * Fills the next server object of the cell. Returns 0 if there are no
1197 * more servers, != 0 otherwise.
1199 * env the Java environment
1200 * cls the current Java class
1201 * cellHandle the handle of the cell to which the users belong
1202 * iterationId the iteration ID of this iteration
1203 * jserverObject a Server object to be populated with the values
1204 * of the next server
1205 * returns 0 if there are no more servers, != 0 otherwise
1207 JNIEXPORT jint JNICALL
1208 Java_org_openafs_jafs_Cell_getServersNext
1209 (JNIEnv
*env
, jclass cls
, jlong cellHandle
, jlong iterationId
,
1210 jobject jserverObject
)
1214 afs_serverEntry_t servEntry
;
1217 if( !afsclient_AFSServerGetNext( (void *) iterationId
, &servEntry
, &ast
) ) {
1218 if( ast
== ADMITERATORDONE
) {
1221 throwAFSException( env
, ast
);
1226 // get the class fields if need be
1227 if( serverCls
== 0 ) {
1228 internal_getServerClass( env
, jserverObject
);
1231 fillServerInfo( env
, (void *) cellHandle
, jserverObject
, servEntry
);
1233 (*env
)->SetBooleanField( env
, jserverObject
, server_cachedInfoField
, TRUE
);
1239 * Signals that the iteration is complete and will not be accessed anymore.
1241 * env the Java environment
1242 * cls the current Java class
1243 * iterationId the iteration ID of this iteration
1245 JNIEXPORT
void JNICALL
1246 Java_org_openafs_jafs_Cell_getServersDone
1247 (JNIEnv
*env
, jclass cls
, jlong iterationId
)
1251 if( !afsclient_AFSServerGetDone( (void *) iterationId
, &ast
) ) {
1252 throwAFSException( env
, ast
);
1259 * Creates a mount point for a volume within the file system.
1261 * env the Java environment
1262 * cls the current Java class
1263 * cellHandle the handle of the cell to which the user belongs
1264 * jdirectory the full path of the place in the AFS file system
1265 * at which to mount the volume
1266 * jvolumeName the name of the volume to mount
1267 * readWrite whether or not this is to be a readwrite mount point
1268 * forceCheck whether or not to check if this volume name exists
1270 JNIEXPORT
void JNICALL
1271 Java_org_openafs_jafs_Cell_createMountPoint (JNIEnv
*env
, jclass cls
,
1274 jstring jvolumeName
,
1276 jboolean forceCheck
) {
1279 const char *directory
;
1280 const char *volumeName
;
1284 if( jdirectory
!= NULL
) {
1285 directory
= (*env
)->GetStringUTFChars(env
, jdirectory
, 0);
1287 throwAFSException( env
, JAFSADMNOMEM
);
1293 if( jvolumeName
!= NULL
) {
1294 volumeName
= (*env
)->GetStringUTFChars(env
, jvolumeName
, 0);
1296 if( directory
!= NULL
) {
1297 (*env
)->ReleaseStringUTFChars(env
, jdirectory
, directory
);
1299 throwAFSException( env
, JAFSADMNOMEM
);
1313 check
= CHECK_VOLUME
;
1315 check
= DONT_CHECK_VOLUME
;
1318 if( !afsclient_MountPointCreate( (void *) cellHandle
, directory
,
1319 volumeName
, type
, check
, &ast
) ) {
1320 if( volumeName
!= NULL
) {
1321 (*env
)->ReleaseStringUTFChars(env
, jvolumeName
, volumeName
);
1323 if( directory
!= NULL
) {
1324 (*env
)->ReleaseStringUTFChars(env
, jdirectory
, directory
);
1326 throwAFSException( env
, ast
);
1330 if( volumeName
!= NULL
) {
1331 (*env
)->ReleaseStringUTFChars(env
, jvolumeName
, volumeName
);
1333 if( directory
!= NULL
) {
1334 (*env
)->ReleaseStringUTFChars(env
, jdirectory
, directory
);
1340 * Sets an ACL for a given place in the AFS file system.
1342 * env the Java environment
1343 * cls the current Java class
1344 * jdirectory the full path of the place in the AFS file system
1345 * for which to add an entry
1346 * jusername the name of the user or group for which to add an entry
1347 * read whether or not to allow read access to this user
1348 * write whether or not to allow write access to this user
1349 * lookup whether or not to allow lookup access to this user
1350 * delete whether or not to allow deletion access to this user
1351 * insert whether or not to allow insertion access to this user
1352 * lock whether or not to allow lock access to this user
1353 * admin whether or not to allow admin access to this user
1355 JNIEXPORT
void JNICALL
1356 Java_org_openafs_jafs_Cell_setACL (JNIEnv
*env
, jclass cls
,
1357 jstring jdirectory
, jstring juserName
,
1358 jboolean read
, jboolean write
,
1359 jboolean lookup
, jboolean
delete,
1360 jboolean insert
, jboolean lock
,
1364 const char *directory
;
1365 const char *userName
;
1369 if( !afsclient_Init( &ast
) ) {
1370 throwAFSException( env
, ast
);
1374 if( jdirectory
!= NULL
) {
1375 directory
= (*env
)->GetStringUTFChars(env
, jdirectory
, 0);
1377 throwAFSException( env
, JAFSADMNOMEM
);
1383 if( juserName
!= NULL
) {
1384 userName
= (*env
)->GetStringUTFChars(env
, juserName
, 0);
1386 if( directory
!= NULL
) {
1387 (*env
)->ReleaseStringUTFChars(env
, jdirectory
, directory
);
1389 throwAFSException( env
, JAFSADMNOMEM
);
1405 acl
.write
= NO_WRITE
;
1409 acl
.lookup
= LOOKUP
;
1411 acl
.lookup
= NO_LOOKUP
;
1417 acl
.del
= NO_DELETE
;
1421 acl
.insert
= INSERT
;
1423 acl
.insert
= NO_INSERT
;
1435 acl
.admin
= NO_ADMIN
;
1438 if( !afsclient_ACLEntryAdd( directory
, userName
, &acl
, &ast
) ) {
1439 if( userName
!= NULL
) {
1440 (*env
)->ReleaseStringUTFChars(env
, juserName
, userName
);
1442 if( directory
!= NULL
) {
1443 (*env
)->ReleaseStringUTFChars(env
, jdirectory
, directory
);
1445 throwAFSException( env
, ast
);
1449 if( userName
!= NULL
) {
1450 (*env
)->ReleaseStringUTFChars(env
, juserName
, userName
);
1452 if( directory
!= NULL
) {
1453 (*env
)->ReleaseStringUTFChars(env
, jdirectory
, directory
);
1458 // reclaim global memory used by this portion
1459 JNIEXPORT
void JNICALL
1460 Java_org_openafs_jafs_Cell_reclaimCellMemory (JNIEnv
*env
, jclass cls
) {