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 <afsconfig.h>
11 #include <afs/param.h>
18 #include <afs/vlserver.h>
19 #include <afs/volser.h>
20 #include <afs/volint.h>
22 #include "afs_vosAdmin.h"
23 #include "../adminutil/afs_AdminInternal.h"
25 /* File descriptors are HANDLE's on NT. The following typedef helps catch
26 * type errors. Duplicated from vol/ihandle.h
33 #define INVALID_FD ((FD_t)-1)
35 #include <afs/partition.h>
37 #include <rx/rxstat.h>
38 #include <afs/afs_utilAdmin.h>
41 #include "lockprocs.h"
43 typedef struct file_server {
46 struct rx_connection *serv;
48 } file_server_t, *file_server_p;
51 * IsValidServerHandle - test a server handle for validity.
55 * IN serverHandle - the serverHandle to be validated.
59 * No locks are obtained or released by this function
63 * Returns != 0 upon successful completion.
67 IsValidServerHandle(file_server_p serverHandle, afs_status_p st)
72 if (serverHandle == NULL) {
73 tst = ADMVOSSERVERHANDLENULL;
74 goto fail_IsValidServerHandle;
77 if (serverHandle->is_valid != 1) {
78 tst = ADMVOSSERVERHANDLEINVALID;
79 goto fail_IsValidServerHandle;
82 if ((serverHandle->begin_magic != BEGIN_MAGIC)
83 || (serverHandle->end_magic != END_MAGIC)) {
84 tst = ADMVOSSERVERHANDLEBADMAGIC;
85 goto fail_IsValidServerHandle;
89 fail_IsValidServerHandle:
99 * IsValidCellHandle - verify that a cell handle can be used to make vos
104 * IN cellHandle - the cellHandle to be validated.
108 * No locks are obtained or released by this function
112 * Returns != 0 upon successful completion.
116 IsValidCellHandle(afs_cell_handle_p cellHandle, afs_status_p st)
119 afs_status_t tst = 0;
121 if (!CellHandleIsValid((void *)cellHandle, &tst)) {
122 goto fail_IsValidCellHandle;
125 if (cellHandle->vos_valid == 0) {
126 tst = ADMVOSCELLHANDLEINVALIDVOS;
127 goto fail_IsValidCellHandle;
131 fail_IsValidCellHandle:
139 /* set <server> and <part> to the correct values depending on
140 * <voltype> and <entry> */
142 GetServerAndPart(struct nvldbentry *entry, int voltype, afs_int32 * server,
143 afs_int32 * part, int *previdx)
145 int i, istart, vtype;
150 /* Doesn't check for non-existance of backup volume */
151 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
153 istart = 0; /* seach the entire entry */
156 /* Seach from beginning of entry or pick up where we left off */
157 istart = ((*previdx < 0) ? 0 : *previdx + 1);
160 for (i = istart; i < entry->nServers; i++) {
161 if (entry->serverFlags[i] & vtype) {
162 *server = entry->serverNumber[i];
163 *part = entry->serverPartition[i];
169 /* Didn't find any, return -1 */
175 * vos_BackupVolumeCreate - create a backup volume for a volume.
179 * IN cellHandle - a previously opened cellHandle that corresponds
180 * to the cell where volume exists.
182 * IN callBack - a call back function pointer that may be called to report
183 * status information. Can be null.
185 * IN volumeId - the volume to create the back up for.
189 * No locks are obtained or released by this function
193 * Returns != 0 upon successful completion.
197 vos_BackupVolumeCreate(const void *cellHandle, vos_MessageCallBack_t callBack,
198 unsigned int volumeId, afs_status_p st)
201 afs_status_t tst = 0;
202 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
203 struct nvldbentry rw_vol_entry;
205 afs_int32 rw_partition;
206 afs_int32 rw_vol_type;
207 struct nvldbentry bk_vol_entry;
209 afs_int32 bk_partition;
210 afs_int32 bk_vol_type;
217 if (!IsValidCellHandle(c_handle, &tst)) {
218 goto fail_vos_BackupVolumeCreate;
222 * Get the volume information and verify that we've been passed
223 * a read write volume id
227 (c_handle, volumeId, &rw_vol_entry, &rw_server, &rw_partition,
228 &rw_vol_type, &tst)) {
229 goto fail_vos_BackupVolumeCreate;
232 if (rw_vol_type != RWVOL) {
233 tst = ADMVOSMUSTBERWVOL;
234 goto fail_vos_BackupVolumeCreate;
238 * Check to see that if a backup volume exists, it exists on the
239 * same server as volumeId
242 if (rw_vol_entry.flags & BACK_EXISTS) {
244 (c_handle, rw_vol_entry.volumeId[BACKVOL], &bk_vol_entry,
245 &bk_server, &bk_partition, &bk_vol_type, &tst)) {
246 goto fail_vos_BackupVolumeCreate;
248 if (!VLDB_IsSameAddrs(c_handle, bk_server, rw_server, &equal, &tst)) {
249 goto fail_vos_BackupVolumeCreate;
252 tst = ADMVOSBACKUPVOLWRONGSERVER;
253 goto fail_vos_BackupVolumeCreate;
258 * Create the new backup volume
261 rc = UV_BackupVolume(c_handle, rw_server, rw_partition, volumeId, &tst);
263 fail_vos_BackupVolumeCreate:
272 * vos_BackupVolumeCreateMultiple - create backup volumes en masse.
276 * IN cellHandle - a previously opened cellHandle that corresponds
277 * to the cell where the volumes exist.
279 * IN serverHandle - the server where the backups are to be created. Can be
282 * IN callBack - a call back function pointer that may be called to report
283 * status information. Can be null.
285 * IN partition - the partition where the backups are to be created. Can be
288 * IN volumePrefix - all volumes with this prefix will have backup volumes
289 * created. Can be null.
291 * IN excludePrefix - exclude the volumes that match volumePrefix.
295 * No locks are obtained or released by this function
299 * Returns != 0 upon successful completion.
303 vos_BackupVolumeCreateMultiple(const void *cellHandle,
304 const void *serverHandle,
305 vos_MessageCallBack_t callBack,
306 const unsigned int *partition,
307 const char *volumePrefix,
308 vos_exclude_t excludePrefix, afs_status_p st)
311 afs_status_t tst = 0;
312 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
313 file_server_p f_server = (file_server_p) serverHandle;
314 struct VldbListByAttributes attr;
317 size_t prefix_len = 0;
318 nbulkentries arrayEntries;
319 afs_int32 nentries = 0;
320 struct nvldbentry *entry;
322 afs_int32 rw_volid, rw_server, rw_partition;
327 memset((void *)&attr, 0, sizeof(attr));
332 * The only required argument to this function is the cellHandle.
333 * If the excludePrefix is set to VOS_EXCLUDE, volumePrefix must
337 if (!IsValidCellHandle(c_handle, &tst)) {
338 goto fail_vos_BackupVolumeCreateMultiple;
341 if ((excludePrefix == VOS_EXCLUDE)
342 && ((volumePrefix == NULL) || (*volumePrefix == 0))) {
343 tst = ADMVOSEXCLUDEREQUIRESPREFIX;
344 goto fail_vos_BackupVolumeCreateMultiple;
347 if (f_server != NULL) {
348 if (!IsValidServerHandle(f_server, &tst)) {
349 goto fail_vos_BackupVolumeCreateMultiple;
351 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
352 attr.Mask |= VLLIST_SERVER;
355 if (partition != NULL) {
356 if (*partition > VOLMAXPARTS) {
357 tst = ADMVOSPARTITIONTOOLARGE;
358 goto fail_vos_BackupVolumeCreateMultiple;
360 attr.partition = *partition;
361 attr.Mask |= VLLIST_PARTITION;
364 if (excludePrefix == VOS_EXCLUDE) {
368 if ((volumePrefix != NULL) && (*volumePrefix != 0)) {
370 prefix_len = strlen(volumePrefix);
373 memset((void *)&arrayEntries, 0, sizeof(arrayEntries));
376 * Get a list of all the volumes in the cell
379 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &arrayEntries, &tst)) {
380 goto fail_vos_BackupVolumeCreateMultiple;
384 * Cycle through the list of volumes and see if we should create a backup
385 * for each individual volume
388 for (i = 0; i < nentries; i++) {
389 entry = &arrayEntries.nbulkentries_val[i];
392 * Skip entries that don't have a RW volume
395 if (!(entry->flags & RW_EXISTS)) {
396 if (callBack != NULL) {
397 const char *messageText;
398 if (util_AdminErrorCodeTranslate
399 (ADMVOSVOLUMENOREADWRITE, 0, &messageText, &tst)) {
400 sprintf(backbuf, "%s %s", messageText, entry->name);
401 (**callBack) (VOS_VERBOSE_MESSAGE, backbuf);
408 * See if we should skip this entry because of the prefix/exclude
409 * combination we've been passed
414 if (!strncmp(entry->name, volumePrefix, prefix_len)) {
418 if (strncmp(entry->name, volumePrefix, prefix_len)) {
424 rw_volid = entry->volumeId[RWVOL];
425 GetServerAndPart(entry, RWVOL, &rw_server, &rw_partition, &previdx);
427 if ((rw_server == -1) || (rw_partition == -1)) {
428 if (callBack != NULL) {
429 const char *messageText;
430 if (util_AdminErrorCodeTranslate
431 (ADMVOSVLDBBADENTRY, 0, &messageText, &tst)) {
432 sprintf(backbuf, "%s %s", messageText, entry->name);
433 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
440 * Check that the RW volume is on the same server that we were
444 if (serverHandle != NULL) {
445 if (!VLDB_IsSameAddrs
446 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))),
447 rw_server, &equal, &tst)) {
448 if (callBack != NULL) {
449 const char *messageText;
450 if (util_AdminErrorCodeTranslate
451 (ADMVOSVLDBBADSERVER, 0, &messageText, &tst)) {
452 sprintf(backbuf, "%s %x %d", messageText,
453 ntohl(rx_HostOf(rx_PeerOf(f_server->serv))),
455 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
461 if (callBack != NULL) {
462 const char *messageText;
463 if (util_AdminErrorCodeTranslate
464 (ADMVOSVLDBDIFFERENTADDR, 0, &messageText, &tst)) {
465 sprintf(backbuf, "%s %s", messageText, entry->name);
466 (**callBack) (VOS_ERROR_MESSAGE, backbuf);
474 * Check that the RW volume is on the same partition we were
478 if (partition != NULL) {
479 if (*partition != rw_partition) {
488 rc = UV_BackupVolume(c_handle, rw_server, rw_partition, rw_volid,
492 fail_vos_BackupVolumeCreateMultiple:
494 if (arrayEntries.nbulkentries_val) {
495 free(arrayEntries.nbulkentries_val);
505 * vos_PartitionGet - get information about a single partition.
509 * IN cellHandle - a previously opened cellHandle that corresponds
510 * to the cell where the server lives.
512 * IN serverHandle - a previously open vos server handle that holds
513 * the partition of interest.
515 * IN callBack - a call back function pointer that may be called to report
516 * status information. Can be null.
518 * IN partition - the integer that represents the partition of interest.
520 * OUT partitionP - a pointer to a vos_partitionEntry_t that upon successful
521 * completion contains information regarding the partition.
525 * No locks are obtained or released by this function
529 * Returns != 0 upon successful completion.
533 vos_PartitionGet(const void *cellHandle, const void *serverHandle,
534 vos_MessageCallBack_t callBack, unsigned int partition,
535 vos_partitionEntry_p partitionP, afs_status_p st)
538 afs_status_t tst = 0;
539 struct diskPartition part_info;
540 file_server_p f_server = (file_server_p) serverHandle;
541 char partitionName[10]; /* this rpc requires a character partition name */
547 if (!IsValidServerHandle(f_server, &tst)) {
548 goto fail_vos_PartitionGet;
551 if (partitionP == NULL) {
552 tst = ADMVOSPARTITIONPNULL;
553 goto fail_vos_PartitionGet;
556 if (!vos_PartitionIdToName(partition, partitionName, &tst)) {
557 goto fail_vos_PartitionGet;
560 tst = AFSVolPartitionInfo(f_server->serv, partitionName, &part_info);
562 goto fail_vos_PartitionGet;
564 strncpy(partitionP->name, part_info.name, VOS_MAX_PARTITION_NAME_LEN);
565 partitionP->name[VOS_MAX_PARTITION_NAME_LEN-1] = '\0';
566 strncpy(partitionP->deviceName, part_info.devName, VOS_MAX_PARTITION_NAME_LEN);
567 partitionP->deviceName[VOS_MAX_PARTITION_NAME_LEN-1] = '\0';
568 partitionP->lockFileDescriptor = part_info.lock_fd;
569 partitionP->totalSpace = part_info.minFree;
570 partitionP->totalFreeSpace = part_info.free;
573 fail_vos_PartitionGet:
582 * The iterator functions and data for the partition retrieval functions.
585 typedef struct partition_get {
586 afs_int32 total_received; /* the total number of valid partiions retrieved */
587 int number_processed; /* the number of valid paritions we've handed out */
588 int index; /* the current index into the part_list array */
589 struct partList part_list; /* the list of partitions */
590 vos_partitionEntry_t partition[CACHED_ITEMS]; /* the cache of partitions */
591 const void *server; /* the server where the parititions exist */
592 } partition_get_t, *partition_get_p;
595 GetPartitionInfoRPC(void *rpc_specific, int slot, int *last_item,
596 int *last_item_contains_data, afs_status_p st)
599 afs_status_t tst = 0;
600 partition_get_p part = (partition_get_p) rpc_specific;
601 vos_partitionEntry_p ptr = (vos_partitionEntry_p) & part->partition[slot];
604 * Skip partition entries that are not valid
607 while (!(part->part_list.partFlags[part->index] & PARTVALID)) {
612 * Get information for the next partition
615 if (!vos_PartitionGet
617 (unsigned int)part->part_list.partId[part->index], ptr, &tst)) {
618 goto fail_GetPartitionInfoRPC;
622 part->number_processed++;
624 if (part->number_processed == part->total_received) {
626 *last_item_contains_data = 1;
630 fail_GetPartitionInfoRPC:
639 GetPartitionInfoFromCache(void *rpc_specific, int slot, void *dest,
643 afs_status_t tst = 0;
644 partition_get_p part = (partition_get_p) rpc_specific;
646 memcpy(dest, (const void *)&part->partition[slot],
647 sizeof(vos_partitionEntry_t));
657 * vos_PartitionGetBegin - begin to iterate over the partitions at a
662 * IN cellHandle - a previously opened cellHandle that corresponds
663 * to the cell where the server exists.
665 * IN serverHandle - the server that houses the partitions of interest.
667 * IN callBack - a call back function pointer that may be called to report
668 * status information. Can be null.
670 * OUT iterationIdP - upon successful completion, contains an iterator that can
671 * be passed to vos_PartitionGetNext.
675 * No locks are obtained or released by this function
679 * Returns != 0 upon successful completion.
683 vos_PartitionGetBegin(const void *cellHandle, const void *serverHandle,
684 vos_MessageCallBack_t callBack, void **iterationIdP,
688 afs_status_t tst = 0;
689 file_server_p f_server = (file_server_p) serverHandle;
690 afs_admin_iterator_p iter =
691 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
692 partition_get_p part = calloc(1, sizeof(partition_get_t));
698 if (!IsValidServerHandle(f_server, &tst)) {
699 goto fail_vos_PartitionGetBegin;
702 if (iterationIdP == NULL) {
703 goto fail_vos_PartitionGetBegin;
706 if ((iter == NULL) || (part == NULL)) {
708 goto fail_vos_PartitionGetBegin;
712 * Fill in the part structure
715 part->server = serverHandle;
716 if (!UV_ListPartitions
717 (f_server->serv, &part->part_list, &part->total_received, &tst)) {
718 goto fail_vos_PartitionGetBegin;
722 * If we didn't receive any partitions, don't spawn a background thread.
723 * Mark the iterator complete.
726 if (part->total_received == 0) {
727 if (!IteratorInit(iter, (void *)part, NULL, NULL, NULL, NULL, &tst)) {
728 goto fail_vos_PartitionGetBegin;
730 iter->done_iterating = 1;
731 iter->st = ADMITERATORDONE;
734 (iter, (void *)part, GetPartitionInfoRPC,
735 GetPartitionInfoFromCache, NULL, NULL, &tst)) {
736 goto fail_vos_PartitionGetBegin;
739 *iterationIdP = (void *)iter;
742 fail_vos_PartitionGetBegin:
760 * vos_PartitionGetNext - get the next partition at a server.
764 * IN iterationId - an iterator previously returned by vos_PartitionGetBegin
766 * OUT partitionP - a pointer to a vos_partitionEntry_t that upon successful
767 * completion contains the next partition.
771 * The iterator is locked while the next parition is retrieved.
775 * Returns != 0 upon successful completion.
779 vos_PartitionGetNext(const void *iterationId, vos_partitionEntry_p partitionP,
783 afs_status_t tst = 0;
784 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
787 tst = ADMITERATORNULL;
788 goto fail_vos_PartitionGetNext;
791 if (partitionP == NULL) {
792 tst = ADMVOSPARTITIONPNULL;
793 goto fail_vos_PartitionGetNext;
796 rc = IteratorNext(iter, (void *)partitionP, &tst);
798 fail_vos_PartitionGetNext:
807 * vos_PartitionGetDone - finish using a partition iterator.
811 * IN iterationId - an iterator previously returned by vos_PartitionGetBegin
815 * The iterator is locked and then destroyed.
819 * Returns != 0 upon successful completion.
823 vos_PartitionGetDone(const void *iterationId, afs_status_p st)
826 afs_status_t tst = 0;
827 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
834 tst = ADMITERATORNULL;
835 goto fail_vos_PartitionGetDone;
838 rc = IteratorDone(iter, &tst);
840 fail_vos_PartitionGetDone:
849 * vos_ServerOpen - open a handle to an individual server for future
854 * IN cellHandle - a previously opened cellHandle that corresponds
855 * to the cell where the server lives.
857 * IN serverName - the machine name of the server
859 * OUT serverHandleP - a void pointer that upon successful completion
860 * contains a handle that is used in future operations upon the server.
864 * No locks are obtained or released by this function
868 * Returns != 0 upon successful completion.
872 vos_ServerOpen(const void *cellHandle, const char *serverName,
873 void **serverHandleP, afs_status_p st)
876 afs_status_t tst = 0;
877 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
878 file_server_p f_server = (file_server_p) malloc(sizeof(file_server_t));
880 struct rx_securityClass *sc[3];
883 if (f_server == NULL) {
885 goto fail_vos_ServerOpen;
892 if (!IsValidCellHandle(c_handle, &tst)) {
893 goto fail_vos_ServerOpen;
896 if (!c_handle->tokens->afs_token_set) {
897 tst = ADMVOSCELLHANDLENOAFSTOKENS;
898 goto fail_vos_ServerOpen;
901 if (!util_AdminServerAddressGetFromName
902 (serverName, &server_address, &tst)) {
903 goto fail_vos_ServerOpen;
906 scIndex = c_handle->tokens->sc_index;
907 sc[scIndex] = c_handle->tokens->afs_sc[scIndex];
909 rx_GetCachedConnection(htonl(server_address),
910 htons(AFSCONF_VOLUMEPORT), VOLSERVICE_ID,
911 sc[scIndex], scIndex);
912 if (f_server->serv != NULL) {
913 f_server->begin_magic = BEGIN_MAGIC;
914 f_server->end_magic = END_MAGIC;
915 f_server->is_valid = 1;
916 *serverHandleP = (void *)f_server;
919 tst = ADMVOSSERVERNOCONNECTION;
920 goto fail_vos_ServerOpen;
932 * vos_ServerClose - close a handle previously obtained from vos_ServerOpen
936 * IN serverHandle - an existing server handle.
940 * No locks are obtained or released by this function
944 * Returns != 0 upon successful completion.
948 vos_ServerClose(const void *serverHandle, afs_status_p st)
951 afs_status_t tst = 0;
952 file_server_p f_server = (file_server_p) serverHandle;
954 if (!IsValidServerHandle(f_server, &tst)) {
955 goto fail_vos_ServerClose;
958 rx_ReleaseCachedConnection(f_server->serv);
959 f_server->is_valid = 0;
963 fail_vos_ServerClose:
972 * vos_ServerSync - synchronize the vldb and the fileserver at a particular
977 * IN cellHandle - a previously opened cellHandle that corresponds
978 * to the cell where the server lives.
980 * IN serverHandle - a handle to the server machine.
982 * IN callBack - a call back function pointer that may be called to report
983 * status information. Can be null.
985 * IN partition - the partition to synchronize. Can be NULL.
987 * IN force - force deletion of bad volumes.
991 * No locks are obtained or released by this function
995 * Returns != 0 upon successful completion.
999 vos_ServerSync(const void *cellHandle, const void *serverHandle,
1000 vos_MessageCallBack_t callBack, const unsigned int *partition,
1004 afs_status_t tst = 0;
1005 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1006 file_server_p f_server = (file_server_p) serverHandle;
1011 * Validate arguments
1014 if (!IsValidCellHandle(c_handle, &tst)) {
1015 goto fail_vos_ServerSync;
1018 if (!IsValidServerHandle(f_server, &tst)) {
1019 goto fail_vos_ServerSync;
1022 if (partition != NULL) {
1023 if (*partition > VOLMAXPARTS) {
1024 tst = ADMVOSPARTITIONTOOLARGE;
1025 goto fail_vos_ServerSync;
1027 part = (afs_int32) * partition;
1035 rc = UV_SyncServer(c_handle, f_server->serv, part, flags, &tst);
1037 fail_vos_ServerSync:
1046 * vos_FileServerAddressChange - change an existing file server address.
1050 * IN cellHandle - a previously opened cellHandle that corresponds
1051 * to the cell where the address should be changed.
1053 * IN callBack - a call back function pointer that may be called to report
1054 * status information. Can be null.
1056 * IN oldAddress - the old server address in host byte order
1058 * IN newAddress - the new server address in host byte order
1062 * No locks are obtained or released by this function
1066 * Returns != 0 upon successful completion.
1070 vos_FileServerAddressChange(const void *cellHandle,
1071 vos_MessageCallBack_t callBack,
1072 unsigned int oldAddress,
1073 unsigned int newAddress, afs_status_p st)
1076 afs_status_t tst = 0;
1077 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1080 * Validate arguments
1083 if (!IsValidCellHandle(c_handle, &tst)) {
1084 goto fail_vos_FileServerAddressChange;
1088 ubik_VL_ChangeAddr(c_handle->vos, 0, oldAddress, newAddress);
1090 goto fail_vos_FileServerAddressChange;
1094 fail_vos_FileServerAddressChange:
1103 * vos_FileServerAddressRemove - remove an existing file server address.
1107 * IN cellHandle - a previously opened cellHandle that corresponds
1108 * to the cell where the address should be removed.
1110 * IN callBack - a call back function pointer that may be called to report
1111 * status information. Can be null.
1113 * IN serverAddress - the server address to remove in host byte order.
1117 * No locks are obtained or released by this function
1121 * Returns != 0 upon successful completion.
1125 vos_FileServerAddressRemove(const void *cellHandle,
1126 vos_MessageCallBack_t callBack,
1127 unsigned int serverAddress,
1131 afs_status_t tst = 0;
1132 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1133 unsigned int dummyAddress = 0xffffffff;
1136 * Validate arguments
1139 if (!IsValidCellHandle(c_handle, &tst)) {
1140 goto fail_vos_FileServerAddressRemove;
1144 ubik_VL_ChangeAddr(c_handle->vos, 0, dummyAddress,
1147 goto fail_vos_FileServerAddressRemove;
1151 fail_vos_FileServerAddressRemove:
1160 * The iterator functions and data for the server retrieval functions.
1162 * These functions are very similar to the FileServerAddressGet
1163 * functions. The main difference being that instead of returning
1164 * a single address at a time for a server, we fill an array with
1165 * all the addresses of a server.
1168 typedef struct server_get {
1169 struct ubik_client *vldb; /* connection for future rpc's if neccessary */
1170 afs_int32 total_addresses; /* total number of addresses */
1171 bulkaddrs addresses; /* the list of addresses */
1172 int address_index; /* current index into address list */
1173 vos_fileServerEntry_t server[CACHED_ITEMS]; /* the cache of servers */
1174 } server_get_t, *server_get_p;
1177 GetServerRPC(void *rpc_specific, int slot, int *last_item,
1178 int *last_item_contains_data, afs_status_p st)
1181 afs_status_t tst = 0;
1182 server_get_p serv = (server_get_p) rpc_specific;
1183 afs_uint32 *addrP = &serv->addresses.bulkaddrs_val[serv->address_index];
1184 afs_int32 base, index;
1187 ListAddrByAttributes m_attrs;
1188 afs_int32 total_multi;
1189 bulkaddrs addr_multi;
1193 * Check to see if this is a multihomed address server
1196 if (((*addrP & 0xff000000) == 0xff000000) && ((*addrP) & 0xffff)) {
1197 base = (*addrP >> 16) & 0xff;
1198 index = (*addrP) & 0xffff;
1200 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
1201 && (index <= VL_MHSRV_PERBLK)) {
1204 * This is a multihomed server. Make an rpc to retrieve
1205 * all its addresses. Copy the addresses into the cache.
1208 m_attrs.Mask = VLADDR_INDEX;
1209 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
1211 addr_multi.bulkaddrs_val = 0;
1212 addr_multi.bulkaddrs_len = 0;
1214 ubik_VL_GetAddrsU(serv->vldb, 0, &m_attrs, &m_uuid,
1215 &m_unique, &total_multi, &addr_multi);
1217 goto fail_GetServerRPC;
1221 * Remove any bogus IP addresses which the user may have
1222 * been unable to remove.
1225 RemoveBadAddresses(&total_multi, &addr_multi);
1228 * Copy all the addresses into the cache
1231 for (i = 0; i < total_multi; i++) {
1232 serv->server[slot].serverAddress[i] =
1233 addr_multi.bulkaddrs_val[i];
1236 serv->server[slot].count = total_multi;
1237 serv->address_index++;
1238 free(addr_multi.bulkaddrs_val);
1242 * The next address is just a plain old address
1246 serv->server[slot].serverAddress[0] = *addrP;
1247 serv->server[slot].count = 1;
1248 serv->address_index++;
1252 * See if we've processed all the entries
1256 if (serv->address_index == serv->total_addresses) {
1258 *last_item_contains_data = 1;
1271 GetServerFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
1274 afs_status_t tst = 0;
1275 server_get_p serv = (server_get_p) rpc_specific;
1277 memcpy(dest, (const void *)&serv->server[slot],
1278 sizeof(vos_fileServerEntry_t));
1289 DestroyServer(void *rpc_specific, afs_status_p st)
1292 afs_status_t tst = 0;
1293 server_get_p serv = (server_get_p) rpc_specific;
1295 if (serv->addresses.bulkaddrs_val != NULL) {
1296 free(serv->addresses.bulkaddrs_val);
1307 * vos_FileServerGetBegin - begin to iterate over the file servers in a cell.
1311 * IN cellHandle - a previously opened cellHandle that corresponds
1312 * to the cell where the file servers exist.
1314 * IN callBack - a call back function pointer that may be called to report
1315 * status information. Can be null.
1317 * OUT iterationIdP - upon successful completion, contains an iterator that
1318 * can be passed to vos_FileServerGetNext.
1322 * No locks are obtained or released by this function
1326 * Returns != 0 upon successful completion.
1330 vos_FileServerGetBegin(const void *cellHandle, vos_MessageCallBack_t callBack,
1331 void **iterationIdP, afs_status_p st)
1334 afs_status_t tst = 0;
1335 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1336 afs_admin_iterator_p iter =
1337 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1338 server_get_p serv = calloc(1, sizeof(server_get_t));
1339 struct VLCallBack unused;
1343 * Validate arguments
1346 if (!IsValidCellHandle(c_handle, &tst)) {
1347 goto fail_vos_FileServerGetBegin;
1350 if (iterationIdP == NULL) {
1351 goto fail_vos_FileServerGetBegin;
1354 if ((iter == NULL) || (serv == NULL)) {
1356 goto fail_vos_FileServerGetBegin;
1360 * Fill in the serv structure
1363 serv->vldb = c_handle->vos;
1365 ubik_VL_GetAddrs(c_handle->vos, 0, 0, 0, &unused,
1366 &serv->total_addresses, &serv->addresses);
1369 goto fail_vos_FileServerGetBegin;
1373 * Remove any bogus IP addresses which the user may have
1374 * been unable to remove.
1377 RemoveBadAddresses(&serv->total_addresses, &serv->addresses);
1379 if (serv->total_addresses == 0) {
1380 if (!IteratorInit(iter, (void *)serv, NULL, NULL, NULL, NULL, &tst)) {
1381 goto fail_vos_FileServerGetBegin;
1383 iter->done_iterating = 1;
1384 iter->st = ADMITERATORDONE;
1387 (iter, (void *)serv, GetServerRPC, GetServerFromCache, NULL,
1388 DestroyServer, &tst)) {
1389 goto fail_vos_FileServerGetBegin;
1392 *iterationIdP = (void *)iter;
1395 fail_vos_FileServerGetBegin:
1402 if (serv->addresses.bulkaddrs_val != NULL) {
1403 free(serv->addresses.bulkaddrs_val);
1416 * vos_FileServerGetNext - get information about the next fileserver in the cell.
1420 * IN iterationId - an iterator previously returned by
1421 * vos_FileServerGetBegin
1423 * OUT serverEntryP - a pointer to a vos_fileServerEntry_t that upon successful
1424 * completion contains information about the next server in the cell.
1428 * The iterator is locked while the next server is retrieved.
1432 * Returns != 0 upon successful completion.
1436 vos_FileServerGetNext(void *iterationId, vos_fileServerEntry_p serverEntryP,
1440 afs_status_t tst = 0;
1441 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1444 tst = ADMITERATORNULL;
1445 goto fail_vos_FileServerGetNext;
1448 if (serverEntryP == NULL) {
1449 tst = ADMVOSSERVERENTRYPNULL;
1450 goto fail_vos_FileServerGetNext;
1453 rc = IteratorNext(iter, (void *)serverEntryP, &tst);
1455 fail_vos_FileServerGetNext:
1464 * vos_FileServerGetDone - finish using a partition iterator.
1468 * IN iterationId - an iterator previously returned by vos_FileServerGetBegin
1472 * The iterator is locked and then destroyed.
1476 * Returns != 0 upon successful completion.
1480 vos_FileServerGetDone(void *iterationId, afs_status_p st)
1483 afs_status_t tst = 0;
1484 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1487 * Validate arguments
1491 tst = ADMITERATORNULL;
1492 goto fail_vos_FileServerGetDone;
1495 rc = IteratorDone(iter, &tst);
1497 fail_vos_FileServerGetDone:
1506 * The iterator functions and data for the transation retrieval functions.
1509 typedef struct transaction_get {
1510 afs_int32 total; /* total number of transactions */
1511 afs_int32 index; /* index to the current transaction */
1512 transDebugInfo *cur; /* the current transaction */
1513 vos_serverTransactionStatus_t tran[CACHED_ITEMS]; /* the cache of trans */
1514 } transaction_get_t, *transaction_get_p;
1517 GetTransactionRPC(void *rpc_specific, int slot, int *last_item,
1518 int *last_item_contains_data, afs_status_p st)
1521 afs_status_t tst = 0;
1522 transaction_get_p t = (transaction_get_p) rpc_specific;
1523 int index = t->index;
1526 * Copy the next transaction into the cache
1529 t->tran[slot].transactionId = t->cur[index].tid;
1530 t->tran[slot].lastActiveTime = t->cur[index].time;
1531 t->tran[slot].creationTime = t->cur[index].creationTime;
1532 t->tran[slot].errorCode = t->cur[index].returnCode;
1533 t->tran[slot].volumeId = t->cur[index].volid;
1534 t->tran[slot].partition = t->cur[index].partition;
1535 strcpy(t->tran[slot].lastProcedureName, t->cur[index].lastProcName);
1536 t->tran[slot].nextReceivePacketSequenceNumber = t->cur[index].readNext;
1537 t->tran[slot].nextSendPacketSequenceNumber = t->cur[index].transmitNext;
1538 t->tran[slot].lastReceiveTime = t->cur[index].lastReceiveTime;
1539 t->tran[slot].lastSendTime = t->cur[index].lastSendTime;
1541 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OK;
1543 switch (t->cur[index].iflags) {
1545 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_OFFLINE;
1548 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_BUSY;
1551 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_READONLY;
1554 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE;
1557 t->tran[slot].volumeAttachMode = VOS_VOLUME_ATTACH_MODE_CREATE_VOLID;
1561 t->tran[slot].volumeActiveStatus = VOS_VOLUME_ACTIVE_STATUS_OK;
1563 switch (t->cur[index].vflags) {
1564 case VTDeleteOnSalvage:
1565 t->tran[slot].volumeActiveStatus =
1566 VOS_VOLUME_ACTIVE_STATUS_DELETE_ON_SALVAGE;
1568 case VTOutOfService:
1569 t->tran[slot].volumeActiveStatus =
1570 VOS_VOLUME_ACTIVE_STATUS_OUT_OF_SERVICE;
1573 t->tran[slot].volumeActiveStatus = VOS_VOLUME_ACTIVE_STATUS_DELETED;
1577 t->tran[slot].volumeTransactionStatus = VOS_VOLUME_TRANSACTION_STATUS_OK;
1579 if (t->cur[index].tflags) {
1580 t->tran[slot].volumeTransactionStatus =
1581 VOS_VOLUME_TRANSACTION_STATUS_DELETED;
1587 * See if we've processed all the entries
1591 if (t->index == t->total) {
1593 *last_item_contains_data = 1;
1604 GetTransactionFromCache(void *rpc_specific, int slot, void *dest,
1608 afs_status_t tst = 0;
1609 transaction_get_p tran = (transaction_get_p) rpc_specific;
1611 memcpy(dest, (const void *)&tran->tran[slot],
1612 sizeof(vos_serverTransactionStatus_p));
1623 DestroyTransaction(void *rpc_specific, afs_status_p st)
1626 afs_status_t tst = 0;
1627 transaction_get_p tran = (transaction_get_p) rpc_specific;
1629 if (tran->cur != NULL) {
1641 * vos_ServerTransactionStatusGetBegin - begin to iterate over the transactions
1642 * at a volume server.
1646 * IN cellHandle - a previously opened cellHandle that corresponds
1647 * to the cell where the volume server exists.
1649 * IN serverHandle - a handle to the server to query.
1651 * IN callBack - a call back function pointer that may be called to report
1652 * status information. Can be null.
1654 * OUT iterationIdP - upon successful completion, contains an iterator that
1655 * can be passed to vos_ServerTransactionStatusGetNext.
1659 * No locks are obtained or released by this function
1663 * Returns != 0 upon successful completion.
1667 vos_ServerTransactionStatusGetBegin(const void *cellHandle,
1668 const void *serverHandle,
1669 vos_MessageCallBack_t callBack,
1670 void **iterationIdP, afs_status_p st)
1673 afs_status_t tst = 0;
1674 file_server_p f_server = (file_server_p) serverHandle;
1675 afs_admin_iterator_p iter =
1676 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1677 transaction_get_p tran = calloc(1, sizeof(transaction_get_t));
1681 * Validate arguments
1684 if (!IsValidServerHandle(f_server, &tst)) {
1685 goto fail_vos_ServerTransactionStatusGetBegin;
1688 if (iterationIdP == NULL) {
1689 goto fail_vos_ServerTransactionStatusGetBegin;
1692 if ((iter == NULL) || (tran == NULL)) {
1694 goto fail_vos_ServerTransactionStatusGetBegin;
1698 * Fill in the tran structure
1701 if (!UV_VolserStatus(f_server->serv, &tran->cur, &tran->total, &tst)) {
1702 goto fail_vos_ServerTransactionStatusGetBegin;
1705 if (tran->total == 0) {
1706 if (!IteratorInit(iter, (void *)tran, NULL, NULL, NULL, NULL, &tst)) {
1707 goto fail_vos_ServerTransactionStatusGetBegin;
1709 iter->done_iterating = 1;
1710 iter->st = ADMITERATORDONE;
1713 (iter, (void *)tran, GetTransactionRPC, GetTransactionFromCache,
1714 NULL, DestroyTransaction, &tst)) {
1715 goto fail_vos_ServerTransactionStatusGetBegin;
1718 *iterationIdP = (void *)iter;
1721 fail_vos_ServerTransactionStatusGetBegin:
1728 if (tran->cur != NULL) {
1742 * vos_ServerTransactionStatusGetNext - get information about the next
1743 * active transaction.
1747 * IN iterationId - an iterator previously returned by
1748 * vos_ServerTransactionStatusGetBegin
1750 * OUT serverTransactionStatusP - a pointer to a vos_serverTransactionStatus_p
1751 * that upon successful completion contains information about the
1756 * The iterator is locked while the next item is retrieved.
1760 * Returns != 0 upon successful completion.
1764 vos_ServerTransactionStatusGetNext(const void *iterationId,
1765 vos_serverTransactionStatus_p
1766 serverTransactionStatusP, afs_status_p st)
1769 afs_status_t tst = 0;
1770 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1773 tst = ADMITERATORNULL;
1774 goto fail_vos_ServerTransactionStatusGetNext;
1777 if (serverTransactionStatusP == NULL) {
1778 tst = ADMVOSSERVERTRANSACTIONSTATUSPNULL;
1779 goto fail_vos_ServerTransactionStatusGetNext;
1782 rc = IteratorNext(iter, (void *)serverTransactionStatusP, &tst);
1784 fail_vos_ServerTransactionStatusGetNext:
1793 * vos_ServerTransactionStatusGetDone - finish using a transaction iterator.
1797 * IN iterationId - an iterator previously returned by
1798 * vos_ServerTransactionStatusGetBegin
1802 * The iterator is locked and then destroyed.
1806 * Returns != 0 upon successful completion.
1810 vos_ServerTransactionStatusGetDone(const void *iterationId, afs_status_p st)
1813 afs_status_t tst = 0;
1814 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1817 * Validate arguments
1821 tst = ADMITERATORNULL;
1822 goto fail_vos_ServerTransactionStatusGetDone;
1825 rc = IteratorDone(iter, &tst);
1827 fail_vos_ServerTransactionStatusGetDone:
1836 copyVLDBEntry(struct nvldbentry *source, vos_vldbEntry_p dest,
1840 afs_status_t tst = 0;
1843 dest->numServers = source->nServers;
1844 for (i = 0; i < VOS_MAX_VOLUME_TYPES; i++) {
1845 dest->volumeId[i] = source->volumeId[i];
1847 dest->cloneId = source->cloneId;
1848 dest->status = VOS_VLDB_ENTRY_OK;
1849 if (source->flags & VLOP_ALLOPERS) {
1850 dest->status |= VOS_VLDB_ENTRY_LOCKED;
1852 if (source->flags & VLOP_MOVE) {
1853 dest->status |= VOS_VLDB_ENTRY_MOVE;
1855 if (source->flags & VLOP_RELEASE) {
1856 dest->status |= VOS_VLDB_ENTRY_RELEASE;
1858 if (source->flags & VLOP_BACKUP) {
1859 dest->status |= VOS_VLDB_ENTRY_BACKUP;
1861 if (source->flags & VLOP_DELETE) {
1862 dest->status |= VOS_VLDB_ENTRY_DELETE;
1864 if (source->flags & VLOP_DUMP) {
1865 dest->status |= VOS_VLDB_ENTRY_DUMP;
1868 if (source->flags & VLF_RWEXISTS) {
1869 dest->status |= VOS_VLDB_ENTRY_RWEXISTS;
1871 if (source->flags & VLF_ROEXISTS) {
1872 dest->status |= VOS_VLDB_ENTRY_ROEXISTS;
1874 if (source->flags & VLF_BACKEXISTS) {
1875 dest->status |= VOS_VLDB_ENTRY_BACKEXISTS;
1878 strncpy(dest->name, source->name, VOS_MAX_VOLUME_NAME_LEN);
1879 dest->name[VOS_MAX_VOLUME_NAME_LEN - 1] = '\0';
1880 for (i = 0; i < VOS_MAX_REPLICA_SITES; i++) {
1881 dest->volumeSites[i].serverAddress = source->serverNumber[i];
1882 dest->volumeSites[i].serverPartition = source->serverPartition[i];
1883 dest->volumeSites[i].serverFlags = 0;
1885 if (source->serverFlags[i] & NEW_REPSITE) {
1886 dest->volumeSites[i].serverFlags |= VOS_VLDB_NEW_REPSITE;
1888 if (source->serverFlags[i] & ITSROVOL) {
1889 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_ONLY;
1891 if (source->serverFlags[i] & ITSRWVOL) {
1892 dest->volumeSites[i].serverFlags |= VOS_VLDB_READ_WRITE;
1894 if (source->serverFlags[i] & ITSBACKVOL) {
1895 dest->volumeSites[i].serverFlags |= VOS_VLDB_BACKUP;
1897 if (source->serverFlags[i] & RO_DONTUSE) {
1898 dest->volumeSites[i].serverFlags |= VOS_VLDB_DONT_USE;
1911 * vos_VLDBGet- get a volume's vldb entry.
1915 * IN cellHandle - a previously opened cellHandle that corresponds
1916 * to the cell where the volume entries exist.
1918 * IN callBack - a call back function pointer that may be called to report
1919 * status information. Can be null.
1921 * IN volumeId - the id of the volume to retrieve.
1923 * IN volumeName - the name of the volume to retrieve.
1925 * OUT vldbEntry - upon successful completion, contains the information regarding
1930 * No locks are obtained or released by this function
1934 * Returns != 0 upon successful completion.
1938 vos_VLDBGet(const void *cellHandle, vos_MessageCallBack_t callBack,
1939 const unsigned int *volumeId, char *volumeName,
1940 vos_vldbEntry_p vldbEntry, afs_status_p st)
1943 afs_status_t tst = 0;
1944 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
1945 struct nvldbentry entry;
1949 * Validate arguments
1952 if (!IsValidCellHandle(c_handle, &tst)) {
1953 goto fail_vos_VLDBGet;
1956 if (vldbEntry == NULL) {
1957 tst = ADMVOSVLDBENTRYNULL;
1958 goto fail_vos_VLDBGet;
1961 if (((volumeName == NULL) || (*volumeName == 0)) && (volumeId == NULL)) {
1962 tst = ADMVOSVOLUMENAMEANDVOLUMEIDNULL;
1963 goto fail_vos_VLDBGet;
1967 * Retrieve the entry
1970 if (!((volumeName == NULL) || (*volumeName == 0))) {
1971 if (!ValidateVolumeName(volumeName, &tst)) {
1972 goto fail_vos_VLDBGet;
1974 if (!aVLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
1975 goto fail_vos_VLDBGet;
1978 if (!aVLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
1979 goto fail_vos_VLDBGet;
1984 * Copy the entry into our structure
1987 if (!copyVLDBEntry(&entry, vldbEntry, &tst)) {
1988 goto fail_vos_VLDBGet;
2001 * The iterator functions and data for the vldb entry retrieval functions.
2004 typedef struct vldb_entry_get {
2005 afs_int32 total; /* total number of vldb entries */
2006 afs_int32 index; /* index to the current vldb entry */
2007 nbulkentries entries; /* the list of entries retrieved */
2008 vos_vldbEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
2009 } vldb_entry_get_t, *vldb_entry_get_p;
2012 GetVLDBEntryRPC(void *rpc_specific, int slot, int *last_item,
2013 int *last_item_contains_data, afs_status_p st)
2016 afs_status_t tst = 0;
2017 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2020 * Copy the next entry into the cache
2024 (&entry->entries.nbulkentries_val[entry->index], &entry->entry[slot],
2026 goto fail_GetVLDBEntryRPC;
2031 * See if we've processed all the entries
2035 if (entry->index == entry->total) {
2037 *last_item_contains_data = 1;
2041 fail_GetVLDBEntryRPC:
2050 GetVLDBEntryFromCache(void *rpc_specific, int slot, void *dest,
2054 afs_status_t tst = 0;
2055 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2057 memcpy(dest, (const void *)&entry->entry[slot], sizeof(vos_vldbEntry_t));
2068 DestroyVLDBEntry(void *rpc_specific, afs_status_p st)
2071 afs_status_t tst = 0;
2072 vldb_entry_get_p entry = (vldb_entry_get_p) rpc_specific;
2074 if (entry->entries.nbulkentries_val != NULL) {
2075 free(entry->entries.nbulkentries_val);
2087 * vos_VLDBGetBegin - begin to iterate over the VLDB.
2091 * IN cellHandle - a previously opened cellHandle that corresponds
2092 * to the cell where the volume entries exist.
2094 * IN serverHandle - a handle to the server whose entries should be listed.
2097 * IN callBack - a call back function pointer that may be called to report
2098 * status information. Can be null.
2100 * IN partition - the partition whose entries should be listed.
2103 * OUT iterationIdP - upon successful completion, contains an iterator that
2104 * can be passed to vos_VLDBGetNext.
2108 * No locks are obtained or released by this function
2112 * Returns != 0 upon successful completion.
2116 vos_VLDBGetBegin(const void *cellHandle, const void *serverHandle,
2117 vos_MessageCallBack_t callBack, unsigned int *partition,
2118 void **iterationIdP, afs_status_p st)
2121 afs_status_t tst = 0;
2122 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2123 file_server_p f_server = (file_server_p) serverHandle;
2124 afs_admin_iterator_p iter =
2125 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
2126 vldb_entry_get_p entry = calloc(1, sizeof(vldb_entry_get_t));
2127 struct VldbListByAttributes attr;
2130 memset(&attr, 0, sizeof(attr));
2133 * Validate arguments
2136 if (!IsValidCellHandle(c_handle, &tst)) {
2137 goto fail_vos_VLDBGetBegin;
2140 if ((iter == NULL) || (entry == NULL)) {
2142 goto fail_vos_VLDBGetBegin;
2145 if (f_server != NULL) {
2146 if (!IsValidServerHandle(f_server, &tst)) {
2147 goto fail_vos_VLDBGetBegin;
2149 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2150 attr.Mask |= VLLIST_SERVER;
2153 if (partition != NULL) {
2154 if (*partition > VOLMAXPARTS) {
2155 tst = ADMVOSPARTITIONTOOLARGE;
2156 goto fail_vos_VLDBGetBegin;
2158 attr.partition = *partition;
2159 attr.Mask |= VLLIST_PARTITION;
2162 if (!VLDB_ListAttributes
2163 (c_handle, &attr, &entry->total, &entry->entries, &tst)) {
2164 goto fail_vos_VLDBGetBegin;
2167 if (entry->total <= 0) {
2168 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
2169 goto fail_vos_VLDBGetBegin;
2171 iter->done_iterating = 1;
2172 iter->st = ADMITERATORDONE;
2175 (iter, (void *)entry, GetVLDBEntryRPC, GetVLDBEntryFromCache,
2176 NULL, DestroyVLDBEntry, &tst)) {
2177 goto fail_vos_VLDBGetBegin;
2180 *iterationIdP = (void *)iter;
2183 fail_vos_VLDBGetBegin:
2189 if (entry->entries.nbulkentries_val != NULL) {
2190 free(entry->entries.nbulkentries_val);
2192 if (entry != NULL) {
2204 * vos_VLDBGetNext - get information about the next volume.
2208 * IN iterationId - an iterator previously returned by
2211 * OUT vldbEntry - a pointer to a vos_vldbEntry_t
2212 * that upon successful completion contains information about the
2217 * The iterator is locked while the next item is retrieved.
2221 * Returns != 0 upon successful completion.
2225 vos_VLDBGetNext(const void *iterationId, vos_vldbEntry_p vldbEntry,
2229 afs_status_t tst = 0;
2230 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2233 tst = ADMITERATORNULL;
2234 goto fail_vos_VLDBGetNext;
2237 if (vldbEntry == NULL) {
2238 tst = ADMVOSVLDBENTRYNULL;
2239 goto fail_vos_VLDBGetNext;
2242 rc = IteratorNext(iter, (void *)vldbEntry, &tst);
2244 fail_vos_VLDBGetNext:
2253 * vos_VLDBGetDone - finish using a volume iterator.
2257 * IN iterationId - an iterator previously returned by vos_VLDBGetBegin
2261 * The iterator is locked and then destroyed.
2265 * Returns != 0 upon successful completion.
2269 vos_VLDBGetDone(const void *iterationId, afs_status_p st)
2272 afs_status_t tst = 0;
2273 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2276 * Validate arguments
2280 tst = ADMITERATORNULL;
2281 goto fail_vos_VLDBGetDone;
2284 rc = IteratorDone(iter, &tst);
2286 fail_vos_VLDBGetDone:
2295 * vos_VLDBEntryRemove - remove a vldb entry.
2299 * IN cellHandle - a previously opened cellHandle that corresponds
2300 * to the cell where the vldb entry exists.
2302 * IN serverHandle - a previously opened serverHandle that corresponds
2303 * to the server where the vldb entry exists. Can be null.
2305 * IN callBack - a call back function pointer that may be called to report
2306 * status information. Can be null.
2308 * IN partition - the partition where the vldb entry exists. Can be null.
2310 * IN volumeId - the volume id of the vldb entry to be deleted. Can be null.
2314 * No locks are obtained or released by this function
2318 * Returns != 0 upon successful completion.
2322 vos_VLDBEntryRemove(const void *cellHandle, const void *serverHandle,
2323 vos_MessageCallBack_t callBack,
2324 const unsigned int *partition, unsigned int *volumeId,
2328 afs_status_t tst = 0;
2329 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2330 file_server_p f_server = (file_server_p) serverHandle;
2331 struct VldbListByAttributes attr;
2332 nbulkentries entries;
2336 memset(&attr, 0, sizeof(attr));
2337 memset(&entries, 0, sizeof(entries));
2340 * Validate arguments
2343 if (!IsValidCellHandle(c_handle, &tst)) {
2344 goto fail_vos_VLDBEntryRemove;
2348 * If the volume is specified, just delete it
2351 if (volumeId != NULL) {
2352 tst = ubik_VL_DeleteEntry(c_handle->vos, 0, *volumeId, -1);
2354 goto fail_vos_VLDBEntryRemove;
2358 if (f_server != NULL) {
2359 if (!IsValidServerHandle(f_server, &tst)) {
2360 goto fail_vos_VLDBEntryRemove;
2362 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2363 attr.Mask |= VLLIST_SERVER;
2366 if (partition != NULL) {
2367 if (*partition > VOLMAXPARTS) {
2368 tst = ADMVOSPARTITIONTOOLARGE;
2369 goto fail_vos_VLDBEntryRemove;
2371 attr.partition = *partition;
2372 attr.Mask |= VLLIST_PARTITION;
2375 if ((f_server == NULL) && (partition == NULL)) {
2376 tst = ADMVOSVLDBDELETEALLNULL;
2377 goto fail_vos_VLDBEntryRemove;
2380 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2381 goto fail_vos_VLDBEntryRemove;
2384 if (nentries <= 0) {
2385 tst = ADMVOSVLDBNOENTRIES;
2386 goto fail_vos_VLDBEntryRemove;
2389 for (i = 0; i < nentries; i++) {
2390 ubik_VL_DeleteEntry(c_handle->vos, 0,
2391 entries.nbulkentries_val[i].volumeId[RWVOL], -1);
2395 fail_vos_VLDBEntryRemove:
2397 if (entries.nbulkentries_val) {
2398 free(entries.nbulkentries_val);
2408 * vos_VLDBUnlock - unlock vldb entries en masse.
2412 * IN cellHandle - a previously opened cellHandle that corresponds
2413 * to the cell where the vldb entries exist.
2415 * IN serverHandle - a previously opened serverHandle that corresponds
2416 * to the server where the vldb entries exist. Can be null.
2418 * IN callBack - a call back function pointer that may be called to report
2419 * status information. Can be null.
2421 * IN partition - the partition where the vldb entries exist. Can be null.
2425 * No locks are obtained or released by this function
2429 * Returns != 0 upon successful completion.
2433 vos_VLDBUnlock(const void *cellHandle, const void *serverHandle,
2434 vos_MessageCallBack_t callBack, const unsigned int *partition,
2438 afs_status_t tst = 0;
2439 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2440 file_server_p f_server = (file_server_p) serverHandle;
2441 struct VldbListByAttributes attr;
2442 nbulkentries entries;
2446 memset(&attr, 0, sizeof(attr));
2447 memset(&entries, 0, sizeof(entries));
2450 * Validate arguments
2453 if (!IsValidCellHandle(c_handle, &tst)) {
2454 goto fail_vos_VLDBUnlock;
2457 if (f_server != NULL) {
2458 if (!IsValidServerHandle(f_server, &tst)) {
2459 goto fail_vos_VLDBUnlock;
2461 attr.server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
2462 attr.Mask |= VLLIST_SERVER;
2465 if (partition != NULL) {
2466 if (*partition > VOLMAXPARTS) {
2467 tst = ADMVOSPARTITIONTOOLARGE;
2468 goto fail_vos_VLDBUnlock;
2470 attr.partition = *partition;
2471 attr.Mask |= VLLIST_PARTITION;
2473 attr.flag = VLOP_ALLOPERS;
2474 attr.Mask |= VLLIST_FLAG;
2477 if (!VLDB_ListAttributes(c_handle, &attr, &nentries, &entries, &tst)) {
2478 goto fail_vos_VLDBUnlock;
2481 if (nentries <= 0) {
2482 tst = ADMVOSVLDBNOENTRIES;
2483 goto fail_vos_VLDBUnlock;
2486 for (i = 0; i < nentries; i++) {
2487 vos_VLDBEntryUnlock(cellHandle, 0,
2488 entries.nbulkentries_val[i].volumeId[RWVOL],
2493 fail_vos_VLDBUnlock:
2495 if (entries.nbulkentries_val) {
2496 free(entries.nbulkentries_val);
2507 * vos_VLDBEntryLock - lock a vldb entry.
2511 * IN cellHandle - a previously opened cellHandle that corresponds
2512 * to the cell where the vldb entry exists.
2514 * IN callBack - a call back function pointer that may be called to report
2515 * status information. Can be null.
2517 * IN volumeId - the volume id of the vldb entry to be deleted.
2521 * No locks are obtained or released by this function
2525 * Returns != 0 upon successful completion.
2529 vos_VLDBEntryLock(const void *cellHandle, vos_MessageCallBack_t callBack,
2530 unsigned int volumeId, afs_status_p st)
2533 afs_status_t tst = 0;
2534 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2537 * Validate arguments
2540 if (!IsValidCellHandle(c_handle, &tst)) {
2541 goto fail_vos_VLDBEntryLock;
2544 tst = ubik_VL_SetLock(c_handle->vos, 0, volumeId, -1, VLOP_DELETE);
2546 goto fail_vos_VLDBEntryLock;
2550 fail_vos_VLDBEntryLock:
2559 * vos_VLDBEntryUnlock - unlock a vldb entry.
2563 * IN cellHandle - a previously opened cellHandle that corresponds
2564 * to the cell where the vldb entry exists.
2566 * IN callBack - a call back function pointer that may be called to report
2567 * status information. Can be null.
2569 * IN volumeId - the volume id of the vldb entry to be unlocked.
2573 * No locks are obtained or released by this function
2577 * Returns != 0 upon successful completion.
2581 vos_VLDBEntryUnlock(const void *cellHandle, vos_MessageCallBack_t callBack,
2582 unsigned int volumeId, afs_status_p st)
2585 afs_status_t tst = 0;
2586 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2589 * Validate arguments
2592 if (!IsValidCellHandle(c_handle, &tst)) {
2593 goto fail_vos_VLDBEntryUnlock;
2598 ubik_VL_ReleaseLock(c_handle->vos, 0, volumeId, -1,
2599 LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
2601 goto fail_vos_VLDBEntryUnlock;
2605 fail_vos_VLDBEntryUnlock:
2614 * vos_VLDBReadOnlySiteCreate - create a readonly site for a volume.
2618 * IN cellHandle - a previously opened cellHandle that corresponds
2619 * to the cell where the volume exists.
2621 * IN serverHandle - a previously opened serverHandle that corresponds
2622 * to the server where the new volume should be created.
2624 * IN callBack - a call back function pointer that may be called to report
2625 * status information. Can be null.
2627 * IN partition - the partition where then new volume should be created.
2629 * IN volumeId - the volume id of the volume to be replicated.
2633 * No locks are obtained or released by this function
2637 * Returns != 0 upon successful completion.
2641 vos_VLDBReadOnlySiteCreate(const void *cellHandle, const void *serverHandle,
2642 vos_MessageCallBack_t callBack,
2643 unsigned int partition, unsigned int volumeId,
2647 afs_status_t tst = 0;
2648 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2649 file_server_p f_server = (file_server_p) serverHandle;
2652 * Validate arguments
2655 if (!IsValidCellHandle(c_handle, &tst)) {
2656 goto fail_vos_VLDBReadOnlySiteCreate;
2659 if (!IsValidServerHandle(f_server, &tst)) {
2660 goto fail_vos_VLDBReadOnlySiteCreate;
2663 if (partition > VOLMAXPARTS) {
2664 tst = ADMVOSPARTITIONTOOLARGE;
2665 goto fail_vos_VLDBReadOnlySiteCreate;
2669 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2671 goto fail_vos_VLDBReadOnlySiteCreate;
2675 fail_vos_VLDBReadOnlySiteCreate:
2684 * vos_VLDBReadOnlySiteDelete - delete a replication site for a volume.
2689 * IN cellHandle - a previously opened cellHandle that corresponds
2690 * to the cell where the volume exists.
2692 * IN serverHandle - a previously opened serverHandle that corresponds
2693 * to the server where the volume should be deleted.
2695 * IN callBack - a call back function pointer that may be called to report
2696 * status information. Can be null.
2698 * IN partition - the partition where then volume should be deleted.
2700 * IN volumeId - the volume id of the volume to be deleted.
2704 * No locks are obtained or released by this function
2708 * Returns != 0 upon successful completion.
2712 vos_VLDBReadOnlySiteDelete(const void *cellHandle, const void *serverHandle,
2713 vos_MessageCallBack_t callBack,
2714 unsigned int partition, unsigned int volumeId,
2718 afs_status_t tst = 0;
2719 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2720 file_server_p f_server = (file_server_p) serverHandle;
2723 * Validate arguments
2726 if (!IsValidCellHandle(c_handle, &tst)) {
2727 goto fail_vos_VLDBReadOnlySiteDelete;
2730 if (!IsValidServerHandle(f_server, &tst)) {
2731 goto fail_vos_VLDBReadOnlySiteDelete;
2734 if (partition > VOLMAXPARTS) {
2735 tst = ADMVOSPARTITIONTOOLARGE;
2736 goto fail_vos_VLDBReadOnlySiteDelete;
2740 (c_handle, ntohl(rx_HostOf(rx_PeerOf(f_server->serv))), partition,
2742 goto fail_vos_VLDBReadOnlySiteDelete;
2746 fail_vos_VLDBReadOnlySiteDelete:
2755 * vos_VLDBSync - synchronize the vldb with the fileserver.
2759 * IN cellHandle - a previously opened cellHandle that corresponds
2760 * to the cell where the sync should occur.
2762 * IN serverHandle - a previously opened serverHandle that corresponds
2763 * to the server where the sync should occur.
2765 * IN callBack - a call back function pointer that may be called to report
2766 * status information. Can be null.
2768 * IN partition - the partition where the sync should occur. Can be null.
2770 * IN force - force deletion of bad volumes.
2774 * No locks are obtained or released by this function
2778 * Returns != 0 upon successful completion.
2782 vos_VLDBSync(const void *cellHandle, const void *serverHandle,
2783 vos_MessageCallBack_t callBack, const unsigned int *partition,
2784 vos_force_t force, afs_status_p st)
2787 afs_status_t tst = 0;
2788 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2789 file_server_p f_server = (file_server_p) serverHandle;
2795 * Validate arguments
2798 if (!IsValidCellHandle(c_handle, &tst)) {
2799 goto fail_vos_VLDBSync;
2802 if (!IsValidServerHandle(f_server, &tst)) {
2803 goto fail_vos_VLDBSync;
2806 if (partition != NULL) {
2807 if (*partition > VOLMAXPARTS) {
2808 tst = ADMVOSPARTITIONTOOLARGE;
2809 goto fail_vos_VLDBSync;
2811 part = (afs_int32) * partition;
2815 if (force == VOS_FORCE) {
2823 rc = UV_SyncVldb(c_handle, f_server->serv, part, flags, force_flag, &tst);
2834 * vos_VolumeCreate - create a new partition.
2838 * IN cellHandle - a previously opened cellHandle that corresponds
2839 * to the cell where the server lives.
2841 * IN serverHandle - a previously open vos server handle that holds
2842 * the partition where the volume should be create.
2844 * IN callBack - a call back function pointer that may be called to report
2845 * status information. Can be null.
2847 * IN partition - the integer that represents the partition that will
2848 * house the new volume.
2850 * IN volumeName - the name of the new volume.
2852 * IN quota - the quota of the new volume.
2854 * OUT volumeId - the volume id of the newly created volume.
2858 * No locks are obtained or released by this function
2862 * Returns != 0 upon successful completion.
2866 vos_VolumeCreate(const void *cellHandle, const void *serverHandle,
2867 vos_MessageCallBack_t callBack, unsigned int partition,
2868 char *volumeName, unsigned int quota,
2869 unsigned int *volumeId, afs_status_p st)
2872 afs_status_t tst = 0;
2873 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2874 file_server_p f_server = (file_server_p) serverHandle;
2875 vos_partitionEntry_t pinfo;
2876 struct nvldbentry vinfo;
2879 * Validate arguments
2882 if (!IsValidCellHandle(c_handle, &tst)) {
2883 goto fail_vos_VolumeCreate;
2886 if (!IsValidServerHandle(f_server, &tst)) {
2887 goto fail_vos_VolumeCreate;
2890 if (partition > VOLMAXPARTS) {
2891 tst = ADMVOSPARTITIONTOOLARGE;
2892 goto fail_vos_VolumeCreate;
2895 if (!ValidateVolumeName(volumeName, &tst)) {
2896 goto fail_vos_VolumeCreate;
2899 if (volumeId == NULL) {
2900 tst = ADMVOSVOLUMEID;
2901 goto fail_vos_VolumeCreate;
2905 * Check that partition is valid at the server
2908 if (!vos_PartitionGet
2909 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
2910 goto fail_vos_VolumeCreate;
2914 * Check that the volume doesn't already exist
2917 if (aVLDB_GetEntryByName(c_handle, volumeName, &vinfo, &tst)) {
2918 tst = ADMVOSVOLUMENAMEDUP;
2919 goto fail_vos_VolumeCreate;
2923 * Create the new volume
2926 rc = UV_CreateVolume(c_handle, f_server->serv, partition, volumeName,
2927 quota, volumeId, &tst);
2929 fail_vos_VolumeCreate:
2938 * vos_VolumeDelete - remove a volume.
2942 * IN cellHandle - a previously opened cellHandle that corresponds
2943 * to the cell where the volume exists.
2945 * IN serverHandle - a previously opened serverHandle that corresponds
2946 * to the server where the volume exists.
2948 * IN callBack - a call back function pointer that may be called to report
2949 * status information. Can be null.
2951 * IN partition - the partition where the volume exists.
2953 * IN volumeId - the volume id of the volume to be deleted.
2957 * No locks are obtained or released by this function
2961 * Returns != 0 upon successful completion.
2965 vos_VolumeDelete(const void *cellHandle, const void *serverHandle,
2966 vos_MessageCallBack_t callBack, unsigned int partition,
2967 unsigned int volumeId, afs_status_p st)
2970 afs_status_t tst = 0;
2971 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
2972 file_server_p f_server = (file_server_p) serverHandle;
2973 vos_partitionEntry_t pinfo;
2976 * Validate arguments
2979 if (!IsValidCellHandle(c_handle, &tst)) {
2980 goto fail_vos_VolumeDelete;
2983 if (!IsValidServerHandle(f_server, &tst)) {
2984 goto fail_vos_VolumeDelete;
2987 if (partition > VOLMAXPARTS) {
2988 tst = ADMVOSPARTITIONTOOLARGE;
2989 goto fail_vos_VolumeDelete;
2993 * Check that partition is valid at the server
2996 if (!vos_PartitionGet
2997 (cellHandle, serverHandle, 0, partition, &pinfo, &tst)) {
2998 goto fail_vos_VolumeDelete;
3001 rc = UV_DeleteVolume(c_handle, f_server->serv, partition, volumeId, &tst);
3003 fail_vos_VolumeDelete:
3012 * vos_VolumeRename - rename 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 vldb entry exists. Can be null.
3022 * IN callBack - a call back function pointer that may be called to report
3023 * status information. Can be null.
3025 * IN readWriteVolumeId - the volume id of the volume to be renamed.
3027 * IN newVolumeName - the new name.
3031 * No locks are obtained or released by this function
3035 * Returns != 0 upon successful completion.
3039 vos_VolumeRename(const void *cellHandle, vos_MessageCallBack_t callBack,
3040 unsigned int readWriteVolumeId, char *newVolumeName,
3044 afs_status_t tst = 0;
3045 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3046 struct nvldbentry entry;
3049 * Validate arguments
3052 if (!IsValidCellHandle(c_handle, &tst)) {
3053 goto fail_vos_VolumeRename;
3056 if ((newVolumeName == NULL) || (*newVolumeName == 0)) {
3057 tst = ADMVOSNEWVOLUMENAMENULL;
3058 goto fail_vos_VolumeRename;
3062 * Retrieve the entry
3065 if (!aVLDB_GetEntryByID(c_handle, readWriteVolumeId, -1, &entry, &tst)) {
3066 goto fail_vos_VolumeRename;
3069 rc = UV_RenameVolume(c_handle, &entry, newVolumeName, &tst);
3071 fail_vos_VolumeRename:
3080 * vos_VolumeDump - dump a volume
3084 * IN cellHandle - a previously opened cellHandle that corresponds
3085 * to the cell where the volume exists.
3087 * IN serverHandle - a previously opened serverHandle that corresponds
3088 * to the server where the volume exists. Can be null.
3090 * IN callBack - a call back function pointer that may be called to report
3091 * status information. Can be null.
3093 * IN volumeId - the volume id of the volume to be dumped.
3095 * IN startTime - files with modification times >= this time will be dumped.
3097 * IN dumpFile - the file to dump the volume to.
3101 * No locks are obtained or released by this function
3105 * Returns != 0 upon successful completion.
3109 vos_VolumeDump(const void *cellHandle, const void *serverHandle,
3110 vos_MessageCallBack_t callBack, unsigned int *partition,
3111 unsigned int volumeId, unsigned int startTime,
3112 const char *dumpFile, afs_status_p st)
3115 afs_status_t tst = 0;
3116 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3117 file_server_p f_server = (file_server_p) serverHandle;
3118 afs_int32 server, part, voltype;
3119 struct nvldbentry entry;
3122 * Validate arguments
3125 if (!IsValidCellHandle(c_handle, &tst)) {
3126 goto fail_vos_VolumeDump;
3129 if (serverHandle != NULL) {
3130 if (!IsValidServerHandle(f_server, &tst)) {
3131 goto fail_vos_VolumeDump;
3136 * You must specify both the serverHandle and the partition
3139 if (serverHandle || partition) {
3140 if (!serverHandle || !partition) {
3141 tst = ADMVOSSERVERANDPARTITION;
3142 goto fail_vos_VolumeDump;
3144 if (*partition > VOLMAXPARTS) {
3145 tst = ADMVOSPARTITIONTOOLARGE;
3146 goto fail_vos_VolumeDump;
3148 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3153 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
3154 goto fail_vos_VolumeDump;
3158 if ((dumpFile == NULL) || (*dumpFile == 0)) {
3159 tst = ADMVOSDUMPFILENULL;
3160 goto fail_vos_VolumeDump;
3163 rc = UV_DumpVolume(c_handle, volumeId, server, part, startTime, dumpFile,
3166 fail_vos_VolumeDump:
3175 * vos_VolumeRestore - restore a volume from a dump
3179 * IN cellHandle - a previously opened cellHandle that corresponds
3180 * to the cell where the volume exists.
3182 * IN serverHandle - a previously opened serverHandle that corresponds
3183 * to the server where the volume exists.
3185 * IN callBack - a call back function pointer that may be called to report
3186 * status information. Can be null.
3188 * IN partition - the partition where the volume exists.
3190 * IN volumeId - the volume id of the volume to be restored.
3192 * IN volumeName - the volume name of the volume to be restored.
3194 * IN dumpFile - the file from which to restore the volume.
3196 * IN dumpType - the type of dump to perform.
3200 * No locks are obtained or released by this function
3204 * Returns != 0 upon successful completion.
3208 vos_VolumeRestore(const void *cellHandle, const void *serverHandle,
3209 vos_MessageCallBack_t callBack, unsigned int partition,
3210 unsigned int *volumeId, char *volumeName,
3211 const char *dumpFile, vos_volumeRestoreType_t dumpType,
3215 afs_status_t tst = 0;
3216 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3217 file_server_p f_server = (file_server_p) serverHandle;
3218 struct nvldbentry entry;
3219 afs_int32 volid, server;
3222 int restoreflags = 0;
3223 afs_int32 Oserver, Opart, Otype;
3224 struct nvldbentry Oentry;
3228 * Validate arguments
3231 if (!IsValidCellHandle(c_handle, &tst)) {
3232 goto fail_vos_VolumeRestore;
3235 if (serverHandle != NULL) {
3236 if (!IsValidServerHandle(f_server, &tst)) {
3237 goto fail_vos_VolumeRestore;
3242 * Must pass volumeName
3245 if ((volumeName == NULL) || (*volumeName == 0)) {
3246 tst = ADMVOSVOLUMENAMENULL;
3247 goto fail_vos_VolumeRestore;
3250 if (!ValidateVolumeName(volumeName, &tst)) {
3251 goto fail_vos_VolumeRestore;
3255 * If volumeId is passed, it must be a valid volume id
3258 if (volumeId != NULL) {
3259 if (!aVLDB_GetEntryByID(c_handle, *volumeId, -1, &entry, &tst)) {
3260 goto fail_vos_VolumeRestore;
3267 server = ntohl(rx_HostOf(rx_PeerOf(f_server->serv)));
3269 if (partition > VOLMAXPARTS) {
3270 tst = ADMVOSPARTITIONTOOLARGE;
3271 goto fail_vos_VolumeRestore;
3275 * Check that dumpFile exists and can be accessed
3278 fd = open(dumpFile, 0);
3279 if ((fd < 0) || (fstat(fd, &status) < 0)) {
3281 tst = ADMVOSDUMPFILEOPENFAIL;
3282 goto fail_vos_VolumeRestore;
3287 if (!aVLDB_GetEntryByName(c_handle, volumeName, &entry, &tst)) {
3288 restoreflags = RV_FULLRST;
3289 } else if (Lp_GetRwIndex(c_handle, &entry, 0) == -1) {
3290 restoreflags = RV_FULLRST;
3292 volid = entry.volumeId[RWVOL];
3293 } else if ((entry.volumeId[RWVOL] != 0)
3294 && (entry.volumeId[RWVOL] != volid)) {
3295 volid = entry.volumeId[RWVOL];
3300 volid = entry.volumeId[RWVOL];
3301 } else if ((entry.volumeId[RWVOL] != 0)
3302 && (entry.volumeId[RWVOL] != volid)) {
3303 volid = entry.volumeId[RWVOL];
3307 * If the vldb says the same volume exists somewhere else
3308 * the caller must specify a full restore, not an incremental
3311 if (dumpType == VOS_RESTORE_FULL) {
3312 restoreflags = RV_FULLRST;
3316 * Check to see if the volume exists where the caller said
3319 (c_handle, volid, &Oentry, &Oserver, &Opart, &Otype, &tst)) {
3320 goto fail_vos_VolumeRestore;
3322 if (!VLDB_IsSameAddrs(c_handle, Oserver, server, &equal, &tst)) {
3323 goto fail_vos_VolumeRestore;
3327 tst = ADMVOSRESTOREVOLEXIST;
3328 goto fail_vos_VolumeRestore;
3333 rc = UV_RestoreVolume(c_handle, server, partition, volid, volumeName,
3334 restoreflags, dumpFile, &tst);
3336 fail_vos_VolumeRestore:
3345 * vos_VolumeOnline - bring a volume online.
3349 * IN serverHandle - a previously opened serverHandle that corresponds
3350 * to the server where the volume exists.
3352 * IN callBack - a call back function pointer that may be called to report
3353 * status information. Can be null.
3355 * IN partition - the partition where the volume exists.
3357 * IN volumeId - the volume id of the volume to be brought online.
3361 * No locks are obtained or released by this function
3365 * Returns != 0 upon successful completion.
3369 vos_VolumeOnline(const void *serverHandle, vos_MessageCallBack_t callBack,
3370 unsigned int partition, unsigned int volumeId,
3371 unsigned int sleepTime, vos_volumeOnlineType_t volumeStatus,
3375 afs_status_t tst = 0;
3376 file_server_p f_server = (file_server_p) serverHandle;
3380 * Validate arguments
3383 if (!IsValidServerHandle(f_server, &tst)) {
3384 goto fail_vos_VolumeOnline;
3387 if (partition > VOLMAXPARTS) {
3388 tst = ADMVOSPARTITIONIDTOOLARGE;
3389 goto fail_vos_VolumeOnline;
3392 if (volumeStatus == VOS_ONLINE_BUSY) {
3396 rc = UV_SetVolume(f_server->serv, partition, volumeId, up, 0, sleepTime,
3399 fail_vos_VolumeOnline:
3408 * vos_VolumeOffline - take a volume offline.
3412 * IN serverHandle - a previously opened serverHandle that corresponds
3413 * to the server where the volume exists.
3415 * IN callBack - a call back function pointer that may be called to report
3416 * status information. Can be null.
3418 * IN partition - the partition where the volume exists.
3420 * IN volumeId - the volume id of the volume to be taken offline.
3424 * No locks are obtained or released by this function
3428 * Returns != 0 upon successful completion.
3432 vos_VolumeOffline(const void *serverHandle, vos_MessageCallBack_t callBack,
3433 unsigned int partition, unsigned int volumeId,
3437 afs_status_t tst = 0;
3438 file_server_p f_server = (file_server_p) serverHandle;
3441 * Validate arguments
3444 if (!IsValidServerHandle(f_server, &tst)) {
3445 goto fail_vos_VolumeOffline;
3448 if (partition > VOLMAXPARTS) {
3449 tst = ADMVOSPARTITIONIDTOOLARGE;
3450 goto fail_vos_VolumeOffline;
3453 rc = UV_SetVolume(f_server->serv, partition, volumeId, ITOffline,
3454 VTOutOfService, 0, &tst);
3456 fail_vos_VolumeOffline:
3465 * copyvolintXInfo - copy a struct volintXInfo to a vos_volumeEntry_p.
3469 * IN source - the volintXInfo structure to copy.
3471 * OUT dest - the vos_volumeEntry_t to fill
3475 * No locks are obtained or released by this function
3479 * Returns != 0 upon successful completion.
3483 copyvolintXInfo(struct volintXInfo *source, vos_volumeEntry_p dest,
3487 afs_status_t tst = 0;
3491 * If the volume is not marked OK, all the other fields are invalid
3492 * We take the extra step of blanking out dest here to prevent the
3493 * user from seeing stale data from a previous call
3496 memset(dest, 0, sizeof(*dest));
3498 switch (source->status) {
3500 dest->status = VOS_OK;
3503 dest->status = VOS_SALVAGE;
3506 dest->status = VOS_NO_VNODE;
3509 dest->status = VOS_NO_VOL;
3512 dest->status = VOS_VOL_EXISTS;
3515 dest->status = VOS_NO_SERVICE;
3518 dest->status = VOS_OFFLINE;
3521 dest->status = VOS_ONLINE;
3524 dest->status = VOS_DISK_FULL;
3527 dest->status = VOS_OVER_QUOTA;
3530 dest->status = VOS_BUSY;
3533 dest->status = VOS_MOVED;
3538 * Check to see if the entry is marked ok before copying all the
3542 if (dest->status == VOS_OK) {
3543 strncpy(dest->name, source->name, VOS_MAX_VOLUME_NAME_LEN);
3544 dest->name[VOS_MAX_VOLUME_NAME_LEN - 1] = '\0';
3545 dest->id = source->volid;
3546 if (source->type == 0) {
3547 dest->type = VOS_READ_WRITE_VOLUME;
3548 } else if (source->type == 1) {
3549 dest->type = VOS_READ_ONLY_VOLUME;
3550 } else if (source->type == 2) {
3551 dest->type = VOS_BACKUP_VOLUME;
3553 dest->backupId = source->backupID;
3554 dest->readWriteId = source->parentID;
3555 dest->readOnlyId = source->cloneID;
3556 dest->copyCreationDate = source->copyDate;
3557 dest->creationDate = source->creationDate;
3558 dest->lastAccessDate = source->accessDate;
3559 dest->lastUpdateDate = source->updateDate;
3560 dest->lastBackupDate = source->backupDate;
3561 dest->accessesSinceMidnight = source->dayUse;
3562 dest->fileCount = source->filecount;
3563 dest->maxQuota = source->maxquota;
3564 dest->currentSize = source->size;
3565 if (source->inUse == 1) {
3566 dest->volumeDisposition = VOS_ONLINE;
3568 dest->volumeDisposition = VOS_OFFLINE;
3571 for (i = 0; i < VOS_VOLUME_READ_WRITE_STATS_NUMBER; i++) {
3572 dest->readStats[i] = source->stat_reads[i];
3573 dest->writeStats[i] = source->stat_writes[i];
3576 for (i = 0; i < VOS_VOLUME_TIME_STATS_NUMBER; i++) {
3577 dest->fileAuthorWriteSameNetwork[i] =
3578 source->stat_fileSameAuthor[i];
3579 dest->fileAuthorWriteDifferentNetwork[i] =
3580 source->stat_fileDiffAuthor[i];
3581 dest->dirAuthorWriteSameNetwork[i] =
3582 source->stat_dirSameAuthor[i];
3583 dest->dirAuthorWriteDifferentNetwork[i] =
3584 source->stat_dirDiffAuthor[i];
3597 * vos_VolumeGet - get information about a particular volume.
3601 * IN cellHandle - a previously opened cellHandle that corresponds
3602 * to the cell where the volume exists.
3604 * IN serverHandle - a previously opened serverHandle that corresponds
3605 * to the server where the volume exists.
3607 * IN callBack - a call back function pointer that may be called to report
3608 * status information. Can be null.
3610 * IN partition - the partition where the volume exists.
3612 * IN volumeId - the volume id of the volume to be retrieved.
3614 * OUT volumeP - upon successful completion, contains the information about the
3619 * No locks are obtained or released by this function
3623 * Returns != 0 upon successful completion.
3627 vos_VolumeGet(const void *cellHandle, const void *serverHandle,
3628 vos_MessageCallBack_t callBack, unsigned int partition,
3629 unsigned int volumeId, vos_volumeEntry_p volumeP,
3633 afs_status_t tst = 0;
3634 file_server_p f_server = (file_server_p) serverHandle;
3635 struct volintXInfo *info = NULL;
3638 * Validate arguments
3641 if (!IsValidServerHandle(f_server, &tst)) {
3642 goto fail_vos_VolumeGet;
3645 if (partition > VOLMAXPARTS) {
3646 tst = ADMVOSPARTITIONIDTOOLARGE;
3647 goto fail_vos_VolumeGet;
3650 if (volumeP == NULL) {
3651 tst = ADMVOSVOLUMEPNULL;
3652 goto fail_vos_VolumeGet;
3656 * Retrieve the information for the volume
3659 if (!UV_XListOneVolume(f_server->serv, partition, volumeId, &info, &tst)) {
3660 goto fail_vos_VolumeGet;
3664 * Copy the volume info to our structure
3667 if (!copyvolintXInfo(info, volumeP, &tst)) {
3668 goto fail_vos_VolumeGet;
3685 * The iterator functions and data for the volume retrieval functions.
3688 typedef struct volume_get {
3689 struct volintXInfo *vollist;
3690 afs_int32 total; /* total number of volumes at this partition */
3691 afs_int32 index; /* index to the current volume */
3692 vos_volumeEntry_t entry[CACHED_ITEMS]; /* the cache of entries */
3693 } volume_get_t, *volume_get_p;
3696 GetVolumeRPC(void *rpc_specific, int slot, int *last_item,
3697 int *last_item_contains_data, afs_status_p st)
3700 afs_status_t tst = 0;
3701 volume_get_p entry = (volume_get_p) rpc_specific;
3704 * Copy the next entry into the cache
3707 if (!copyvolintXInfo
3708 (&entry->vollist[entry->index], &entry->entry[slot], &tst)) {
3709 goto fail_GetVolumeRPC;
3714 * See if we've processed all the entries
3718 if (entry->index == entry->total) {
3720 *last_item_contains_data = 1;
3733 GetVolumeFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
3736 afs_status_t tst = 0;
3737 volume_get_p entry = (volume_get_p) rpc_specific;
3739 memcpy(dest, (const void *)&entry->entry[slot],
3740 sizeof(vos_volumeEntry_t));
3751 DestroyVolume(void *rpc_specific, afs_status_p st)
3754 afs_status_t tst = 0;
3755 volume_get_p entry = (volume_get_p) rpc_specific;
3757 if (entry->vollist != NULL) {
3758 free(entry->vollist);
3770 * vos_VolumeGetBegin - begin to iterator over the list of volumes at a server.
3774 * IN cellHandle - a previously opened cellHandle that corresponds
3775 * to the cell where the volumes exist.
3777 * IN serverHandle - a handle to the server where the volumes exist.
3779 * IN callBack - a call back function pointer that may be called to report
3780 * status information. Can be null.
3782 * IN partition - the partition whose volumes should be listed. Can be null.
3784 * OUT iterationIdP - upon successful completion, contains an iterator that
3785 * can be passed to vos_VolumeGetBegin.
3789 * No locks are obtained or released by this function
3793 * Returns != 0 upon successful completion.
3797 vos_VolumeGetBegin(const void *cellHandle, const void *serverHandle,
3798 vos_MessageCallBack_t callBack, unsigned int partition,
3799 void **iterationIdP, afs_status_p st)
3802 afs_status_t tst = 0;
3803 file_server_p f_server = (file_server_p) serverHandle;
3804 afs_admin_iterator_p iter =
3805 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
3806 volume_get_p entry = calloc(1, sizeof(volume_get_t));
3809 * Validate arguments
3812 if (!IsValidServerHandle(f_server, &tst)) {
3813 goto fail_vos_VolumeGetBegin;
3816 if (partition > VOLMAXPARTS) {
3817 tst = ADMVOSPARTITIONIDTOOLARGE;
3818 goto fail_vos_VolumeGetBegin;
3821 if ((iter == NULL) || (entry == NULL)) {
3823 goto fail_vos_VolumeGetBegin;
3827 * Get a list of all the volumes contained in the partition at the
3831 if (!UV_XListVolumes
3832 (f_server->serv, partition, 1, &entry->vollist, &entry->total,
3834 goto fail_vos_VolumeGetBegin;
3837 if (entry->total == 0) {
3838 if (!IteratorInit(iter, (void *)entry, NULL, NULL, NULL, NULL, &tst)) {
3839 goto fail_vos_VolumeGetBegin;
3841 iter->done_iterating = 1;
3842 iter->st = ADMITERATORDONE;
3845 (iter, (void *)entry, GetVolumeRPC, GetVolumeFromCache, NULL,
3846 DestroyVolume, &tst)) {
3847 goto fail_vos_VolumeGetBegin;
3850 *iterationIdP = (void *)iter;
3853 fail_vos_VolumeGetBegin:
3859 if (entry != NULL) {
3871 * vos_VolumeGetNext - get information about the next volume.
3875 * IN iterationId - an iterator previously returned by
3876 * vos_VolumeGetBegin
3878 * OUT volumeP - a pointer to a vos_volumeEntry_t
3879 * that upon successful completion contains information about the
3884 * The iterator is locked while the next item is retrieved.
3888 * Returns != 0 upon successful completion.
3892 vos_VolumeGetNext(const void *iterationId, vos_volumeEntry_p volumeP,
3896 afs_status_t tst = 0;
3897 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3900 tst = ADMITERATORNULL;
3901 goto fail_vos_VolumeGetNext;
3904 if (volumeP == NULL) {
3905 tst = ADMVOSVOLUMEPNULL;
3906 goto fail_vos_VolumeGetNext;
3909 rc = IteratorNext(iter, (void *)volumeP, &tst);
3911 fail_vos_VolumeGetNext:
3920 * vos_VolumeGetDone - finish using a volume iterator.
3924 * IN iterationId - an iterator previously returned by vos_VolumeGetBegin
3928 * The iterator is locked and then destroyed.
3932 * Returns != 0 upon successful completion.
3936 vos_VolumeGetDone(const void *iterationId, afs_status_p st)
3939 afs_status_t tst = 0;
3940 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
3943 * Validate arguments
3947 tst = ADMITERATORNULL;
3948 goto fail_vos_VolumeGetDone;
3951 rc = IteratorDone(iter, &tst);
3953 fail_vos_VolumeGetDone:
3962 * vos_VolumeMove - move a volume from one server to another.
3966 * IN cellHandle - a previously opened cellHandle that corresponds
3967 * to the cell where the volume exists.
3969 * IN callBack - a call back function pointer that may be called to report
3970 * status information. Can be null.
3972 * IN volumeId - the volume id of the volume to be moved.
3974 * IN fromServer - a previously opened serverHandle that corresponds
3975 * to the server where the volume currently resides.
3977 * IN fromPartition - the partition where the volume currently resides.
3979 * IN toServer - a previously opened serverHandle that corresponds
3980 * to the server where the volume will be moved.
3982 * IN toPartition - the partition where the volume will be moved.
3986 * No locks are obtained or released by this function
3990 * Returns != 0 upon successful completion.
3994 vos_VolumeMove(const void *cellHandle, vos_MessageCallBack_t callBack,
3995 unsigned int volumeId, const void *fromServer,
3996 unsigned int fromPartition, const void *toServer,
3997 unsigned int toPartition, afs_status_p st)
4000 afs_status_t tst = 0;
4001 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4002 file_server_p from_server = (file_server_p) fromServer;
4003 file_server_p to_server = (file_server_p) toServer;
4004 afs_int32 from_server_addr =
4005 ntohl(rx_HostOf(rx_PeerOf(from_server->serv)));
4006 afs_int32 to_server_addr = ntohl(rx_HostOf(rx_PeerOf(to_server->serv)));
4007 afs_int32 from_partition = fromPartition;
4008 afs_int32 to_partition = toPartition;
4011 * Validate arguments
4014 if (!IsValidCellHandle(c_handle, &tst)) {
4015 goto fail_vos_VolumeMove;
4018 if (!IsValidServerHandle(from_server, &tst)) {
4019 goto fail_vos_VolumeMove;
4022 if (!IsValidServerHandle(to_server, &tst)) {
4023 goto fail_vos_VolumeMove;
4026 if (fromPartition > VOLMAXPARTS) {
4027 tst = ADMVOSPARTITIONIDTOOLARGE;
4028 goto fail_vos_VolumeMove;
4031 if (toPartition > VOLMAXPARTS) {
4032 tst = ADMVOSPARTITIONIDTOOLARGE;
4033 goto fail_vos_VolumeMove;
4040 rc = UV_MoveVolume(c_handle, volumeId, from_server_addr, from_partition,
4041 to_server_addr, to_partition, &tst);
4043 fail_vos_VolumeMove:
4052 * vos_VolumeRelease - release a volume.
4056 * IN cellHandle - a previously opened cellHandle that corresponds
4057 * to the cell where the volume exists.
4059 * IN callBack - a call back function pointer that may be called to report
4060 * status information. Can be null.
4062 * IN volumeId - the volume to be released.
4064 * IN force - force a complete release.
4068 * No locks are obtained or released by this function
4072 * Returns != 0 upon successful completion.
4076 vos_VolumeRelease(const void *cellHandle, vos_MessageCallBack_t callBack,
4077 unsigned int volumeId, vos_force_t force, afs_status_p st)
4080 afs_status_t tst = 0;
4081 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4082 afs_int32 server, part, forc = 0, voltype, volume;
4083 struct nvldbentry entry;
4086 * Validate arguments
4089 if (!IsValidCellHandle(c_handle, &tst)) {
4090 goto fail_vos_VolumeRelease;
4094 (c_handle, volumeId, &entry, &server, &part, &voltype, &tst)) {
4095 goto fail_vos_VolumeRelease;
4098 if (force == VOS_FORCE) {
4103 rc = UV_ReleaseVolume(c_handle, volume, server, part, forc, &tst);
4105 fail_vos_VolumeRelease:
4114 * vos_VolumeZap - forcibly delete a volume.
4118 * IN cellHandle - a previously opened cellHandle that corresponds
4119 * to the cell where the volume exists.
4121 * IN serverHandle - a previously opened serverHandle that corresponds
4122 * to the server where the volume exists.
4124 * IN callBack - a call back function pointer that may be called to report
4125 * status information. Can be null.
4127 * IN partition - the partition where the volume exists.
4129 * IN volumeId - the volume id of the vldb entry to be deleted.
4131 * IN force - force the deletion of bad volumes.
4135 * No locks are obtained or released by this function
4139 * Returns != 0 upon successful completion.
4143 vos_VolumeZap(const void *cellHandle, const void *serverHandle,
4144 vos_MessageCallBack_t callBack, unsigned int partition,
4145 unsigned int volumeId, vos_force_t force, afs_status_p st)
4148 afs_status_t tst = 0;
4149 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4150 file_server_p f_server = (file_server_p) serverHandle;
4153 * Verify that the cellHandle is capable of making vos rpc's
4156 if (!IsValidCellHandle(c_handle, &tst)) {
4157 goto fail_vos_VolumeZap;
4160 if (!IsValidServerHandle(f_server, &tst)) {
4161 goto fail_vos_VolumeZap;
4164 if (force == VOS_FORCE) {
4165 rc = UV_NukeVolume(c_handle, f_server->serv, partition, volumeId,
4168 rc = UV_VolumeZap(c_handle, f_server->serv, partition, volumeId,
4181 * vos_PartitionNameToId - translate a string representing a partition
4186 * IN partitionName - a string representing a partition. Must be of
4189 * OUT partitionId - a number containing the partition id upon successful
4194 * No locks are obtained or released by this function
4198 * Returns != 0 upon successful completion.
4202 vos_PartitionNameToId(const char *partitionName, unsigned int *partitionId,
4206 afs_status_t tst = 0;
4207 size_t partition_name_len;
4211 * Validate arguments
4214 if (partitionName == NULL) {
4215 tst = ADMVOSPARTITIONNAMENULL;
4216 goto fail_vos_PartitionNameToId;
4219 if (partitionId == NULL) {
4220 tst = ADMVOSPARTITIONIDNULL;
4221 goto fail_vos_PartitionNameToId;
4225 * Check that string begins with /vicep
4228 if (strncmp(partitionName, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
4229 tst = ADMVOSPARTITIONNAMEINVALID;
4230 goto fail_vos_PartitionNameToId;
4234 * Check that the string is either one or two characters
4235 * longer than VICE_PREFIX_SIZE
4238 partition_name_len = strlen(partitionName);
4240 if (partition_name_len == VICE_PREFIX_SIZE) {
4241 tst = ADMVOSPARTITIONNAMETOOSHORT;
4242 goto fail_vos_PartitionNameToId;
4245 if (partition_name_len > (VICE_PREFIX_SIZE + 2)) {
4246 tst = ADMVOSPARTITIONNAMETOOLONG;
4247 goto fail_vos_PartitionNameToId;
4251 * Check that all characters past the prefix are lower case
4254 for (i = VICE_PREFIX_SIZE; i < partition_name_len; i++) {
4255 if (!islower(partitionName[i])) {
4256 tst = ADMVOSPARTITIONNAMENOTLOWER;
4257 goto fail_vos_PartitionNameToId;
4262 * Convert the name to a number
4265 if (partitionName[VICE_PREFIX_SIZE + 1] == 0) {
4266 *partitionId = partitionName[VICE_PREFIX_SIZE] - 'a';
4269 (partitionName[VICE_PREFIX_SIZE] - 'a') * 26 +
4270 (partitionName[VICE_PREFIX_SIZE + 1] - 'a') + 26;
4273 if (*partitionId > VOLMAXPARTS) {
4274 tst = ADMVOSPARTITIONIDTOOLARGE;
4275 goto fail_vos_PartitionNameToId;
4279 fail_vos_PartitionNameToId:
4288 * vos_PartitionIdToName - translate a number representing a partition
4289 * to a character string.
4293 * IN partitionId - an integer representing the partition.
4295 * OUT partitionName - a string containing the converted partition ID
4296 * upon successful completion.
4300 * No locks are obtained or released by this function
4304 * Returns != 0 upon successful completion.
4308 vos_PartitionIdToName(unsigned int partitionId, char *partitionName,
4312 afs_status_t tst = 0;
4314 if (partitionId > VOLMAXPARTS) {
4315 tst = ADMVOSPARTITIONIDTOOLARGE;
4316 goto fail_vos_PartitionIdToName;
4319 if (partitionName == NULL) {
4320 tst = ADMVOSPARTITIONNAMENULL;
4321 goto fail_vos_PartitionIdToName;
4324 if (partitionId < 26) {
4325 strcpy(partitionName, VICE_PARTITION_PREFIX);
4326 partitionName[6] = partitionId + 'a';
4327 partitionName[7] = '\0';
4329 strcpy(partitionName, VICE_PARTITION_PREFIX);
4331 partitionName[6] = 'a' + (partitionId / 26);
4332 partitionName[7] = 'a' + (partitionId % 26);
4333 partitionName[8] = '\0';
4337 fail_vos_PartitionIdToName:
4346 * vos_VolumeQuotaChange - change the quota of a volume.
4350 * IN cellHandle - a previously opened cellHandle that corresponds
4351 * to the cell where the volume exists.
4353 * IN serverHandle - a previously opened serverHandle that corresponds
4354 * to the server where the volume exists.
4356 * IN callBack - a call back function pointer that may be called to report
4357 * status information. Can be null.
4359 * IN partition - the partition where the volume exists.
4361 * IN volumeId - the volume id of the volume to be modified.
4363 * IN volumeQuota - the new volume quota.
4367 * No locks are obtained or released by this function
4371 * Returns != 0 upon successful completion.
4375 vos_VolumeQuotaChange(const void *cellHandle, const void *serverHandle,
4376 vos_MessageCallBack_t callBack, unsigned int partition,
4377 unsigned int volumeId, unsigned int volumeQuota,
4381 afs_status_t tst = 0;
4382 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
4383 file_server_p f_server = (file_server_p) serverHandle;
4386 struct volintInfo tstatus;
4387 int active_trans = 0;
4390 * Verify that the cellHandle is capable of making vos rpc's
4393 if (!IsValidCellHandle(c_handle, &tst)) {
4394 goto fail_vos_VolumeQuotaChange;
4397 if (!IsValidServerHandle(f_server, &tst)) {
4398 goto fail_vos_VolumeQuotaChange;
4401 memset((void *)&tstatus, 0, sizeof(tstatus));
4402 tstatus.dayUse = -1;
4403 tstatus.spare2 = -1;
4404 tstatus.maxquota = volumeQuota;
4408 AFSVolTransCreate(f_server->serv, volumeId, partition, ITBusy, &ttid);
4410 goto fail_vos_VolumeQuotaChange;
4414 tst = AFSVolSetInfo(f_server->serv, ttid, &tstatus);
4416 goto fail_vos_VolumeQuotaChange;
4420 fail_vos_VolumeQuotaChange:
4423 afs_status_t tst2 = 0;
4424 tst2 = AFSVolEndTrans(f_server->serv, ttid, &rcode);
4445 * vos_VolumeGet2 - get information about a particular volume.
4449 * IN cellHandle - a previously opened cellHandle that corresponds
4450 * to the cell where the volume exists.
4452 * IN serverHandle - a previously opened serverHandle that corresponds
4453 * to the server where the volume exists.
4455 * IN callBack - a call back function pointer that may be called to report
4456 * status information. Can be null.
4458 * IN partition - the partition where the volume exists.
4460 * IN volumeId - the volume id of the volume to be retrieved.
4462 * OUT pinfo - upon successful completion, contains the information about the
4467 * No locks are obtained or released by this function
4471 * Returns != 0 upon successful completion.
4475 vos_VolumeGet2(const void *cellHandle, const void *serverHandle,
4476 vos_MessageCallBack_t callBack, unsigned int partition,
4477 unsigned int volumeId, volintInfo* pinfo,
4481 afs_status_t tst = 0;
4482 file_server_p f_server = (file_server_p) serverHandle;
4483 volintInfo *pinfo_=0;
4486 * Validate arguments
4489 if (!IsValidServerHandle(f_server, &tst)) {
4490 goto fail_vos_VolumeGet2;
4493 if (partition > VOLMAXPARTS) {
4494 tst = ADMVOSPARTITIONIDTOOLARGE;
4495 goto fail_vos_VolumeGet2;
4498 if (pinfo == NULL) {
4499 tst = ADMVOSVOLUMEPNULL;
4500 goto fail_vos_VolumeGet2;
4504 * Retrieve the information for the volume
4507 if (!UV_ListOneVolume(f_server->serv, partition, volumeId, &pinfo_,&tst)) {
4508 goto fail_vos_VolumeGet2;
4514 fail_vos_VolumeGet2:
4516 if (pinfo_ != NULL) {
4517 memcpy(pinfo,pinfo_,sizeof(volintInfo));
4528 * vos_ClearVolUpdateCounter - reset volUpdateCounter of a volume to zero
4532 * IN cellHandle - a previously opened cellHandle that corresponds
4533 * to the cell where the volume exists.
4535 * IN serverHandle - a previously opened serverHandle that corresponds
4536 * to the server where the volume exists.
4538 * IN partition - the partition where the volume exists.
4540 * IN volumeId - the volume id of the volume to be retrieved.
4544 * No locks are obtained or released by this function
4548 * Returns != 0 upon successful completion.
4552 vos_ClearVolUpdateCounter(const void *cellHandle,
4553 const void *serverHandle,
4554 unsigned int partition,
4555 unsigned int volumeId,
4559 afs_status_t tst = 0;