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>
15 #ifdef IGNORE_SOME_GCC_WARNINGS
16 # pragma GCC diagnostic warning "-Wimplicit-function-declaration"
20 #include <WINNT/afsreg.h>
24 #include <sys/statfs.h>
29 #include <rx/rx_queue.h>
32 #include <rx/rx_globals.h>
34 #include <afs/vlserver.h>
35 #include <afs/cellconfig.h>
37 #include <afs/afsutil.h>
39 #include <afs/afsint.h>
44 #include <afs/ihandle.h>
45 #include <afs/vnode.h>
46 #include <afs/volume.h>
47 #include <afs/com_err.h>
51 #include "volser_internal.h"
52 #include "volser_prototypes.h"
53 #include "vsutils_prototypes.h"
54 #include "lockprocs_prototypes.h"
56 #ifdef HAVE_POSIX_REGEX
60 /* Local Prototypes */
61 int PrintDiagnostics(char *astring, afs_int32 acode);
62 int GetVolumeInfo(afs_uint32 volid, afs_uint32 *server, afs_int32 *part,
63 afs_int32 *voltype, struct nvldbentry *rentry);
76 COMMONPARM_OFFSET_CELL = 25,
77 COMMONPARM_OFFSET_NOAUTH = 26,
78 COMMONPARM_OFFSET_LOCALAUTH = 27,
79 COMMONPARM_OFFSET_VERBOSE = 28,
80 COMMONPARM_OFFSET_ENCRYPT = 29,
81 COMMONPARM_OFFSET_NORESOLVE = 30,
82 COMMONPARM_OFFSET_CONFIG = 31,
86 cmd_AddParmAtOffset(ts, COMMONPARM_OFFSET_CELL, \
87 "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");\
88 cmd_AddParmAlias(ts, COMMONPARM_OFFSET_CELL, "-c"); /* original -cell option */ \
89 cmd_AddParmAtOffset(ts, COMMONPARM_OFFSET_NOAUTH, \
90 "-noauth", CMD_FLAG, CMD_OPTIONAL, "don't authenticate");\
91 cmd_AddParmAtOffset(ts, COMMONPARM_OFFSET_LOCALAUTH, \
92 "-localauth",CMD_FLAG,CMD_OPTIONAL,"use server tickets");\
93 cmd_AddParmAtOffset(ts, COMMONPARM_OFFSET_VERBOSE, \
94 "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose");\
95 cmd_AddParmAtOffset(ts, COMMONPARM_OFFSET_ENCRYPT, \
96 "-encrypt", CMD_FLAG, CMD_OPTIONAL, "encrypt commands");\
97 cmd_AddParmAtOffset(ts, COMMONPARM_OFFSET_NORESOLVE, \
98 "-noresolve", CMD_FLAG, CMD_OPTIONAL, "don't resolve addresses"); \
99 cmd_AddParmAtOffset(ts, COMMONPARM_OFFSET_CONFIG, \
100 "-config", CMD_SINGLE, CMD_OPTIONAL, "config location"); \
102 #define ERROR_EXIT(code) do { \
108 extern struct ubik_client *cstruct;
111 static struct tqHead busyHead, notokHead;
114 qInit(struct tqHead *ahead)
116 memset(ahead, 0, sizeof(struct tqHead));
122 qPut(struct tqHead *ahead, afs_uint32 volid)
126 elem = malloc(sizeof(struct tqElem));
127 elem->next = ahead->next;
135 qGet(struct tqHead *ahead, afs_uint32 *volid)
139 if (ahead->count <= 0)
141 *volid = ahead->next->volid;
143 ahead->next = tmp->next;
149 /* returns 1 if <filename> exists else 0 */
151 FileExists(char *filename)
157 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
161 code = USD_IOCTL(ufd, USD_IOCTL_GETSIZE, &size);
169 /* returns 1 if <name> doesnot end in .readonly or .backup, else 0 */
171 VolNameOK(char *name)
176 total = strlen(name);
177 if (!strcmp(&name[total - 9], ".readonly")) {
179 } else if (!strcmp(&name[total - 7], ".backup")) {
186 /* return 1 if name is a number else 0 */
188 IsNumeric(char *name)
197 for (i = 0; i < len; i++) {
198 if (*ptr < '0' || *ptr > '9') {
210 * Parse a server dotted address and return the address in network byte order
213 GetServerNoresolve(char *aname)
219 code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
221 addr = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
222 addr = htonl(addr); /* convert to network byte order */
228 * Parse a server name/address and return a non-loopback address in network byte order
231 GetServer(char *aname)
234 afs_uint32 addr; /* in network byte order */
236 char hostname[MAXHOSTCHARS];
237 afs_uint32 **addr_list;
240 addr = GetServerNoresolve(aname);
242 if (!rx_IsLoopbackAddr(ntohl(addr)))
248 th = gethostbyname(aname);
249 if (th != NULL && th->h_addrtype == AF_INET) {
250 addr_list = (afs_uint32 **)th->h_addr_list;
251 for(i = 0; addr_list[i] != NULL; i++) {
252 if (!rx_IsLoopbackAddr(ntohl(*addr_list[i]))) {
253 memcpy(&addr, addr_list[i], sizeof(addr));
259 * If we reach this point all of the addresses returned by
260 * gethostbyname() are loopback addresses. We assume that means
261 * that the name is supposed to describe the machine this code
262 * is executing on. Try gethostname() to and check to see if
263 * that name can provide us a non-loopback address.
265 code = gethostname(hostname, MAXHOSTCHARS);
267 th = gethostbyname(hostname);
268 if (th != NULL && th->h_addrtype == AF_INET) {
269 addr_list = (afs_uint32 **)th->h_addr_list;
270 for (i=0; addr_list[i] != NULL; i++) {
271 if (!rx_IsLoopbackAddr(ntohl(*addr_list[i]))) {
272 memcpy(&addr, addr_list[i], sizeof(addr));
281 * No non-loopback address could be obtained for 'aname'.
287 GetVolumeType(char *aname)
290 if (!strcmp(aname, "ro"))
292 else if (!strcmp(aname, "rw"))
294 else if (!strcmp(aname, "bk"))
301 IsPartValid(afs_int32 partId, afs_uint32 server, afs_int32 *code)
303 struct partList dummyPartList;
309 *code = UV_ListPartitions(server, &dummyPartList, &cnt);
312 for (i = 0; i < cnt; i++) {
313 if (dummyPartList.partFlags[i] & PARTVALID)
314 if (dummyPartList.partId[i] == partId)
322 /*sends the contents of file associated with <fd> and <blksize> to Rx Stream
323 * associated with <call> */
325 SendFile(usd_handle_t ufd, struct rx_call *call, long blksize)
327 char *buffer = (char *)0;
331 buffer = malloc(blksize);
333 fprintf(STDERR, "malloc failed\n");
338 #if !defined(AFS_NT40_ENV) && !defined(AFS_PTHREAD_ENV)
339 /* Only for this for non-NT, non-pthread. For NT, we can't select on
340 * non-socket FDs. For pthread environments, we don't need to select at
341 * all, since the following read() will block. */
344 FD_SET((intptr_t)(ufd->handle), &in);
345 /* don't timeout if read blocks */
346 IOMGR_Select(((intptr_t)(ufd->handle)) + 1, &in, 0, 0, 0);
348 error = USD_READ(ufd, buffer, blksize, &nbytes);
350 fprintf(STDERR, "File system read failed: %s\n",
351 afs_error_message(error));
358 if (rx_Write(call, buffer, nbytes) != nbytes) {
368 /* function invoked by UV_RestoreVolume, reads the data from rx_trx_stream and
369 * writes it out to the volume. */
371 WriteData(struct rx_call *call, void *rock)
373 char *filename = (char *) rock;
376 afs_int32 error, code;
378 afs_int64 currOffset;
384 if (!filename || !*filename) {
385 usd_StandardInput(&ufd);
389 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
392 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
395 fprintf(STDERR, "Could not access file '%s': %s\n", filename,
396 afs_error_message(code));
400 /* test if we have a valid dump */
401 USD_SEEK(ufd, 0, SEEK_END, &currOffset);
402 USD_SEEK(ufd, currOffset - sizeof(afs_uint32), SEEK_SET, &currOffset);
403 USD_READ(ufd, (char *)&buffer, sizeof(afs_uint32), &got);
404 if ((got != sizeof(afs_uint32)) || (ntohl(buffer) != DUMPENDMAGIC)) {
405 fprintf(STDERR, "Signature missing from end of file '%s'\n", filename);
409 USD_SEEK(ufd, 0, SEEK_SET, &currOffset);
411 code = SendFile(ufd, call, blksize);
418 code = USD_CLOSE(ufd);
420 fprintf(STDERR, "Could not close dump file %s\n",
421 (filename && *filename) ? filename : "STDOUT");
429 /* Receive data from <call> stream into file associated
430 * with <fd> <blksize>
433 ReceiveFile(usd_handle_t ufd, struct rx_call *call, long blksize)
437 afs_uint32 bytesleft, w;
440 buffer = malloc(blksize);
442 fprintf(STDERR, "memory allocation failed\n");
446 while ((bytesread = rx_Read(call, buffer, blksize)) > 0) {
447 for (bytesleft = bytesread; bytesleft; bytesleft -= w) {
448 #if !defined(AFS_NT40_ENV) && !defined(AFS_PTHREAD_ENV)
449 /* Only for this for non-NT, non-pthread. For NT, we can't select
450 * on non-socket FDs. For pthread environments, we don't need to
451 * select at all, since the following write() will block. */
454 FD_SET((intptr_t)(ufd->handle), &out);
455 /* don't timeout if write blocks */
456 IOMGR_Select(((intptr_t)(ufd->handle)) + 1, 0, &out, 0, 0);
459 USD_WRITE(ufd, &buffer[bytesread - bytesleft], bytesleft, &w);
461 fprintf(STDERR, "File system write failed: %s\n",
462 afs_error_message(error));
475 DumpFunction(struct rx_call *call, void *rock)
477 char *filename = (char *)rock;
478 usd_handle_t ufd; /* default is to stdout */
479 afs_int32 error = 0, code;
484 /* Open the output file */
485 if (!filename || !*filename) {
486 usd_StandardOutput(&ufd);
491 usd_Open(filename, USD_OPEN_CREATE | USD_OPEN_RDWR, 0666, &ufd);
495 code = USD_IOCTL(ufd, USD_IOCTL_SETSIZE, &size);
498 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
501 fprintf(STDERR, "Could not create file '%s': %s\n", filename,
502 afs_error_message(code));
503 ERROR_EXIT(VOLSERBADOP);
507 code = ReceiveFile(ufd, call, blksize);
512 /* Close the output file */
514 code = USD_CLOSE(ufd);
516 fprintf(STDERR, "Could not close dump file %s\n",
517 (filename && *filename) ? filename : "STDIN");
527 DisplayFormat(volintInfo *pntr, afs_uint32 server, afs_int32 part,
528 int *totalOK, int *totalNotOK, int *totalBusy, int fast,
529 int longlist, int disp)
535 fprintf(STDOUT, "%-10lu\n", (unsigned long)pntr->volid);
536 } else if (longlist) {
537 if (pntr->status == VOK) {
538 fprintf(STDOUT, "%-32s ", pntr->name);
539 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
541 fprintf(STDOUT, "RW ");
543 fprintf(STDOUT, "RO ");
545 fprintf(STDOUT, "BK ");
546 fprintf(STDOUT, "%10d K ", pntr->size);
547 if (pntr->inUse == 1) {
548 fprintf(STDOUT, "On-line");
551 fprintf(STDOUT, "Off-line");
554 if (pntr->needsSalvaged == 1)
555 fprintf(STDOUT, "**needs salvage**");
556 fprintf(STDOUT, "\n");
557 MapPartIdIntoName(part, pname);
558 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(server),
560 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
561 (unsigned long)pntr->parentID,
562 (unsigned long)pntr->cloneID,
563 (unsigned long)pntr->backupID);
564 fprintf(STDOUT, " MaxQuota %10d K \n", pntr->maxquota);
565 t = pntr->creationDate;
566 fprintf(STDOUT, " Creation %s",
569 fprintf(STDOUT, " Copy %s",
572 t = pntr->backupDate;
574 fprintf(STDOUT, " Backup Never\n");
576 fprintf(STDOUT, " Backup %s",
579 t = pntr->accessDate;
581 fprintf(STDOUT, " Last Access %s",
584 t = pntr->updateDate;
586 fprintf(STDOUT, " Last Update Never\n");
588 fprintf(STDOUT, " Last Update %s",
591 " %d accesses in the past day (i.e., vnode references)\n",
593 } else if (pntr->status == VBUSY) {
595 qPut(&busyHead, pntr->volid);
597 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
598 (unsigned long)pntr->volid);
601 qPut(¬okHead, pntr->volid);
603 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
604 (unsigned long)pntr->volid);
606 fprintf(STDOUT, "\n");
607 } else { /* default listing */
608 if (pntr->status == VOK) {
609 fprintf(STDOUT, "%-32s ", pntr->name);
610 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
612 fprintf(STDOUT, "RW ");
614 fprintf(STDOUT, "RO ");
616 fprintf(STDOUT, "BK ");
617 fprintf(STDOUT, "%10d K ", pntr->size);
618 if (pntr->inUse == 1) {
619 fprintf(STDOUT, "On-line");
622 fprintf(STDOUT, "Off-line");
625 if (pntr->needsSalvaged == 1)
626 fprintf(STDOUT, "**needs salvage**");
627 fprintf(STDOUT, "\n");
628 } else if (pntr->status == VBUSY) {
630 qPut(&busyHead, pntr->volid);
632 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
633 (unsigned long)pntr->volid);
636 qPut(¬okHead, pntr->volid);
638 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
639 (unsigned long)pntr->volid);
644 /*------------------------------------------------------------------------
645 * PRIVATE XDisplayFormat
648 * Display the contents of one extended volume info structure.
651 * a_xInfoP : Ptr to extended volume info struct to print.
652 * a_servID : Server ID to print.
653 * a_partID : Partition ID to print.
654 * a_totalOKP : Ptr to total-OK counter.
655 * a_totalNotOKP : Ptr to total-screwed counter.
656 * a_totalBusyP : Ptr to total-busy counter.
657 * a_fast : Fast listing?
658 * a_int32 : Int32 listing?
659 * a_showProblems : Show volume problems?
665 * Nothing interesting.
669 *------------------------------------------------------------------------*/
672 XDisplayFormat(volintXInfo *a_xInfoP, afs_uint32 a_servID, afs_int32 a_partID,
673 int *a_totalOKP, int *a_totalNotOKP, int *a_totalBusyP,
674 int a_fast, int a_int32, int a_showProblems)
675 { /*XDisplayFormat */
683 fprintf(STDOUT, "%-10lu\n", (unsigned long)a_xInfoP->volid);
684 } else if (a_int32) {
686 * Fully-detailed listing.
688 if (a_xInfoP->status == VOK) {
690 * Volume's status is OK - all the fields are valid.
692 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
693 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
694 if (a_xInfoP->type == 0)
695 fprintf(STDOUT, "RW ");
696 if (a_xInfoP->type == 1)
697 fprintf(STDOUT, "RO ");
698 if (a_xInfoP->type == 2)
699 fprintf(STDOUT, "BK ");
700 fprintf(STDOUT, "%10d K used ", a_xInfoP->size);
701 fprintf(STDOUT, "%d files ", a_xInfoP->filecount);
702 if (a_xInfoP->inUse == 1) {
703 fprintf(STDOUT, "On-line");
706 fprintf(STDOUT, "Off-line");
709 fprintf(STDOUT, "\n");
710 MapPartIdIntoName(a_partID, pname);
711 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(a_servID),
713 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
714 (unsigned long)a_xInfoP->parentID,
715 (unsigned long)a_xInfoP->cloneID,
716 (unsigned long)a_xInfoP->backupID);
717 fprintf(STDOUT, " MaxQuota %10d K \n", a_xInfoP->maxquota);
719 t = a_xInfoP->creationDate;
720 fprintf(STDOUT, " Creation %s",
723 t = a_xInfoP->copyDate;
724 fprintf(STDOUT, " Copy %s",
727 t = a_xInfoP->backupDate;
729 fprintf(STDOUT, " Backup Never\n");
731 fprintf(STDOUT, " Backup %s",
734 t = a_xInfoP->accessDate;
736 fprintf(STDOUT, " Last Access %s",
739 t = a_xInfoP->updateDate;
741 fprintf(STDOUT, " Last Update Never\n");
743 fprintf(STDOUT, " Last Update %s",
746 " %d accesses in the past day (i.e., vnode references)\n",
750 * Print all the read/write and authorship stats.
752 fprintf(STDOUT, "\n Raw Read/Write Stats\n");
754 " |-------------------------------------------|\n");
756 " | Same Network | Diff Network |\n");
758 " |----------|----------|----------|----------|\n");
760 " | Total | Auth | Total | Auth |\n");
762 " |----------|----------|----------|----------|\n");
763 fprintf(STDOUT, "Reads | %8d | %8d | %8d | %8d |\n",
764 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET],
765 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH],
766 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET],
767 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
768 fprintf(STDOUT, "Writes | %8d | %8d | %8d | %8d |\n",
769 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET],
770 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH],
771 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET],
772 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
774 " |-------------------------------------------|\n\n");
777 " Writes Affecting Authorship\n");
779 " |-------------------------------------------|\n");
781 " | File Authorship | Directory Authorship|\n");
783 " |----------|----------|----------|----------|\n");
785 " | Same | Diff | Same | Diff |\n");
787 " |----------|----------|----------|----------|\n");
788 fprintf(STDOUT, "0-60 sec | %8d | %8d | %8d | %8d |\n",
789 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_0],
790 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0],
791 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0],
792 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]);
793 fprintf(STDOUT, "1-10 min | %8d | %8d | %8d | %8d |\n",
794 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1],
795 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1],
796 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1],
797 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]);
798 fprintf(STDOUT, "10min-1hr | %8d | %8d | %8d | %8d |\n",
799 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_2],
800 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_2],
801 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_2],
802 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_2]);
803 fprintf(STDOUT, "1hr-1day | %8d | %8d | %8d | %8d |\n",
804 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_3],
805 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_3],
806 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_3],
807 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_3]);
808 fprintf(STDOUT, "1day-1wk | %8d | %8d | %8d | %8d |\n",
809 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_4],
810 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_4],
811 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_4],
812 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_4]);
813 fprintf(STDOUT, "> 1wk | %8d | %8d | %8d | %8d |\n",
814 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_5],
815 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5],
816 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5],
817 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]);
819 " |-------------------------------------------|\n");
820 } /*Volume status OK */
821 else if (a_xInfoP->status == VBUSY) {
823 qPut(&busyHead, a_xInfoP->volid);
825 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
826 (unsigned long)a_xInfoP->volid);
830 qPut(¬okHead, a_xInfoP->volid);
832 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
833 (unsigned long)a_xInfoP->volid);
834 } /*Screwed volume */
835 fprintf(STDOUT, "\n");
841 if (a_xInfoP->status == VOK) {
842 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
843 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
844 if (a_xInfoP->type == 0)
845 fprintf(STDOUT, "RW ");
846 if (a_xInfoP->type == 1)
847 fprintf(STDOUT, "RO ");
848 if (a_xInfoP->type == 2)
849 fprintf(STDOUT, "BK ");
850 fprintf(STDOUT, "%10d K ", a_xInfoP->size);
851 if (a_xInfoP->inUse == 1) {
852 fprintf(STDOUT, "On-line");
855 fprintf(STDOUT, "Off-line");
858 fprintf(STDOUT, "\n");
860 else if (a_xInfoP->status == VBUSY) {
862 qPut(&busyHead, a_xInfoP->volid);
864 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
865 (unsigned long)a_xInfoP->volid);
869 qPut(¬okHead, a_xInfoP->volid);
871 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
872 (unsigned long)a_xInfoP->volid);
873 } /*Screwed volume */
874 } /*Default listing */
875 } /*XDisplayFormat */
877 /*------------------------------------------------------------------------
878 * PRIVATE XDisplayFormat2
881 * Display the formated contents of one extended volume info structure.
884 * a_xInfoP : Ptr to extended volume info struct to print.
885 * a_servID : Server ID to print.
886 * a_partID : Partition ID to print.
887 * a_totalOKP : Ptr to total-OK counter.
888 * a_totalNotOKP : Ptr to total-screwed counter.
889 * a_totalBusyP : Ptr to total-busy counter.
890 * a_fast : Fast listing?
891 * a_int32 : Int32 listing?
892 * a_showProblems : Show volume problems?
898 * Nothing interesting.
902 *------------------------------------------------------------------------*/
905 XDisplayFormat2(volintXInfo *a_xInfoP, afs_uint32 a_servID, afs_int32 a_partID,
906 int *a_totalOKP, int *a_totalNotOKP, int *a_totalBusyP,
907 int a_fast, int a_int32, int a_showProblems)
908 { /*XDisplayFormat */
914 fprintf(STDOUT, "vold_id\t%-10lu\n", (unsigned long)a_xInfoP->volid);
915 } else if (a_int32) {
917 * Fully-detailed listing.
919 if (a_xInfoP->status == VOK) {
921 * Volume's status is OK - all the fields are valid.
924 static long server_cache = -1, partition_cache = -1;
925 static char hostname[256], address[32], pname[16];
926 int i,ai[] = {VOLINT_STATS_TIME_IDX_0,VOLINT_STATS_TIME_IDX_1,VOLINT_STATS_TIME_IDX_2,
927 VOLINT_STATS_TIME_IDX_3,VOLINT_STATS_TIME_IDX_4,VOLINT_STATS_TIME_IDX_5};
929 if (a_servID != server_cache) {
933 strcpy(hostname, hostutil_GetNameByINet(a_servID));
934 strcpy(address, inet_ntoa(s));
935 server_cache = a_servID;
937 if (a_partID != partition_cache) {
938 MapPartIdIntoName(a_partID, pname);
939 partition_cache = a_partID;
942 fprintf(STDOUT, "name\t\t%s\n", a_xInfoP->name);
943 fprintf(STDOUT, "id\t\t%lu\n", afs_printable_uint32_lu(a_xInfoP->volid));
944 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
945 fprintf(STDOUT, "part\t\t%s\n", pname);
946 fprintf(STDOUT, "status\t\tOK\n");
947 fprintf(STDOUT, "backupID\t%lu\n",
948 afs_printable_uint32_lu(a_xInfoP->backupID));
949 fprintf(STDOUT, "parentID\t%lu\n",
950 afs_printable_uint32_lu(a_xInfoP->parentID));
951 fprintf(STDOUT, "cloneID\t\t%lu\n",
952 afs_printable_uint32_lu(a_xInfoP->cloneID));
953 fprintf(STDOUT, "inUse\t\t%s\n", a_xInfoP->inUse ? "Y" : "N");
954 switch (a_xInfoP->type) {
956 fprintf(STDOUT, "type\t\tRW\n");
959 fprintf(STDOUT, "type\t\tRO\n");
962 fprintf(STDOUT, "type\t\tBK\n");
965 fprintf(STDOUT, "type\t\t?\n");
968 t = a_xInfoP->creationDate;
969 fprintf(STDOUT, "creationDate\t%-9lu\t%s",
970 afs_printable_uint32_lu(a_xInfoP->creationDate),
973 t = a_xInfoP->accessDate;
974 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
975 afs_printable_uint32_lu(a_xInfoP->accessDate),
978 t = a_xInfoP->updateDate;
979 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
980 afs_printable_uint32_lu(a_xInfoP->updateDate),
983 t = a_xInfoP->backupDate;
984 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
985 afs_printable_uint32_lu(a_xInfoP->backupDate),
988 t = a_xInfoP->copyDate;
989 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
990 afs_printable_uint32_lu(a_xInfoP->copyDate),
993 fprintf(STDOUT, "diskused\t%u\n", a_xInfoP->size);
994 fprintf(STDOUT, "maxquota\t%u\n", a_xInfoP->maxquota);
996 fprintf(STDOUT, "filecount\t%u\n", a_xInfoP->filecount);
997 fprintf(STDOUT, "dayUse\t\t%u\n", a_xInfoP->dayUse);
1001 fprintf(STDOUT,"reads_same_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET]);
1002 fprintf(STDOUT,"reads_same_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH]);
1003 fprintf(STDOUT,"reads_diff_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET]);
1004 fprintf(STDOUT,"reads_diff_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
1006 fprintf(STDOUT,"writes_same_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET]);
1007 fprintf(STDOUT,"writes_same_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH]);
1008 fprintf(STDOUT,"writes_diff_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET]);
1009 fprintf(STDOUT,"writes_diff_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
1013 fprintf(STDOUT,"file_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileSameAuthor[ai[i]]);
1014 fprintf(STDOUT,"file_diff_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileDiffAuthor[ai[i]]);
1015 fprintf(STDOUT,"dir_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirSameAuthor[ai[i]]);
1016 fprintf(STDOUT,"dir_dif_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirDiffAuthor[ai[i]]);
1019 } /*Volume status OK */
1020 else if (a_xInfoP->status == VBUSY) {
1022 qPut(&busyHead, a_xInfoP->volid);
1024 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
1025 (unsigned long)a_xInfoP->volid);
1029 qPut(¬okHead, a_xInfoP->volid);
1031 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
1032 (unsigned long)a_xInfoP->volid);
1033 } /*Screwed volume */
1039 if (a_xInfoP->status == VOK) {
1040 fprintf(STDOUT, "name\t%-32s\n", a_xInfoP->name);
1041 fprintf(STDOUT, "volID\t%10lu\n", (unsigned long)a_xInfoP->volid);
1042 if (a_xInfoP->type == 0)
1043 fprintf(STDOUT, "type\tRW\n");
1044 if (a_xInfoP->type == 1)
1045 fprintf(STDOUT, "type\tRO\n");
1046 if (a_xInfoP->type == 2)
1047 fprintf(STDOUT, "type\tBK\n");
1048 fprintf(STDOUT, "size\t%10dK\n", a_xInfoP->size);
1050 fprintf(STDOUT, "inUse\t%d\n",a_xInfoP->inUse);
1051 if (a_xInfoP->inUse == 1)
1057 else if (a_xInfoP->status == VBUSY) {
1059 qPut(&busyHead, a_xInfoP->volid);
1061 fprintf(STDOUT, "VOLUME_BUSY\t%lu\n",
1062 (unsigned long)a_xInfoP->volid);
1066 qPut(¬okHead, a_xInfoP->volid);
1068 fprintf(STDOUT, "COULD_NOT_ATTACH_VOLUME\t%lu\n",
1069 (unsigned long)a_xInfoP->volid);
1070 } /*Screwed volume */
1071 } /*Default listing */
1072 } /*XDisplayFormat */
1075 DisplayFormat2(long server, long partition, volintInfo *pntr)
1077 static long server_cache = -1, partition_cache = -1;
1078 static char hostname[256], address[32], pname[16];
1081 if (server != server_cache) {
1085 strcpy(hostname, hostutil_GetNameByINet(server));
1086 strcpy(address, inet_ntoa(s));
1087 server_cache = server;
1089 if (partition != partition_cache) {
1090 MapPartIdIntoName(partition, pname);
1091 partition_cache = partition;
1094 if (pntr->status == VOK)
1095 fprintf(STDOUT, "name\t\t%s\n", pntr->name);
1097 fprintf(STDOUT, "id\t\t%lu\n",
1098 afs_printable_uint32_lu(pntr->volid));
1099 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
1100 fprintf(STDOUT, "part\t\t%s\n", pname);
1101 switch (pntr->status) {
1103 fprintf(STDOUT, "status\t\tOK\n");
1106 fprintf(STDOUT, "status\t\tBUSY\n");
1109 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
1112 fprintf(STDOUT, "backupID\t%lu\n",
1113 afs_printable_uint32_lu(pntr->backupID));
1114 fprintf(STDOUT, "parentID\t%lu\n",
1115 afs_printable_uint32_lu(pntr->parentID));
1116 fprintf(STDOUT, "cloneID\t\t%lu\n",
1117 afs_printable_uint32_lu(pntr->cloneID));
1118 fprintf(STDOUT, "inUse\t\t%s\n", pntr->inUse ? "Y" : "N");
1119 fprintf(STDOUT, "needsSalvaged\t%s\n", pntr->needsSalvaged ? "Y" : "N");
1120 /* 0xD3 is from afs/volume.h since I had trouble including the file */
1121 fprintf(STDOUT, "destroyMe\t%s\n", pntr->destroyMe == 0xD3 ? "Y" : "N");
1122 switch (pntr->type) {
1124 fprintf(STDOUT, "type\t\tRW\n");
1127 fprintf(STDOUT, "type\t\tRO\n");
1130 fprintf(STDOUT, "type\t\tBK\n");
1133 fprintf(STDOUT, "type\t\t?\n");
1136 t = pntr->creationDate;
1137 fprintf(STDOUT, "creationDate\t%-9lu\t%s",
1138 afs_printable_uint32_lu(pntr->creationDate),
1141 t = pntr->accessDate;
1142 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
1143 afs_printable_uint32_lu(pntr->accessDate),
1146 t = pntr->updateDate;
1147 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
1148 afs_printable_uint32_lu(pntr->updateDate),
1151 t = pntr->backupDate;
1152 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
1153 afs_printable_uint32_lu(pntr->backupDate),
1157 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
1158 afs_printable_uint32_lu(pntr->copyDate),
1161 fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n",
1162 afs_printable_uint32_lu(pntr->flags));
1163 fprintf(STDOUT, "diskused\t%u\n", pntr->size);
1164 fprintf(STDOUT, "maxquota\t%u\n", pntr->maxquota);
1165 fprintf(STDOUT, "minquota\t%lu\t(Optional)\n",
1166 afs_printable_uint32_lu(pntr->spare0));
1167 fprintf(STDOUT, "filecount\t%u\n", pntr->filecount);
1168 fprintf(STDOUT, "dayUse\t\t%u\n", pntr->dayUse);
1169 fprintf(STDOUT, "weekUse\t\t%lu\t(Optional)\n",
1170 afs_printable_uint32_lu(pntr->spare1));
1171 fprintf(STDOUT, "spare2\t\t%lu\t(Optional)\n",
1172 afs_printable_uint32_lu(pntr->spare2));
1173 fprintf(STDOUT, "spare3\t\t%lu\t(Optional)\n",
1174 afs_printable_uint32_lu(pntr->spare3));
1179 DisplayVolumes2(long server, long partition, volintInfo *pntr, long count)
1183 for (i = 0; i < count; i++) {
1184 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1185 DisplayFormat2(server, partition, pntr);
1186 fprintf(STDOUT, "END_OF_ENTRY\n\n");
1193 DisplayVolumes(afs_uint32 server, afs_int32 part, volintInfo *pntr,
1194 afs_int32 count, afs_int32 longlist, afs_int32 fast,
1197 int totalOK, totalNotOK, totalBusy, i;
1198 afs_uint32 volid = 0;
1205 for (i = 0; i < count; i++) {
1206 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy,
1211 while (busyHead.count) {
1212 qGet(&busyHead, &volid);
1213 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1214 (unsigned long)volid);
1218 while (notokHead.count) {
1219 qGet(¬okHead, &volid);
1220 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1221 (unsigned long)volid);
1225 fprintf(STDOUT, "\n");
1228 "Total volumes onLine %d ; Total volumes offLine %d ; Total busy %d\n\n",
1229 totalOK, totalNotOK, totalBusy);
1233 /*------------------------------------------------------------------------
1234 * PRIVATE XDisplayVolumes
1237 * Display extended volume information.
1240 * a_servID : Pointer to the Rx call we're performing.
1241 * a_partID : Partition for which we want the extended list.
1242 * a_xInfoP : Ptr to extended volume info.
1243 * a_count : Number of volume records contained above.
1244 * a_int32 : Int32 listing generated?
1245 * a_fast : Fast listing generated?
1246 * a_quiet : Quiet listing generated?
1252 * Nothing interesting.
1256 *------------------------------------------------------------------------*/
1259 XDisplayVolumes(afs_uint32 a_servID, afs_int32 a_partID, volintXInfo *a_xInfoP,
1260 afs_int32 a_count, afs_int32 a_int32, afs_int32 a_fast,
1262 { /*XDisplayVolumes */
1264 int totalOK; /*Total OK volumes */
1265 int totalNotOK; /*Total screwed volumes */
1266 int totalBusy; /*Total busy volumes */
1267 int i; /*Loop variable */
1268 afs_uint32 volid = 0; /*Current volume ID */
1271 * Initialize counters and (global!!) queues.
1280 * Display each volume in the list.
1282 for (i = 0; i < a_count; i++) {
1283 XDisplayFormat(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1284 &totalBusy, a_fast, a_int32, 0);
1289 * If any volumes were found to be busy or screwed, display them.
1292 while (busyHead.count) {
1293 qGet(&busyHead, &volid);
1294 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1295 (unsigned long)volid);
1299 while (notokHead.count) {
1300 qGet(¬okHead, &volid);
1301 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1302 (unsigned long)volid);
1307 fprintf(STDOUT, "\n");
1310 "Total volumes: %d on-line, %d off-line, %d busyd\n\n",
1311 totalOK, totalNotOK, totalBusy);
1315 } /*XDisplayVolumes */
1317 /*------------------------------------------------------------------------
1318 * PRIVATE XDisplayVolumes2
1321 * Display extended formated volume information.
1324 * a_servID : Pointer to the Rx call we're performing.
1325 * a_partID : Partition for which we want the extended list.
1326 * a_xInfoP : Ptr to extended volume info.
1327 * a_count : Number of volume records contained above.
1328 * a_int32 : Int32 listing generated?
1329 * a_fast : Fast listing generated?
1330 * a_quiet : Quiet listing generated?
1336 * Nothing interesting.
1340 *------------------------------------------------------------------------*/
1343 XDisplayVolumes2(afs_uint32 a_servID, afs_int32 a_partID, volintXInfo *a_xInfoP,
1344 afs_int32 a_count, afs_int32 a_int32, afs_int32 a_fast,
1346 { /*XDisplayVolumes */
1348 int totalOK; /*Total OK volumes */
1349 int totalNotOK; /*Total screwed volumes */
1350 int totalBusy; /*Total busy volumes */
1351 int i; /*Loop variable */
1352 afs_uint32 volid = 0; /*Current volume ID */
1355 * Initialize counters and (global!!) queues.
1364 * Display each volume in the list.
1366 for (i = 0; i < a_count; i++) {
1367 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1368 XDisplayFormat2(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1369 &totalBusy, a_fast, a_int32, 0);
1370 fprintf(STDOUT, "END_OF_ENTRY\n");
1375 * If any volumes were found to be busy or screwed, display them.
1378 while (busyHead.count) {
1379 qGet(&busyHead, &volid);
1380 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
1381 (unsigned long)volid);
1385 while (notokHead.count) {
1386 qGet(¬okHead, &volid);
1387 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
1388 (unsigned long)volid);
1393 fprintf(STDOUT, "\n");
1396 "VOLUMES_ONLINE\t%d\nVOLUMES_OFFLINE\t%d\nVOLUMES_BUSY\t%d\n",
1397 totalOK, totalNotOK, totalBusy);
1401 } /*XDisplayVolumes2 */
1404 /* set <server> and <part> to the correct values depending on
1405 * <voltype> and <entry> */
1407 GetServerAndPart(struct nvldbentry *entry, int voltype, afs_uint32 *server,
1408 afs_int32 *part, int *previdx)
1410 int i, istart, vtype;
1415 /* Doesn't check for non-existance of backup volume */
1416 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
1418 istart = 0; /* seach the entire entry */
1421 /* Seach from beginning of entry or pick up where we left off */
1422 istart = ((*previdx < 0) ? 0 : *previdx + 1);
1425 for (i = istart; i < entry->nServers; i++) {
1426 if (entry->serverFlags[i] & vtype) {
1427 *server = entry->serverNumber[i];
1428 *part = entry->serverPartition[i];
1434 /* Didn't find any, return -1 */
1440 PrintLocked(afs_int32 aflags)
1442 afs_int32 flags = aflags & VLOP_ALLOPERS;
1445 fprintf(STDOUT, " Volume is currently LOCKED \n");
1447 if (flags & VLOP_MOVE) {
1448 fprintf(STDOUT, " Volume is locked for a move operation\n");
1450 if (flags & VLOP_RELEASE) {
1451 fprintf(STDOUT, " Volume is locked for a release operation\n");
1453 if (flags & VLOP_BACKUP) {
1454 fprintf(STDOUT, " Volume is locked for a backup operation\n");
1456 if (flags & VLOP_DELETE) {
1457 fprintf(STDOUT, " Volume is locked for a delete/misc operation\n");
1459 if (flags & VLOP_DUMP) {
1460 fprintf(STDOUT, " Volume is locked for a dump/restore operation\n");
1466 PostVolumeStats(struct nvldbentry *entry)
1468 SubEnumerateEntry(entry);
1469 /* Check for VLOP_ALLOPERS */
1470 PrintLocked(entry->flags);
1474 /*------------------------------------------------------------------------
1475 * PRIVATE XVolumeStats
1478 * Display extended volume information.
1481 * a_xInfoP : Ptr to extended volume info.
1482 * a_entryP : Ptr to the volume's VLDB entry.
1483 * a_srvID : Server ID.
1484 * a_partID : Partition ID.
1485 * a_volType : Type of volume to print.
1491 * Nothing interesting.
1495 *------------------------------------------------------------------------*/
1498 XVolumeStats(volintXInfo *a_xInfoP, struct nvldbentry *a_entryP,
1499 afs_int32 a_srvID, afs_int32 a_partID, int a_volType)
1502 int totalOK, totalNotOK, totalBusy; /*Dummies - we don't really count here */
1504 XDisplayFormat(a_xInfoP, /*Ptr to extended volume info */
1505 a_srvID, /*Server ID to print */
1506 a_partID, /*Partition ID to print */
1507 &totalOK, /*Ptr to total-OK counter */
1508 &totalNotOK, /*Ptr to total-screwed counter */
1509 &totalBusy, /*Ptr to total-busy counter */
1510 0, /*Don't do a fast listing */
1511 1, /*Do a long listing */
1512 1); /*Show volume problems */
1518 VolumeStats_int(volintInfo *pntr, struct nvldbentry *entry, afs_uint32 server,
1519 afs_int32 part, int voltype)
1525 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy, 0, 1,
1530 /* command to forcibly remove a volume */
1532 NukeVolume(struct cmd_syndesc *as)
1541 server = GetServer(tp = as->parms[0].items->data);
1543 fprintf(STDERR, "vos: server '%s' not found in host table\n", tp);
1547 partID = volutil_GetPartitionID(tp = as->parms[1].items->data);
1549 fprintf(STDERR, "vos: could not parse '%s' as a partition name", tp);
1553 volID = vsu_GetVolumeID(tp = as->parms[2].items->data, cstruct, &err);
1556 PrintError("", err);
1559 "vos: could not parse '%s' as a numeric volume ID", tp);
1564 "vos: forcibly removing all traces of volume %d, please wait...",
1567 code = UV_NukeVolume(server, partID, volID);
1569 fprintf(STDOUT, "done.\n");
1571 fprintf(STDOUT, "failed with code %d.\n", code);
1576 /*------------------------------------------------------------------------
1577 * PRIVATE ExamineVolume
1580 * Routine used to examine a single volume, contacting the VLDB as
1581 * well as the Volume Server.
1584 * as : Ptr to parsed command line arguments.
1587 * 0 for a successful operation,
1588 * Otherwise, one of the ubik or VolServer error values.
1591 * Nothing interesting.
1595 *------------------------------------------------------------------------
1598 ExamineVolume(struct cmd_syndesc *as, void *arock)
1600 struct nvldbentry entry;
1601 afs_int32 vcode = 0;
1602 volintInfo *pntr = (volintInfo *) 0;
1603 volintXInfo *xInfoP = (volintXInfo *) 0;
1605 afs_int32 code, err, error = 0;
1606 int voltype, foundserv = 0, foundentry = 0;
1610 int wantExtendedInfo; /*Do we want extended vol info? */
1611 int isSubEnum=0; /* Keep track whether sub enumerate called. */
1612 wantExtendedInfo = (as->parms[1].items ? 1 : 0); /* -extended */
1614 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1617 PrintError("", err);
1619 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1620 as->parms[0].items->data);
1625 fprintf(STDOUT, "Fetching VLDB entry for %lu .. ",
1626 (unsigned long)volid);
1629 vcode = VLDB_GetEntryByID(volid, -1, &entry);
1632 "Could not fetch the entry for volume number %lu from VLDB \n",
1633 (unsigned long)volid);
1637 fprintf(STDOUT, "done\n");
1638 MapHostToNetwork(&entry);
1640 if (entry.volumeId[RWVOL] == volid)
1642 else if (entry.volumeId[BACKVOL] == volid)
1644 else /* (entry.volumeId[ROVOL] == volid) */
1647 do { /* do {...} while (voltype == ROVOL) */
1648 /* Get the entry for the volume. If its a RW vol, get the RW entry.
1649 * It its a BK vol, get the RW entry (even if VLDB may say the BK doen't exist).
1650 * If its a RO vol, get the next RO entry.
1652 GetServerAndPart(&entry, ((voltype == ROVOL) ? ROVOL : RWVOL),
1653 &aserver, &apart, &previdx);
1654 if (previdx == -1) { /* searched all entries */
1656 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1657 as->parms[0].items->data);
1664 /* Get information about the volume from the server */
1666 fprintf(STDOUT, "Getting volume listing from the server %s .. ",
1667 hostutil_GetNameByINet(aserver));
1670 if (wantExtendedInfo)
1671 code = UV_XListOneVolume(aserver, apart, volid, &xInfoP);
1673 code = UV_ListOneVolume(aserver, apart, volid, &pntr);
1675 fprintf(STDOUT, "done\n");
1679 if (code == ENODEV) {
1680 if ((voltype == BACKVOL) && !(entry.flags & VLF_BACKEXISTS)) {
1681 /* The VLDB says there is no backup volume and its not on disk */
1682 fprintf(STDERR, "Volume %s does not exist\n",
1683 as->parms[0].items->data);
1687 "Volume does not exist on server %s as indicated by the VLDB\n",
1688 hostutil_GetNameByINet(aserver));
1691 PrintDiagnostics("examine", code);
1693 fprintf(STDOUT, "\n");
1696 if (wantExtendedInfo)
1697 XVolumeStats(xInfoP, &entry, aserver, apart, voltype);
1698 else if (as->parms[2].items) {
1699 DisplayFormat2(aserver, apart, pntr);
1700 EnumerateEntry(&entry);
1703 VolumeStats_int(pntr, &entry, aserver, apart, voltype);
1705 if ((voltype == BACKVOL) && !(entry.flags & VLF_BACKEXISTS)) {
1706 /* The VLDB says there is no backup volume yet we found one on disk */
1707 fprintf(STDERR, "Volume %s does not exist in VLDB\n",
1708 as->parms[0].items->data);
1717 } while (voltype == ROVOL);
1720 fprintf(STDERR, "Dump only information from VLDB\n\n");
1721 fprintf(STDOUT, "%s \n", entry.name); /* PostVolumeStats doesn't print name */
1725 PostVolumeStats(&entry);
1730 /*------------------------------------------------------------------------
1734 * Routine used to change the status of a single volume.
1737 * as : Ptr to parsed command line arguments.
1740 * 0 for a successful operation,
1741 * Otherwise, one of the ubik or VolServer error values.
1744 * Nothing interesting.
1748 *------------------------------------------------------------------------
1751 SetFields(struct cmd_syndesc *as, void *arock)
1753 struct nvldbentry entry;
1756 afs_int32 code, err;
1762 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1765 PrintError("", err);
1767 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1768 as->parms[0].items->data);
1772 code = VLDB_GetEntryByID(volid, RWVOL, &entry);
1775 "Could not fetch the entry for volume number %lu from VLDB \n",
1776 (unsigned long)volid);
1779 MapHostToNetwork(&entry);
1781 GetServerAndPart(&entry, RWVOL, &aserver, &apart, &previdx);
1782 if (previdx == -1) {
1783 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1784 as->parms[0].items->data);
1788 init_volintInfo(&info);
1792 if (as->parms[1].items) {
1795 code = util_GetHumanInt32(as->parms[1].items->data, &info.maxquota);
1797 fprintf(STDERR, "invalid quota value\n");
1801 if (as->parms[2].items) {
1806 if (as->parms[3].items) {
1807 /* -clearVolUpCounter */
1812 fprintf(STDERR,"Nothing to set.\n");
1815 code = UV_SetVolumeInfo(aserver, apart, volid, &info);
1818 "Could not update volume info fields for volume number %lu\n",
1819 (unsigned long)volid);
1823 /*------------------------------------------------------------------------
1827 * Brings a volume online.
1830 * as : Ptr to parsed command line arguments.
1833 * 0 for a successful operation,
1836 * Nothing interesting.
1840 *------------------------------------------------------------------------
1843 volOnline(struct cmd_syndesc *as, void *arock)
1846 afs_int32 partition;
1848 afs_int32 code, err = 0;
1850 server = GetServer(as->parms[0].items->data);
1852 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1853 as->parms[0].items->data);
1857 partition = volutil_GetPartitionID(as->parms[1].items->data);
1858 if (partition < 0) {
1859 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1860 as->parms[1].items->data);
1864 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1867 PrintError("", err);
1869 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1870 as->parms[0].items->data);
1874 code = UV_SetVolume(server, partition, volid, ITOffline, 0 /*online */ ,
1877 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1884 /*------------------------------------------------------------------------
1885 * PRIVATE volOffline
1888 * Brings a volume offline.
1891 * as : Ptr to parsed command line arguments.
1894 * 0 for a successful operation,
1897 * Nothing interesting.
1901 *------------------------------------------------------------------------
1904 volOffline(struct cmd_syndesc *as, void *arock)
1907 afs_int32 partition;
1909 afs_int32 code, err = 0;
1910 afs_int32 transflag, sleeptime, transdone;
1912 server = GetServer(as->parms[0].items->data);
1914 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1915 as->parms[0].items->data);
1919 partition = volutil_GetPartitionID(as->parms[1].items->data);
1920 if (partition < 0) {
1921 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1922 as->parms[1].items->data);
1926 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1929 PrintError("", err);
1931 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1932 as->parms[0].items->data);
1936 transflag = (as->parms[4].items ? ITBusy : ITOffline);
1937 sleeptime = (as->parms[3].items ? atol(as->parms[3].items->data) : 0);
1938 transdone = ((sleeptime || as->parms[4].items) ? 0 /*online */ : VTOutOfService);
1939 if (as->parms[4].items && !as->parms[3].items) {
1940 fprintf(STDERR, "-sleep option must be used with -busy flag\n");
1945 UV_SetVolume(server, partition, volid, transflag, transdone,
1948 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1956 CreateVolume(struct cmd_syndesc *as, void *arock)
1960 afs_uint32 volid = 0, rovolid = 0, bkvolid = 0;
1961 afs_uint32 *arovolid;
1963 struct nvldbentry entry;
1968 arovolid = &rovolid;
1971 tserver = GetServer(as->parms[0].items->data);
1973 fprintf(STDERR, "vos: host '%s' not found in host table\n",
1974 as->parms[0].items->data);
1977 pnum = volutil_GetPartitionID(as->parms[1].items->data);
1979 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1980 as->parms[1].items->data);
1983 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
1985 PrintError("", code);
1988 "vos : partition %s does not exist on the server\n",
1989 as->parms[1].items->data);
1992 if (!ISNAMEVALID(as->parms[2].items->data)) {
1994 "vos: the name of the root volume %s exceeds the size limit of %d\n",
1995 as->parms[2].items->data, VOLSER_OLDMAXVOLNAME - 10);
1998 if (!VolNameOK(as->parms[2].items->data)) {
2000 "Illegal volume name %s, should not end in .readonly or .backup\n",
2001 as->parms[2].items->data);
2004 if (IsNumeric(as->parms[2].items->data)) {
2005 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
2006 as->parms[2].items->data);
2009 vcode = VLDB_GetEntryByName(as->parms[2].items->data, &entry);
2011 fprintf(STDERR, "Volume %s already exists\n",
2012 as->parms[2].items->data);
2013 PrintDiagnostics("create", code);
2017 if (as->parms[3].items) {
2018 code = util_GetHumanInt32(as->parms[3].items->data, "a);
2020 fprintf(STDERR, "vos: bad integer specified for quota.\n");
2025 if (as->parms[4].items) {
2026 if (!IsNumeric(as->parms[4].items->data)) {
2027 fprintf(STDERR, "vos: Given volume ID %s should be numeric.\n",
2028 as->parms[4].items->data);
2032 code = util_GetUInt32(as->parms[4].items->data, &volid);
2034 fprintf(STDERR, "vos: bad integer specified for volume ID.\n");
2039 if (as->parms[5].items) {
2040 if (!IsNumeric(as->parms[5].items->data)) {
2041 fprintf(STDERR, "vos: Given RO volume ID %s should be numeric.\n",
2042 as->parms[5].items->data);
2046 code = util_GetUInt32(as->parms[5].items->data, &rovolid);
2048 fprintf(STDERR, "vos: bad integer specified for volume ID.\n");
2058 UV_CreateVolume3(tserver, pnum, as->parms[2].items->data, quota, 0,
2059 0, 0, 0, &volid, arovolid, &bkvolid);
2061 PrintDiagnostics("create", code);
2064 MapPartIdIntoName(pnum, part);
2065 fprintf(STDOUT, "Volume %lu created on partition %s of %s\n",
2066 (unsigned long)volid, part, as->parms[0].items->data);
2073 DeleteAll(struct nvldbentry *entry)
2076 afs_int32 error, code, curserver, curpart;
2079 MapHostToNetwork(entry);
2081 for (i = 0; i < entry->nServers; i++) {
2082 curserver = entry->serverNumber[i];
2083 curpart = entry->serverPartition[i];
2084 if (entry->serverFlags[i] & VLSF_ROVOL) {
2085 volid = entry->volumeId[ROVOL];
2087 volid = entry->volumeId[RWVOL];
2089 code = UV_DeleteVolume(curserver, curpart, volid);
2098 DeleteVolume(struct cmd_syndesc *as, void *arock)
2100 afs_int32 err, code = 0;
2101 afs_uint32 server = 0;
2102 afs_int32 partition = -1;
2107 if (as->parms[0].items) {
2108 server = GetServer(as->parms[0].items->data);
2110 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2111 as->parms[0].items->data);
2116 if (as->parms[1].items) {
2117 partition = volutil_GetPartitionID(as->parms[1].items->data);
2118 if (partition < 0) {
2119 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2120 as->parms[1].items->data);
2124 /* Check for validity of the partition */
2125 if (!IsPartValid(partition, server, &code)) {
2127 PrintError("", code);
2130 "vos : partition %s does not exist on the server\n",
2131 as->parms[1].items->data);
2137 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
2139 fprintf(STDERR, "Can't find volume name '%s' in VLDB\n",
2140 as->parms[2].items->data);
2142 PrintError("", err);
2146 /* If the server or partition option are not complete, try to fill
2147 * them in from the VLDB entry.
2149 if ((partition == -1) || !server) {
2150 struct nvldbentry entry;
2152 code = VLDB_GetEntryByID(volid, -1, &entry);
2155 "Could not fetch the entry for volume %lu from VLDB\n",
2156 (unsigned long)volid);
2157 PrintError("", code);
2161 if (((volid == entry.volumeId[RWVOL]) && (entry.flags & VLF_RWEXISTS))
2162 || ((volid == entry.volumeId[BACKVOL])
2163 && (entry.flags & VLF_BACKEXISTS))) {
2164 idx = Lp_GetRwIndex(&entry);
2165 if ((idx == -1) || (server && (server != entry.serverNumber[idx]))
2166 || ((partition != -1)
2167 && (partition != entry.serverPartition[idx]))) {
2168 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2169 as->parms[2].items->data);
2172 } else if ((volid == entry.volumeId[ROVOL])
2173 && (entry.flags & VLF_ROEXISTS)) {
2174 for (idx = -1, j = 0; j < entry.nServers; j++) {
2175 if (!(entry.serverFlags[j] & VLSF_ROVOL))
2178 if (((server == 0) || (server == entry.serverNumber[j]))
2179 && ((partition == -1)
2180 || (partition == entry.serverPartition[j]))) {
2183 "VLDB: Volume '%s' matches more than one RO\n",
2184 as->parms[2].items->data);
2191 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2192 as->parms[2].items->data);
2196 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2197 as->parms[2].items->data);
2201 server = htonl(entry.serverNumber[idx]);
2202 partition = entry.serverPartition[idx];
2206 code = UV_DeleteVolume(server, partition, volid);
2208 PrintDiagnostics("remove", code);
2212 MapPartIdIntoName(partition, pname);
2213 fprintf(STDOUT, "Volume %lu on partition %s server %s deleted\n",
2214 (unsigned long)volid, pname, hostutil_GetNameByINet(server));
2218 #define TESTM 0 /* set for move space tests, clear for production */
2220 MoveVolume(struct cmd_syndesc *as, void *arock)
2224 afs_uint32 fromserver, toserver;
2225 afs_int32 frompart, topart;
2226 afs_int32 flags, code, err;
2227 char fromPartName[10], toPartName[10];
2229 struct diskPartition64 partition; /* for space check */
2232 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2235 PrintError("", err);
2237 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2238 as->parms[0].items->data);
2241 fromserver = GetServer(as->parms[1].items->data);
2242 if (fromserver == 0) {
2243 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2244 as->parms[1].items->data);
2247 toserver = GetServer(as->parms[3].items->data);
2248 if (toserver == 0) {
2249 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2250 as->parms[3].items->data);
2253 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2255 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2256 as->parms[2].items->data);
2259 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2261 PrintError("", code);
2264 "vos : partition %s does not exist on the server\n",
2265 as->parms[2].items->data);
2268 topart = volutil_GetPartitionID(as->parms[4].items->data);
2270 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2271 as->parms[4].items->data);
2274 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2276 PrintError("", code);
2279 "vos : partition %s does not exist on the server\n",
2280 as->parms[4].items->data);
2285 if (as->parms[5].items) flags |= RV_NOCLONE;
2288 * check source partition for space to clone volume
2291 MapPartIdIntoName(topart, toPartName);
2292 MapPartIdIntoName(frompart, fromPartName);
2295 * check target partition for space to move volume
2298 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2300 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2304 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2307 p = (volintInfo *) 0;
2308 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2310 fprintf(STDERR, "vos:cannot access volume %lu\n",
2311 (unsigned long)volid);
2315 fprintf(STDOUT, "volume %lu size %d\n", (unsigned long)volid,
2317 if (partition.free <= p->size) {
2319 "vos: no space on target partition %s to move volume %lu\n",
2320 toPartName, (unsigned long)volid);
2327 fprintf(STDOUT, "size test - don't do move\n");
2331 /* successful move still not guaranteed but shoot for it */
2334 UV_MoveVolume2(volid, fromserver, frompart, toserver, topart, flags);
2336 PrintDiagnostics("move", code);
2339 MapPartIdIntoName(topart, toPartName);
2340 MapPartIdIntoName(frompart, fromPartName);
2341 fprintf(STDOUT, "Volume %lu moved from %s %s to %s %s \n",
2342 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2343 as->parms[3].items->data, toPartName);
2349 CopyVolume(struct cmd_syndesc *as, void *arock)
2352 afs_uint32 fromserver, toserver;
2353 afs_int32 frompart, topart, code, err, flags;
2354 char fromPartName[10], toPartName[10], *tovolume;
2355 struct nvldbentry entry;
2356 struct diskPartition64 partition; /* for space check */
2359 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2362 PrintError("", err);
2364 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2365 as->parms[0].items->data);
2368 fromserver = GetServer(as->parms[1].items->data);
2369 if (fromserver == 0) {
2370 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2371 as->parms[1].items->data);
2375 toserver = GetServer(as->parms[4].items->data);
2376 if (toserver == 0) {
2377 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2378 as->parms[4].items->data);
2382 tovolume = as->parms[3].items->data;
2383 if (!ISNAMEVALID(tovolume)) {
2385 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2386 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2389 if (!VolNameOK(tovolume)) {
2391 "Illegal volume name %s, should not end in .readonly or .backup\n",
2395 if (IsNumeric(tovolume)) {
2396 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
2400 code = VLDB_GetEntryByName(tovolume, &entry);
2402 fprintf(STDERR, "Volume %s already exists\n", tovolume);
2403 PrintDiagnostics("copy", code);
2407 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2409 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2410 as->parms[2].items->data);
2413 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2415 PrintError("", code);
2418 "vos : partition %s does not exist on the server\n",
2419 as->parms[2].items->data);
2423 topart = volutil_GetPartitionID(as->parms[5].items->data);
2425 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2426 as->parms[5].items->data);
2429 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2431 PrintError("", code);
2434 "vos : partition %s does not exist on the server\n",
2435 as->parms[5].items->data);
2440 if (as->parms[6].items) flags |= RV_OFFLINE;
2441 if (as->parms[7].items) flags |= RV_RDONLY;
2442 if (as->parms[8].items) flags |= RV_NOCLONE;
2444 MapPartIdIntoName(topart, toPartName);
2445 MapPartIdIntoName(frompart, fromPartName);
2448 * check target partition for space to move volume
2451 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2453 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2457 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2460 p = (volintInfo *) 0;
2461 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2463 fprintf(STDERR, "vos:cannot access volume %lu\n",
2464 (unsigned long)volid);
2468 if (partition.free <= p->size) {
2470 "vos: no space on target partition %s to copy volume %lu\n",
2471 toPartName, (unsigned long)volid);
2477 /* successful copy still not guaranteed but shoot for it */
2480 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2483 PrintDiagnostics("copy", code);
2486 MapPartIdIntoName(topart, toPartName);
2487 MapPartIdIntoName(frompart, fromPartName);
2488 fprintf(STDOUT, "Volume %lu copied from %s %s to %s on %s %s \n",
2489 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2490 tovolume, as->parms[4].items->data, toPartName);
2497 ShadowVolume(struct cmd_syndesc *as, void *arock)
2499 afs_uint32 volid, tovolid;
2500 afs_uint32 fromserver, toserver;
2501 afs_int32 frompart, topart;
2502 afs_int32 code, err, flags;
2503 char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
2504 struct diskPartition64 partition; /* for space check */
2507 p = (volintInfo *) 0;
2508 q = (volintInfo *) 0;
2510 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2513 PrintError("", err);
2515 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2516 as->parms[0].items->data);
2519 fromserver = GetServer(as->parms[1].items->data);
2520 if (fromserver == 0) {
2521 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2522 as->parms[1].items->data);
2526 toserver = GetServer(as->parms[3].items->data);
2527 if (toserver == 0) {
2528 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2529 as->parms[3].items->data);
2533 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2535 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2536 as->parms[2].items->data);
2539 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2541 PrintError("", code);
2544 "vos : partition %s does not exist on the server\n",
2545 as->parms[2].items->data);
2549 topart = volutil_GetPartitionID(as->parms[4].items->data);
2551 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2552 as->parms[4].items->data);
2555 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2557 PrintError("", code);
2560 "vos : partition %s does not exist on the server\n",
2561 as->parms[4].items->data);
2565 if (as->parms[5].items) {
2566 tovolume = as->parms[5].items->data;
2567 if (!ISNAMEVALID(tovolume)) {
2569 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2570 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2573 if (!VolNameOK(tovolume)) {
2575 "Illegal volume name %s, should not end in .readonly or .backup\n",
2579 if (IsNumeric(tovolume)) {
2581 "Illegal volume name %s, should not be a number\n",
2586 /* use actual name of source volume */
2587 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2589 fprintf(STDERR, "vos:cannot access volume %lu\n",
2590 (unsigned long)volid);
2593 strcpy(toVolName, p->name);
2594 tovolume = toVolName;
2595 /* save p for size checks later */
2598 if (as->parms[6].items) {
2599 tovolid = vsu_GetVolumeID(as->parms[6].items->data, cstruct, &err);
2602 PrintError("", err);
2604 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2605 as->parms[6].items->data);
2611 tovolid = vsu_GetVolumeID(tovolume, cstruct, &err);
2614 PrintError("", err);
2616 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2625 if (as->parms[7].items) flags |= RV_OFFLINE;
2626 if (as->parms[8].items) flags |= RV_RDONLY;
2627 if (as->parms[9].items) flags |= RV_NOCLONE;
2628 if (as->parms[10].items) flags |= RV_CPINCR;
2630 MapPartIdIntoName(topart, toPartName);
2631 MapPartIdIntoName(frompart, fromPartName);
2634 * check target partition for space to move volume
2637 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2639 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2643 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2646 /* Don't do this again if we did it above */
2648 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2650 fprintf(STDERR, "vos:cannot access volume %lu\n",
2651 (unsigned long)volid);
2656 /* OK if this fails */
2657 code = UV_ListOneVolume(toserver, topart, tovolid, &q);
2659 /* Treat existing volume size as "free" */
2661 p->size = (q->size < p->size) ? p->size - q->size : 0;
2663 if (partition.free <= p->size) {
2665 "vos: no space on target partition %s to copy volume %lu\n",
2666 toPartName, (unsigned long)volid);
2674 /* successful copy still not guaranteed but shoot for it */
2677 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2678 topart, tovolid, flags);
2680 PrintDiagnostics("shadow", code);
2683 MapPartIdIntoName(topart, toPartName);
2684 MapPartIdIntoName(frompart, fromPartName);
2685 fprintf(STDOUT, "Volume %lu shadowed from %s %s to %s %s \n",
2686 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2687 as->parms[3].items->data, toPartName);
2694 CloneVolume(struct cmd_syndesc *as, void *arock)
2696 afs_uint32 volid, cloneid;
2698 afs_int32 part, voltype;
2699 char partName[10], *volname;
2700 afs_int32 code, err, flags;
2701 struct nvldbentry entry;
2703 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2706 PrintError("", err);
2708 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2709 as->parms[0].items->data);
2713 if (as->parms[1].items || as->parms[2].items) {
2714 if (!as->parms[1].items || !as->parms[2].items) {
2716 "Must specify both -server and -partition options\n");
2719 server = GetServer(as->parms[1].items->data);
2721 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2722 as->parms[1].items->data);
2725 part = volutil_GetPartitionID(as->parms[2].items->data);
2727 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2728 as->parms[2].items->data);
2731 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
2733 PrintError("", code);
2736 "vos : partition %s does not exist on the server\n",
2737 as->parms[2].items->data);
2741 code = GetVolumeInfo(volid, &server, &part, &voltype, &entry);
2747 if (as->parms[3].items) {
2748 volname = as->parms[3].items->data;
2749 if (strlen(volname) > VOLSER_OLDMAXVOLNAME - 1) {
2751 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2752 volname, VOLSER_OLDMAXVOLNAME - 1);
2757 * In order that you be able to make clones of RO or BK, this
2758 * check must be omitted.
2760 if (!VolNameOK(volname)) {
2762 "Illegal volume name %s, should not end in .readonly or .backup\n",
2767 if (IsNumeric(volname)) {
2769 "Illegal volume name %s, should not be a number\n",
2776 if (as->parms[4].items) {
2777 cloneid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2780 PrintError("", err);
2782 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2783 as->parms[4].items->data);
2789 if (as->parms[5].items) flags |= RV_OFFLINE;
2790 if (as->parms[6].items && as->parms[7].items) {
2791 fprintf(STDERR, "vos: cannot specify that a volume be -readwrite and -readonly\n");
2794 if (as->parms[6].items) flags |= RV_RDONLY;
2795 if (as->parms[7].items) flags |= RV_RWONLY;
2799 UV_CloneVolume(server, part, volid, cloneid, volname, flags);
2802 PrintDiagnostics("clone", code);
2805 MapPartIdIntoName(part, partName);
2806 fprintf(STDOUT, "Created clone for volume %s\n",
2807 as->parms[0].items->data);
2814 BackupVolume(struct cmd_syndesc *as, void *arock)
2818 afs_int32 apart, vtype, code, err;
2819 struct nvldbentry entry;
2822 afs_uint32 buserver;
2823 afs_int32 bupart, butype;
2824 struct nvldbentry buentry;
2826 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2829 PrintError("", err);
2831 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2832 as->parms[0].items->data);
2835 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2839 /* verify this is a readwrite volume */
2841 if (vtype != RWVOL) {
2842 fprintf(STDERR, "%s not RW volume\n", as->parms[0].items->data);
2846 /* is there a backup volume already? */
2848 if (entry.flags & VLF_BACKEXISTS) {
2849 /* yep, where is it? */
2851 buvolid = entry.volumeId[BACKVOL];
2852 code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
2857 code = VLDB_IsSameAddrs(buserver, aserver, &err);
2860 "Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
2866 "FATAL ERROR: backup volume %lu exists on server %lu\n",
2867 (unsigned long)buvolid, (unsigned long)buserver);
2872 /* nope, carry on */
2874 code = UV_BackupVolume(aserver, apart, avolid);
2877 PrintDiagnostics("backup", code);
2880 fprintf(STDOUT, "Created backup volume for %s \n",
2881 as->parms[0].items->data);
2886 ReleaseVolume(struct cmd_syndesc *as, void *arock)
2889 struct nvldbentry entry;
2892 afs_int32 apart, vtype, code, err;
2895 if (as->parms[1].items) /* -force */
2896 flags |= (REL_COMPLETE | REL_FULLDUMPS);
2897 if (as->parms[2].items) { /* -stayonline */
2898 fprintf(STDERR, "vos: -stayonline not supported\n");
2901 if (as->parms[3].items) /* -force-reclone */
2902 flags |= REL_COMPLETE;
2904 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2907 PrintError("", err);
2909 fprintf(STDERR, "vos: can't find volume '%s'\n",
2910 as->parms[0].items->data);
2913 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2917 if (vtype != RWVOL) {
2918 fprintf(STDERR, "%s not a RW volume\n", as->parms[0].items->data);
2922 if (!ISNAMEVALID(entry.name)) {
2924 "Volume name %s is too long, rename before releasing\n",
2929 code = UV_ReleaseVolume(avolid, aserver, apart, flags);
2932 PrintDiagnostics("release", code);
2935 fprintf(STDOUT, "Released volume %s successfully\n",
2936 as->parms[0].items->data);
2941 DumpVolumeCmd(struct cmd_syndesc *as, void *arock)
2945 afs_int32 apart, voltype, fromdate = 0, code, err, i, flags;
2946 char filename[MAXPATHLEN];
2947 struct nvldbentry entry;
2949 rx_SetRxDeadTime(60 * 10);
2950 for (i = 0; i < MAXSERVERS; i++) {
2951 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
2954 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
2955 if (rx_ServiceOf(rxConn))
2956 rx_ServiceOf(rxConn)->connDeadTime = rx_connDeadTime;
2959 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2962 PrintError("", err);
2964 fprintf(STDERR, "vos: can't find volume '%s'\n",
2965 as->parms[0].items->data);
2969 if (as->parms[3].items || as->parms[4].items) {
2970 if (!as->parms[3].items || !as->parms[4].items) {
2972 "Must specify both -server and -partition options\n");
2975 aserver = GetServer(as->parms[3].items->data);
2977 fprintf(STDERR, "Invalid server name\n");
2980 apart = volutil_GetPartitionID(as->parms[4].items->data);
2982 fprintf(STDERR, "Invalid partition name\n");
2986 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
2991 if (as->parms[1].items && strcmp(as->parms[1].items->data, "0")) {
2992 code = ktime_DateToInt32(as->parms[1].items->data, &fromdate);
2994 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
2995 as->parms[1].items->data, code);
2999 if (as->parms[2].items) {
3000 strcpy(filename, as->parms[2].items->data);
3002 strcpy(filename, "");
3005 flags = as->parms[6].items ? VOLDUMPV2_OMITDIRS : 0;
3007 if (as->parms[5].items) {
3009 UV_DumpClonedVolume(avolid, aserver, apart, fromdate,
3010 DumpFunction, filename, flags);
3013 UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction,
3016 if ((code == RXGEN_OPCODE) && (as->parms[6].items)) {
3017 flags &= ~VOLDUMPV2_OMITDIRS;
3021 PrintDiagnostics("dump", code);
3024 if (strcmp(filename, ""))
3025 fprintf(STDERR, "Dumped volume %s in file %s\n",
3026 as->parms[0].items->data, filename);
3028 fprintf(STDERR, "Dumped volume %s in stdout \n",
3029 as->parms[0].items->data);
3043 RestoreVolumeCmd(struct cmd_syndesc *as, void *arock)
3045 afs_uint32 avolid, aparentid;
3047 afs_int32 apart, code, vcode, err;
3048 afs_int32 aoverwrite = ASK;
3049 afs_int32 acreation = 0, alastupdate = 0;
3050 int restoreflags = 0;
3051 int readonly = 0, offline = 0, voltype = RWVOL;
3052 char afilename[MAXPATHLEN], avolname[VOLSER_MAXVOLNAME + 1], apartName[10];
3053 char volname[VOLSER_MAXVOLNAME + 1];
3054 struct nvldbentry entry;
3057 if (as->parms[4].items) {
3058 avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
3061 PrintError("", err);
3063 fprintf(STDERR, "vos: can't find volume '%s'\n",
3064 as->parms[4].items->data);
3070 if (as->parms[5].items) {
3071 if ((strcmp(as->parms[5].items->data, "a") == 0)
3072 || (strcmp(as->parms[5].items->data, "abort") == 0)) {
3074 } else if ((strcmp(as->parms[5].items->data, "f") == 0)
3075 || (strcmp(as->parms[5].items->data, "full") == 0)) {
3077 } else if ((strcmp(as->parms[5].items->data, "i") == 0)
3078 || (strcmp(as->parms[5].items->data, "inc") == 0)
3079 || (strcmp(as->parms[5].items->data, "increment") == 0)
3080 || (strcmp(as->parms[5].items->data, "incremental") == 0)) {
3083 fprintf(STDERR, "vos: %s is not a valid argument to -overwrite\n",
3084 as->parms[5].items->data);
3088 if (as->parms[6].items)
3090 if (as->parms[7].items) {
3095 if (as->parms[8].items) {
3096 if ((strcmp(as->parms[8].items->data, "d") == 0)
3097 || (strcmp(as->parms[8].items->data, "dump") == 0)) {
3098 acreation = TS_DUMP;
3099 } else if ((strcmp(as->parms[8].items->data, "k") == 0)
3100 || (strcmp(as->parms[8].items->data, "keep") == 0)) {
3101 acreation = TS_KEEP;
3102 } else if ((strcmp(as->parms[8].items->data, "n") == 0)
3103 || (strcmp(as->parms[8].items->data, "new") == 0)) {
3106 fprintf(STDERR, "vos: %s is not a valid argument to -creation\n",
3107 as->parms[8].items->data);
3112 if (as->parms[9].items) {
3113 if ((strcmp(as->parms[9].items->data, "d") == 0)
3114 || (strcmp(as->parms[9].items->data, "dump") == 0)) {
3115 alastupdate = TS_DUMP;
3116 } else if ((strcmp(as->parms[9].items->data, "k") == 0)
3117 || (strcmp(as->parms[9].items->data, "keep") == 0)) {
3118 alastupdate = TS_KEEP;
3119 } else if ((strcmp(as->parms[9].items->data, "n") == 0)
3120 || (strcmp(as->parms[9].items->data, "new") == 0)) {
3121 alastupdate = TS_NEW;
3123 fprintf(STDERR, "vos: %s is not a valid argument to -lastupdate\n",
3124 as->parms[9].items->data);
3129 aserver = GetServer(as->parms[0].items->data);
3131 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3132 as->parms[0].items->data);
3135 apart = volutil_GetPartitionID(as->parms[1].items->data);
3137 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3138 as->parms[1].items->data);
3141 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3143 PrintError("", code);
3146 "vos : partition %s does not exist on the server\n",
3147 as->parms[1].items->data);
3150 strcpy(avolname, as->parms[2].items->data);
3151 if (!ISNAMEVALID(avolname)) {
3153 "vos: the name of the volume %s exceeds the size limit\n",
3157 if (!VolNameOK(avolname)) {
3159 "Illegal volume name %s, should not end in .readonly or .backup\n",
3163 if (as->parms[3].items) {
3164 strcpy(afilename, as->parms[3].items->data);
3165 if (!FileExists(afilename)) {
3166 fprintf(STDERR, "Can't access file %s\n", afilename);
3170 strcpy(afilename, "");
3173 /* Check if volume exists or not */
3175 vsu_ExtractName(volname, avolname);
3176 vcode = VLDB_GetEntryByName(volname, &entry);
3177 if (vcode) { /* no volume - do a full restore */
3178 restoreflags = RV_FULLRST;
3179 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3181 "Volume does not exist; Will perform a full restore\n");
3184 else if ((!readonly && Lp_GetRwIndex(&entry) == -1) /* RW volume does not exist - do a full */
3185 ||(readonly && !Lp_ROMatch(0, 0, &entry))) { /* RO volume does not exist - do a full */
3186 restoreflags = RV_FULLRST;
3187 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3189 "%s Volume does not exist; Will perform a full restore\n",
3190 readonly ? "RO" : "RW");
3193 avolid = entry.volumeId[voltype];
3194 } else if (entry.volumeId[voltype] != 0
3195 && entry.volumeId[voltype] != avolid) {
3196 avolid = entry.volumeId[voltype];
3198 aparentid = entry.volumeId[RWVOL];
3201 else { /* volume exists - do we do a full incremental or abort */
3203 afs_int32 Opart, Otype, vol_elsewhere = 0;
3204 struct nvldbentry Oentry;
3208 avolid = entry.volumeId[voltype];
3209 } else if (entry.volumeId[voltype] != 0
3210 && entry.volumeId[voltype] != avolid) {
3211 avolid = entry.volumeId[voltype];
3213 aparentid = entry.volumeId[RWVOL];
3215 /* A file name was specified - check if volume is on another partition */
3216 vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
3220 vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
3223 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
3227 if (!vcode || (Opart != apart))
3230 if (aoverwrite == ASK) {
3231 if (strcmp(afilename, "") == 0) { /* The file is from standard in */
3233 "Volume exists and no -overwrite option specified; Aborting restore command\n");
3237 /* Ask what to do */
3238 if (vol_elsewhere) {
3240 "The volume %s %u already exists on a different server/part\n",
3241 volname, entry.volumeId[voltype]);
3243 "Do you want to do a full restore or abort? [fa](a): ");
3246 "The volume %s %u already exists in the VLDB\n",
3247 volname, entry.volumeId[voltype]);
3249 "Do you want to do a full/incremental restore or abort? [fia](a): ");
3252 while (!(dc == EOF || dc == '\n'))
3253 dc = getchar(); /* goto end of line */
3254 if ((c == 'f') || (c == 'F'))
3256 else if ((c == 'i') || (c == 'I'))
3262 if (aoverwrite == ABORT) {
3263 fprintf(STDERR, "Volume exists; Aborting restore command\n");
3265 } else if (aoverwrite == FULL) {
3266 restoreflags = RV_FULLRST;
3268 "Volume exists; Will delete and perform full restore\n");
3269 } else if (aoverwrite == INC) {
3271 if (vol_elsewhere) {
3273 "%s volume %lu already exists on a different server/part; not allowed\n",
3274 readonly ? "RO" : "RW", (unsigned long)avolid);
3280 restoreflags |= RV_OFFLINE;
3282 restoreflags |= RV_RDONLY;
3284 switch (acreation) {
3286 restoreflags |= RV_CRDUMP;
3289 restoreflags |= RV_CRKEEP;
3292 restoreflags |= RV_CRNEW;
3295 if (aoverwrite == FULL)
3296 restoreflags |= RV_CRNEW;
3298 restoreflags |= RV_CRKEEP;
3301 switch (alastupdate) {
3303 restoreflags |= RV_LUDUMP;
3306 restoreflags |= RV_LUKEEP;
3309 restoreflags |= RV_LUNEW;
3312 restoreflags |= RV_LUDUMP;
3314 if (as->parms[10].items) {
3315 restoreflags |= RV_NODEL;
3320 UV_RestoreVolume2(aserver, apart, avolid, aparentid,
3321 avolname, restoreflags, WriteData, afilename);
3323 PrintDiagnostics("restore", code);
3326 MapPartIdIntoName(apart, apartName);
3329 * patch typo here - originally "parms[1]", should be "parms[0]"
3332 fprintf(STDOUT, "Restored volume %s on %s %s\n", avolname,
3333 as->parms[0].items->data, apartName);
3338 LockReleaseCmd(struct cmd_syndesc *as, void *arock)
3341 afs_int32 code, err;
3343 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
3346 PrintError("", err);
3348 fprintf(STDERR, "vos: can't find volume '%s'\n",
3349 as->parms[0].items->data);
3353 code = UV_LockRelease(avolid);
3355 PrintDiagnostics("unlock", code);
3358 fprintf(STDOUT, "Released lock on vldb entry for volume %s\n",
3359 as->parms[0].items->data);
3364 AddSite(struct cmd_syndesc *as, void *arock)
3368 afs_int32 apart, code, err, arovolid, valid = 0;
3369 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3371 vsu_ExtractName(avolname, as->parms[2].items->data);;
3372 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3375 PrintError("", err);
3377 fprintf(STDERR, "vos: can't find volume '%s'\n",
3378 as->parms[2].items->data);
3382 if (as->parms[3].items) {
3383 vsu_ExtractName(avolname, as->parms[3].items->data);
3384 arovolid = vsu_GetVolumeID(avolname, cstruct, &err);
3386 fprintf(STDERR, "vos: invalid ro volume id '%s'\n",
3387 as->parms[3].items->data);
3391 aserver = GetServer(as->parms[0].items->data);
3393 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3394 as->parms[0].items->data);
3397 apart = volutil_GetPartitionID(as->parms[1].items->data);
3399 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3400 as->parms[1].items->data);
3403 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3405 PrintError("", code);
3408 "vos : partition %s does not exist on the server\n",
3409 as->parms[1].items->data);
3412 if (as->parms[4].items) {
3415 code = UV_AddSite2(aserver, apart, avolid, arovolid, valid);
3417 PrintDiagnostics("addsite", code);
3420 MapPartIdIntoName(apart, apartName);
3421 fprintf(STDOUT, "Added replication site %s %s for volume %s\n",
3422 as->parms[0].items->data, apartName, as->parms[2].items->data);
3427 RemoveSite(struct cmd_syndesc *as, void *arock)
3432 afs_int32 apart, code, err;
3433 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3435 vsu_ExtractName(avolname, as->parms[2].items->data);
3436 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3439 PrintError("", err);
3441 fprintf(STDERR, "vos: can't find volume '%s'\n",
3442 as->parms[2].items->data);
3445 aserver = GetServer(as->parms[0].items->data);
3447 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3448 as->parms[0].items->data);
3451 apart = volutil_GetPartitionID(as->parms[1].items->data);
3453 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3454 as->parms[1].items->data);
3458 *skip the partition validity check, since it is possible that the partition
3459 *has since been decomissioned.
3462 if (!IsPartValid(apart,aserver,&code)){
3463 if(code) PrintError("",code);
3464 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
3468 code = UV_RemoveSite(aserver, apart, avolid);
3470 PrintDiagnostics("remsite", code);
3473 MapPartIdIntoName(apart, apartName);
3474 fprintf(STDOUT, "Removed replication site %s %s for volume %s\n",
3475 as->parms[0].items->data, apartName, as->parms[2].items->data);
3480 ChangeLocation(struct cmd_syndesc *as, void *arock)
3484 afs_int32 apart, code, err;
3487 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3490 PrintError("", err);
3492 fprintf(STDERR, "vos: can't find volume '%s'\n",
3493 as->parms[2].items->data);
3496 aserver = GetServer(as->parms[0].items->data);
3498 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3499 as->parms[0].items->data);
3502 apart = volutil_GetPartitionID(as->parms[1].items->data);
3504 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3505 as->parms[1].items->data);
3508 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3510 PrintError("", code);
3513 "vos : partition %s does not exist on the server\n",
3514 as->parms[1].items->data);
3517 code = UV_ChangeLocation(aserver, apart, avolid);
3519 PrintDiagnostics("changeloc", code);
3522 MapPartIdIntoName(apart, apartName);
3523 fprintf(STDOUT, "Changed location to %s %s for volume %s\n",
3524 as->parms[0].items->data, apartName, as->parms[2].items->data);
3529 ListPartitions(struct cmd_syndesc *as, void *arock)
3533 struct partList dummyPartList;
3538 aserver = GetServer(as->parms[0].items->data);
3540 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3541 as->parms[0].items->data);
3546 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3548 PrintDiagnostics("listpart", code);
3552 fprintf(STDOUT, "The partitions on the server are:\n");
3553 for (i = 0; i < cnt; i++) {
3554 if (dummyPartList.partFlags[i] & PARTVALID) {
3555 memset(pname, 0, sizeof(pname));
3556 MapPartIdIntoName(dummyPartList.partId[i], pname);
3557 fprintf(STDOUT, " %10s ", pname);
3559 if ((i % 5) == 0 && (i != 0))
3560 fprintf(STDOUT, "\n");
3563 fprintf(STDOUT, "\n");
3564 fprintf(STDOUT, "Total: %d\n", total);
3570 CompareVolName(const void *p1, const void *p2)
3572 volintInfo *arg1, *arg2;
3574 arg1 = (volintInfo *) p1;
3575 arg2 = (volintInfo *) p2;
3576 return (strcmp(arg1->name, arg2->name));
3580 /*------------------------------------------------------------------------
3581 * PRIVATE XCompareVolName
3584 * Comparison routine for volume names coming from an extended
3588 * a_obj1P : Char ptr to first extended vol info object
3589 * a_obj1P : Char ptr to second extended vol info object
3592 * The value of strcmp() on the volume names within the passed
3593 * objects (i,e., -1, 0, or 1).
3596 * Passed to qsort() as the designated comparison routine.
3600 *------------------------------------------------------------------------*/
3603 XCompareVolName(const void *a_obj1P, const void *a_obj2P)
3604 { /*XCompareVolName */
3607 (((struct volintXInfo *)(a_obj1P))->name,
3608 ((struct volintXInfo *)(a_obj2P))->name));
3610 } /*XCompareVolName */
3613 CompareVolID(const void *p1, const void *p2)
3615 volintInfo *arg1, *arg2;
3617 arg1 = (volintInfo *) p1;
3618 arg2 = (volintInfo *) p2;
3619 if (arg1->volid == arg2->volid)
3621 if (arg1->volid > arg2->volid)
3628 /*------------------------------------------------------------------------
3629 * PRIVATE XCompareVolID
3632 * Comparison routine for volume IDs coming from an extended
3636 * a_obj1P : Char ptr to first extended vol info object
3637 * a_obj1P : Char ptr to second extended vol info object
3640 * The value of strcmp() on the volume names within the passed
3641 * objects (i,e., -1, 0, or 1).
3644 * Passed to qsort() as the designated comparison routine.
3648 *------------------------------------------------------------------------*/
3651 XCompareVolID(const void *a_obj1P, const void *a_obj2P)
3652 { /*XCompareVolID */
3654 afs_int32 id1, id2; /*Volume IDs we're comparing */
3656 id1 = ((struct volintXInfo *)(a_obj1P))->volid;
3657 id2 = ((struct volintXInfo *)(a_obj2P))->volid;