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_Volume.h"
25 #include <afs_vosAdmin.h>
26 #include <afs_AdminCommonErrors.h>
28 //// definitions in Internal.c //////////////////
30 extern jclass volumeCls
;
31 extern jfieldID volume_nameField
;
32 extern jfieldID volume_idField
;
33 extern jfieldID volume_readWriteIdField
;
34 extern jfieldID volume_readOnlyIdField
;
35 extern jfieldID volume_backupIdField
;
36 extern jfieldID volume_creationDateField
;
37 extern jfieldID volume_lastAccessDateField
;
38 extern jfieldID volume_lastUpdateDateField
;
39 extern jfieldID volume_lastBackupDateField
;
40 extern jfieldID volume_copyCreationDateField
;
41 extern jfieldID volume_accessesSinceMidnightField
;
42 extern jfieldID volume_fileCountField
;
43 extern jfieldID volume_maxQuotaField
;
44 extern jfieldID volume_currentSizeField
;
45 extern jfieldID volume_statusField
;
46 extern jfieldID volume_dispositionField
;
47 extern jfieldID volume_typeField
;
49 //////////////////////////////////////////////////////////
52 * Extract the information from the given volume entry and populate the
55 * env the Java environment
56 * volume the Volume object to populate with the info
57 * volEntry the container of the volume's information
59 extern void fillVolumeInfo( JNIEnv
*env
, jobject volume
,
60 vos_volumeEntry_t volEntry
) {
64 // get the class fields if need be
65 if( volumeCls
== 0 ) {
66 internal_getVolumeClass( env
, volume
);
69 // set name, just in case it was a completely blank object
70 jvolume
= (*env
)->NewStringUTF(env
, volEntry
.name
);
71 (*env
)->SetObjectField(env
, volume
, volume_nameField
, jvolume
);
73 (*env
)->SetIntField(env
, volume
, volume_idField
, volEntry
.id
);
74 (*env
)->SetIntField(env
, volume
, volume_readWriteIdField
,
75 volEntry
.readWriteId
);
76 (*env
)->SetIntField(env
, volume
, volume_readOnlyIdField
,
78 (*env
)->SetIntField(env
, volume
, volume_backupIdField
, volEntry
.backupId
);
79 (*env
)->SetLongField(env
, volume
, volume_creationDateField
,
80 volEntry
.creationDate
);
81 (*env
)->SetLongField(env
, volume
, volume_lastAccessDateField
,
82 volEntry
.lastAccessDate
);
83 (*env
)->SetLongField(env
, volume
, volume_lastUpdateDateField
,
84 volEntry
.lastUpdateDate
);
85 (*env
)->SetLongField(env
, volume
, volume_lastBackupDateField
,
86 volEntry
.lastBackupDate
);
87 (*env
)->SetLongField(env
, volume
, volume_copyCreationDateField
,
88 volEntry
.copyCreationDate
);
89 (*env
)->SetIntField(env
, volume
, volume_accessesSinceMidnightField
,
90 volEntry
.accessesSinceMidnight
);
91 (*env
)->SetIntField(env
, volume
, volume_fileCountField
, volEntry
.fileCount
);
92 (*env
)->SetIntField(env
, volume
, volume_maxQuotaField
, volEntry
.maxQuota
);
93 (*env
)->SetIntField(env
, volume
, volume_currentSizeField
,
94 volEntry
.currentSize
);
96 // set status variable
97 switch( volEntry
.status
) {
99 (*env
)->SetIntField(env
, volume
, volume_statusField
,
100 org_openafs_jafs_Volume_VOLUME_OK
);
103 (*env
)->SetIntField(env
, volume
, volume_statusField
,
104 org_openafs_jafs_Volume_VOLUME_SALVAGE
);
107 (*env
)->SetIntField(env
, volume
, volume_statusField
,
108 org_openafs_jafs_Volume_VOLUME_NO_VNODE
);
111 (*env
)->SetIntField(env
, volume
, volume_statusField
,
112 org_openafs_jafs_Volume_VOLUME_NO_VOL
);
115 (*env
)->SetIntField(env
, volume
, volume_statusField
,
116 org_openafs_jafs_Volume_VOLUME_VOL_EXISTS
);
119 (*env
)->SetIntField(env
, volume
, volume_statusField
,
120 org_openafs_jafs_Volume_VOLUME_NO_SERVICE
);
123 (*env
)->SetIntField(env
, volume
, volume_statusField
,
124 org_openafs_jafs_Volume_VOLUME_OFFLINE
);
127 (*env
)->SetIntField(env
, volume
, volume_statusField
,
128 org_openafs_jafs_Volume_VOLUME_ONLINE
);
131 (*env
)->SetIntField(env
, volume
, volume_statusField
,
132 org_openafs_jafs_Volume_VOLUME_DISK_FULL
);
135 (*env
)->SetIntField(env
, volume
, volume_statusField
,
136 org_openafs_jafs_Volume_VOLUME_OVER_QUOTA
);
139 (*env
)->SetIntField(env
, volume
, volume_statusField
,
140 org_openafs_jafs_Volume_VOLUME_BUSY
);
143 (*env
)->SetIntField(env
, volume
, volume_statusField
,
144 org_openafs_jafs_Volume_VOLUME_MOVED
);
147 throwAFSException( env
, volEntry
.status
);
150 // set disposition variable
151 switch( volEntry
.volumeDisposition
) {
153 (*env
)->SetIntField(env
, volume
, volume_dispositionField
,
154 org_openafs_jafs_Volume_VOLUME_OK
);
157 (*env
)->SetIntField(env
, volume
, volume_dispositionField
,
158 org_openafs_jafs_Volume_VOLUME_SALVAGE
);
161 (*env
)->SetIntField(env
, volume
, volume_dispositionField
,
162 org_openafs_jafs_Volume_VOLUME_NO_VNODE
);
165 (*env
)->SetIntField(env
, volume
, volume_dispositionField
,
166 org_openafs_jafs_Volume_VOLUME_NO_VOL
);
169 (*env
)->SetIntField(env
, volume
, volume_dispositionField
,
170 org_openafs_jafs_Volume_VOLUME_VOL_EXISTS
);
173 (*env
)->SetIntField(env
, volume
, volume_dispositionField
,
174 org_openafs_jafs_Volume_VOLUME_NO_SERVICE
);
177 (*env
)->SetIntField(env
, volume
, volume_dispositionField
,
178 org_openafs_jafs_Volume_VOLUME_OFFLINE
);
181 (*env
)->SetIntField(env
, volume
, volume_dispositionField
,
182 org_openafs_jafs_Volume_VOLUME_ONLINE
);
185 (*env
)->SetIntField(env
, volume
, volume_dispositionField
,
186 org_openafs_jafs_Volume_VOLUME_DISK_FULL
);
189 (*env
)->SetIntField(env
, volume
, volume_dispositionField
,
190 org_openafs_jafs_Volume_VOLUME_OVER_QUOTA
);
193 (*env
)->SetIntField(env
, volume
, volume_dispositionField
,
194 org_openafs_jafs_Volume_VOLUME_BUSY
);
197 (*env
)->SetIntField(env
, volume
, volume_dispositionField
,
198 org_openafs_jafs_Volume_VOLUME_MOVED
);
201 throwAFSException( env
, volEntry
.volumeDisposition
);
205 switch( volEntry
.type
) {
206 case VOS_READ_WRITE_VOLUME
:
207 (*env
)->SetIntField(env
, volume
, volume_typeField
,
208 org_openafs_jafs_Volume_VOLUME_TYPE_READ_WRITE
);
210 case VOS_READ_ONLY_VOLUME
:
211 (*env
)->SetIntField(env
, volume
, volume_typeField
,
212 org_openafs_jafs_Volume_VOLUME_TYPE_READ_ONLY
);
214 case VOS_BACKUP_VOLUME
:
215 (*env
)->SetIntField(env
, volume
, volume_typeField
,
216 org_openafs_jafs_Volume_VOLUME_TYPE_BACKUP
);
219 throwAFSException( env
, volEntry
.type
);
225 * Fills in the information fields of the provided Volume.
227 * env the Java environment
228 * cls the current Java class
229 * cellHandle the handle of the cell to which the volume belongs
230 * serverHandle the vos handle of the server on which the volume
232 * partition the numeric id of the partition on which the volume
234 * volId the numeric id of the volume for which to get the info
235 * jvolumeObject the Volume object in which to fill in
238 JNIEXPORT
void JNICALL
239 Java_org_openafs_jafs_Volume_getVolumeInfo (JNIEnv
*env
, jclass cls
,
242 jint partition
, jint volID
,
243 jobject jvolumeObject
) {
246 vos_volumeEntry_t volEntry
;
248 // get the volume entry
249 if ( !vos_VolumeGet( (void *) cellHandle
, (void *) serverHandle
, NULL
,
250 (unsigned int) partition
, (unsigned int) volID
,
251 &volEntry
, &ast
) ) {
252 throwAFSException( env
, ast
);
256 fillVolumeInfo( env
, jvolumeObject
, volEntry
);
261 * Creates a volume on a particular partition.
263 * env the Java environment
264 * cls the current Java class
265 * cellHandle the handle of the cell in which to create the volume
266 * serverHandle the vos handle of the server on which to create
268 * partition the numeric id of the partition on which to create
270 * jvolName the name of the volume to create
271 * quota the amount of space (in KB) to set as this volume's quota
272 * returns the numeric ID assigned to the volume
274 JNIEXPORT jint JNICALL
275 Java_org_openafs_jafs_Volume_create (JNIEnv
*env
, jclass cls
,
276 jlong cellHandle
, jlong serverHandle
,
277 jint partition
, jstring jvolName
,
284 if( jvolName
!= NULL
) {
285 volName
= (*env
)->GetStringUTFChars(env
, jvolName
, 0);
287 throwAFSException( env
, JAFSADMNOMEM
);
294 if( !vos_VolumeCreate( (void *) cellHandle
, (void *) serverHandle
, NULL
,
295 (unsigned int) partition
, volName
,
296 (unsigned int) quota
, &id
, &ast
) ) {
297 if( volName
!= NULL
) {
298 (*env
)->ReleaseStringUTFChars(env
, jvolName
, volName
);
300 throwAFSException( env
, ast
);
304 if( volName
!= NULL
) {
305 (*env
)->ReleaseStringUTFChars(env
, jvolName
, volName
);
312 * Deletes a volume from a particular partition.
314 * env the Java environment
315 * cls the current Java class
316 * cellHandle the handle of the cell in which to delete the volume
317 * serverHandle the vos handle of the server from which to delete
319 * partition the numeric id of the partition from which to delete
321 * volId the numeric id of the volume to delete
323 JNIEXPORT
void JNICALL
324 Java_org_openafs_jafs_Volume_delete (JNIEnv
*env
, jclass cls
,
325 jlong cellHandle
, jlong serverHandle
,
326 jint partition
, jint volID
) {
330 if( !vos_VolumeDelete( (void *) cellHandle
, (void *) serverHandle
, NULL
,
331 (unsigned int) partition
,
332 (unsigned int) volID
, &ast
) ) {
333 throwAFSException( env
, ast
);
340 * Creates a backup volume for the specified regular volume.
342 * env the Java environment
343 * cls the current Java class
344 * cellHandle the handle of the cell to which the volume belongs
345 * volId the numeric id of the volume for which to create a backup
348 JNIEXPORT
void JNICALL
349 Java_org_openafs_jafs_Volume_createBackupVolume (JNIEnv
*env
, jclass cls
,
355 if( !vos_BackupVolumeCreate( (void *) cellHandle
, NULL
,
356 (unsigned int) volID
, &ast
) ) {
357 throwAFSException( env
, ast
);
364 * Creates a read-only volume for the specified regular volume.
366 * env the Java environment
367 * cls the current Java class
368 * cellHandle the handle of the cell to which the volume belongs
369 * serverHandle the vos handle of the server on which the read-only
370 * volume is to reside
371 * partition the numeric id of the partition on which the read-only
372 * volume is to reside
373 * volId the numeric id of the volume for which to
374 * create a read-only volume
376 JNIEXPORT
void JNICALL
377 Java_org_openafs_jafs_Volume_createReadOnlyVolume (JNIEnv
*env
, jclass cls
,
385 if( !vos_VLDBReadOnlySiteCreate( (void *) cellHandle
, (void *) serverHandle
,
386 NULL
, (unsigned int) partition
,
387 (unsigned int) volID
, &ast
) ) {
388 throwAFSException( env
, ast
);
395 * Deletes a read-only volume for the specified regular volume.
397 * env the Java environment
398 * cls the current Java class
399 * cellHandle the handle of the cell to which the volume belongs
400 * serverHandle the vos handle of the server on which the read-only
402 * partition the numeric id of the partition on which the read-only
404 * volId the numeric read-write id of the volume for which to
405 * delete the read-only volume
407 JNIEXPORT
void JNICALL
408 Java_org_openafs_jafs_Volume_deleteReadOnlyVolume (JNIEnv
*env
, jclass cls
,
416 if( !vos_VLDBReadOnlySiteDelete( (void *) cellHandle
, (void *) serverHandle
,
417 NULL
, (unsigned int) partition
,
418 (unsigned int) volID
, &ast
) ) {
419 throwAFSException( env
, ast
);
426 * Changes the quota of the specified volume.
428 * env the Java environment
429 * cls the current Java class
430 * cellHandle the handle of the cell to which the volume belongs
431 * serverHandle the vos handle of the server on which the volume
433 * partition the numeric id of the partition on which the volume
435 * volId the numeric id of the volume for which to change the quota
436 * newQuota the new quota (in KB) to assign the volume
438 JNIEXPORT
void JNICALL
439 Java_org_openafs_jafs_Volume_changeQuota (JNIEnv
*env
, jclass cls
,
442 jint partition
, jint volID
,
447 if( !vos_VolumeQuotaChange( (void *) cellHandle
, (void *) serverHandle
,
448 NULL
, (unsigned int) partition
,
449 (unsigned int) volID
, (unsigned int) newQuota
,
451 throwAFSException( env
, ast
);
458 * Move the specified volume to a different site.
460 * env the Java environment
461 * cls the current Java class
462 * cellHandle the handle of the cell to which the volume belongs
463 * fromServerHandle the vos handle of the server on which the volume
465 * fromPartition the numeric id of the partition on which the volume
467 * toServerHandle the vos handle of the server to which the volume
469 * toPartition the numeric id of the partition to which the volume
471 * volId the numeric id of the volume to move
473 JNIEXPORT
void JNICALL
474 Java_org_openafs_jafs_Volume_move
475 (JNIEnv
*env
, jclass cls
, jlong cellHandle
, jlong fromServerHandle
,
476 jint fromPartition
, jlong toServerHandle
, jint toPartition
, jint volID
)
480 if( !vos_VolumeMove( (void *) cellHandle
, NULL
, (unsigned int) volID
,
481 (void *) fromServerHandle
, (unsigned int) fromPartition
,
482 (void *) toServerHandle
, (unsigned int) toPartition
,
484 throwAFSException( env
, ast
);
491 * Releases the specified volume that has readonly volume sites.
493 * env the Java environment
494 * cls the current Java class
495 * cellHandle the handle of the cell to which the volume belongs
496 * volId the numeric id of the volume to release
497 * forceComplete whether or not to force a complete release
499 JNIEXPORT
void JNICALL
500 Java_org_openafs_jafs_Volume_release
501 (JNIEnv
*env
, jclass cls
, jlong cellHandle
, jint volID
, jboolean forceComplete
)
506 if( forceComplete
) {
512 if( !vos_VolumeRelease( (void *) cellHandle
, NULL
, (unsigned int) volID
,
514 throwAFSException( env
, ast
);
521 * Dumps the specified volume to a file.
523 * env the Java environment
524 * cls the current Java class
525 * cellHandle the handle of the cell to which the volume belongs
526 * serverHandle the vos handle of the server on which the volume
528 * partition the numeric id of the partition on which the
530 * volId the numeric id of the volume to dump
531 * startTime files with a modification time >= to this time will
533 * jdumpFile the full path of the file to which to dump
535 JNIEXPORT
void JNICALL
536 Java_org_openafs_jafs_Volume_dump (JNIEnv
*env
, jclass cls
,
537 jlong cellHandle
, jlong serverHandle
,
538 jint partition
, jint volID
,
539 jint startTime
, jstring jdumpFile
) {
542 const char *dumpFile
;
544 if( jdumpFile
!= NULL
) {
545 dumpFile
= (*env
)->GetStringUTFChars(env
, jdumpFile
, 0);
547 throwAFSException( env
, JAFSADMNOMEM
);
554 if( !vos_VolumeDump( (void *) cellHandle
, (void *) serverHandle
, NULL
,
555 (unsigned int *) &partition
, (unsigned int) volID
,
556 (unsigned int) startTime
, dumpFile
, &ast
) ) {
557 if( dumpFile
!= NULL
) {
558 (*env
)->ReleaseStringUTFChars(env
, jdumpFile
, dumpFile
);
560 throwAFSException( env
, ast
);
564 if( dumpFile
!= NULL
) {
565 (*env
)->ReleaseStringUTFChars(env
, jdumpFile
, dumpFile
);
571 * Restores the specified volume from a dump file.
573 * env the Java environment
574 * cls the current Java class
575 * cellHandle the handle of the cell to which the volume belongs
576 * serverHandle the vos handle of the server on which the volume is
578 * partition the numeric id of the partition on which the volume is
580 * volId the numeric id to assign the restored volume (can be 0)
581 * jvolName the name of the volume to restore as
582 * jdumpFile the full path of the dump file from which to restore
583 * incremental if true, restores an incremental dump over an existing
584 * volume (server and partition values must correctly
585 * indicate the current position of the existing volume),
586 * otherwise restores a full dump
588 JNIEXPORT
void JNICALL
589 Java_org_openafs_jafs_Volume_restore (JNIEnv
*env
, jclass cls
,
590 jlong cellHandle
, jlong serverHandle
,
591 jint partition
, jint volID
,
592 jstring jvolName
, jstring jdumpFile
,
593 jboolean incremental
) {
597 const char *dumpFile
;
599 vos_volumeRestoreType_t vrt
;
601 if( jvolName
!= NULL
) {
602 volName
= (*env
)->GetStringUTFChars(env
, jvolName
, 0);
604 throwAFSException( env
, JAFSADMNOMEM
);
611 if( jdumpFile
!= NULL
) {
612 dumpFile
= (*env
)->GetStringUTFChars(env
, jdumpFile
, 0);
614 if( volName
!= NULL
) {
615 (*env
)->ReleaseStringUTFChars(env
, jvolName
, volName
);
617 throwAFSException( env
, JAFSADMNOMEM
);
627 volumeIDp
= (int *) &volID
;
631 vrt
= VOS_RESTORE_INCREMENTAL
;
633 vrt
= VOS_RESTORE_FULL
;
636 if( !vos_VolumeRestore( (void *) cellHandle
, (void *) serverHandle
, NULL
,
637 (unsigned int) partition
, (unsigned int *) volumeIDp
,
638 volName
, dumpFile
, vrt
, &ast
) ) {
639 if( volName
!= NULL
) {
640 (*env
)->ReleaseStringUTFChars(env
, jvolName
, volName
);
642 if( dumpFile
!= NULL
) {
643 (*env
)->ReleaseStringUTFChars(env
, jdumpFile
, dumpFile
);
645 throwAFSException( env
, ast
);
649 if( dumpFile
!= NULL
) {
650 (*env
)->ReleaseStringUTFChars(env
, jdumpFile
, dumpFile
);
652 if( volName
!= NULL
) {
653 (*env
)->ReleaseStringUTFChars(env
, jvolName
, volName
);
659 * Renames the specified read-write volume.
661 * env the Java environment
662 * cls the current Java class
663 * cellHandle the handle of the cell to which the volume belongs
664 * volId the numeric id of the read-write volume to rename
665 * jnewName the new name for the volume
667 JNIEXPORT
void JNICALL
668 Java_org_openafs_jafs_Volume_rename (JNIEnv
*env
, jclass cls
,
669 jlong cellHandle
, jint volID
,
675 if( jnewName
!= NULL
) {
676 newName
= (*env
)->GetStringUTFChars(env
, jnewName
, 0);
678 throwAFSException( env
, JAFSADMNOMEM
);
685 if( !vos_VolumeRename( (void *) cellHandle
, NULL
, (unsigned int) volID
,
687 if( newName
!= NULL
) {
688 (*env
)->ReleaseStringUTFChars(env
, jnewName
, newName
);
690 throwAFSException( env
, ast
);
694 if( newName
!= NULL
) {
695 (*env
)->ReleaseStringUTFChars(env
, jnewName
, newName
);
701 * "Mounts" the specified volume, bringing it online.
703 * env the Java environment
704 * cls the current Java class
705 * serverHandle the vos handle of the server on which the volume
707 * partition the numeric id of the partition on which the volume
709 * volId the numeric id of the volume to bring online
710 * sleepTime ? (not sure what this is yet, possibly a time to wait
711 * before brining it online)
712 * offline ? (not sure what this is either, probably the current
713 * status of the volume -- busy or offline)
715 JNIEXPORT
void JNICALL
716 Java_org_openafs_jafs_Volume_mount (JNIEnv
*env
, jclass cls
,
717 jlong serverHandle
, jint partition
,
718 jint volID
, jint sleepTime
,
722 vos_volumeOnlineType_t volumeStatus
;
725 volumeStatus
= VOS_ONLINE_OFFLINE
;
727 volumeStatus
= VOS_ONLINE_BUSY
;
730 if( !vos_VolumeOnline( (void *) serverHandle
, NULL
, (unsigned int) partition
,
731 (unsigned int) volID
, (unsigned int) sleepTime
,
732 volumeStatus
, &ast
) ) {
733 throwAFSException( env
, ast
);
740 * "Unmounts" the specified volume, bringing it offline.
742 * env the Java environment
743 * cls the current Java class
744 * serverHandle the vos handle of the server on which the volume
746 * partition the numeric id of the partition on which the volume
748 * volId the numeric id of the volume to bring offline
750 JNIEXPORT
void JNICALL
751 Java_org_openafs_jafs_Volume_unmount (JNIEnv
*env
, jclass cls
,
752 jlong serverHandle
, jint partition
,
757 if( !vos_VolumeOffline( (void *) serverHandle
, NULL
,
758 (unsigned int) partition
, (unsigned int) volID
,
760 throwAFSException( env
, ast
);
767 * Locks the VLDB entry specified volume
769 * env the Java environment
770 * cls the current Java class
771 * cellHandle the handle of the cell on which the volume resides
772 * volId the numeric id of the volume to lock
774 JNIEXPORT
void JNICALL
775 Java_org_openafs_jafs_Volume_lock (JNIEnv
*env
, jclass cls
,
776 jlong cellHandle
, jint volID
) {
780 if( !vos_VLDBEntryLock( (void *) cellHandle
, NULL
, (unsigned int) volID
,
782 throwAFSException( env
, ast
);
789 * Unlocks the VLDB entry of the specified volume
791 * env the Java environment
792 * cls the current Java class
793 * cellHandle the handle of the cell on which the volume resides
794 * volId the numeric id of the volume to unlock
796 JNIEXPORT
void JNICALL
797 Java_org_openafs_jafs_Volume_unlock (JNIEnv
*env
, jclass cls
,
798 jlong cellHandle
, jint volID
) {
802 if( !vos_VLDBEntryUnlock( (void *) cellHandle
, NULL
, (unsigned int) volID
,
804 throwAFSException( env
, ast
);
811 * Translates a volume name into a volume id
813 * env the Java environment
814 * cls the current Java class
815 * cellHandle the handle of the cell to which the volume belongs
816 * jname the name of the volume in question, cannot end in backup or
818 * type the type of volume: read-write, read-only, or backup.
819 * Acceptable values are:
820 * org_openafs_jafs_Volume_VOLUME_TYPE_READ_WRITE
821 * org_openafs_jafs_Volume_VOLUME_TYPE_READ_ONLY
822 * org_openafs_jafs_Volume_VOLUME_TYPE_BACKUP
823 * returns the id of the volume in question
825 JNIEXPORT jint JNICALL
826 Java_org_openafs_jafs_Volume_translateNameToID (JNIEnv
*env
, jclass cls
,
828 jstring jname
, jint type
) {
832 vos_vldbEntry_t vldbEntry
;
834 if( jname
!= NULL
) {
835 name
= (*env
)->GetStringUTFChars(env
, jname
, 0);
837 throwAFSException( env
, JAFSADMNOMEM
);
845 if( !vos_VLDBGet( (void *) cellHandle
, NULL
, NULL
, name
,
846 &vldbEntry
, &ast
) ) {
848 (*env
)->ReleaseStringUTFChars(env
, jname
, name
);
850 throwAFSException( env
, ast
);
855 (*env
)->ReleaseStringUTFChars(env
, jname
, name
);
858 if( type
== org_openafs_jafs_Volume_VOLUME_TYPE_READ_WRITE
) {
859 return vldbEntry
.volumeId
[VOS_READ_WRITE_VOLUME
];
860 } else if( type
== org_openafs_jafs_Volume_VOLUME_TYPE_READ_ONLY
) {
861 return vldbEntry
.volumeId
[VOS_READ_ONLY_VOLUME
];
863 return vldbEntry
.volumeId
[VOS_BACKUP_VOLUME
];
869 // reclaim global memory being used by this portion
870 JNIEXPORT
void JNICALL
871 Java_org_openafs_jafs_Volume_reclaimVolumeMemory (JNIEnv
*env
, jclass cls
) {
874 (*env
)->DeleteGlobalRef(env
, volumeCls
);