2 * Copyright 2000, International Business Machines Corporation and others.
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
10 #include <afs/param.h>
11 #include <afsconfig.h>
29 #include <sys/types.h>
30 #include <sys/socket.h>
32 #include <netinet/in.h>
33 #include <arpa/inet.h>
36 #include "afs_vosAdmin.h"
37 #include "../adminutil/afs_AdminInternal.h"
38 #include <afs/afs_utilAdmin.h>
39 #include <afs/vlserver.h>
40 #include <afs/volser.h>
41 #include <afs/volint.h>
42 #include <afs/partition.h>
46 #include "lockprocs.h"
48 extern int VL_GetAddrsU();
50 typedef struct file_server {
53 struct rx_connection *serv;
55 } file_server_t, *file_server_p;
58 * IsValidServerHandle - test a server handle for validity.
62 * IN serverHandle - the serverHandle to be validated.
66 * No locks are obtained or released by this function
70 * Returns != 0 upon successful completion.
73 static int IsValidServerHandle(
74 file_server_p serverHandle,
80 if (serverHandle == NULL) {
81 tst = ADMVOSSERVERHANDLENULL;
82 goto fail_IsValidServerHandle;
85 if (serverHandle->is_valid != 1) {
86 tst = ADMVOSSERVERHANDLEINVALID;
87 goto fail_IsValidServerHandle;
90 if ((serverHandle->begin_magic != BEGIN_MAGIC) ||
91 (serverHandle->end_magic != END_MAGIC)) {
92 tst = ADMVOSSERVERHANDLEBADMAGIC;
93 goto fail_IsValidServerHandle;
97 fail_IsValidServerHandle:
107 * IsValidCellHandle - verify that a cell handle can be used to make vos
112 * IN cellHandle - the cellHandle to be validated.
116 * No locks are obtained or released by this function
120 * Returns != 0 upon successful completion.
123 static int IsValidCellHandle(
124 afs_cell_handle_p cellHandle,
128 afs_status_t tst = 0;
130 if (!CellHandleIsValid((void *) cellHandle, &tst)) {
131 goto fail_IsValidCellHandle;
134 if (cellHandle->vos_valid == 0) {
135 tst = ADMVOSCELLHANDLEINVALIDVOS;
136 goto fail_IsValidCellHandle;
140 fail_IsValidCellHandle:
148 /* set <server> and <part> to the correct values depending on
149 * <voltype> and <entry> */
150 static void GetServerAndPart (
151 struct nvldbentry *entry,
157 int i, istart, vtype;
162 /* Doesn't check for non-existance of backup volume */
163 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
165 istart = 0; /* seach the entire entry */
168 /* Seach from beginning of entry or pick up where we left off */
169 istart = ((*previdx < 0) ? 0 : *previdx+1);
172 for (i = istart; i < entry->nServers; i++) {
173 if (entry->serverFlags[i] & vtype) {
174 *server = entry->serverNumber[i];
175 *part = entry->serverPartition[i];
181 /* Didn't find any, return -1 */
187 * vos_BackupVolumeCreate - create a backup volume for a volume.
191 * IN cellHandle - a previously opened cellHandle that corresponds
192 * to the cell where volume exists.
194 * IN callBack - a call back function pointer that may be called to report
195 * status information. Can be null.
197 * IN volumeId - the volume to create the back up for.
201 * No locks are obtained or released by this function
205 * Returns != 0 upon successful completion.
208 int ADMINAPI vos_BackupVolumeCreate(
209 const void *cellHandle,
210 vos_MessageCallBack_t callBack,
211 unsigned int volumeId,
215 afs_status_t tst = 0;
216 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
217 struct nvldbentry rw_vol_entry;
219 afs_int32 rw_partition;
220 afs_int32 rw_vol_type;
221 struct nvldbentry bk_vol_entry;
223 afs_int32 bk_partition;
224 afs_int32 bk_vol_type;
231 if (!IsValidCellHandle(c_handle, &tst)) {
232 goto fail_vos_BackupVolumeCreate;
236 * Get the volume information and verify that we've been passed
237 * a read write volume id
240 if (!GetVolumeInfo(c_handle, volumeId, &rw_vol_entry, &rw_server,
241 &rw_partition, &rw_vol_type, &tst)) {
242 goto fail_vos_BackupVolumeCreate;
245 if (rw_vol_type != RWVOL) {
246 tst = ADMVOSMUSTBERWVOL;
247 goto fail_vos_BackupVolumeCreate;
251 * Check to see that if a backup volume exists, it exists on the
252 * same server as volumeId
255 if (rw_vol_entry.flags & BACK_EXISTS) {
256 if (!GetVolumeInfo(c_handle, rw_vol_entry.volumeId[BACKVOL],
257 &bk_vol_entry, &bk_server, &bk_partition,
258 &bk_vol_type, &tst)) {
259 goto fail_vos_BackupVolumeCreate;
261 if (!VLDB_IsSameAddrs(c_handle, bk_server, rw_server, &equal, &tst)) {
262 goto fail_vos_BackupVolumeCreate;
265 tst = ADMVOSBACKUPVOLWRONGSERVER;
266 goto fail_vos_BackupVolumeCreate;
271 * Create the new backup volume
274 rc = UV_BackupVolume(c_handle, rw_server, rw_partition, volumeId, &tst);
276 fail_vos_BackupVolumeCreate:
285 * vos_BackupVolumeCreateMultiple - create backup volumes en masse.
289 * IN cellHandle - a previously opened cellHandle that corresponds
290 * to the cell where the volumes exist.
292 * IN serverHandle - the server where the backups are to be created. Can be
295 * IN callBack - a call back function pointer that may be called to report
296 * status information. Can be null.
298 * IN partition - the partition where the backups are to be created. Can be
301 * IN volumePrefix - all volumes with this prefix will have backup volumes
302 * created. Can be null.
304 * IN excludePrefix - exclude the volumes that match volumePrefix.
308 * No locks are obtained or released by this function
312 * Returns != 0 upon successful completion.
315 int ADMINAPI vos_BackupVolumeCreateMultiple(
316 const void *cellHandle,
317 const void *serverHandle,
318 vos_MessageCallBack_t callBack,
319 const unsigned int *partition,
320 const char *volumePrefix,
321 vos_exclude_t excludePrefix,
325 afs_status_t tst = 0;
326 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
327 file_server_p f_server = (file_server_p) serverHandle;
328 struct VldbListByAttributes attr;
331 size_t prefix_len = 0;
332 nbulkentries arrayEntries;
333 afs_int32 nentries = 0;
334 register struct nvldbentry *entry;
336 afs_int32 rw_volid, rw_server, rw_partition;
341 memset((void *) &attr, 0, sizeof(attr));
346 * The only required argument to this function is the cellHandle.
347 * If the excludePrefix is set to VOS_EXCLUDE, volumePrefix must
351 if (!IsValidCellHandle(c_handle, &tst)) {
352 goto fail_vos_BackupVolumeCreateMultiple;
355 if ((excludePrefix == VOS_EXCLUDE) &&
356 ((volumePrefix == NULL) || (*volumePrefix == 0))) {
357 tst = ADMVOSEXCLUDEREQUIRESPREFIX;
358 goto fail_vos_BackupVolumeCreateMultiple;
361 if (f_server != NULL) {
362 if (!IsValidServerHandle(f_server, &tst)) {
363 goto fail_vos_BackupVolumeCreateMultiple;
365 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
366 attr.Mask |= VLLIST_SERVER;
369 if (partition != NULL) {
370 if (*partition > VOLMAXPARTS) {
371 tst = ADMVOSPARTITIONTOOLARGE;
372 goto fail_vos_BackupVolumeCreateMultiple;
374 attr.partition = *partition;
375 attr.Mask |= VLLIST_PARTITION;
378 if (excludePrefix == VOS_EXCLUDE) {
382 if ((volumePrefix != NULL) && (*volumePrefix != 0)) {
384 prefix_len = strlen(volumePrefix);
387 memset((void *) &arrayEntries, 0, sizeof(arrayEntries));
390 * Get a list of all the volumes in the cell
393 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &arrayEntries, &tst)) {
394 goto fail_vos_BackupVolumeCreateMultiple;
398 * Cycle through the list of volumes and see if we should create a backup
399 * for each individual volume
402 for(i=0;i<nentries;i++) {
403 entry = &arrayEntries.nbulkentries_val[i];
406 * Skip entries that don't have a RW volume
409 if (!(entry->flags & RW_EXISTS)) {
410 if (callBack != NULL) {
411 const char *messageText;
412 if (util_AdminErrorCodeTranslate(ADMVOSVOLUMENOREADWRITE, 0,
413 &messageText, &tst)) {
414 sprintf(backbuf, "%s %s", messageText, entry->name);
415 (**callBack)(VOS_VERBOSE_MESSAGE, backbuf);
422 * See if we should skip this entry because of the prefix/exclude
423 * combination we've been passed
428 if (!strncmp(entry->name, volumePrefix, prefix_len)) {
432 if (strncmp(entry->name, volumePrefix, prefix_len)) {
438 rw_volid = entry->volumeId[RWVOL];
439 GetServerAndPart(entry, RWVOL, &rw_server, &rw_partition, &previdx);
441 if ((rw_server == -1) || (rw_partition == -1)) {
442 if (callBack != NULL) {
443 const char *messageText;
444 if (util_AdminErrorCodeTranslate(ADMVOSVLDBBADENTRY, 0,
445 &messageText, &tst)) {
446 sprintf(backbuf, "%s %s", messageText, entry->name);
447 (**callBack)(VOS_ERROR_MESSAGE, backbuf);
454 * Check that the RW volume is on the same server that we were
458 if (serverHandle != NULL) {
459 if (!VLDB_IsSameAddrs(c_handle,
460 ntohl(rx_HostOf(rx_PeerOf(f_server->serv))),
461 rw_server, &equal, &tst)) {
462 if (callBack != NULL) {
463 const char *messageText;
464 if (util_AdminErrorCodeTranslate(ADMVOSVLDBBADSERVER, 0,
465 &messageText, &tst)) {
466 sprintf(backbuf, "%s %x %d", messageText,
467 ntohl(rx_HostOf(rx_PeerOf(f_server->serv))),
469 (**callBack)(VOS_ERROR_MESSAGE, backbuf);
475 if (callBack != NULL) {
476 const char *messageText;
477 if (util_AdminErrorCodeTranslate(ADMVOSVLDBDIFFERENTADDR, 0,
478 &messageText, &tst)) {
479 sprintf(backbuf, "%s %s", messageText,
481 (**callBack)(VOS_ERROR_MESSAGE, backbuf);
489 * Check that the RW volume is on the same partition we were
493 if (partition != NULL) {
494 if (*partition != rw_partition) {
503 rc = UV_BackupVolume(c_handle, rw_server, rw_partition, rw_volid, &tst);
506 fail_vos_BackupVolumeCreateMultiple:
508 if (arrayEntries.nbulkentries_val) {
509 free(arrayEntries.nbulkentries_val);
519 * vos_PartitionGet - get information about a single partition.
523 * IN cellHandle - a previously opened cellHandle that corresponds
524 * to the cell where the server lives.
526 * IN serverHandle - a previously open vos server handle that holds
527 * the partition of interest.
529 * IN callBack - a call back function pointer that may be called to report
530 * status information. Can be null.
532 * IN partition - the integer that represents the partition of interest.
534 * OUT partitionP - a pointer to a vos_partitionEntry_t that upon successful
535 * completion contains information regarding the partition.
539 * No locks are obtained or released by this function
543 * Returns != 0 upon successful completion.
546 int ADMINAPI vos_PartitionGet(
547 const void *cellHandle,
548 const void *serverHandle,
549 vos_MessageCallBack_t callBack,
550 unsigned int partition,
551 vos_partitionEntry_p partitionP,
555 afs_status_t tst = 0;
556 struct diskPartition part_info;
557 file_server_p f_server = (file_server_p) serverHandle;
558 char partitionName[10]; /* this rpc requires a character partition name */
564 if (!IsValidServerHandle(f_server, &tst)) {
565 goto fail_vos_PartitionGet;
568 if (partitionP == NULL) {
569 tst = ADMVOSPARTITIONPNULL;
570 goto fail_vos_PartitionGet;
573 if (!vos_PartitionIdToName(partition, partitionName, &tst)) {
574 goto fail_vos_PartitionGet;
577 tst = AFSVolPartitionInfo(f_server->serv, partitionName, &part_info);
579 goto fail_vos_PartitionGet;
581 strcpy(partitionP->name, part_info.name);
582 strcpy(partitionP->deviceName, part_info.devName);
583 partitionP->lockFileDescriptor = part_info.lock_fd;
584 partitionP->totalSpace = part_info.minFree;
585 partitionP->totalFreeSpace = part_info.free;
588 fail_vos_PartitionGet:
597 * The iterator functions and data for the partition retrieval functions.
600 typedef struct partition_get {
601 afs_int32 total_received; /* the total number of valid partiions retrieved */
602 int number_processed; /* the number of valid paritions we've handed out */
603 int index; /* the current index into the part_list array */
604 struct partList part_list; /* the list of partitions */
605 vos_partitionEntry_t partition[CACHED_ITEMS]; /* the cache of partitions */
606 const void *server; /* the server where the parititions exist */
607 } partition_get_t, *partition_get_p;
609 static int GetPartitionInfoRPC(
613 int *last_item_contains_data,
617 afs_status_t tst = 0;
618 partition_get_p part = (partition_get_p) rpc_specific;
619 vos_partitionEntry_p ptr = (vos_partitionEntry_p) &part->partition[slot];
622 * Skip partition entries that are not valid
625 while (!(part->part_list.partFlags[part->index] & PARTVALID)) {
630 * Get information for the next partition
633 if (!vos_PartitionGet(0, part->server, 0,
634 (unsigned int) part->part_list.partId[part->index],
636 goto fail_GetPartitionInfoRPC;
640 part->number_processed++;
642 if (part->number_processed == part->total_received) {
644 *last_item_contains_data = 1;
648 fail_GetPartitionInfoRPC:
656 static int GetPartitionInfoFromCache(
663 afs_status_t tst = 0;
664 partition_get_p part = (partition_get_p) rpc_specific;
666 memcpy(dest, (const void *) &part->partition[slot],
667 sizeof(vos_partitionEntry_t));
677 * vos_PartitionGetBegin - begin to iterate over the partitions at a
682 * IN cellHandle - a previously opened cellHandle that corresponds
683 * to the cell where the server exists.
685 * IN serverHandle - the server that houses the partitions of interest.
687 * IN callBack - a call back function pointer that may be called to report
688 * status information. Can be null.
690 * OUT iterationIdP - upon successful completion, contains an iterator that can
691 * be passed to vos_PartitionGetNext.
695 * No locks are obtained or released by this function
699 * Returns != 0 upon successful completion.
702 int ADMINAPI vos_PartitionGetBegin(
703 const void *cellHandle,
704 const void *serverHandle,
705 vos_MessageCallBack_t callBack,
710 afs_status_t tst = 0;
711 file_server_p f_server = (file_server_p) serverHandle;
712 afs_admin_iterator_p iter = (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
713 partition_get_p part = (partition_get_p) calloc(1, sizeof(partition_get_t));
719 if (!IsValidServerHandle(f_server, &tst)) {
720 goto fail_vos_PartitionGetBegin;
723 if (iterationIdP == NULL) {
724 goto fail_vos_PartitionGetBegin;
727 if ((iter == NULL) || (part == NULL)) {
729 goto fail_vos_PartitionGetBegin;
733 * Fill in the part structure
736 part->server = serverHandle;
737 if (!UV_ListPartitions(f_server->serv, &part->part_list,
738 &part->total_received, &tst)) {
739 goto fail_vos_PartitionGetBegin;
743 * If we didn't receive any partitions, don't spawn a background thread.
744 * Mark the iterator complete.
747 if (part->total_received == 0) {
748 if (!IteratorInit(iter, (void *) part, NULL, NULL, NULL, NULL, &tst)) {
749 goto fail_vos_PartitionGetBegin;
751 iter->done_iterating = 1;
752 iter->st = ADMITERATORDONE;
754 if (!IteratorInit(iter, (void *) part, GetPartitionInfoRPC,
755 GetPartitionInfoFromCache, NULL, NULL, &tst)) {
756 goto fail_vos_PartitionGetBegin;
759 *iterationIdP = (void *) iter;
762 fail_vos_PartitionGetBegin:
780 * vos_PartitionGetNext - get the next partition at a server.
784 * IN iterationId - an iterator previously returned by vos_PartitionGetBegin
786 * OUT partitionP - a pointer to a vos_partitionEntry_t that upon successful
787 * completion contains the next partition.
791 * The iterator is locked while the next parition is retrieved.
795 * Returns != 0 upon successful completion.
798 int ADMINAPI vos_PartitionGetNext(
799 const void *iterationId,
800 vos_partitionEntry_p partitionP,
804 afs_status_t tst = 0;
805 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
808 tst = ADMITERATORNULL;
809 goto fail_vos_PartitionGetNext;
812 if (partitionP == NULL) {
813 tst = ADMVOSPARTITIONPNULL;
814 goto fail_vos_PartitionGetNext;
817 rc = IteratorNext(iter, (void *) partitionP, &tst);
819 fail_vos_PartitionGetNext:
828 * vos_PartitionGetDone - finish using a partition iterator.
832 * IN iterationId - an iterator previously returned by vos_PartitionGetBegin
836 * The iterator is locked and then destroyed.
840 * Returns != 0 upon successful completion.
843 int ADMINAPI vos_PartitionGetDone(
844 const void *iterationId,
848 afs_status_t tst = 0;
849 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
856 tst = ADMITERATORNULL;
857 goto fail_vos_PartitionGetDone;
860 rc = IteratorDone(iter, &tst);
862 fail_vos_PartitionGetDone:
871 * vos_ServerOpen - open a handle to an individual server for future
876 * IN cellHandle - a previously opened cellHandle that corresponds
877 * to the cell where the server lives.
879 * IN serverName - the machine name of the server
881 * OUT serverHandleP - a void pointer that upon successful completion
882 * contains a handle that is used in future operations upon the server.
886 * No locks are obtained or released by this function
890 * Returns != 0 upon successful completion.
893 int ADMINAPI vos_ServerOpen(
894 const void *cellHandle,
895 const char *serverName,
896 void **serverHandleP,
900 afs_status_t tst = 0;
901 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
902 file_server_p f_server = (file_server_p) malloc(sizeof(file_server_t));
904 struct rx_securityClass *sc[3];
907 if (f_server == NULL) {
909 goto fail_vos_ServerOpen;
916 if (!IsValidCellHandle(c_handle, &tst)) {
917 goto fail_vos_ServerOpen;
920 if (!c_handle->tokens->afs_token_set) {
921 tst = ADMVOSCELLHANDLENOAFSTOKENS;
922 goto fail_vos_ServerOpen;
925 if (!util_AdminServerAddressGetFromName(serverName, &server_address,
927 goto fail_vos_ServerOpen;
930 scIndex = c_handle->tokens->sc_index;
931 sc[scIndex] = c_handle->tokens->afs_sc[scIndex];
932 f_server->serv = rx_GetCachedConnection(htonl(server_address),
933 htons(AFSCONF_VOLUMEPORT),
934 VOLSERVICE_ID, sc[scIndex], scIndex);
935 if (f_server->serv != NULL) {
936 f_server->begin_magic = BEGIN_MAGIC;
937 f_server->end_magic = END_MAGIC;
938 f_server->is_valid = 1;
939 *serverHandleP = (void *) f_server;
942 tst = ADMVOSSERVERNOCONNECTION;
943 goto fail_vos_ServerOpen;
955 * vos_ServerClose - close a handle previously obtained from vos_ServerOpen
959 * IN serverHandle - an existing server handle.
963 * No locks are obtained or released by this function
967 * Returns != 0 upon successful completion.
970 int ADMINAPI vos_ServerClose(
971 const void *serverHandle,
975 afs_status_t tst = 0;
976 file_server_p f_server = (file_server_p) serverHandle;
978 if (!IsValidServerHandle(f_server, &tst)) {
979 goto fail_vos_ServerClose;
982 rx_ReleaseCachedConnection(f_server->serv);
983 f_server->is_valid = 0;
987 fail_vos_ServerClose:
996 * vos_ServerSync - synchronize the vldb and the fileserver at a particular
1001 * IN cellHandle - a previously opened cellHandle that corresponds
1002 * to the cell where the server lives.
1004 * IN serverHandle - a handle to the server machine.
1006 * IN callBack - a call back function pointer that may be called to report
1007 * status information. Can be null.
1009 * IN partition - the partition to synchronize. Can be NULL.
1011 * IN force - force deletion of bad volumes.
1015 * No locks are obtained or released by this function
1019 * Returns != 0 upon successful completion.
1022 int ADMINAPI vos_ServerSync(
1023 const void *cellHandle,
1024 const void *serverHandle,
1025 vos_MessageCallBack_t callBack,
1026 const unsigned int *partition,
1030 afs_status_t tst = 0;
1031 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1032 file_server_p f_server = (file_server_p) serverHandle;
1037 * Validate arguments
1040 if (!IsValidCellHandle(c_handle, &tst)) {
1041 goto fail_vos_ServerSync;
1044 if (!IsValidServerHandle(f_server, &tst)) {
1045 goto fail_vos_ServerSync;
1048 if (partition != NULL) {
1049 if (*partition > VOLMAXPARTS) {
1050 tst = ADMVOSPARTITIONTOOLARGE;
1051 goto fail_vos_ServerSync;
1053 part = (afs_int32) *partition;
1061 rc = UV_SyncServer(c_handle, f_server->serv, part, flags, &tst);
1063 fail_vos_ServerSync:
1072 * vos_FileServerAddressChange - change an existing file server address.
1076 * IN cellHandle - a previously opened cellHandle that corresponds
1077 * to the cell where the address should be changed.
1079 * IN callBack - a call back function pointer that may be called to report
1080 * status information. Can be null.
1082 * IN oldAddress - the old server address in host byte order
1084 * IN newAddress - the new server address in host byte order
1088 * No locks are obtained or released by this function
1092 * Returns != 0 upon successful completion.
1095 int ADMINAPI vos_FileServerAddressChange(
1096 const void *cellHandle,
1097 vos_MessageCallBack_t callBack,
1103 afs_status_t tst = 0;
1104 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1107 * Validate arguments
1110 if (!IsValidCellHandle(c_handle, &tst)) {
1111 goto fail_vos_FileServerAddressChange;
1114 tst = ubik_Call_New(VL_ChangeAddr, c_handle->vos, 0,
1115 oldAddress, newAddress);
1117 goto fail_vos_FileServerAddressChange;
1121 fail_vos_FileServerAddressChange:
1130 * vos_FileServerAddressRemove - remove an existing file server address.
1134 * IN cellHandle - a previously opened cellHandle that corresponds
1135 * to the cell where the address should be removed.
1137 * IN callBack - a call back function pointer that may be called to report
1138 * status information. Can be null.
1140 * IN serverAddress - the server address to remove in host byte order.
1144 * No locks are obtained or released by this function
1148 * Returns != 0 upon successful completion.
1151 int ADMINAPI vos_FileServerAddressRemove(
1152 const void *cellHandle,
1153 vos_MessageCallBack_t callBack,
1158 afs_status_t tst = 0;
1159 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1160 int dummyAddress = 0xffffffff;
1163 * Validate arguments
1166 if (!IsValidCellHandle(c_handle, &tst)) {
1167 goto fail_vos_FileServerAddressRemove;
1170 tst = ubik_Call_New(VL_ChangeAddr, c_handle->vos, 0,
1171 dummyAddress, serverAddress);
1173 goto fail_vos_FileServerAddressRemove;
1177 fail_vos_FileServerAddressRemove:
1186 * The iterator functions and data for the server retrieval functions.
1188 * These functions are very similar to the FileServerAddressGet
1189 * functions. The main difference being that instead of returning
1190 * a single address at a time for a server, we fill an array with
1191 * all the addresses of a server.
1194 typedef struct server_get {
1195 struct ubik_client *vldb; /* connection for future rpc's if neccessary */
1196 afs_int32 total_addresses; /* total number of addresses */
1197 bulkaddrs addresses; /* the list of addresses */
1198 int address_index; /* current index into address list */
1199 vos_fileServerEntry_t server[CACHED_ITEMS]; /* the cache of servers */
1200 } server_get_t, *server_get_p;
1202 static int GetServerRPC(
1206 int *last_item_contains_data,
1210 afs_status_t tst = 0;
1211 server_get_p serv = (server_get_p) rpc_specific;
1212 afs_uint32 *addrP = &serv->addresses.bulkaddrs_val[serv->address_index];
1213 afs_int32 base, index;
1216 ListAddrByAttributes m_attrs;
1217 afs_int32 total_multi;
1218 bulkaddrs addr_multi;
1222 * Check to see if this is a multihomed address server
1225 if ( ((*addrP & 0xff000000) == 0xff000000) && ((*addrP)&0xffff) ) {
1226 base = (*addrP>>16) & 0xff;
1227 index = (*addrP) & 0xffff;
1229 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) &&
1230 (index >= 1) && (index <= VL_MHSRV_PERBLK)) {
1233 * This is a multihomed server. Make an rpc to retrieve
1234 * all its addresses. Copy the addresses into the cache.
1237 m_attrs.Mask = VLADDR_INDEX;
1238 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
1240 addr_multi.bulkaddrs_val = 0;
1241 addr_multi.bulkaddrs_len = 0;
1242 tst = ubik_Call(VL_GetAddrsU, serv->vldb, 0, &m_attrs, &m_uuid,
1247 goto fail_GetServerRPC;
1251 * Remove any bogus IP addresses which the user may have
1252 * been unable to remove.
1255 RemoveBadAddresses (&total_multi, &addr_multi);
1258 * Copy all the addresses into the cache
1261 for(i=0;i<total_multi;i++) {
1262 serv->server[slot].serverAddress[i] =
1263 addr_multi.bulkaddrs_val[i];
1266 serv->server[slot].count = total_multi;
1267 serv->address_index++;
1268 free(addr_multi.bulkaddrs_val);
1272 * The next address is just a plain old address
1276 serv->server[slot].serverAddress[0] = *addrP;
1277 serv->server[slot].count = 1;
1278 serv->address_index++;
1282 * See if we've processed all the entries
1286 if (serv->address_index == serv->total_addresses) {
1288 *last_item_contains_data = 1;
1300 static int GetServerFromCache(
1307 afs_status_t tst = 0;
1308 server_get_p serv = (server_get_p) rpc_specific;
1310 memcpy(dest, (const void *) &serv->server[slot],
1311 sizeof(vos_fileServerEntry_t));
1321 static int DestroyServer(
1326 afs_status_t tst = 0;
1327 server_get_p serv = (server_get_p) rpc_specific;
1329 if (serv->addresses.bulkaddrs_val != NULL) {
1330 free(serv->addresses.bulkaddrs_val);
1341 * vos_FileServerGetBegin - begin to iterate over the file servers in a cell.
1345 * IN cellHandle - a previously opened cellHandle that corresponds
1346 * to the cell where the file servers exist.
1348 * IN callBack - a call back function pointer that may be called to report
1349 * status information. Can be null.
1351 * OUT iterationIdP - upon successful completion, contains an iterator that
1352 * can be passed to vos_FileServerGetNext.
1356 * No locks are obtained or released by this function
1360 * Returns != 0 upon successful completion.
1363 int ADMINAPI vos_FileServerGetBegin(
1364 const void *cellHandle,
1365 vos_MessageCallBack_t callBack,
1366 void **iterationIdP,
1370 afs_status_t tst = 0;
1371 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1372 afs_admin_iterator_p iter = (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1373 server_get_p serv = (server_get_p) calloc(1, sizeof(server_get_t));
1374 struct VLCallBack unused;
1378 * Validate arguments
1381 if (!IsValidCellHandle(c_handle, &tst)) {
1382 goto fail_vos_FileServerGetBegin;
1385 if (iterationIdP == NULL) {
1386 goto fail_vos_FileServerGetBegin;
1389 if ((iter == NULL) || (serv == NULL)) {
1391 goto fail_vos_FileServerGetBegin;
1395 * Fill in the serv structure
1398 serv->vldb = c_handle->vos;
1399 tst = ubik_Call_New(VL_GetAddrs, c_handle->vos, 0, 0, 0, &unused,
1400 &serv->total_addresses, &serv->addresses);
1403 goto fail_vos_FileServerGetBegin;
1407 * Remove any bogus IP addresses which the user may have
1408 * been unable to remove.
1411 RemoveBadAddresses (&serv->total_addresses, &serv->addresses);
1413 if (serv->total_addresses == 0) {
1414 if (!IteratorInit(iter, (void *) serv, NULL, NULL, NULL, NULL, &tst)) {
1415 goto fail_vos_FileServerGetBegin;
1417 iter->done_iterating = 1;
1418 iter->st = ADMITERATORDONE;
1420 if (!IteratorInit(iter, (void *) serv, GetServerRPC,
1421 GetServerFromCache, NULL, DestroyServer, &tst)) {
1422 goto fail_vos_FileServerGetBegin;
1425 *iterationIdP = (void *) iter;
1428 fail_vos_FileServerGetBegin:
1435 if (serv->addresses.bulkaddrs_val != NULL) {
1436 free(serv->addresses.bulkaddrs_val);
1449 * vos_FileServerGetNext - get information about the next fileserver in the cell.
1453 * IN iterationId - an iterator previously returned by
1454 * vos_FileServerGetBegin
1456 * OUT serverEntryP - a pointer to a vos_fileServerEntry_t that upon successful
1457 * completion contains information about the next server in the cell.
1461 * The iterator is locked while the next server is retrieved.
1465 * Returns != 0 upon successful completion.
1468 int ADMINAPI vos_FileServerGetNext(
1470 vos_fileServerEntry_p serverEntryP,
1474 afs_status_t tst = 0;
1475 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1478 tst = ADMITERATORNULL;
1479 goto fail_vos_FileServerGetNext;
1482 if (serverEntryP == NULL) {
1483 tst = ADMVOSSERVERENTRYPNULL;
1484 goto fail_vos_FileServerGetNext;
1487 rc = IteratorNext(iter, (void *) serverEntryP, &tst);
1489 fail_vos_FileServerGetNext:
1498 * vos_FileServerGetDone - finish using a partition iterator.
1502 * IN iterationId - an iterator previously returned by vos_FileServerGetBegin
1506 * The iterator is locked and then destroyed.
1510 * Returns != 0 upon successful completion.
1513 int ADMINAPI vos_FileServerGetDone(
1518 afs_status_t tst = 0;
1519 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1522 * Validate arguments
1526 tst = ADMITERATORNULL;
1527 goto fail_vos_FileServerGetDone;
1530 rc = IteratorDone(iter, &tst);
1532 fail_vos_FileServerGetDone:
1541 * The iterator functions and data for the transation retrieval functions.
1544 typedef struct transaction_get {
1545 afs_int32 total; /* total number of transactions */
1546 afs_int32 index; /* index to the current transaction */
1547 transDebugInfo *cur; /* the current transaction */
1548 vos_serverTransactionStatus_t tran[CACHED_ITEMS]; /* the cache of trans */
1549 } transaction_get_t, *transaction_get_p;
1551 static int GetTransactionRPC(
1555 int *last_item_contains_data,
1559 afs_status_t tst = 0;
1560 transaction_get_p t = (transaction_get_p) rpc_specific;
1561 int index = t->index;
1564 * Copy the next transaction into the cache
1567 t->tran[slot].transactionId = t->cur[index].tid;
1568 t->tran[slot].lastActiveTime = t->cur[index].time;
1569 t->tran[slot].creationTime = t->cur[index].creationTime;
1570 t->tran[slot].errorCode = t->cur[index].returnCode;
1571 t->tran[slot].volumeId = t->cur[index].volid;
1572 t->tran[slot].partition = t->cur[index].partition;
1573 strcpy(t->tran[slot].lastProcedureName, t->cur[index].lastProcName);
1574 t->tran[slot].nextReceivePacketSequenceNumber = t->cur[index].readNext;
1575 t->tran[slot].nextSendPacketSequenceNumber = t->cur[index].transmitNext;
1576 t->tran[slot].lastReceiveTime = t->cur[index].lastReceiveTime;
1577 t->tran[slot].lastSendTime = t->cur[index].lastSendTime;
1579 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OK;
1581 switch(t->cur[index].iflags){
1583 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OFFLINE;
1586 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_BUSY;
1589 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_READONLY;
1592 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE;
1595 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE_VOLID;
1599 t->tran[slot].volumeActiveStatus = VOS_VOLUME_ACTIVE_STATUS_OK;
1601 switch(t->cur[index].vflags){
1602 case VTDeleteOnSalvage:
1603 t->tran[slot].volumeActiveStatus =
1604 VOS_VOLUME_ACTIVE_STATUS_DELETE_ON_SALVAGE;
1606 case VTOutOfService:
1607 t->tran[slot].volumeActiveStatus =
1608 VOS_VOLUME_ACTIVE_STATUS_OUT_OF_SERVICE;
1611 t->tran[slot].volumeActiveStatus =
1612 VOS_VOLUME_ACTIVE_STATUS_DELETED;
1616 t->tran[slot].volumeTransactionStatus = VOS_VOLUME_TRANSACTION_STATUS_OK;
1618 if (t->cur[index].tflags) {
1619 t->tran[slot].volumeTransactionStatus =
1620 VOS_VOLUME_TRANSACTION_STATUS_DELETED;
1626 * See if we've processed all the entries
1630 if (t->index == t->total) {
1632 *last_item_contains_data = 1;
1642 static int GetTransactionFromCache(
1649 afs_status_t tst = 0;
1650 transaction_get_p tran = (transaction_get_p) rpc_specific;
1652 memcpy(dest, (const void *) &tran->tran[slot],
1653 sizeof(vos_serverTransactionStatus_p));
1663 static int DestroyTransaction(
1668 afs_status_t tst = 0;
1669 transaction_get_p tran = (transaction_get_p) rpc_specific;
1671 if (tran->cur != NULL) {
1683 * vos_ServerTransactionStatusGetBegin - begin to iterate over the transactions
1684 * at a volume server.
1688 * IN cellHandle - a previously opened cellHandle that corresponds
1689 * to the cell where the volume server exists.
1691 * IN serverHandle - a handle to the server to query.
1693 * IN callBack - a call back function pointer that may be called to report
1694 * status information. Can be null.
1696 * OUT iterationIdP - upon successful completion, contains an iterator that
1697 * can be passed to vos_ServerTransactionStatusGetNext.
1701 * No locks are obtained or released by this function
1705 * Returns != 0 upon successful completion.
1708 int ADMINAPI vos_ServerTransactionStatusGetBegin(
1709 const void *cellHandle,
1710 const void *serverHandle,
1711 vos_MessageCallBack_t callBack,
1712 void **iterationIdP,
1716 afs_status_t tst = 0;
1717 file_server_p f_server = (file_server_p) serverHandle;
1718 afs_admin_iterator_p iter = (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1719 transaction_get_p tran = (transaction_get_p) calloc(1, sizeof(transaction_get_t));
1723 * Validate arguments
1726 if (!IsValidServerHandle(f_server, &tst)) {
1727 goto fail_vos_ServerTransactionStatusGetBegin;
1730 if (iterationIdP == NULL) {
1731 goto fail_vos_ServerTransactionStatusGetBegin;
1734 if ((iter == NULL) || (tran == NULL)) {
1736 goto fail_vos_ServerTransactionStatusGetBegin;
1740 * Fill in the tran structure
1743 if (!UV_VolserStatus(f_server->serv, &tran->cur, &tran->total, &tst)) {
1744 goto fail_vos_ServerTransactionStatusGetBegin;
1747 if (tran->total == 0) {
1748 if (!IteratorInit(iter, (void *) tran, NULL,
1749 NULL, NULL, NULL, &tst)) {
1750 goto fail_vos_ServerTransactionStatusGetBegin;
1752 iter->done_iterating = 1;
1753 iter->st = ADMITERATORDONE;
1755 if (!IteratorInit(iter, (void *) tran, GetTransactionRPC,
1756 GetTransactionFromCache, NULL,
1757 DestroyTransaction, &tst)) {
1758 goto fail_vos_ServerTransactionStatusGetBegin;
1761 *iterationIdP = (void *) iter;
1764 fail_vos_ServerTransactionStatusGetBegin:
1771 if (tran->cur != NULL) {
1785 * vos_ServerTransactionStatusGetNext - get information about the next
1786 * active transaction.
1790 * IN iterationId - an iterator previously returned by
1791 * vos_ServerTransactionStatusGetBegin
1793 * OUT serverTransactionStatusP - a pointer to a vos_serverTransactionStatus_p
1794 * that upon successful completion contains information about the
1799 * The iterator is locked while the next item is retrieved.
1803 * Returns != 0 upon successful completion.
1806 int ADMINAPI vos_ServerTransactionStatusGetNext(
1807 const void *iterationId,
1808 vos_serverTransactionStatus_p serverTransactionStatusP,
1812 afs_status_t tst = 0;
1813 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1816 tst = ADMITERATORNULL;
1817 goto fail_vos_ServerTransactionStatusGetNext;
1820 if (serverTransactionStatusP == NULL) {
1821 tst = ADMVOSSERVERTRANSACTIONSTATUSPNULL;
1822 goto fail_vos_ServerTransactionStatusGetNext;
1825 rc = IteratorNext(iter, (void *) serverTransactionStatusP, &tst);
1827 fail_vos_ServerTransactionStatusGetNext:
1836 * vos_ServerTransactionStatusGetDone - finish using a transaction iterator.
1840 * IN iterationId - an iterator previously returned by
1841 * vos_ServerTransactionStatusGetBegin
1845 * The iterator is locked and then destroyed.
1849 * Returns != 0 upon successful completion.
1852 int ADMINAPI vos_ServerTransactionStatusGetDone(
1853 const void *iterationId,
1857 afs_status_t tst = 0;
1858 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1861 * Validate arguments
1865 tst = ADMITERATORNULL;
1866 goto fail_vos_ServerTransactionStatusGetDone;
1869 rc = IteratorDone(iter, &tst);
1871 fail_vos_ServerTransactionStatusGetDone:
1879 static int copyVLDBEntry(
1880 struct nvldbentry *source,
1881 vos_vldbEntry_p dest,
1885 afs_status_t tst = 0;
1888 dest->numServers = source->nServers;
1889 for (i=0;i<VOS_MAX_VOLUME_TYPES;i++) {
1890 dest->volumeId[i] = source->volumeId[i];
1892 dest->cloneId = source->cloneId;
1893 dest->status = VOS_VLDB_ENTRY_OK;
1894 if (source->flags & VLOP_ALLOPERS) {
1895 dest->status |= VOS_VLDB_ENTRY_LOCKED;
1898 if (source->flags & VLOP_MOVE) {
1899 dest->status |= VOS_VLDB_ENTRY_MOVE;
1901 if (source->flags & VLOP_RELEASE) {
1902 dest->status |= VOS_VLDB_ENTRY_RELEASE;
1904 if (source->flags & VLOP_BACKUP) {
1905 dest->status |= VOS_VLDB_ENTRY_BACKUP;
1907 if (source->flags & VLOP_DELETE) {
1908 dest->status |= VOS_VLDB_ENTRY_DELETE;
1910 if (source->flags & VLOP_DUMP) {
1911 dest->status |= VOS_VLDB_ENTRY_DUMP;
1914 if (source->flags & VLF_RWEXISTS) {
1915 dest->status |= VOS_VLDB_ENTRY_RWEXISTS;
1917 if (source->flags & VLF_ROEXISTS) {
1918 dest->status |= VOS_VLDB_ENTRY_ROEXISTS;
1920 if (source->flags & VLF_BACKEXISTS) {
1921 dest->status |= VOS_VLDB_ENTRY_BACKEXISTS;
1924 strcpy(dest->name, source->name);
1925 for (i=0;i<VOS_MAX_REPLICA_SITES;i++) {
1926 dest->volumeSites[i].serverAddress = source->serverNumber[i];
1927 dest->volumeSites[i].serverPartition = source->serverPartition[i];
1928 dest->volumeSites[i].serverFlags = 0;
1930 if (source->serverFlags[i] & NEW_REPSITE) {
1931 dest->volumeSites[i].serverFlags |= VOS_VLDB_NEW_REPSITE;
1933 if (source->serverFlags[i] & ITSROVOL) {
1934 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_ONLY;
1936 if (source->serverFlags[i] & ITSRWVOL) {
1937 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_WRITE;
1939 if (source->serverFlags[i] & ITSBACKVOL) {
1940 dest->volumeSites[i].serverFlags |= VOS_VLDB_BACKUP;
1942 if (source->serverFlags[i] & RO_DONTUSE) {
1943 dest->volumeSites[i].serverFlags |= VOS_VLDB_DONT_USE;
1956 * vos_VLDBGet- get a volume's vldb entry.
1960 * IN cellHandle - a previously opened cellHandle that corresponds
1961 * to the cell where the volume entries exist.
1963 * IN callBack - a call back function pointer that may be called to report
1964 * status information. Can be null.
1966 * IN volumeId - the id of the volume to retrieve.
1968 * IN volumeName - the name of the volume to retrieve.
1970 * OUT vldbEntry - upon successful completion, contains the information regarding
1975 * No locks are obtained or released by this function
1979 * Returns != 0 upon successful completion.
1982 int ADMINAPI vos_VLDBGet(
1983 const void *cellHandle,
1984 vos_MessageCallBack_t callBack,
1985 const unsigned int *volumeId,
1986 const char *volumeName,
1987 vos_vldbEntry_p vldbEntry,
1991 afs_status_t tst = 0;
1992 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1993 struct nvldbentry entry;
1997 * Validate arguments
2000 if (!IsValidCellHandle(c_handle, &tst)) {
2001 goto fail_vos_VLDBGet;
2004 if (vldbEntry == NULL) {
2005 tst = ADMVOSVLDBENTRYNULL;
2006 goto fail_vos_VLDBGet;
2009 if (((volumeName == NULL) || (*volumeName == 0)) &&
2010 (volumeId == NULL)) {
2011 tst = ADMVOSVOLUMENAMEANDVOLUMEIDNULL;
2012 goto fail_vos_VLDBGet;
2016 * Retrieve the entry
2019 if (!((volumeName == NULL) || (*volumeName == 0))) {
2020 if (!ValidateVolumeName(volumeName, &tst)) {
2021 goto fail_vos_VLDBGet;
2023 if (!VLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
2024 goto fail_vos_VLDBGet;
2027 if (!VLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
2028 goto fail_vos_VLDBGet;
2033 * Copy the entry into our structure
2036 if (!copyVLDBEntry(&entry, vldbEntry, &tst)) {
2037 goto fail_vos_VLDBGet;
2050 * The iterator functions and data for the vldb entry retrieval functions.
2053 typedef struct vldb_entry_get {
2054 afs_int32 total; /* total number of vldb entries */
2055 afs_int32 index; /* index to the current vldb entry */
2056 nbulkentries entries; /* the list of entries retrieved */
2057 vos_vldbEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
2058 } vldb_entry_get_t, *vldb_entry_get_p;
2060 static int GetVLDBEntryRPC(
2064 int *last_item_contains_data,
2068 afs_status_t tst = 0;
2069 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2072 * Copy the next entry into the cache
2075 if (!copyVLDBEntry(&entry->entries.nbulkentries_val[entry->index],
2076 &entry->entry[slot],
2078 goto fail_GetVLDBEntryRPC;
2083 * See if we've processed all the entries
2087 if (entry->index == entry->total) {
2089 *last_item_contains_data = 1;
2093 fail_GetVLDBEntryRPC:
2101 static int GetVLDBEntryFromCache(
2108 afs_status_t tst = 0;
2109 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2111 memcpy(dest, (const void *) &entry->entry[slot],
2112 sizeof(vos_vldbEntry_t));
2122 static int DestroyVLDBEntry(
2127 afs_status_t tst = 0;
2128 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2130 if (entry->entries.nbulkentries_val != NULL) {
2131 free(entry->entries.nbulkentries_val);
2143 * vos_VLDBGetBegin - begin to iterate over the VLDB.
2147 * IN cellHandle - a previously opened cellHandle that corresponds
2148 * to the cell where the volume entries exist.
2150 * IN serverHandle - a handle to the server whose entries should be listed.
2153 * IN callBack - a call back function pointer that may be called to report
2154 * status information. Can be null.
2156 * IN partition - the partition whose entries should be listed.
2159 * OUT iterationIdP - upon successful completion, contains an iterator that
2160 * can be passed to vos_VLDBGetNext.
2164 * No locks are obtained or released by this function
2168 * Returns != 0 upon successful completion.
2171 int ADMINAPI vos_VLDBGetBegin(
2172 const void *cellHandle,
2173 const void *serverHandle,
2174 vos_MessageCallBack_t callBack,
2175 unsigned int *partition,
2176 void **iterationIdP,
2180 afs_status_t tst = 0;
2181 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2182 file_server_p f_server = (file_server_p) serverHandle;
2183 afs_admin_iterator_p iter = (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
2184 vldb_entry_get_p entry = (vldb_entry_get_p) calloc(1, sizeof(vldb_entry_get_t));
2185 struct VldbListByAttributes attr;
2188 memset(&attr, 0, sizeof(attr));
2191 * Validate arguments
2194 if (!IsValidCellHandle(c_handle, &tst)) {
2195 goto fail_vos_VLDBGetBegin;
2198 if ((iter == NULL) || (entry == NULL)) {
2200 goto fail_vos_VLDBGetBegin;
2203 if (f_server != NULL) {
2204 if (!IsValidServerHandle(f_server, &tst)) {
2205 goto fail_vos_VLDBGetBegin;
2207 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2208 attr.Mask |= VLLIST_SERVER;
2211 if (partition != NULL) {
2212 if (*partition > VOLMAXPARTS) {
2213 tst = ADMVOSPARTITIONTOOLARGE;
2214 goto fail_vos_VLDBGetBegin;
2216 attr.partition = *partition;
2217 attr.Mask |= VLLIST_PARTITION;
2220 if (!VLDB_ListAttributes(c_handle, &attr, &entry->total, &entry->entries, &tst)) {
2221 goto fail_vos_VLDBGetBegin;
2224 if (entry->total <= 0) {
2225 if (!IteratorInit(iter, (void *) entry, NULL,
2226 NULL, NULL, NULL, &tst)) {
2227 goto fail_vos_VLDBGetBegin;
2229 iter->done_iterating = 1;
2230 iter->st = ADMITERATORDONE;
2232 if (!IteratorInit(iter, (void *) entry, GetVLDBEntryRPC,
2233 GetVLDBEntryFromCache, NULL,
2234 DestroyVLDBEntry, &tst)) {
2235 goto fail_vos_VLDBGetBegin;
2238 *iterationIdP = (void *) iter;
2241 fail_vos_VLDBGetBegin:
2247 if (entry->entries.nbulkentries_val != NULL) {
2248 free(entry->entries.nbulkentries_val);
2250 if (entry != NULL) {
2262 * vos_VLDBGetNext - get information about the next volume.
2266 * IN iterationId - an iterator previously returned by
2269 * OUT vldbEntry - a pointer to a vos_vldbEntry_t
2270 * that upon successful completion contains information about the
2275 * The iterator is locked while the next item is retrieved.
2279 * Returns != 0 upon successful completion.
2282 int ADMINAPI vos_VLDBGetNext(
2283 const void *iterationId,
2284 vos_vldbEntry_p vldbEntry,
2288 afs_status_t tst = 0;
2289 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2292 tst = ADMITERATORNULL;
2293 goto fail_vos_VLDBGetNext;
2296 if (vldbEntry == NULL) {
2297 tst = ADMVOSVLDBENTRYNULL;
2298 goto fail_vos_VLDBGetNext;
2301 rc = IteratorNext(iter, (void *) vldbEntry, &tst);
2303 fail_vos_VLDBGetNext:
2312 * vos_VLDBGetDone - finish using a volume iterator.
2316 * IN iterationId - an iterator previously returned by vos_VLDBGetBegin
2320 * The iterator is locked and then destroyed.
2324 * Returns != 0 upon successful completion.
2327 int ADMINAPI vos_VLDBGetDone(
2328 const void *iterationId,
2332 afs_status_t tst = 0;
2333 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2336 * Validate arguments
2340 tst = ADMITERATORNULL;
2341 goto fail_vos_VLDBGetDone;
2344 rc = IteratorDone(iter, &tst);
2346 fail_vos_VLDBGetDone:
2355 * vos_VLDBEntryRemove - remove a vldb entry.
2359 * IN cellHandle - a previously opened cellHandle that corresponds
2360 * to the cell where the vldb entry exists.
2362 * IN serverHandle - a previously opened serverHandle that corresponds
2363 * to the server where the vldb entry exists. Can be null.
2365 * IN callBack - a call back function pointer that may be called to report
2366 * status information. Can be null.
2368 * IN partition - the partition where the vldb entry exists. Can be null.
2370 * IN volumeId - the volume id of the vldb entry to be deleted. Can be null.
2374 * No locks are obtained or released by this function
2378 * Returns != 0 upon successful completion.
2381 int ADMINAPI vos_VLDBEntryRemove(
2382 const void *cellHandle,
2383 const void *serverHandle,
2384 vos_MessageCallBack_t callBack,
2385 const unsigned int *partition,
2386 unsigned int *volumeId,
2390 afs_status_t tst = 0;
2391 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2392 file_server_p f_server = (file_server_p) serverHandle;
2393 struct VldbListByAttributes attr;
2394 nbulkentries entries;
2398 memset(&attr, 0, sizeof(attr));
2399 memset(&entries, 0, sizeof(entries));
2402 * Validate arguments
2405 if (!IsValidCellHandle(c_handle, &tst)) {
2406 goto fail_vos_VLDBEntryRemove;
2410 * If the volume is specified, just delete it
2413 if (volumeId != NULL) {
2414 tst = ubik_Call(VL_DeleteEntry, c_handle->vos, 0, *volumeId, -1);
2416 goto fail_vos_VLDBEntryRemove;
2420 if (f_server != NULL) {
2421 if (!IsValidServerHandle(f_server, &tst)) {
2422 goto fail_vos_VLDBEntryRemove;
2424 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2425 attr.Mask |= VLLIST_SERVER;
2428 if (partition != NULL) {
2429 if (*partition > VOLMAXPARTS) {
2430 tst = ADMVOSPARTITIONTOOLARGE;
2431 goto fail_vos_VLDBEntryRemove;
2433 attr.partition = *partition;
2434 attr.Mask |= VLLIST_PARTITION;
2437 if ((f_server == NULL) && (partition == NULL)) {
2438 tst = ADMVOSVLDBDELETEALLNULL;
2439 goto fail_vos_VLDBEntryRemove;
2442 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2443 goto fail_vos_VLDBEntryRemove;
2446 if (nentries <= 0) {
2447 tst = ADMVOSVLDBNOENTRIES;
2448 goto fail_vos_VLDBEntryRemove;
2451 for(i=0;i<nentries;i++) {
2452 ubik_Call(VL_DeleteEntry, c_handle->vos, 0, entries.nbulkentries_val[i].volumeId[RWVOL]);
2456 fail_vos_VLDBEntryRemove:
2458 if (entries.nbulkentries_val) {
2459 free(entries.nbulkentries_val);
2469 * vos_VLDBUnlock - unlock vldb entries en masse.
2473 * IN cellHandle - a previously opened cellHandle that corresponds
2474 * to the cell where the vldb entries exist.
2476 * IN serverHandle - a previously opened serverHandle that corresponds
2477 * to the server where the vldb entries exist. Can be null.
2479 * IN callBack - a call back function pointer that may be called to report
2480 * status information. Can be null.
2482 * IN partition - the partition where the vldb entries exist. Can be null.
2486 * No locks are obtained or released by this function
2490 * Returns != 0 upon successful completion.
2493 int ADMINAPI vos_VLDBUnlock(
2494 const void *cellHandle,
2495 const void *serverHandle,
2496 vos_MessageCallBack_t callBack,
2497 const unsigned int *partition,
2501 afs_status_t tst = 0;
2502 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2503 file_server_p f_server = (file_server_p) serverHandle;
2504 struct VldbListByAttributes attr;
2505 nbulkentries entries;
2509 memset(&attr, 0, sizeof(attr));
2510 memset(&entries, 0, sizeof(entries));
2513 * Validate arguments
2516 if (!IsValidCellHandle(c_handle, &tst)) {
2517 goto fail_vos_VLDBUnlock;
2520 if (f_server != NULL) {
2521 if (!IsValidServerHandle(f_server, &tst)) {
2522 goto fail_vos_VLDBUnlock;
2524 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2525 attr.Mask |= VLLIST_SERVER;
2528 if (partition != NULL) {
2529 if (*partition > VOLMAXPARTS) {
2530 tst = ADMVOSPARTITIONTOOLARGE;
2531 goto fail_vos_VLDBUnlock;
2533 attr.partition = *partition;
2534 attr.Mask |= VLLIST_PARTITION;
2536 attr.flag = VLOP_ALLOPERS;
2537 attr.Mask |= VLLIST_FLAG;
2540 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2541 goto fail_vos_VLDBUnlock;
2544 if (nentries <= 0) {
2545 tst = ADMVOSVLDBNOENTRIES;
2546 goto fail_vos_VLDBUnlock;
2549 for(i=0;i<nentries;i++) {
2550 vos_VLDBEntryUnlock(cellHandle, 0,
2551 entries.nbulkentries_val[i].volumeId[RWVOL], &tst);
2555 fail_vos_VLDBUnlock:
2557 if (entries.nbulkentries_val) {
2558 free(entries.nbulkentries_val);
2569 * vos_VLDBEntryLock - lock a vldb entry.
2573 * IN cellHandle - a previously opened cellHandle that corresponds
2574 * to the cell where the vldb entry exists.
2576 * IN callBack - a call back function pointer that may be called to report
2577 * status information. Can be null.
2579 * IN volumeId - the volume id of the vldb entry to be deleted.
2583 * No locks are obtained or released by this function
2587 * Returns != 0 upon successful completion.
2590 int ADMINAPI vos_VLDBEntryLock(
2591 const void *cellHandle,
2592 vos_MessageCallBack_t callBack,
2593 unsigned int volumeId,
2597 afs_status_t tst = 0;
2598 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2601 * Validate arguments
2604 if (!IsValidCellHandle(c_handle, &tst)) {
2605 goto fail_vos_VLDBEntryLock;
2608 tst = ubik_Call(VL_SetLock, c_handle->vos, 0, volumeId, -1, VLOP_DELETE);
2610 goto fail_vos_VLDBEntryLock;
2614 fail_vos_VLDBEntryLock:
2623 * vos_VLDBEntryUnlock - unlock a vldb entry.
2627 * IN cellHandle - a previously opened cellHandle that corresponds
2628 * to the cell where the vldb entry exists.
2630 * IN callBack - a call back function pointer that may be called to report
2631 * status information. Can be null.
2633 * IN volumeId - the volume id of the vldb entry to be unlocked.
2637 * No locks are obtained or released by this function
2641 * Returns != 0 upon successful completion.
2644 int ADMINAPI vos_VLDBEntryUnlock(
2645 const void *cellHandle,
2646 vos_MessageCallBack_t callBack,
2647 unsigned int volumeId,
2651 afs_status_t tst = 0;
2652 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2655 * Validate arguments
2658 if (!IsValidCellHandle(c_handle, &tst)) {
2659 goto fail_vos_VLDBEntryUnlock;
2663 tst = ubik_Call(VL_ReleaseLock, c_handle->vos, 0, volumeId, -1,
2664 LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
2666 goto fail_vos_VLDBEntryUnlock;
2670 fail_vos_VLDBEntryUnlock:
2679 * vos_VLDBReadOnlySiteCreate - create a readonly site for a volume.
2683 * IN cellHandle - a previously opened cellHandle that corresponds
2684 * to the cell where the volume exists.
2686 * IN serverHandle - a previously opened serverHandle that corresponds
2687 * to the server where the new volume should be created.
2689 * IN callBack - a call back function pointer that may be called to report
2690 * status information. Can be null.
2692 * IN partition - the partition where then new volume should be created.
2694 * IN volumeId - the volume id of the volume to be replicated.
2698 * No locks are obtained or released by this function
2702 * Returns != 0 upon successful completion.
2705 int ADMINAPI vos_VLDBReadOnlySiteCreate(
2706 const void *cellHandle,
2707 const void *serverHandle,
2708 vos_MessageCallBack_t callBack,
2709 unsigned int partition,
2710 unsigned int volumeId,
2714 afs_status_t tst = 0;
2715 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2716 file_server_p f_server = (file_server_p) serverHandle;
2719 * Validate arguments
2722 if (!IsValidCellHandle(c_handle, &tst)) {
2723 goto fail_vos_VLDBReadOnlySiteCreate;
2726 if (!IsValidServerHandle(f_server, &tst)) {
2727 goto fail_vos_VLDBReadOnlySiteCreate;
2730 if (partition > VOLMAXPARTS) {
2731 tst = ADMVOSPARTITIONTOOLARGE;
2732 goto fail_vos_VLDBReadOnlySiteCreate;
2735 if (!UV_AddSite(c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))),
2736 partition, volumeId, &tst)) {
2737 goto fail_vos_VLDBReadOnlySiteCreate;
2741 fail_vos_VLDBReadOnlySiteCreate:
2750 * vos_VLDBReadOnlySiteDelete - delete a replication site for a volume.
2755 * IN cellHandle - a previously opened cellHandle that corresponds
2756 * to the cell where the volume exists.
2758 * IN serverHandle - a previously opened serverHandle that corresponds
2759 * to the server where the volume should be deleted.
2761 * IN callBack - a call back function pointer that may be called to report
2762 * status information. Can be null.
2764 * IN partition - the partition where then volume should be deleted.
2766 * IN volumeId - the volume id of the volume to be deleted.
2770 * No locks are obtained or released by this function
2774 * Returns != 0 upon successful completion.
2777 int ADMINAPI vos_VLDBReadOnlySiteDelete(
2778 const void *cellHandle,
2779 const void *serverHandle,
2780 vos_MessageCallBack_t callBack,
2781 unsigned int partition,
2782 unsigned int volumeId,
2786 afs_status_t tst = 0;
2787 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2788 file_server_p f_server = (file_server_p) serverHandle;
2791 * Validate arguments
2794 if (!IsValidCellHandle(c_handle, &tst)) {
2795 goto fail_vos_VLDBReadOnlySiteDelete;
2798 if (!IsValidServerHandle(f_server, &tst)) {
2799 goto fail_vos_VLDBReadOnlySiteDelete;
2802 if (partition > VOLMAXPARTS) {
2803 tst = ADMVOSPARTITIONTOOLARGE;
2804 goto fail_vos_VLDBReadOnlySiteDelete;
2807 if (!UV_RemoveSite(c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))),
2808 partition, volumeId, &tst)) {
2809 goto fail_vos_VLDBReadOnlySiteDelete;
2813 fail_vos_VLDBReadOnlySiteDelete:
2822 * vos_VLDBSync - synchronize the vldb with the fileserver.
2826 * IN cellHandle - a previously opened cellHandle that corresponds
2827 * to the cell where the sync should occur.
2829 * IN serverHandle - a previously opened serverHandle that corresponds
2830 * to the server where the sync should occur.
2832 * IN callBack - a call back function pointer that may be called to report
2833 * status information. Can be null.
2835 * IN partition - the partition where the sync should occur. Can be null.
2837 * IN force - force deletion of bad volumes.
2841 * No locks are obtained or released by this function
2845 * Returns != 0 upon successful completion.
2848 int ADMINAPI vos_VLDBSync(
2849 const void *cellHandle,
2850 const void *serverHandle,
2851 vos_MessageCallBack_t callBack,
2852 const unsigned int *partition,
2857 afs_status_t tst = 0;
2858 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2859 file_server_p f_server = (file_server_p) serverHandle;
2865 * Validate arguments
2868 if (!IsValidCellHandle(c_handle, &tst)) {
2869 goto fail_vos_VLDBSync;
2872 if (!IsValidServerHandle(f_server, &tst)) {
2873 goto fail_vos_VLDBSync;
2876 if (partition != NULL) {
2877 if (*partition > VOLMAXPARTS) {
2878 tst = ADMVOSPARTITIONTOOLARGE;
2879 goto fail_vos_VLDBSync;
2881 part = (afs_int32) *partition;
2885 if (force == VOS_FORCE) {
2893 rc = UV_SyncVldb(c_handle, f_server->serv, part, flags, force_flag, &tst);
2904 * vos_VolumeCreate - create a new partition.
2908 * IN cellHandle - a previously opened cellHandle that corresponds
2909 * to the cell where the server lives.
2911 * IN serverHandle - a previously open vos server handle that holds
2912 * the partition where the volume should be create.
2914 * IN callBack - a call back function pointer that may be called to report
2915 * status information. Can be null.
2917 * IN partition - the integer that represents the partition that will
2918 * house the new volume.
2920 * IN volumeName - the name of the new volume.
2922 * IN quota - the quota of the new volume.
2924 * OUT volumeId - the volume id of the newly created volume.
2928 * No locks are obtained or released by this function
2932 * Returns != 0 upon successful completion.
2935 int ADMINAPI vos_VolumeCreate(
2936 const void *cellHandle,
2937 const void *serverHandle,
2938 vos_MessageCallBack_t callBack,
2939 unsigned int partition,
2940 const char *volumeName,
2942 unsigned int *volumeId,
2946 afs_status_t tst = 0;
2947 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2948 file_server_p f_server = (file_server_p) serverHandle;
2949 vos_partitionEntry_t pinfo;
2950 struct nvldbentry vinfo;
2953 * Validate arguments
2956 if (!IsValidCellHandle(c_handle, &tst)) {
2957 goto fail_vos_VolumeCreate;
2960 if (!IsValidServerHandle(f_server, &tst)) {
2961 goto fail_vos_VolumeCreate;
2964 if (partition > VOLMAXPARTS) {
2965 tst = ADMVOSPARTITIONTOOLARGE;
2966 goto fail_vos_VolumeCreate;
2969 if (!ValidateVolumeName(volumeName, &tst)) {
2970 goto fail_vos_VolumeCreate;
2973 if (volumeId == NULL) {
2974 tst = ADMVOSVOLUMEID;
2975 goto fail_vos_VolumeCreate;
2979 * Check that partition is valid at the server
2982 if (!vos_PartitionGet(cellHandle, serverHandle, 0, partition,
2984 goto fail_vos_VolumeCreate;
2988 * Check that the volume doesn't already exist
2991 if (VLDB_GetEntryByName(c_handle, volumeName, &vinfo, &tst)) {
2992 tst = ADMVOSVOLUMENAMEDUP;
2993 goto fail_vos_VolumeCreate;
2997 * Create the new volume
3000 rc = UV_CreateVolume(c_handle, f_server->serv,
3001 partition, volumeName, quota, volumeId, &tst);
3003 fail_vos_VolumeCreate:
3012 * vos_VolumeDelete - remove a volume.
3016 * IN cellHandle - a previously opened cellHandle that corresponds
3017 * to the cell where the volume exists.
3019 * IN serverHandle - a previously opened serverHandle that corresponds
3020 * to the server where the volume exists.
3022 * IN callBack - a call back function pointer that may be called to report
3023 * status information. Can be null.
3025 * IN partition - the partition where the volume exists.
3027 * IN volumeId - the volume id of the volume to be deleted.
3031 * No locks are obtained or released by this function
3035 * Returns != 0 upon successful completion.
3038 int ADMINAPI vos_VolumeDelete(
3039 const void *cellHandle,
3040 const void *serverHandle,
3041 vos_MessageCallBack_t callBack,
3042 unsigned int partition,
3043 unsigned int volumeId,
3047 afs_status_t tst = 0;
3048 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3049 file_server_p f_server = (file_server_p) serverHandle;
3050 vos_partitionEntry_t pinfo;
3053 * Validate arguments
3056 if (!IsValidCellHandle(c_handle, &tst)) {
3057 goto fail_vos_VolumeDelete;
3060 if (!IsValidServerHandle(f_server, &tst)) {
3061 goto fail_vos_VolumeDelete;
3064 if (partition > VOLMAXPARTS) {
3065 tst = ADMVOSPARTITIONTOOLARGE;
3066 goto fail_vos_VolumeDelete;
3070 * Check that partition is valid at the server
3073 if (!vos_PartitionGet(cellHandle, serverHandle, 0,
3074 partition, &pinfo, &tst)) {
3075 goto fail_vos_VolumeDelete;
3078 rc = UV_DeleteVolume(c_handle, f_server->serv, partition, volumeId, &tst);
3080 fail_vos_VolumeDelete:
3089 * vos_VolumeRename - rename a volume.
3093 * IN cellHandle - a previously opened cellHandle that corresponds
3094 * to the cell where the volume exists.
3096 * IN serverHandle - a previously opened serverHandle that corresponds
3097 * to the server where the vldb entry exists. Can be null.
3099 * IN callBack - a call back function pointer that may be called to report
3100 * status information. Can be null.
3102 * IN readWriteVolumeId - the volume id of the volume to be renamed.
3104 * IN newVolumeName - the new name.
3108 * No locks are obtained or released by this function
3112 * Returns != 0 upon successful completion.
3115 int ADMINAPI vos_VolumeRename(
3116 const void *cellHandle,
3117 vos_MessageCallBack_t callBack,
3118 unsigned int readWriteVolumeId,
3119 const char *newVolumeName,
3123 afs_status_t tst = 0;
3124 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3125 struct nvldbentry entry;
3128 * Validate arguments
3131 if (!IsValidCellHandle(c_handle, &tst)) {
3132 goto fail_vos_VolumeRename;
3135 if ((newVolumeName == NULL) || (*newVolumeName == 0)) {
3136 tst = ADMVOSNEWVOLUMENAMENULL;
3137 goto fail_vos_VolumeRename;
3141 * Retrieve the entry
3144 if (!VLDB_GetEntryByID(c_handle, readWriteVolumeId, -1, &entry, &tst)) {
3145 goto fail_vos_VolumeRename;
3148 rc = UV_RenameVolume(c_handle, &entry, newVolumeName, &tst);
3150 fail_vos_VolumeRename:
3159 * vos_VolumeDump - dump a volume
3163 * IN cellHandle - a previously opened cellHandle that corresponds
3164 * to the cell where the volume exists.
3166 * IN serverHandle - a previously opened serverHandle that corresponds
3167 * to the server where the volume exists. Can be null.
3169 * IN callBack - a call back function pointer that may be called to report
3170 * status information. Can be null.
3172 * IN volumeId - the volume id of the volume to be dumped.
3174 * IN startTime - files with modification times >= this time will be dumped.
3176 * IN dumpFile - the file to dump the volume to.
3180 * No locks are obtained or released by this function
3184 * Returns != 0 upon successful completion.
3187 int ADMINAPI vos_VolumeDump(
3188 const void *cellHandle,
3189 const void *serverHandle,
3190 vos_MessageCallBack_t callBack,
3191 unsigned int *partition,
3192 unsigned int volumeId,
3193 unsigned int startTime,
3194 const char *dumpFile,
3198 afs_status_t tst = 0;
3199 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3200 file_server_p f_server = (file_server_p) serverHandle;
3201 afs_int32 server, part, voltype;
3202 struct nvldbentry entry;
3205 * Validate arguments
3208 if (!IsValidCellHandle(c_handle, &tst)) {
3209 goto fail_vos_VolumeDump;
3212 if (serverHandle != NULL) {
3213 if (!IsValidServerHandle(f_server, &tst)) {
3214 goto fail_vos_VolumeDump;
3219 * You must specify both the serverHandle and the partition
3222 if (serverHandle || partition) {
3223 if (!serverHandle || !partition) {
3224 tst = ADMVOSSERVERANDPARTITION;
3225 goto fail_vos_VolumeDump;
3227 if (*partition > VOLMAXPARTS) {
3228 tst = ADMVOSPARTITIONTOOLARGE;
3229 goto fail_vos_VolumeDump;
3231 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3235 if (!GetVolumeInfo(c_handle, volumeId, &entry, &server,
3236 &part, &voltype, &tst)) {
3237 goto fail_vos_VolumeDump;
3241 if ((dumpFile == NULL) || (*dumpFile == 0)) {
3242 tst = ADMVOSDUMPFILENULL;
3243 goto fail_vos_VolumeDump;
3246 rc = UV_DumpVolume(c_handle, volumeId, server, part, startTime,
3249 fail_vos_VolumeDump:
3258 * vos_VolumeRestore - restore a volume from a dump
3262 * IN cellHandle - a previously opened cellHandle that corresponds
3263 * to the cell where the volume exists.
3265 * IN serverHandle - a previously opened serverHandle that corresponds
3266 * to the server where the volume exists.
3268 * IN callBack - a call back function pointer that may be called to report
3269 * status information. Can be null.
3271 * IN partition - the partition where the volume exists.
3273 * IN volumeId - the volume id of the volume to be restored.
3275 * IN volumeName - the volume name of the volume to be restored.
3277 * IN dumpFile - the file from which to restore the volume.
3279 * IN dumpType - the type of dump to perform.
3283 * No locks are obtained or released by this function
3287 * Returns != 0 upon successful completion.
3290 int ADMINAPI vos_VolumeRestore(
3291 const void *cellHandle,
3292 const void *serverHandle,
3293 vos_MessageCallBack_t callBack,
3294 unsigned int partition,
3295 unsigned int *volumeId,
3296 const char *volumeName,
3297 const char *dumpFile,
3298 vos_volumeRestoreType_t dumpType,
3302 afs_status_t tst = 0;
3303 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3304 file_server_p f_server = (file_server_p) serverHandle;
3305 struct nvldbentry entry;
3306 afs_int32 volid, server;
3309 int restoreflags = 0;
3310 afs_int32 Oserver, Opart, Otype;
3311 struct nvldbentry Oentry;
3315 * Validate arguments
3318 if (!IsValidCellHandle(c_handle, &tst)) {
3319 goto fail_vos_VolumeRestore;
3322 if (serverHandle != NULL) {
3323 if (!IsValidServerHandle(f_server, &tst)) {
3324 goto fail_vos_VolumeRestore;
3329 * Must pass volumeName
3332 if ((volumeName == NULL) || (*volumeName == 0)) {
3333 tst = ADMVOSVOLUMENAMENULL;
3334 goto fail_vos_VolumeRestore;
3337 if (!ValidateVolumeName(volumeName, &tst)) {
3338 goto fail_vos_VolumeRestore;
3342 * If volumeId is passed, it must be a valid volume id
3345 if (volumeId != NULL) {
3346 if (!VLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
3347 goto fail_vos_VolumeRestore;
3354 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3356 if (partition > VOLMAXPARTS) {
3357 tst = ADMVOSPARTITIONTOOLARGE;
3358 goto fail_vos_VolumeRestore;
3362 * Check that dumpFile exists and can be accessed
3365 fd = open(dumpFile, 0);
3366 if ((fd < 0) || (fstat(fd, &status) < 0)) {
3368 tst = ADMVOSDUMPFILEOPENFAIL;
3369 goto fail_vos_VolumeRestore;
3374 if (!VLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
3375 restoreflags = RV_FULLRST;
3376 } else if (Lp_GetRwIndex(c_handle, &entry, 0) == -1) {
3377 restoreflags = RV_FULLRST;
3379 volid = entry.volumeId[RWVOL];
3380 } else if ((entry.volumeId[RWVOL] != 0) &&
3381 (entry.volumeId[RWVOL] != volid)) {
3382 volid = entry.volumeId[RWVOL];
3387 volid = entry.volumeId[RWVOL];
3388 } else if ((entry.volumeId[RWVOL] != 0) &&
3389 (entry.volumeId[RWVOL] != volid)) {
3390 volid = entry.volumeId[RWVOL];
3394 * If the vldb says the same volume exists somewhere else
3395 * the caller must specify a full restore, not an incremental
3398 if (dumpType == VOS_RESTORE_FULL) {
3399 restoreflags = RV_FULLRST;
3403 * Check to see if the volume exists where the caller said
3405 if (!GetVolumeInfo(c_handle, volid, &Oentry, &Oserver, &Opart,
3407 goto fail_vos_VolumeRestore;
3409 if (!VLDB_IsSameAddrs(c_handle, Oserver, server, &equal, &tst)) {
3410 goto fail_vos_VolumeRestore;
3414 tst = ADMVOSRESTOREVOLEXIST;
3415 goto fail_vos_VolumeRestore;
3420 rc = UV_RestoreVolume(c_handle, server, partition, volid, volumeName,
3421 restoreflags, dumpFile, &tst);
3423 fail_vos_VolumeRestore:
3432 * vos_VolumeOnline - bring a volume online.
3436 * IN serverHandle - a previously opened serverHandle that corresponds
3437 * to the server where the volume exists.
3439 * IN callBack - a call back function pointer that may be called to report
3440 * status information. Can be null.
3442 * IN partition - the partition where the volume exists.
3444 * IN volumeId - the volume id of the volume to be brought online.
3448 * No locks are obtained or released by this function
3452 * Returns != 0 upon successful completion.
3455 int ADMINAPI vos_VolumeOnline(
3456 const void *serverHandle,
3457 vos_MessageCallBack_t callBack,
3458 unsigned int partition,
3459 unsigned int volumeId,
3460 unsigned int sleepTime,
3461 vos_volumeOnlineType_t volumeStatus,
3465 afs_status_t tst = 0;
3466 file_server_p f_server = (file_server_p) serverHandle;
3470 * Validate arguments
3473 if (!IsValidServerHandle(f_server, &tst)) {
3474 goto fail_vos_VolumeOnline;
3477 if (partition > VOLMAXPARTS) {
3478 tst = ADMVOSPARTITIONIDTOOLARGE;
3479 goto fail_vos_VolumeOnline;
3482 if (volumeStatus == VOS_ONLINE_BUSY) {
3486 rc = UV_SetVolume(f_server->serv, partition, volumeId, up, 0,
3489 fail_vos_VolumeOnline:
3498 * vos_VolumeOffline - take a volume offline.
3502 * IN serverHandle - a previously opened serverHandle that corresponds
3503 * to the server where the volume exists.
3505 * IN callBack - a call back function pointer that may be called to report
3506 * status information. Can be null.
3508 * IN partition - the partition where the volume exists.
3510 * IN volumeId - the volume id of the volume to be taken offline.
3514 * No locks are obtained or released by this function
3518 * Returns != 0 upon successful completion.
3521 int ADMINAPI vos_VolumeOffline(
3522 const void *serverHandle,
3523 vos_MessageCallBack_t callBack,
3524 unsigned int partition,
3525 unsigned int volumeId,
3529 afs_status_t tst = 0;
3530 file_server_p f_server = (file_server_p) serverHandle;
3533 * Validate arguments
3536 if (!IsValidServerHandle(f_server, &tst)) {
3537 goto fail_vos_VolumeOffline;
3540 if (partition > VOLMAXPARTS) {
3541 tst = ADMVOSPARTITIONIDTOOLARGE;
3542 goto fail_vos_VolumeOffline;
3545 rc = UV_SetVolume(f_server->serv, partition, volumeId, ITOffline,
3546 VTOutOfService, 0, &tst);
3548 fail_vos_VolumeOffline:
3557 * copyvolintXInfo - copy a struct volintXInfo to a vos_volumeEntry_p.
3561 * IN source - the volintXInfo structure to copy.
3563 * OUT dest - the vos_volumeEntry_t to fill
3567 * No locks are obtained or released by this function
3571 * Returns != 0 upon successful completion.
3574 static int copyvolintXInfo(
3575 struct volintXInfo *source,
3576 vos_volumeEntry_p dest,
3580 afs_status_t tst = 0;
3584 * If the volume is not marked OK, all the other fields are invalid
3585 * We take the extra step of blanking out dest here to prevent the
3586 * user from seeing stale data from a previous call
3589 memset(dest, 0, sizeof(dest));
3591 switch(source->status){
3593 dest->status = VOS_OK;
3596 dest->status = VOS_SALVAGE;
3599 dest->status = VOS_NO_VNODE;
3602 dest->status = VOS_NO_VOL;
3605 dest->status = VOS_VOL_EXISTS;
3608 dest->status = VOS_NO_SERVICE;
3611 dest->status = VOS_OFFLINE;
3614 dest->status = VOS_ONLINE;
3617 dest->status = VOS_DISK_FULL;
3620 dest->status = VOS_OVER_QUOTA;
3623 dest->status = VOS_BUSY;
3626 dest->status = VOS_MOVED;
3631 * Check to see if the entry is marked ok before copying all the
3635 if (dest->status == VOS_OK) {
3636 strcpy(dest->name, source->name);
3637 dest->id = source->volid;
3638 if (source->type == 0) {
3639 dest->type = VOS_READ_WRITE_VOLUME;
3640 } else if (source->type == 1) {
3641 dest->type = VOS_READ_ONLY_VOLUME;
3642 } else if (source->type == 2) {
3643 dest->type = VOS_BACKUP_VOLUME;
3645 dest->backupId = source->backupID;
3646 dest->readWriteId = source->parentID;
3647 dest->readOnlyId = source->cloneID;
3648 dest->copyCreationDate = source->copyDate;
3649 dest->creationDate = source->creationDate;
3650 dest->lastAccessDate = source->accessDate;
3651 dest->lastUpdateDate = source->updateDate;
3652 dest->lastBackupDate = source->backupDate;
3653 dest->accessesSinceMidnight = source->dayUse;
3654 dest->fileCount = source->filecount;
3655 dest->maxQuota = source->maxquota;
3656 dest->currentSize = source->size;
3657 if (source->inUse == 1) {
3658 dest->volumeDisposition = VOS_ONLINE;
3660 dest->volumeDisposition = VOS_OFFLINE;
3663 for(i=0;i<VOS_VOLUME_READ_WRITE_STATS_NUMBER;i++) {
3664 dest->readStats[i] = source->stat_reads[i];
3665 dest->writeStats[i] = source->stat_writes[i];
3668 for(i=0;i<VOS_VOLUME_TIME_STATS_NUMBER;i++) {
3669 dest->fileAuthorWriteSameNetwork[i] = source->stat_fileSameAuthor[i];
3670 dest->fileAuthorWriteDifferentNetwork[i] =
3671 source->stat_fileDiffAuthor[i];
3672 dest->dirAuthorWriteSameNetwork[i] = source->stat_dirSameAuthor[i];
3673 dest->dirAuthorWriteDifferentNetwork[i] = source->stat_dirDiffAuthor[i];
3686 * vos_VolumeGet - get information about a particular volume.
3690 * IN cellHandle - a previously opened cellHandle that corresponds
3691 * to the cell where the volume exists.
3693 * IN serverHandle - a previously opened serverHandle that corresponds
3694 * to the server where the volume exists.
3696 * IN callBack - a call back function pointer that may be called to report
3697 * status information. Can be null.
3699 * IN partition - the partition where the volume exists.
3701 * IN volumeId - the volume id of the volume to be retrieved.
3703 * OUT volumeP - upon successful completion, contains the information about the
3708 * No locks are obtained or released by this function
3712 * Returns != 0 upon successful completion.
3715 int ADMINAPI vos_VolumeGet(
3716 const void *cellHandle,
3717 const void *serverHandle,
3718 vos_MessageCallBack_t callBack,
3719 unsigned int partition,
3720 unsigned int volumeId,
3721 vos_volumeEntry_p volumeP,
3725 afs_status_t tst = 0;
3726 file_server_p f_server = (file_server_p) serverHandle;
3727 struct volintXInfo *info = NULL;
3730 * Validate arguments
3733 if (!IsValidServerHandle(f_server, &tst)) {
3734 goto fail_vos_VolumeGet;
3737 if (partition > VOLMAXPARTS) {
3738 tst = ADMVOSPARTITIONIDTOOLARGE;
3739 goto fail_vos_VolumeGet;
3742 if (volumeP == NULL) {
3743 tst = ADMVOSVOLUMEPNULL;
3744 goto fail_vos_VolumeGet;
3748 * Retrieve the information for the volume
3751 if (!UV_XListOneVolume(f_server->serv, partition, volumeId, &info, &tst)) {
3752 goto fail_vos_VolumeGet;
3756 * Copy the volume info to our structure
3759 if (!copyvolintXInfo(info, volumeP, &tst)) {
3760 goto fail_vos_VolumeGet;
3777 * The iterator functions and data for the volume retrieval functions.
3780 typedef struct volume_get {
3781 struct volintXInfo *vollist;
3782 afs_int32 total; /* total number of volumes at this partition */
3783 afs_int32 index; /* index to the current volume */
3784 vos_volumeEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
3785 } volume_get_t, *volume_get_p;
3787 static int GetVolumeRPC(
3791 int *last_item_contains_data,
3795 afs_status_t tst = 0;
3796 volume_get_p entry = (volume_get_p) rpc_specific;
3799 * Copy the next entry into the cache
3802 if (!copyvolintXInfo(&entry->vollist[entry->index],
3803 &entry->entry[slot],
3805 goto fail_GetVolumeRPC;
3810 * See if we've processed all the entries
3814 if (entry->index == entry->total) {
3816 *last_item_contains_data = 1;
3828 static int GetVolumeFromCache(
3835 afs_status_t tst = 0;
3836 volume_get_p entry = (volume_get_p) rpc_specific;
3838 memcpy(dest, (const void *) &entry->entry[slot],
3839 sizeof(vos_volumeEntry_t));
3849 static int DestroyVolume(
3854 afs_status_t tst = 0;
3855 volume_get_p entry = (volume_get_p) rpc_specific;
3857 if (entry->vollist != NULL) {
3858 free(entry->vollist);
3870 * vos_VolumeGetBegin - begin to iterator over the list of volumes at a server.
3874 * IN cellHandle - a previously opened cellHandle that corresponds
3875 * to the cell where the volumes exist.
3877 * IN serverHandle - a handle to the server where the volumes exist.
3879 * IN callBack - a call back function pointer that may be called to report
3880 * status information. Can be null.
3882 * IN partition - the partition whose volumes should be listed. Can be null.
3884 * OUT iterationIdP - upon successful completion, contains an iterator that
3885 * can be passed to vos_VolumeGetBegin.
3889 * No locks are obtained or released by this function
3893 * Returns != 0 upon successful completion.
3896 int ADMINAPI vos_VolumeGetBegin(
3897 const void *cellHandle,
3898 const void *serverHandle,
3899 vos_MessageCallBack_t callBack,
3900 unsigned int partition,
3901 void **iterationIdP,
3905 afs_status_t tst = 0;
3906 file_server_p f_server = (file_server_p) serverHandle;
3907 afs_admin_iterator_p iter = (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
3908 volume_get_p entry = (volume_get_p) calloc(1, sizeof(volume_get_t));
3911 * Validate arguments
3914 if (!IsValidServerHandle(f_server, &tst)) {
3915 goto fail_vos_VolumeGetBegin;
3918 if (partition > VOLMAXPARTS) {
3919 tst = ADMVOSPARTITIONIDTOOLARGE;
3920 goto fail_vos_VolumeGetBegin;
3923 if ((iter == NULL) || (entry == NULL)) {
3925 goto fail_vos_VolumeGetBegin;
3929 * Get a list of all the volumes contained in the partition at the
3933 if (!UV_XListVolumes(f_server->serv, partition, 1, &entry->vollist,
3934 &entry->total, &tst)) {
3935 goto fail_vos_VolumeGetBegin;
3938 if (entry->total == 0) {
3939 if (!IteratorInit(iter, (void *) entry, NULL, NULL, NULL, NULL, &tst)) {
3940 goto fail_vos_VolumeGetBegin;
3942 iter->done_iterating = 1;
3943 iter->st = ADMITERATORDONE;
3945 if (!IteratorInit(iter, (void *) entry, GetVolumeRPC,
3946 GetVolumeFromCache, NULL, DestroyVolume, &tst)) {
3947 goto fail_vos_VolumeGetBegin;
3950 *iterationIdP = (void *) iter;
3953 fail_vos_VolumeGetBegin:
3959 if (entry != NULL) {
3971 * vos_VolumeGetNext - get information about the next volume.
3975 * IN iterationId - an iterator previously returned by
3976 * vos_VolumeGetBegin
3978 * OUT volumeP - a pointer to a vos_volumeEntry_t
3979 * that upon successful completion contains information about the
3984 * The iterator is locked while the next item is retrieved.
3988 * Returns != 0 upon successful completion.
3991 int ADMINAPI vos_VolumeGetNext(
3992 const void *iterationId,
3993 vos_volumeEntry_p volumeP,
3997 afs_status_t tst = 0;
3998 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
4001 tst = ADMITERATORNULL;
4002 goto fail_vos_VolumeGetNext;
4005 if (volumeP == NULL) {
4006 tst = ADMVOSVOLUMEPNULL;
4007 goto fail_vos_VolumeGetNext;
4010 rc = IteratorNext(iter, (void *) volumeP, &tst);
4012 fail_vos_VolumeGetNext:
4021 * vos_VolumeGetDone - finish using a volume iterator.
4025 * IN iterationId - an iterator previously returned by vos_VolumeGetBegin
4029 * The iterator is locked and then destroyed.
4033 * Returns != 0 upon successful completion.
4036 int ADMINAPI vos_VolumeGetDone(
4037 const void *iterationId,
4041 afs_status_t tst = 0;
4042 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
4045 * Validate arguments
4049 tst = ADMITERATORNULL;
4050 goto fail_vos_VolumeGetDone;
4053 rc = IteratorDone(iter, &tst);
4055 fail_vos_VolumeGetDone:
4064 * vos_VolumeMove - move a volume from one server to another.
4068 * IN cellHandle - a previously opened cellHandle that corresponds
4069 * to the cell where the volume exists.
4071 * IN callBack - a call back function pointer that may be called to report
4072 * status information. Can be null.
4074 * IN volumeId - the volume id of the volume to be moved.
4076 * IN fromServer - a previously opened serverHandle that corresponds
4077 * to the server where the volume currently resides.
4079 * IN fromPartition - the partition where the volume currently resides.
4081 * IN toServer - a previously opened serverHandle that corresponds
4082 * to the server where the volume will be moved.
4084 * IN toPartition - the partition where the volume will be moved.
4088 * No locks are obtained or released by this function
4092 * Returns != 0 upon successful completion.
4095 int ADMINAPI vos_VolumeMove(
4096 const void *cellHandle,
4097 vos_MessageCallBack_t callBack,
4098 unsigned int volumeId,
4099 const void *fromServer,
4100 unsigned int fromPartition,
4101 const void *toServer,
4102 unsigned int toPartition,
4106 afs_status_t tst = 0;
4107 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4108 file_server_p from_server = (file_server_p) fromServer;
4109 file_server_p to_server = (file_server_p) toServer;
4110 afs_int32 from_server_addr = ntohl(rx_HostOf(rx_PeerOf(from_server->serv)));
4111 afs_int32 to_server_addr = ntohl(rx_HostOf(rx_PeerOf(to_server->serv)));
4112 afs_int32 from_partition = fromPartition;
4113 afs_int32 to_partition = toPartition;
4116 * Validate arguments
4119 if (!IsValidCellHandle(c_handle, &tst)) {
4120 goto fail_vos_VolumeMove;
4123 if (!IsValidServerHandle(from_server, &tst)) {
4124 goto fail_vos_VolumeMove;
4127 if (!IsValidServerHandle(to_server, &tst)) {
4128 goto fail_vos_VolumeMove;
4131 if (fromPartition > VOLMAXPARTS) {
4132 tst = ADMVOSPARTITIONIDTOOLARGE;
4133 goto fail_vos_VolumeMove;
4136 if (toPartition > VOLMAXPARTS) {
4137 tst = ADMVOSPARTITIONIDTOOLARGE;
4138 goto fail_vos_VolumeMove;
4145 rc = UV_MoveVolume(c_handle, volumeId, from_server_addr, from_partition,
4146 to_server_addr, to_partition, &tst);
4148 fail_vos_VolumeMove:
4157 * vos_VolumeRelease - release a volume.
4161 * IN cellHandle - a previously opened cellHandle that corresponds
4162 * to the cell where the volume exists.
4164 * IN callBack - a call back function pointer that may be called to report
4165 * status information. Can be null.
4167 * IN volumeId - the volume to be released.
4169 * IN force - force a complete release.
4173 * No locks are obtained or released by this function
4177 * Returns != 0 upon successful completion.
4180 int ADMINAPI vos_VolumeRelease(
4181 const void *cellHandle,
4182 vos_MessageCallBack_t callBack,
4183 unsigned int volumeId,
4188 afs_status_t tst = 0;
4189 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4190 afs_int32 server, part, forc = 0, voltype, volume;
4191 struct nvldbentry entry;
4194 * Validate arguments
4197 if (!IsValidCellHandle(c_handle, &tst)) {
4198 goto fail_vos_VolumeRelease;
4201 if (!GetVolumeInfo(c_handle, volumeId, &entry, &server,
4202 &part, &voltype, &tst)) {
4203 goto fail_vos_VolumeRelease;
4206 if (force == VOS_FORCE) {
4211 rc = UV_ReleaseVolume(c_handle, volume, server, part, forc, &tst);
4213 fail_vos_VolumeRelease:
4222 * vos_VolumeZap - forcibly delete a volume.
4226 * IN cellHandle - a previously opened cellHandle that corresponds
4227 * to the cell where the volume exists.
4229 * IN serverHandle - a previously opened serverHandle that corresponds
4230 * to the server where the volume exists.
4232 * IN callBack - a call back function pointer that may be called to report
4233 * status information. Can be null.
4235 * IN partition - the partition where the volume exists.
4237 * IN volumeId - the volume id of the vldb entry to be deleted.
4239 * IN force - force the deletion of bad volumes.
4243 * No locks are obtained or released by this function
4247 * Returns != 0 upon successful completion.
4250 int ADMINAPI vos_VolumeZap(
4251 const void *cellHandle,
4252 const void *serverHandle,
4253 vos_MessageCallBack_t callBack,
4254 unsigned int partition,
4255 unsigned int volumeId,
4260 afs_status_t tst = 0;
4261 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4262 file_server_p f_server = (file_server_p) serverHandle;
4265 * Verify that the cellHandle is capable of making vos rpc's
4268 if (!IsValidCellHandle(c_handle, &tst)) {
4269 goto fail_vos_VolumeZap;
4272 if (!IsValidServerHandle(f_server, &tst)) {
4273 goto fail_vos_VolumeZap;
4276 if (force == VOS_FORCE) {
4277 rc = UV_NukeVolume(c_handle, f_server->serv, partition, volumeId, &tst);
4279 rc = UV_VolumeZap(c_handle, f_server->serv, partition, volumeId, &tst);
4291 * vos_PartitionNameToId - translate a string representing a partition
4296 * IN partitionName - a string representing a partition. Must be of
4299 * OUT partitionId - a number containing the partition id upon successful
4304 * No locks are obtained or released by this function
4308 * Returns != 0 upon successful completion.
4311 int ADMINAPI vos_PartitionNameToId(
4312 const char *partitionName,
4313 unsigned int *partitionId,
4317 afs_status_t tst = 0;
4318 size_t partition_name_len;
4322 * Validate arguments
4325 if (partitionName == NULL) {
4326 tst = ADMVOSPARTITIONNAMENULL;
4327 goto fail_vos_PartitionNameToId;
4330 if (partitionId == NULL) {
4331 tst = ADMVOSPARTITIONIDNULL;
4332 goto fail_vos_PartitionNameToId;
4336 * Check that string begins with /vicep
4339 if (strncmp(partitionName, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
4340 tst = ADMVOSPARTITIONNAMEINVALID;
4341 goto fail_vos_PartitionNameToId;
4345 * Check that the string is either one or two characters
4346 * longer than VICE_PREFIX_SIZE
4349 partition_name_len = strlen(partitionName);
4351 if (partition_name_len == VICE_PREFIX_SIZE) {
4352 tst = ADMVOSPARTITIONNAMETOOSHORT;
4353 goto fail_vos_PartitionNameToId;
4356 if (partition_name_len > (VICE_PREFIX_SIZE + 2)) {
4357 tst = ADMVOSPARTITIONNAMETOOLONG;
4358 goto fail_vos_PartitionNameToId;
4362 * Check that all characters past the prefix are lower case
4365 for(i=VICE_PREFIX_SIZE;i<partition_name_len;i++) {
4366 if (!islower(partitionName[i])) {
4367 tst = ADMVOSPARTITIONNAMENOTLOWER;
4368 goto fail_vos_PartitionNameToId;
4373 * Convert the name to a number
4376 if (partitionName[VICE_PREFIX_SIZE + 1] == 0) {
4377 *partitionId = partitionName[VICE_PREFIX_SIZE] - 'a';
4379 *partitionId = (partitionName[VICE_PREFIX_SIZE] - 'a') * 26 +
4380 (partitionName[VICE_PREFIX_SIZE + 1] - 'a') + 26;
4383 if (*partitionId > VOLMAXPARTS) {
4384 tst = ADMVOSPARTITIONIDTOOLARGE;
4385 goto fail_vos_PartitionNameToId;
4389 fail_vos_PartitionNameToId:
4398 * vos_PartitionIdToName - translate a number representing a partition
4399 * to a character string.
4403 * IN partitionId - an integer representing the partition.
4405 * OUT partitionName - a string containing the converted partition ID
4406 * upon successful completion.
4410 * No locks are obtained or released by this function
4414 * Returns != 0 upon successful completion.
4417 int ADMINAPI vos_PartitionIdToName(
4418 unsigned int partitionId,
4419 char *partitionName,
4423 afs_status_t tst = 0;
4425 if (partitionId > VOLMAXPARTS) {
4426 tst = ADMVOSPARTITIONIDTOOLARGE;
4427 goto fail_vos_PartitionIdToName;
4430 if (partitionName == NULL) {
4431 tst = ADMVOSPARTITIONNAMENULL;
4432 goto fail_vos_PartitionIdToName;
4435 if(partitionId < 26) {
4436 strcpy(partitionName, VICE_PARTITION_PREFIX);
4437 partitionName[6] = partitionId + 'a';
4438 partitionName[7] = '\0';
4440 strcpy(partitionName, VICE_PARTITION_PREFIX);
4442 partitionName[6] = 'a' + (partitionId/26);
4443 partitionName[7] = 'a' + (partitionId%26);
4444 partitionName[8] = '\0';
4448 fail_vos_PartitionIdToName:
4457 * vos_VolumeQuotaChange - change the quota of a volume.
4461 * IN cellHandle - a previously opened cellHandle that corresponds
4462 * to the cell where the volume exists.
4464 * IN serverHandle - a previously opened serverHandle that corresponds
4465 * to the server where the volume exists.
4467 * IN callBack - a call back function pointer that may be called to report
4468 * status information. Can be null.
4470 * IN partition - the partition where the volume exists.
4472 * IN volumeId - the volume id of the volume to be modified.
4474 * IN volumeQuota - the new volume quota.
4478 * No locks are obtained or released by this function
4482 * Returns != 0 upon successful completion.
4485 int ADMINAPI vos_VolumeQuotaChange(
4486 const void *cellHandle,
4487 const void *serverHandle,
4488 vos_MessageCallBack_t callBack,
4489 unsigned int partition,
4490 unsigned int volumeId,
4491 unsigned int volumeQuota,
4495 afs_status_t tst = 0;
4496 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4497 file_server_p f_server = (file_server_p) serverHandle;
4500 struct volintInfo tstatus;
4501 int active_trans = 0;
4504 * Verify that the cellHandle is capable of making vos rpc's
4507 if (!IsValidCellHandle(c_handle, &tst)) {
4508 goto fail_vos_VolumeQuotaChange;
4511 if (!IsValidServerHandle(f_server, &tst)) {
4512 goto fail_vos_VolumeQuotaChange;
4515 memset((void *) &tstatus, 0, sizeof(tstatus));
4516 tstatus.dayUse = -1;
4517 tstatus.maxquota = volumeQuota;
4519 tst = AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
4521 goto fail_vos_VolumeQuotaChange;
4525 tst = AFSVolSetInfo(f_server->serv, ttid, &tstatus);
4527 goto fail_vos_VolumeQuotaChange;
4531 fail_vos_VolumeQuotaChange:
4534 afs_status_t tst2 = 0;
4535 tst2 = AFSVolEndTrans(f_server->serv, ttid, &rcode);