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 static int PrintDiagnostics(char *astring, afs_int32 acode);
62 static 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,
83 COMMONPARM_OFFSET_RXGK = 32,
87 cmd_AddParmAtOffset(ts, COMMONPARM_OFFSET_CELL, \
88 "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");\
89 cmd_AddParmAlias(ts, COMMONPARM_OFFSET_CELL, "-c"); /* original -cell option */ \
90 cmd_AddParmAtOffset(ts, COMMONPARM_OFFSET_NOAUTH, \
91 "-noauth", CMD_FLAG, CMD_OPTIONAL, "don't authenticate");\
92 cmd_AddParmAtOffset(ts, COMMONPARM_OFFSET_LOCALAUTH, \
93 "-localauth",CMD_FLAG,CMD_OPTIONAL,"use server tickets");\
94 cmd_AddParmAtOffset(ts, COMMONPARM_OFFSET_VERBOSE, \
95 "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose");\
96 cmd_AddParmAtOffset(ts, COMMONPARM_OFFSET_ENCRYPT, \
97 "-encrypt", CMD_FLAG, CMD_OPTIONAL, "encrypt commands");\
98 cmd_AddParmAtOffset(ts, COMMONPARM_OFFSET_NORESOLVE, \
99 "-noresolve", CMD_FLAG, CMD_OPTIONAL, "don't resolve addresses"); \
100 cmd_AddParmAtOffset(ts, COMMONPARM_OFFSET_CONFIG, \
101 "-config", CMD_SINGLE, CMD_OPTIONAL, "config location"); \
102 cmd_AddParmAtOffset(ts, COMMONPARM_OFFSET_RXGK, \
103 "-rxgk", CMD_SINGLE, CMD_OPTIONAL, "rxgk security level to use"); \
105 #define ERROR_EXIT(code) do { \
111 extern struct ubik_client *cstruct;
114 static struct tqHead busyHead, notokHead;
117 qInit(struct tqHead *ahead)
119 memset(ahead, 0, sizeof(struct tqHead));
124 qPut(struct tqHead *ahead, afs_uint32 volid)
128 elem = malloc(sizeof(struct tqElem));
129 elem->next = ahead->next;
137 qGet(struct tqHead *ahead, afs_uint32 *volid)
141 if (ahead->count <= 0)
143 *volid = ahead->next->volid;
145 ahead->next = tmp->next;
151 /* returns 1 if <filename> exists else 0 */
153 FileExists(char *filename)
159 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
163 code = USD_IOCTL(ufd, USD_IOCTL_GETSIZE, &size);
171 /* returns 1 if <name> doesnot end in .readonly or .backup, else 0 */
173 VolNameOK(char *name)
177 total = strlen(name);
178 if (!strcmp(&name[total - 9], ".readonly")) {
180 } else if (!strcmp(&name[total - 7], ".backup")) {
187 /* return 1 if name is a number else 0 */
189 IsNumeric(char *name)
198 for (i = 0; i < len; i++) {
199 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 IsPartValid(afs_int32 partId, afs_uint32 server, afs_int32 *code)
289 struct partList dummyPartList;
295 *code = UV_ListPartitions(server, &dummyPartList, &cnt);
298 for (i = 0; i < cnt; i++) {
299 if (dummyPartList.partFlags[i] & PARTVALID)
300 if (dummyPartList.partId[i] == partId)
306 /*sends the contents of file associated with <fd> and <blksize> to Rx Stream
307 * associated with <call> */
309 SendFile(usd_handle_t ufd, struct rx_call *call, long blksize)
311 char *buffer = (char *)0;
315 buffer = malloc(blksize);
317 fprintf(STDERR, "malloc failed\n");
322 #if !defined(AFS_NT40_ENV) && !defined(AFS_PTHREAD_ENV)
323 /* Only for this for non-NT, non-pthread. For NT, we can't select on
324 * non-socket FDs. For pthread environments, we don't need to select at
325 * all, since the following read() will block. */
328 FD_SET((intptr_t)(ufd->handle), &in);
329 /* don't timeout if read blocks */
330 IOMGR_Select(((intptr_t)(ufd->handle)) + 1, &in, 0, 0, 0);
332 error = USD_READ(ufd, buffer, blksize, &nbytes);
334 fprintf(STDERR, "File system read failed: %s\n",
335 afs_error_message(error));
342 if (rx_Write(call, buffer, nbytes) != nbytes) {
352 /* function invoked by UV_RestoreVolume, reads the data from rx_trx_stream and
353 * writes it out to the volume. */
355 WriteData(struct rx_call *call, void *rock)
357 char *filename = (char *) rock;
360 afs_int32 error, code;
362 afs_int64 currOffset;
368 if (!filename || !*filename) {
369 usd_StandardInput(&ufd);
373 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
376 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
379 fprintf(STDERR, "Could not access file '%s': %s\n", filename,
380 afs_error_message(code));
384 /* test if we have a valid dump */
385 USD_SEEK(ufd, 0, SEEK_END, &currOffset);
386 USD_SEEK(ufd, currOffset - sizeof(afs_uint32), SEEK_SET, &currOffset);
387 USD_READ(ufd, (char *)&buffer, sizeof(afs_uint32), &got);
388 if ((got != sizeof(afs_uint32)) || (ntohl(buffer) != DUMPENDMAGIC)) {
389 fprintf(STDERR, "Signature missing from end of file '%s'\n", filename);
393 USD_SEEK(ufd, 0, SEEK_SET, &currOffset);
395 code = SendFile(ufd, call, blksize);
402 code = USD_CLOSE(ufd);
404 fprintf(STDERR, "Could not close dump file %s\n",
405 (filename && *filename) ? filename : "STDOUT");
413 /* Receive data from <call> stream into file associated
414 * with <fd> <blksize>
417 ReceiveFile(usd_handle_t ufd, struct rx_call *call, long blksize)
421 afs_uint32 bytesleft, w;
424 buffer = malloc(blksize);
426 fprintf(STDERR, "memory allocation failed\n");
430 while ((bytesread = rx_Read(call, buffer, blksize)) > 0) {
431 for (bytesleft = bytesread; bytesleft; bytesleft -= w) {
432 #if !defined(AFS_NT40_ENV) && !defined(AFS_PTHREAD_ENV)
433 /* Only for this for non-NT, non-pthread. For NT, we can't select
434 * on non-socket FDs. For pthread environments, we don't need to
435 * select at all, since the following write() will block. */
438 FD_SET((intptr_t)(ufd->handle), &out);
439 /* don't timeout if write blocks */
440 IOMGR_Select(((intptr_t)(ufd->handle)) + 1, 0, &out, 0, 0);
443 USD_WRITE(ufd, &buffer[bytesread - bytesleft], bytesleft, &w);
445 fprintf(STDERR, "File system write failed: %s\n",
446 afs_error_message(error));
459 DumpFunction(struct rx_call *call, void *rock)
461 char *filename = (char *)rock;
462 usd_handle_t ufd; /* default is to stdout */
463 afs_int32 error = 0, code;
468 /* Open the output file */
469 if (!filename || !*filename) {
470 usd_StandardOutput(&ufd);
475 usd_Open(filename, USD_OPEN_CREATE | USD_OPEN_RDWR, 0666, &ufd);
479 code = USD_IOCTL(ufd, USD_IOCTL_SETSIZE, &size);
482 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
485 fprintf(STDERR, "Could not create file '%s': %s\n", filename,
486 afs_error_message(code));
487 ERROR_EXIT(VOLSERBADOP);
491 code = ReceiveFile(ufd, call, blksize);
496 /* Close the output file */
498 code = USD_CLOSE(ufd);
500 fprintf(STDERR, "Could not close dump file %s\n",
501 (filename && *filename) ? filename : "STDIN");
511 DisplayFormat(volintInfo *pntr, afs_uint32 server, afs_int32 part,
512 int *totalOK, int *totalNotOK, int *totalBusy, int fast,
513 int longlist, int disp)
519 fprintf(STDOUT, "%-10lu\n", (unsigned long)pntr->volid);
520 } else if (longlist) {
521 if (pntr->status == VOK) {
522 fprintf(STDOUT, "%-32s ", pntr->name);
523 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
525 fprintf(STDOUT, "RW ");
527 fprintf(STDOUT, "RO ");
529 fprintf(STDOUT, "BK ");
530 fprintf(STDOUT, "%10d K ", pntr->size);
531 if (pntr->inUse == 1) {
532 fprintf(STDOUT, "On-line");
535 fprintf(STDOUT, "Off-line");
538 if (pntr->needsSalvaged == 1)
539 fprintf(STDOUT, "**needs salvage**");
540 fprintf(STDOUT, "\n");
541 MapPartIdIntoName(part, pname);
542 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(server),
544 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
545 (unsigned long)pntr->parentID,
546 (unsigned long)pntr->cloneID,
547 (unsigned long)pntr->backupID);
548 fprintf(STDOUT, " MaxQuota %10d K \n", pntr->maxquota);
549 t = pntr->creationDate;
550 fprintf(STDOUT, " Creation %s",
553 fprintf(STDOUT, " Copy %s",
556 t = pntr->backupDate;
558 fprintf(STDOUT, " Backup Never\n");
560 fprintf(STDOUT, " Backup %s",
563 t = pntr->accessDate;
565 fprintf(STDOUT, " Last Access %s",
568 t = pntr->updateDate;
570 fprintf(STDOUT, " Last Update Never\n");
572 fprintf(STDOUT, " Last Update %s",
575 " %d accesses in the past day (i.e., vnode references)\n",
577 } else if (pntr->status == VBUSY) {
579 qPut(&busyHead, pntr->volid);
581 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
582 (unsigned long)pntr->volid);
585 qPut(¬okHead, pntr->volid);
587 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
588 (unsigned long)pntr->volid);
590 fprintf(STDOUT, "\n");
591 } else { /* default listing */
592 if (pntr->status == VOK) {
593 fprintf(STDOUT, "%-32s ", pntr->name);
594 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
596 fprintf(STDOUT, "RW ");
598 fprintf(STDOUT, "RO ");
600 fprintf(STDOUT, "BK ");
601 fprintf(STDOUT, "%10d K ", pntr->size);
602 if (pntr->inUse == 1) {
603 fprintf(STDOUT, "On-line");
606 fprintf(STDOUT, "Off-line");
609 if (pntr->needsSalvaged == 1)
610 fprintf(STDOUT, "**needs salvage**");
611 fprintf(STDOUT, "\n");
612 } else if (pntr->status == VBUSY) {
614 qPut(&busyHead, pntr->volid);
616 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
617 (unsigned long)pntr->volid);
620 qPut(¬okHead, pntr->volid);
622 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
623 (unsigned long)pntr->volid);
628 /*------------------------------------------------------------------------
629 * PRIVATE XDisplayFormat
632 * Display the contents of one extended volume info structure.
635 * a_xInfoP : Ptr to extended volume info struct to print.
636 * a_servID : Server ID to print.
637 * a_partID : Partition ID to print.
638 * a_totalOKP : Ptr to total-OK counter.
639 * a_totalNotOKP : Ptr to total-screwed counter.
640 * a_totalBusyP : Ptr to total-busy counter.
641 * a_fast : Fast listing?
642 * a_int32 : Int32 listing?
643 * a_showProblems : Show volume problems?
649 * Nothing interesting.
653 *------------------------------------------------------------------------*/
656 XDisplayFormat(volintXInfo *a_xInfoP, afs_uint32 a_servID, afs_int32 a_partID,
657 int *a_totalOKP, int *a_totalNotOKP, int *a_totalBusyP,
658 int a_fast, int a_int32, int a_showProblems)
659 { /*XDisplayFormat */
667 fprintf(STDOUT, "%-10lu\n", (unsigned long)a_xInfoP->volid);
668 } else if (a_int32) {
670 * Fully-detailed listing.
672 if (a_xInfoP->status == VOK) {
674 * Volume's status is OK - all the fields are valid.
676 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
677 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
678 if (a_xInfoP->type == 0)
679 fprintf(STDOUT, "RW ");
680 if (a_xInfoP->type == 1)
681 fprintf(STDOUT, "RO ");
682 if (a_xInfoP->type == 2)
683 fprintf(STDOUT, "BK ");
684 fprintf(STDOUT, "%10d K used ", a_xInfoP->size);
685 fprintf(STDOUT, "%d files ", a_xInfoP->filecount);
686 if (a_xInfoP->inUse == 1) {
687 fprintf(STDOUT, "On-line");
690 fprintf(STDOUT, "Off-line");
693 fprintf(STDOUT, "\n");
694 MapPartIdIntoName(a_partID, pname);
695 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(a_servID),
697 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
698 (unsigned long)a_xInfoP->parentID,
699 (unsigned long)a_xInfoP->cloneID,
700 (unsigned long)a_xInfoP->backupID);
701 fprintf(STDOUT, " MaxQuota %10d K \n", a_xInfoP->maxquota);
703 t = a_xInfoP->creationDate;
704 fprintf(STDOUT, " Creation %s",
707 t = a_xInfoP->copyDate;
708 fprintf(STDOUT, " Copy %s",
711 t = a_xInfoP->backupDate;
713 fprintf(STDOUT, " Backup Never\n");
715 fprintf(STDOUT, " Backup %s",
718 t = a_xInfoP->accessDate;
720 fprintf(STDOUT, " Last Access %s",
723 t = a_xInfoP->updateDate;
725 fprintf(STDOUT, " Last Update Never\n");
727 fprintf(STDOUT, " Last Update %s",
730 " %d accesses in the past day (i.e., vnode references)\n",
734 * Print all the read/write and authorship stats.
736 fprintf(STDOUT, "\n Raw Read/Write Stats\n");
738 " |-------------------------------------------|\n");
740 " | Same Network | Diff Network |\n");
742 " |----------|----------|----------|----------|\n");
744 " | Total | Auth | Total | Auth |\n");
746 " |----------|----------|----------|----------|\n");
747 fprintf(STDOUT, "Reads | %8d | %8d | %8d | %8d |\n",
748 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET],
749 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH],
750 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET],
751 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
752 fprintf(STDOUT, "Writes | %8d | %8d | %8d | %8d |\n",
753 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET],
754 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH],
755 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET],
756 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
758 " |-------------------------------------------|\n\n");
761 " Writes Affecting Authorship\n");
763 " |-------------------------------------------|\n");
765 " | File Authorship | Directory Authorship|\n");
767 " |----------|----------|----------|----------|\n");
769 " | Same | Diff | Same | Diff |\n");
771 " |----------|----------|----------|----------|\n");
772 fprintf(STDOUT, "0-60 sec | %8d | %8d | %8d | %8d |\n",
773 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_0],
774 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0],
775 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0],
776 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]);
777 fprintf(STDOUT, "1-10 min | %8d | %8d | %8d | %8d |\n",
778 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1],
779 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1],
780 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1],
781 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]);
782 fprintf(STDOUT, "10min-1hr | %8d | %8d | %8d | %8d |\n",
783 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_2],
784 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_2],
785 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_2],
786 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_2]);
787 fprintf(STDOUT, "1hr-1day | %8d | %8d | %8d | %8d |\n",
788 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_3],
789 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_3],
790 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_3],
791 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_3]);
792 fprintf(STDOUT, "1day-1wk | %8d | %8d | %8d | %8d |\n",
793 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_4],
794 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_4],
795 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_4],
796 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_4]);
797 fprintf(STDOUT, "> 1wk | %8d | %8d | %8d | %8d |\n",
798 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_5],
799 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5],
800 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5],
801 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]);
803 " |-------------------------------------------|\n");
804 } /*Volume status OK */
805 else if (a_xInfoP->status == VBUSY) {
807 qPut(&busyHead, a_xInfoP->volid);
809 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
810 (unsigned long)a_xInfoP->volid);
814 qPut(¬okHead, a_xInfoP->volid);
816 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
817 (unsigned long)a_xInfoP->volid);
818 } /*Screwed volume */
819 fprintf(STDOUT, "\n");
825 if (a_xInfoP->status == VOK) {
826 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
827 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
828 if (a_xInfoP->type == 0)
829 fprintf(STDOUT, "RW ");
830 if (a_xInfoP->type == 1)
831 fprintf(STDOUT, "RO ");
832 if (a_xInfoP->type == 2)
833 fprintf(STDOUT, "BK ");
834 fprintf(STDOUT, "%10d K ", a_xInfoP->size);
835 if (a_xInfoP->inUse == 1) {
836 fprintf(STDOUT, "On-line");
839 fprintf(STDOUT, "Off-line");
842 fprintf(STDOUT, "\n");
844 else if (a_xInfoP->status == VBUSY) {
846 qPut(&busyHead, a_xInfoP->volid);
848 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
849 (unsigned long)a_xInfoP->volid);
853 qPut(¬okHead, a_xInfoP->volid);
855 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
856 (unsigned long)a_xInfoP->volid);
857 } /*Screwed volume */
858 } /*Default listing */
859 } /*XDisplayFormat */
861 /*------------------------------------------------------------------------
862 * PRIVATE XDisplayFormat2
865 * Display the formated contents of one extended volume info structure.
868 * a_xInfoP : Ptr to extended volume info struct to print.
869 * a_servID : Server ID to print.
870 * a_partID : Partition ID to print.
871 * a_totalOKP : Ptr to total-OK counter.
872 * a_totalNotOKP : Ptr to total-screwed counter.
873 * a_totalBusyP : Ptr to total-busy counter.
874 * a_fast : Fast listing?
875 * a_int32 : Int32 listing?
876 * a_showProblems : Show volume problems?
882 * Nothing interesting.
886 *------------------------------------------------------------------------*/
889 XDisplayFormat2(volintXInfo *a_xInfoP, afs_uint32 a_servID, afs_int32 a_partID,
890 int *a_totalOKP, int *a_totalNotOKP, int *a_totalBusyP,
891 int a_fast, int a_int32, int a_showProblems)
892 { /*XDisplayFormat */
898 fprintf(STDOUT, "vold_id\t%-10lu\n", (unsigned long)a_xInfoP->volid);
899 } else if (a_int32) {
901 * Fully-detailed listing.
903 if (a_xInfoP->status == VOK) {
905 * Volume's status is OK - all the fields are valid.
908 static long server_cache = -1, partition_cache = -1;
909 static char hostname[256], address[32], pname[16];
910 int i,ai[] = {VOLINT_STATS_TIME_IDX_0,VOLINT_STATS_TIME_IDX_1,VOLINT_STATS_TIME_IDX_2,
911 VOLINT_STATS_TIME_IDX_3,VOLINT_STATS_TIME_IDX_4,VOLINT_STATS_TIME_IDX_5};
913 if (a_servID != server_cache) {
917 strcpy(hostname, hostutil_GetNameByINet(a_servID));
918 strcpy(address, inet_ntoa(s));
919 server_cache = a_servID;
921 if (a_partID != partition_cache) {
922 MapPartIdIntoName(a_partID, pname);
923 partition_cache = a_partID;
926 fprintf(STDOUT, "name\t\t%s\n", a_xInfoP->name);
927 fprintf(STDOUT, "id\t\t%lu\n", afs_printable_uint32_lu(a_xInfoP->volid));
928 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
929 fprintf(STDOUT, "part\t\t%s\n", pname);
930 fprintf(STDOUT, "status\t\tOK\n");
931 fprintf(STDOUT, "backupID\t%lu\n",
932 afs_printable_uint32_lu(a_xInfoP->backupID));
933 fprintf(STDOUT, "parentID\t%lu\n",
934 afs_printable_uint32_lu(a_xInfoP->parentID));
935 fprintf(STDOUT, "cloneID\t\t%lu\n",
936 afs_printable_uint32_lu(a_xInfoP->cloneID));
937 fprintf(STDOUT, "inUse\t\t%s\n", a_xInfoP->inUse ? "Y" : "N");
938 switch (a_xInfoP->type) {
940 fprintf(STDOUT, "type\t\tRW\n");
943 fprintf(STDOUT, "type\t\tRO\n");
946 fprintf(STDOUT, "type\t\tBK\n");
949 fprintf(STDOUT, "type\t\t?\n");
952 t = a_xInfoP->creationDate;
953 fprintf(STDOUT, "creationDate\t%-9lu\t%s",
954 afs_printable_uint32_lu(a_xInfoP->creationDate),
957 t = a_xInfoP->accessDate;
958 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
959 afs_printable_uint32_lu(a_xInfoP->accessDate),
962 t = a_xInfoP->updateDate;
963 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
964 afs_printable_uint32_lu(a_xInfoP->updateDate),
967 t = a_xInfoP->backupDate;
968 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
969 afs_printable_uint32_lu(a_xInfoP->backupDate),
972 t = a_xInfoP->copyDate;
973 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
974 afs_printable_uint32_lu(a_xInfoP->copyDate),
977 fprintf(STDOUT, "diskused\t%u\n", a_xInfoP->size);
978 fprintf(STDOUT, "maxquota\t%u\n", a_xInfoP->maxquota);
980 fprintf(STDOUT, "filecount\t%u\n", a_xInfoP->filecount);
981 fprintf(STDOUT, "dayUse\t\t%u\n", a_xInfoP->dayUse);
983 fprintf(STDOUT,"reads_same_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET]);
984 fprintf(STDOUT,"reads_same_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH]);
985 fprintf(STDOUT,"reads_diff_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET]);
986 fprintf(STDOUT,"reads_diff_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
988 fprintf(STDOUT,"writes_same_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET]);
989 fprintf(STDOUT,"writes_same_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH]);
990 fprintf(STDOUT,"writes_diff_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET]);
991 fprintf(STDOUT,"writes_diff_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
995 fprintf(STDOUT,"file_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileSameAuthor[ai[i]]);
996 fprintf(STDOUT,"file_diff_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileDiffAuthor[ai[i]]);
997 fprintf(STDOUT,"dir_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirSameAuthor[ai[i]]);
998 fprintf(STDOUT,"dir_dif_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirDiffAuthor[ai[i]]);
1001 } /*Volume status OK */
1002 else if (a_xInfoP->status == VBUSY) {
1004 qPut(&busyHead, a_xInfoP->volid);
1006 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
1007 (unsigned long)a_xInfoP->volid);
1011 qPut(¬okHead, a_xInfoP->volid);
1013 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
1014 (unsigned long)a_xInfoP->volid);
1015 } /*Screwed volume */
1021 if (a_xInfoP->status == VOK) {
1022 fprintf(STDOUT, "name\t%-32s\n", a_xInfoP->name);
1023 fprintf(STDOUT, "volID\t%10lu\n", (unsigned long)a_xInfoP->volid);
1024 if (a_xInfoP->type == 0)
1025 fprintf(STDOUT, "type\tRW\n");
1026 if (a_xInfoP->type == 1)
1027 fprintf(STDOUT, "type\tRO\n");
1028 if (a_xInfoP->type == 2)
1029 fprintf(STDOUT, "type\tBK\n");
1030 fprintf(STDOUT, "size\t%10dK\n", a_xInfoP->size);
1032 fprintf(STDOUT, "inUse\t%d\n",a_xInfoP->inUse);
1033 if (a_xInfoP->inUse == 1)
1039 else if (a_xInfoP->status == VBUSY) {
1041 qPut(&busyHead, a_xInfoP->volid);
1043 fprintf(STDOUT, "VOLUME_BUSY\t%lu\n",
1044 (unsigned long)a_xInfoP->volid);
1048 qPut(¬okHead, a_xInfoP->volid);
1050 fprintf(STDOUT, "COULD_NOT_ATTACH_VOLUME\t%lu\n",
1051 (unsigned long)a_xInfoP->volid);
1052 } /*Screwed volume */
1053 } /*Default listing */
1054 } /*XDisplayFormat */
1057 DisplayFormat2(long server, long partition, volintInfo *pntr)
1059 static long server_cache = -1, partition_cache = -1;
1060 static char hostname[256], address[32], pname[16];
1063 if (server != server_cache) {
1067 strcpy(hostname, hostutil_GetNameByINet(server));
1068 strcpy(address, inet_ntoa(s));
1069 server_cache = server;
1071 if (partition != partition_cache) {
1072 MapPartIdIntoName(partition, pname);
1073 partition_cache = partition;
1076 if (pntr->status == VOK)
1077 fprintf(STDOUT, "name\t\t%s\n", pntr->name);
1079 fprintf(STDOUT, "id\t\t%lu\n",
1080 afs_printable_uint32_lu(pntr->volid));
1081 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
1082 fprintf(STDOUT, "part\t\t%s\n", pname);
1083 switch (pntr->status) {
1085 fprintf(STDOUT, "status\t\tOK\n");
1088 fprintf(STDOUT, "status\t\tBUSY\n");
1091 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
1094 fprintf(STDOUT, "backupID\t%lu\n",
1095 afs_printable_uint32_lu(pntr->backupID));
1096 fprintf(STDOUT, "parentID\t%lu\n",
1097 afs_printable_uint32_lu(pntr->parentID));
1098 fprintf(STDOUT, "cloneID\t\t%lu\n",
1099 afs_printable_uint32_lu(pntr->cloneID));
1100 fprintf(STDOUT, "inUse\t\t%s\n", pntr->inUse ? "Y" : "N");
1101 fprintf(STDOUT, "needsSalvaged\t%s\n", pntr->needsSalvaged ? "Y" : "N");
1102 /* 0xD3 is from afs/volume.h since I had trouble including the file */
1103 fprintf(STDOUT, "destroyMe\t%s\n", pntr->destroyMe == 0xD3 ? "Y" : "N");
1104 switch (pntr->type) {
1106 fprintf(STDOUT, "type\t\tRW\n");
1109 fprintf(STDOUT, "type\t\tRO\n");
1112 fprintf(STDOUT, "type\t\tBK\n");
1115 fprintf(STDOUT, "type\t\t?\n");
1118 t = pntr->creationDate;
1119 fprintf(STDOUT, "creationDate\t%-9lu\t%s",
1120 afs_printable_uint32_lu(pntr->creationDate),
1123 t = pntr->accessDate;
1124 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
1125 afs_printable_uint32_lu(pntr->accessDate),
1128 t = pntr->updateDate;
1129 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
1130 afs_printable_uint32_lu(pntr->updateDate),
1133 t = pntr->backupDate;
1134 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
1135 afs_printable_uint32_lu(pntr->backupDate),
1139 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
1140 afs_printable_uint32_lu(pntr->copyDate),
1143 fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n",
1144 afs_printable_uint32_lu(pntr->flags));
1145 fprintf(STDOUT, "diskused\t%u\n", pntr->size);
1146 fprintf(STDOUT, "maxquota\t%u\n", pntr->maxquota);
1147 fprintf(STDOUT, "minquota\t%lu\t(Optional)\n",
1148 afs_printable_uint32_lu(pntr->spare0));
1149 fprintf(STDOUT, "filecount\t%u\n", pntr->filecount);
1150 fprintf(STDOUT, "dayUse\t\t%u\n", pntr->dayUse);
1151 fprintf(STDOUT, "weekUse\t\t%lu\t(Optional)\n",
1152 afs_printable_uint32_lu(pntr->spare1));
1153 fprintf(STDOUT, "spare2\t\t%lu\t(Optional)\n",
1154 afs_printable_uint32_lu(pntr->spare2));
1155 fprintf(STDOUT, "spare3\t\t%lu\t(Optional)\n",
1156 afs_printable_uint32_lu(pntr->spare3));
1161 DisplayVolumes2(long server, long partition, volintInfo *pntr, long count)
1165 for (i = 0; i < count; i++) {
1166 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1167 DisplayFormat2(server, partition, pntr);
1168 fprintf(STDOUT, "END_OF_ENTRY\n\n");
1175 DisplayVolumes(afs_uint32 server, afs_int32 part, volintInfo *pntr,
1176 afs_int32 count, afs_int32 longlist, afs_int32 fast,
1179 int totalOK, totalNotOK, totalBusy, i;
1180 afs_uint32 volid = 0;
1187 for (i = 0; i < count; i++) {
1188 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy,
1193 while (busyHead.count) {
1194 qGet(&busyHead, &volid);
1195 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1196 (unsigned long)volid);
1200 while (notokHead.count) {
1201 qGet(¬okHead, &volid);
1202 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1203 (unsigned long)volid);
1207 fprintf(STDOUT, "\n");
1210 "Total volumes onLine %d ; Total volumes offLine %d ; Total busy %d\n\n",
1211 totalOK, totalNotOK, totalBusy);
1215 /*------------------------------------------------------------------------
1216 * PRIVATE XDisplayVolumes
1219 * Display extended volume information.
1222 * a_servID : Pointer to the Rx call we're performing.
1223 * a_partID : Partition for which we want the extended list.
1224 * a_xInfoP : Ptr to extended volume info.
1225 * a_count : Number of volume records contained above.
1226 * a_int32 : Int32 listing generated?
1227 * a_fast : Fast listing generated?
1228 * a_quiet : Quiet listing generated?
1234 * Nothing interesting.
1238 *------------------------------------------------------------------------*/
1241 XDisplayVolumes(afs_uint32 a_servID, afs_int32 a_partID, volintXInfo *a_xInfoP,
1242 afs_int32 a_count, afs_int32 a_int32, afs_int32 a_fast,
1244 { /*XDisplayVolumes */
1246 int totalOK; /*Total OK volumes */
1247 int totalNotOK; /*Total screwed volumes */
1248 int totalBusy; /*Total busy volumes */
1249 int i; /*Loop variable */
1250 afs_uint32 volid = 0; /*Current volume ID */
1253 * Initialize counters and (global!!) queues.
1262 * Display each volume in the list.
1264 for (i = 0; i < a_count; i++) {
1265 XDisplayFormat(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1266 &totalBusy, a_fast, a_int32, 0);
1271 * If any volumes were found to be busy or screwed, display them.
1274 while (busyHead.count) {
1275 qGet(&busyHead, &volid);
1276 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1277 (unsigned long)volid);
1281 while (notokHead.count) {
1282 qGet(¬okHead, &volid);
1283 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1284 (unsigned long)volid);
1289 fprintf(STDOUT, "\n");
1292 "Total volumes: %d on-line, %d off-line, %d busyd\n\n",
1293 totalOK, totalNotOK, totalBusy);
1297 } /*XDisplayVolumes */
1299 /*------------------------------------------------------------------------
1300 * PRIVATE XDisplayVolumes2
1303 * Display extended formated volume information.
1306 * a_servID : Pointer to the Rx call we're performing.
1307 * a_partID : Partition for which we want the extended list.
1308 * a_xInfoP : Ptr to extended volume info.
1309 * a_count : Number of volume records contained above.
1310 * a_int32 : Int32 listing generated?
1311 * a_fast : Fast listing generated?
1312 * a_quiet : Quiet listing generated?
1318 * Nothing interesting.
1322 *------------------------------------------------------------------------*/
1325 XDisplayVolumes2(afs_uint32 a_servID, afs_int32 a_partID, volintXInfo *a_xInfoP,
1326 afs_int32 a_count, afs_int32 a_int32, afs_int32 a_fast,
1328 { /*XDisplayVolumes */
1330 int totalOK; /*Total OK volumes */
1331 int totalNotOK; /*Total screwed volumes */
1332 int totalBusy; /*Total busy volumes */
1333 int i; /*Loop variable */
1334 afs_uint32 volid = 0; /*Current volume ID */
1337 * Initialize counters and (global!!) queues.
1346 * Display each volume in the list.
1348 for (i = 0; i < a_count; i++) {
1349 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1350 XDisplayFormat2(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1351 &totalBusy, a_fast, a_int32, 0);
1352 fprintf(STDOUT, "END_OF_ENTRY\n");
1357 * If any volumes were found to be busy or screwed, display them.
1360 while (busyHead.count) {
1361 qGet(&busyHead, &volid);
1362 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
1363 (unsigned long)volid);
1367 while (notokHead.count) {
1368 qGet(¬okHead, &volid);
1369 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
1370 (unsigned long)volid);
1375 fprintf(STDOUT, "\n");
1378 "VOLUMES_ONLINE\t%d\nVOLUMES_OFFLINE\t%d\nVOLUMES_BUSY\t%d\n",
1379 totalOK, totalNotOK, totalBusy);
1383 } /*XDisplayVolumes2 */
1386 * Retrieve the sites (i.e., server id, partition id) from a vldb entry for a
1387 * given volume type. May be called repeatedly to get each read-only site.
1389 * @param[in] entry vldb entry from a previous vldb query
1390 * @param[in] voltype type of volume of interest (rw, ro, bk)
1391 * @param[out] server vldb entry server number for voltype
1392 * @param[out] part vldb part id for voltype
1393 * @param[inout] previdx cursor; should be initialized to -1
1394 * before first call on a given entry.
1396 * @returns true when a volume site has been found
1399 GetServerAndPart(struct nvldbentry *entry, int voltype, afs_uint32 *server,
1400 afs_int32 *part, int *previdx)
1402 int i, istart, vtype;
1404 /* Doesn't check for non-existence of backup volume */
1405 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
1407 istart = 0; /* search the entire entry */
1410 /* Search from beginning of entry or pick up where we left off */
1411 istart = ((*previdx < 0) ? 0 : *previdx + 1);
1414 for (i = istart; i < entry->nServers; i++) {
1415 if (entry->serverFlags[i] & vtype) {
1416 *server = entry->serverNumber[i];
1417 *part = entry->serverPartition[i];
1423 /* Didn't find any more, reset index. */
1429 PrintLocked(afs_int32 aflags)
1431 afs_int32 flags = aflags & VLOP_ALLOPERS;
1434 fprintf(STDOUT, " Volume is currently LOCKED \n");
1436 if (flags & VLOP_MOVE) {
1437 fprintf(STDOUT, " Volume is locked for a move operation\n");
1439 if (flags & VLOP_RELEASE) {
1440 fprintf(STDOUT, " Volume is locked for a release operation\n");
1442 if (flags & VLOP_BACKUP) {
1443 fprintf(STDOUT, " Volume is locked for a backup operation\n");
1445 if (flags & VLOP_DELETE) {
1446 fprintf(STDOUT, " Volume is locked for a delete/misc operation\n");
1448 if (flags & VLOP_DUMP) {
1449 fprintf(STDOUT, " Volume is locked for a dump/restore operation\n");
1455 PostVolumeStats(struct nvldbentry *entry)
1457 SubEnumerateEntry(entry);
1458 /* Check for VLOP_ALLOPERS */
1459 PrintLocked(entry->flags);
1463 /*------------------------------------------------------------------------
1464 * PRIVATE XVolumeStats
1467 * Display extended volume information.
1470 * a_xInfoP : Ptr to extended volume info.
1471 * a_entryP : Ptr to the volume's VLDB entry.
1472 * a_srvID : Server ID.
1473 * a_partID : Partition ID.
1474 * a_volType : Type of volume to print.
1480 * Nothing interesting.
1484 *------------------------------------------------------------------------*/
1487 XVolumeStats(volintXInfo *a_xInfoP, struct nvldbentry *a_entryP,
1488 afs_int32 a_srvID, afs_int32 a_partID, int a_volType)
1491 int totalOK, totalNotOK, totalBusy; /*Dummies - we don't really count here */
1493 XDisplayFormat(a_xInfoP, /*Ptr to extended volume info */
1494 a_srvID, /*Server ID to print */
1495 a_partID, /*Partition ID to print */
1496 &totalOK, /*Ptr to total-OK counter */
1497 &totalNotOK, /*Ptr to total-screwed counter */
1498 &totalBusy, /*Ptr to total-busy counter */
1499 0, /*Don't do a fast listing */
1500 1, /*Do a long listing */
1501 1); /*Show volume problems */
1507 VolumeStats_int(volintInfo *pntr, struct nvldbentry *entry, afs_uint32 server,
1508 afs_int32 part, int voltype)
1514 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy, 0, 1,
1519 /* command to forcibly remove a volume */
1521 NukeVolume(struct cmd_syndesc *as)
1530 server = GetServer(tp = as->parms[0].items->data);
1532 fprintf(STDERR, "vos: server '%s' not found in host table\n", tp);
1536 partID = volutil_GetPartitionID(tp = as->parms[1].items->data);
1538 fprintf(STDERR, "vos: could not parse '%s' as a partition name", tp);
1542 volID = vsu_GetVolumeID(tp = as->parms[2].items->data, cstruct, &err);
1545 PrintError("", err);
1548 "vos: could not parse '%s' as a numeric volume ID", tp);
1553 "vos: forcibly removing all traces of volume %d, please wait...",
1556 code = UV_NukeVolume(server, partID, volID);
1558 fprintf(STDOUT, "done.\n");
1560 fprintf(STDOUT, "failed with code %d.\n", code);
1564 /*------------------------------------------------------------------------
1565 * PRIVATE ExamineVolume
1568 * Routine used to examine a single volume, contacting the VLDB as
1569 * well as the Volume Server.
1572 * as : Ptr to parsed command line arguments.
1575 * 0 for a successful operation,
1576 * Otherwise, one of the ubik or VolServer error values.
1579 * Nothing interesting.
1583 *------------------------------------------------------------------------
1586 ExamineVolume(struct cmd_syndesc *as, void *arock)
1588 struct nvldbentry entry;
1589 afs_int32 vcode = 0;
1590 volintInfo *pntr = (volintInfo *) 0;
1591 volintXInfo *xInfoP = (volintXInfo *) 0;
1593 afs_int32 code, err, error = 0;
1594 int voltype, foundserv = 0, foundentry = 0;
1598 int wantExtendedInfo; /*Do we want extended vol info? */
1599 int isSubEnum=0; /* Keep track whether sub enumerate called. */
1600 wantExtendedInfo = (as->parms[1].items ? 1 : 0); /* -extended */
1602 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1605 PrintError("", err);
1607 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1608 as->parms[0].items->data);
1613 fprintf(STDOUT, "Fetching VLDB entry for %lu .. ",
1614 (unsigned long)volid);
1617 vcode = VLDB_GetEntryByID(volid, -1, &entry);
1620 "Could not fetch the entry for volume number %lu from VLDB \n",
1621 (unsigned long)volid);
1625 fprintf(STDOUT, "done\n");
1626 MapHostToNetwork(&entry);
1628 if (entry.volumeId[RWVOL] == volid)
1630 else if (entry.volumeId[BACKVOL] == volid)
1632 else /* (entry.volumeId[ROVOL] == volid) */
1635 do { /* do {...} while (voltype == ROVOL) */
1636 /* Get the entry for the volume. If its a RW vol, get the RW entry.
1637 * It its a BK vol, get the RW entry (even if VLDB may say the BK doen't exist).
1638 * If its a RO vol, get the next RO entry.
1640 foundentry = GetServerAndPart(&entry, ((voltype == ROVOL) ? ROVOL : RWVOL),
1641 &aserver, &apart, &previdx);
1642 if (!foundentry) { /* searched all entries */
1643 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1644 as->parms[0].items->data);
1649 /* Get information about the volume from the server */
1651 fprintf(STDOUT, "Getting volume listing from the server %s .. ",
1652 hostutil_GetNameByINet(aserver));
1655 if (wantExtendedInfo)
1656 code = UV_XListOneVolume(aserver, apart, volid, &xInfoP);
1658 code = UV_ListOneVolume(aserver, apart, volid, &pntr);
1660 fprintf(STDOUT, "done\n");
1664 if (code == ENODEV) {
1665 if ((voltype == BACKVOL) && !(entry.flags & VLF_BACKEXISTS)) {
1666 /* The VLDB says there is no backup volume and its not on disk */
1667 fprintf(STDERR, "Volume %s does not exist\n",
1668 as->parms[0].items->data);
1672 "Volume does not exist on server %s as indicated by the VLDB\n",
1673 hostutil_GetNameByINet(aserver));
1676 PrintDiagnostics("examine", code);
1678 fprintf(STDOUT, "\n");
1681 if (wantExtendedInfo)
1682 XVolumeStats(xInfoP, &entry, aserver, apart, voltype);
1683 else if (as->parms[2].items) {
1684 DisplayFormat2(aserver, apart, pntr);
1685 EnumerateEntry(&entry);
1688 VolumeStats_int(pntr, &entry, aserver, apart, voltype);
1690 if ((voltype == BACKVOL) && !(entry.flags & VLF_BACKEXISTS)) {
1691 /* The VLDB says there is no backup volume yet we found one on disk */
1692 fprintf(STDERR, "Volume %s does not exist in VLDB\n",
1693 as->parms[0].items->data);
1702 } while (voltype == ROVOL);
1705 fprintf(STDERR, "Dump only information from VLDB\n\n");
1706 fprintf(STDOUT, "%s \n", entry.name); /* PostVolumeStats doesn't print name */
1710 PostVolumeStats(&entry);
1715 /*------------------------------------------------------------------------
1719 * Routine used to change the status of a single volume.
1722 * as : Ptr to parsed command line arguments.
1725 * 0 for a successful operation,
1726 * Otherwise, one of the ubik or VolServer error values.
1729 * Nothing interesting.
1733 *------------------------------------------------------------------------
1736 SetFields(struct cmd_syndesc *as, void *arock)
1738 struct nvldbentry entry;
1741 afs_int32 code, err;
1748 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1751 PrintError("", err);
1753 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1754 as->parms[0].items->data);
1758 code = VLDB_GetEntryByID(volid, RWVOL, &entry);
1761 "Could not fetch the entry for volume number %lu from VLDB \n",
1762 (unsigned long)volid);
1765 MapHostToNetwork(&entry);
1767 found = GetServerAndPart(&entry, RWVOL, &aserver, &apart, &previdx);
1769 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1770 as->parms[0].items->data);
1774 init_volintInfo(&info);
1778 if (as->parms[1].items) {
1781 code = util_GetHumanInt32(as->parms[1].items->data, &info.maxquota);
1783 fprintf(STDERR, "invalid quota value\n");
1787 if (as->parms[2].items) {
1792 if (as->parms[3].items) {
1793 /* -clearVolUpCounter */
1798 fprintf(STDERR,"Nothing to set.\n");
1801 code = UV_SetVolumeInfo(aserver, apart, volid, &info);
1804 "Could not update volume info fields for volume number %lu\n",
1805 (unsigned long)volid);
1809 /*------------------------------------------------------------------------
1813 * Brings a volume online.
1816 * as : Ptr to parsed command line arguments.
1819 * 0 for a successful operation,
1822 * Nothing interesting.
1826 *------------------------------------------------------------------------
1829 volOnline(struct cmd_syndesc *as, void *arock)
1832 afs_int32 partition;
1834 afs_int32 code, err = 0;
1836 server = GetServer(as->parms[0].items->data);
1838 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1839 as->parms[0].items->data);
1843 partition = volutil_GetPartitionID(as->parms[1].items->data);
1844 if (partition < 0) {
1845 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1846 as->parms[1].items->data);
1850 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1853 PrintError("", err);
1855 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1856 as->parms[0].items->data);
1860 code = UV_SetVolume(server, partition, volid, ITOffline, 0 /*online */ ,
1863 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1870 /*------------------------------------------------------------------------
1871 * PRIVATE volOffline
1874 * Brings a volume offline.
1877 * as : Ptr to parsed command line arguments.
1880 * 0 for a successful operation,
1883 * Nothing interesting.
1887 *------------------------------------------------------------------------
1890 volOffline(struct cmd_syndesc *as, void *arock)
1893 afs_int32 partition;
1895 afs_int32 code, err = 0;
1896 afs_int32 transflag, sleeptime, transdone;
1898 server = GetServer(as->parms[0].items->data);
1900 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1901 as->parms[0].items->data);
1905 partition = volutil_GetPartitionID(as->parms[1].items->data);
1906 if (partition < 0) {
1907 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1908 as->parms[1].items->data);
1912 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1915 PrintError("", err);
1917 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1918 as->parms[0].items->data);
1922 transflag = (as->parms[4].items ? ITBusy : ITOffline);
1923 sleeptime = (as->parms[3].items ? atol(as->parms[3].items->data) : 0);
1924 transdone = ((sleeptime || as->parms[4].items) ? 0 /*online */ : VTOutOfService);
1925 if (as->parms[4].items && !as->parms[3].items) {
1926 fprintf(STDERR, "-sleep option must be used with -busy flag\n");
1931 UV_SetVolume(server, partition, volid, transflag, transdone,
1934 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1942 CreateVolume(struct cmd_syndesc *as, void *arock)
1946 afs_uint32 volid = 0, rovolid = 0, bkvolid = 0;
1947 afs_uint32 *arovolid;
1949 struct nvldbentry entry;
1954 arovolid = &rovolid;
1957 tserver = GetServer(as->parms[0].items->data);
1959 fprintf(STDERR, "vos: host '%s' not found in host table\n",
1960 as->parms[0].items->data);
1963 pnum = volutil_GetPartitionID(as->parms[1].items->data);
1965 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1966 as->parms[1].items->data);
1969 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
1971 PrintError("", code);
1974 "vos : partition %s does not exist on the server\n",
1975 as->parms[1].items->data);
1978 if (!ISNAMEVALID(as->parms[2].items->data)) {
1980 "vos: the name of the root volume %s exceeds the size limit of %d\n",
1981 as->parms[2].items->data, VOLSER_OLDMAXVOLNAME - 10);
1984 if (!VolNameOK(as->parms[2].items->data)) {
1986 "Illegal volume name %s, should not end in .readonly or .backup\n",
1987 as->parms[2].items->data);
1990 if (IsNumeric(as->parms[2].items->data)) {
1991 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
1992 as->parms[2].items->data);
1995 vcode = VLDB_GetEntryByName(as->parms[2].items->data, &entry);
1997 fprintf(STDERR, "Volume %s already exists\n",
1998 as->parms[2].items->data);
1999 PrintDiagnostics("create", code);
2003 if (as->parms[3].items) {
2004 code = util_GetHumanInt32(as->parms[3].items->data, "a);
2006 fprintf(STDERR, "vos: bad integer specified for quota.\n");
2011 if (as->parms[4].items) {
2012 if (!IsNumeric(as->parms[4].items->data)) {
2013 fprintf(STDERR, "vos: Given volume ID %s should be numeric.\n",
2014 as->parms[4].items->data);
2018 code = util_GetUInt32(as->parms[4].items->data, &volid);
2020 fprintf(STDERR, "vos: bad integer specified for volume ID.\n");
2025 if (as->parms[5].items) {
2026 if (!IsNumeric(as->parms[5].items->data)) {
2027 fprintf(STDERR, "vos: Given RO volume ID %s should be numeric.\n",
2028 as->parms[5].items->data);
2032 code = util_GetUInt32(as->parms[5].items->data, &rovolid);
2034 fprintf(STDERR, "vos: bad integer specified for volume ID.\n");
2044 UV_CreateVolume3(tserver, pnum, as->parms[2].items->data, quota, 0,
2045 0, 0, 0, &volid, arovolid, &bkvolid);
2047 PrintDiagnostics("create", code);
2050 MapPartIdIntoName(pnum, part);
2051 fprintf(STDOUT, "Volume %lu created on partition %s of %s\n",
2052 (unsigned long)volid, part, as->parms[0].items->data);
2058 DeleteVolume(struct cmd_syndesc *as, void *arock)
2060 afs_int32 err, code = 0;
2061 afs_uint32 server = 0;
2062 afs_int32 partition = -1;
2067 if (as->parms[1].items && !as->parms[0].items) {
2068 fprintf(STDERR, "vos: The -partition option requires the -server option.\n");
2072 if (as->parms[0].items) {
2073 server = GetServer(as->parms[0].items->data);
2075 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2076 as->parms[0].items->data);
2081 if (as->parms[1].items) {
2082 partition = volutil_GetPartitionID(as->parms[1].items->data);
2083 if (partition < 0) {
2084 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2085 as->parms[1].items->data);
2089 /* Check for validity of the partition */
2090 if (!IsPartValid(partition, server, &code)) {
2092 PrintError("", code);
2095 "vos : partition %s does not exist on the server\n",
2096 as->parms[1].items->data);
2102 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
2104 fprintf(STDERR, "Can't find volume name '%s' in VLDB\n",
2105 as->parms[2].items->data);
2107 PrintError("", err);
2111 /* If the server or partition option are not complete, try to fill
2112 * them in from the VLDB entry.
2114 if ((partition == -1) || !server) {
2115 struct nvldbentry entry;
2117 code = VLDB_GetEntryByID(volid, -1, &entry);
2120 "Could not fetch the entry for volume %lu from VLDB\n",
2121 (unsigned long)volid);
2122 PrintError("", code);
2126 if (((volid == entry.volumeId[RWVOL]) && (entry.flags & VLF_RWEXISTS))
2127 || ((volid == entry.volumeId[BACKVOL])
2128 && (entry.flags & VLF_BACKEXISTS))) {
2129 idx = Lp_GetRwIndex(&entry);
2130 if ((idx == -1) || (server && (server != entry.serverNumber[idx]))
2131 || ((partition != -1)
2132 && (partition != entry.serverPartition[idx]))) {
2133 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2134 as->parms[2].items->data);
2137 } else if ((volid == entry.volumeId[ROVOL])
2138 && (entry.flags & VLF_ROEXISTS)) {
2139 for (idx = -1, j = 0; j < entry.nServers; j++) {
2140 if (!(entry.serverFlags[j] & VLSF_ROVOL))
2143 if (((server == 0) || (server == entry.serverNumber[j]))
2144 && ((partition == -1)
2145 || (partition == entry.serverPartition[j]))) {
2148 "VLDB: Volume '%s' matches more than one RO\n",
2149 as->parms[2].items->data);
2156 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2157 as->parms[2].items->data);
2161 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2162 as->parms[2].items->data);
2166 server = htonl(entry.serverNumber[idx]);
2167 partition = entry.serverPartition[idx];
2170 code = UV_DeleteVolume(server, partition, volid);
2172 PrintDiagnostics("remove", code);
2176 MapPartIdIntoName(partition, pname);
2177 fprintf(STDOUT, "Volume %lu on partition %s server %s deleted\n",
2178 (unsigned long)volid, pname, hostutil_GetNameByINet(server));
2182 #define TESTM 0 /* set for move space tests, clear for production */
2184 MoveVolume(struct cmd_syndesc *as, void *arock)
2188 afs_uint32 fromserver, toserver;
2189 afs_int32 frompart, topart;
2190 afs_int32 flags, code, err;
2191 char fromPartName[10], toPartName[10];
2193 struct diskPartition64 partition; /* for space check */
2196 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2199 PrintError("", err);
2201 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2202 as->parms[0].items->data);
2205 fromserver = GetServer(as->parms[1].items->data);
2206 if (fromserver == 0) {
2207 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2208 as->parms[1].items->data);
2211 toserver = GetServer(as->parms[3].items->data);
2212 if (toserver == 0) {
2213 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2214 as->parms[3].items->data);
2217 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2219 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2220 as->parms[2].items->data);
2223 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2225 PrintError("", code);
2228 "vos : partition %s does not exist on the server\n",
2229 as->parms[2].items->data);
2232 topart = volutil_GetPartitionID(as->parms[4].items->data);
2234 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2235 as->parms[4].items->data);
2238 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2240 PrintError("", code);
2243 "vos : partition %s does not exist on the server\n",
2244 as->parms[4].items->data);
2249 if (as->parms[5].items) flags |= RV_NOCLONE;
2252 * check source partition for space to clone volume
2255 MapPartIdIntoName(topart, toPartName);
2256 MapPartIdIntoName(frompart, fromPartName);
2259 * check target partition for space to move volume
2262 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2264 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2268 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2271 p = (volintInfo *) 0;
2272 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2274 fprintf(STDERR, "vos:cannot access volume %lu\n",
2275 (unsigned long)volid);
2279 fprintf(STDOUT, "volume %lu size %d\n", (unsigned long)volid,
2281 if (partition.free <= p->size) {
2283 "vos: no space on target partition %s to move volume %lu\n",
2284 toPartName, (unsigned long)volid);
2291 fprintf(STDOUT, "size test - don't do move\n");
2295 /* successful move still not guaranteed but shoot for it */
2298 UV_MoveVolume2(volid, fromserver, frompart, toserver, topart, flags);
2300 PrintDiagnostics("move", code);
2303 MapPartIdIntoName(topart, toPartName);
2304 MapPartIdIntoName(frompart, fromPartName);
2305 fprintf(STDOUT, "Volume %lu moved from %s %s to %s %s \n",
2306 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2307 as->parms[3].items->data, toPartName);
2313 CopyVolume(struct cmd_syndesc *as, void *arock)
2316 afs_uint32 fromserver, toserver;
2317 afs_int32 frompart, topart, code, err, flags;
2318 char fromPartName[10], toPartName[10], *tovolume;
2319 struct nvldbentry entry;
2320 struct diskPartition64 partition; /* for space check */
2323 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2326 PrintError("", err);
2328 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2329 as->parms[0].items->data);
2332 fromserver = GetServer(as->parms[1].items->data);
2333 if (fromserver == 0) {
2334 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2335 as->parms[1].items->data);
2339 toserver = GetServer(as->parms[4].items->data);
2340 if (toserver == 0) {
2341 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2342 as->parms[4].items->data);
2346 tovolume = as->parms[3].items->data;
2347 if (!ISNAMEVALID(tovolume)) {
2349 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2350 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2353 if (!VolNameOK(tovolume)) {
2355 "Illegal volume name %s, should not end in .readonly or .backup\n",
2359 if (IsNumeric(tovolume)) {
2360 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
2364 code = VLDB_GetEntryByName(tovolume, &entry);
2366 fprintf(STDERR, "Volume %s already exists\n", tovolume);
2367 PrintDiagnostics("copy", code);
2371 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2373 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2374 as->parms[2].items->data);
2377 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2379 PrintError("", code);
2382 "vos : partition %s does not exist on the server\n",
2383 as->parms[2].items->data);
2387 topart = volutil_GetPartitionID(as->parms[5].items->data);
2389 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2390 as->parms[5].items->data);
2393 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2395 PrintError("", code);
2398 "vos : partition %s does not exist on the server\n",
2399 as->parms[5].items->data);
2404 if (as->parms[6].items) flags |= RV_OFFLINE;
2405 if (as->parms[7].items) flags |= RV_RDONLY;
2406 if (as->parms[8].items) flags |= RV_NOCLONE;
2408 MapPartIdIntoName(topart, toPartName);
2409 MapPartIdIntoName(frompart, fromPartName);
2412 * check target partition for space to move volume
2415 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2417 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2421 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2424 p = (volintInfo *) 0;
2425 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2427 fprintf(STDERR, "vos:cannot access volume %lu\n",
2428 (unsigned long)volid);
2432 if (partition.free <= p->size) {
2434 "vos: no space on target partition %s to copy volume %lu\n",
2435 toPartName, (unsigned long)volid);
2441 /* successful copy still not guaranteed but shoot for it */
2444 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2447 PrintDiagnostics("copy", code);
2450 MapPartIdIntoName(topart, toPartName);
2451 MapPartIdIntoName(frompart, fromPartName);
2452 fprintf(STDOUT, "Volume %lu copied from %s %s to %s on %s %s \n",
2453 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2454 tovolume, as->parms[4].items->data, toPartName);
2460 ShadowVolume(struct cmd_syndesc *as, void *arock)
2462 afs_uint32 volid, tovolid;
2463 afs_uint32 fromserver, toserver;
2464 afs_int32 frompart, topart;
2465 afs_int32 code, err, flags;
2466 char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
2467 struct diskPartition64 partition; /* for space check */
2470 p = (volintInfo *) 0;
2471 q = (volintInfo *) 0;
2473 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2476 PrintError("", err);
2478 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2479 as->parms[0].items->data);
2482 fromserver = GetServer(as->parms[1].items->data);
2483 if (fromserver == 0) {
2484 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2485 as->parms[1].items->data);
2489 toserver = GetServer(as->parms[3].items->data);
2490 if (toserver == 0) {
2491 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2492 as->parms[3].items->data);
2496 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2498 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2499 as->parms[2].items->data);
2502 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2504 PrintError("", code);
2507 "vos : partition %s does not exist on the server\n",
2508 as->parms[2].items->data);
2512 topart = volutil_GetPartitionID(as->parms[4].items->data);
2514 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2515 as->parms[4].items->data);
2518 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2520 PrintError("", code);
2523 "vos : partition %s does not exist on the server\n",
2524 as->parms[4].items->data);
2528 if (as->parms[5].items) {
2529 tovolume = as->parms[5].items->data;
2530 if (!ISNAMEVALID(tovolume)) {
2532 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2533 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2536 if (!VolNameOK(tovolume)) {
2538 "Illegal volume name %s, should not end in .readonly or .backup\n",
2542 if (IsNumeric(tovolume)) {
2544 "Illegal volume name %s, should not be a number\n",
2549 /* use actual name of source volume */
2550 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2552 fprintf(STDERR, "vos:cannot access volume %lu\n",
2553 (unsigned long)volid);
2556 strcpy(toVolName, p->name);
2557 tovolume = toVolName;
2558 /* save p for size checks later */
2561 if (as->parms[6].items) {
2562 tovolid = vsu_GetVolumeID(as->parms[6].items->data, cstruct, &err);
2565 PrintError("", err);
2567 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2568 as->parms[6].items->data);
2574 tovolid = vsu_GetVolumeID(tovolume, cstruct, &err);
2577 PrintError("", err);
2579 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2588 if (as->parms[7].items) flags |= RV_OFFLINE;
2589 if (as->parms[8].items) flags |= RV_RDONLY;
2590 if (as->parms[9].items) flags |= RV_NOCLONE;
2591 if (as->parms[10].items) flags |= RV_CPINCR;
2593 MapPartIdIntoName(topart, toPartName);
2594 MapPartIdIntoName(frompart, fromPartName);
2597 * check target partition for space to move volume
2600 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2602 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2606 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2609 /* Don't do this again if we did it above */
2611 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2613 fprintf(STDERR, "vos:cannot access volume %lu\n",
2614 (unsigned long)volid);
2619 /* OK if this fails */
2620 code = UV_ListOneVolume(toserver, topart, tovolid, &q);
2622 /* Treat existing volume size as "free" */
2624 p->size = (q->size < p->size) ? p->size - q->size : 0;
2626 if (partition.free <= p->size) {
2628 "vos: no space on target partition %s to copy volume %lu\n",
2629 toPartName, (unsigned long)volid);
2637 /* successful copy still not guaranteed but shoot for it */
2640 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2641 topart, tovolid, flags);
2643 PrintDiagnostics("shadow", code);
2646 MapPartIdIntoName(topart, toPartName);
2647 MapPartIdIntoName(frompart, fromPartName);
2648 fprintf(STDOUT, "Volume %lu shadowed from %s %s to %s %s \n",
2649 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2650 as->parms[3].items->data, toPartName);
2656 CloneVolume(struct cmd_syndesc *as, void *arock)
2658 afs_uint32 volid, cloneid;
2660 afs_int32 part, voltype;
2661 char partName[10], *volname;
2662 afs_int32 code, err, flags;
2663 struct nvldbentry entry;
2665 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2668 PrintError("", err);
2670 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2671 as->parms[0].items->data);
2675 if (as->parms[1].items || as->parms[2].items) {
2676 if (!as->parms[1].items || !as->parms[2].items) {
2678 "Must specify both -server and -partition options\n");
2681 server = GetServer(as->parms[1].items->data);
2683 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2684 as->parms[1].items->data);
2687 part = volutil_GetPartitionID(as->parms[2].items->data);
2689 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2690 as->parms[2].items->data);
2693 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
2695 PrintError("", code);
2698 "vos : partition %s does not exist on the server\n",
2699 as->parms[2].items->data);
2703 code = GetVolumeInfo(volid, &server, &part, &voltype, &entry);
2709 if (as->parms[3].items) {
2710 volname = as->parms[3].items->data;
2711 if (strlen(volname) > VOLSER_OLDMAXVOLNAME - 1) {
2713 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2714 volname, VOLSER_OLDMAXVOLNAME - 1);
2717 if (IsNumeric(volname)) {
2719 "Illegal volume name %s, should not be a number\n",
2726 if (as->parms[4].items) {
2727 cloneid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2730 PrintError("", err);
2732 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2733 as->parms[4].items->data);
2739 if (as->parms[5].items) flags |= RV_OFFLINE;
2740 if (as->parms[6].items && as->parms[7].items) {
2741 fprintf(STDERR, "vos: cannot specify that a volume be -readwrite and -readonly\n");
2744 if (as->parms[6].items) flags |= RV_RDONLY;
2745 if (as->parms[7].items) flags |= RV_RWONLY;
2748 UV_CloneVolume(server, part, volid, cloneid, volname, flags);
2751 PrintDiagnostics("clone", code);
2754 MapPartIdIntoName(part, partName);
2755 fprintf(STDOUT, "Created clone for volume %s\n",
2756 as->parms[0].items->data);
2762 BackupVolume(struct cmd_syndesc *as, void *arock)
2766 afs_int32 apart, vtype, code, err;
2767 struct nvldbentry entry;
2770 afs_uint32 buserver;
2771 afs_int32 bupart, butype;
2772 struct nvldbentry buentry;
2774 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2777 PrintError("", err);
2779 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2780 as->parms[0].items->data);
2783 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2787 /* verify this is a readwrite volume */
2789 if (vtype != RWVOL) {
2790 fprintf(STDERR, "%s not RW volume\n", as->parms[0].items->data);
2794 /* is there a backup volume already? */
2796 if (entry.flags & VLF_BACKEXISTS) {
2797 /* yep, where is it? */
2799 buvolid = entry.volumeId[BACKVOL];
2800 code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
2805 code = VLDB_IsSameAddrs(buserver, aserver, &err);
2808 "Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
2814 "FATAL ERROR: backup volume %lu exists on server %lu\n",
2815 (unsigned long)buvolid, (unsigned long)buserver);
2820 /* nope, carry on */
2822 code = UV_BackupVolume(aserver, apart, avolid);
2825 PrintDiagnostics("backup", code);
2828 fprintf(STDOUT, "Created backup volume for %s \n",
2829 as->parms[0].items->data);
2834 ReleaseVolume(struct cmd_syndesc *as, void *arock)
2837 struct nvldbentry entry;
2840 afs_int32 apart, vtype, code, err;
2843 if (as->parms[1].items) /* -force */
2844 flags |= (REL_COMPLETE | REL_FULLDUMPS);
2845 if (as->parms[2].items) { /* -stayonline */
2846 fprintf(STDERR, "vos: -stayonline not supported\n");
2849 if (as->parms[3].items) /* -force-reclone */
2850 flags |= REL_COMPLETE;
2852 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2855 PrintError("", err);
2857 fprintf(STDERR, "vos: can't find volume '%s'\n",
2858 as->parms[0].items->data);
2861 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2865 if (vtype != RWVOL) {
2866 fprintf(STDERR, "%s not a RW volume\n", as->parms[0].items->data);
2870 if (!ISNAMEVALID(entry.name)) {
2872 "Volume name %s is too long, rename before releasing\n",
2877 code = UV_ReleaseVolume(avolid, aserver, apart, flags);
2880 PrintDiagnostics("release", code);
2883 fprintf(STDOUT, "Released volume %s successfully\n",
2884 as->parms[0].items->data);
2889 DumpVolumeCmd(struct cmd_syndesc *as, void *arock)
2893 afs_int32 apart, voltype, fromdate = 0, code, err, i, flags;
2894 char filename[MAXPATHLEN];
2895 struct nvldbentry entry;
2897 rx_SetRxDeadTime(60 * 10);
2898 for (i = 0; i < MAXSERVERS; i++) {
2899 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
2902 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
2903 if (rx_ServiceOf(rxConn))
2904 rx_ServiceOf(rxConn)->connDeadTime = rx_connDeadTime;
2907 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2910 PrintError("", err);
2912 fprintf(STDERR, "vos: can't find volume '%s'\n",
2913 as->parms[0].items->data);
2917 if (as->parms[3].items || as->parms[4].items) {
2918 if (!as->parms[3].items || !as->parms[4].items) {
2920 "Must specify both -server and -partition options\n");
2923 aserver = GetServer(as->parms[3].items->data);
2925 fprintf(STDERR, "Invalid server name\n");
2928 apart = volutil_GetPartitionID(as->parms[4].items->data);
2930 fprintf(STDERR, "Invalid partition name\n");
2934 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
2939 if (as->parms[1].items && strcmp(as->parms[1].items->data, "0")) {
2940 code = ktime_DateToInt32(as->parms[1].items->data, &fromdate);
2942 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
2943 as->parms[1].items->data, code);
2947 if (as->parms[2].items) {
2948 strcpy(filename, as->parms[2].items->data);
2950 strcpy(filename, "");
2953 flags = as->parms[6].items ? VOLDUMPV2_OMITDIRS : 0;
2955 if (as->parms[5].items) {
2957 UV_DumpClonedVolume(avolid, aserver, apart, fromdate,
2958 DumpFunction, filename, flags);
2961 UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction,
2964 if ((code == RXGEN_OPCODE) && (as->parms[6].items)) {
2965 flags &= ~VOLDUMPV2_OMITDIRS;
2969 PrintDiagnostics("dump", code);
2972 if (strcmp(filename, ""))
2973 fprintf(STDERR, "Dumped volume %s in file %s\n",
2974 as->parms[0].items->data, filename);
2976 fprintf(STDERR, "Dumped volume %s in stdout \n",
2977 as->parms[0].items->data);
2991 RestoreVolumeCmd(struct cmd_syndesc *as, void *arock)
2993 afs_uint32 avolid, aparentid;
2995 afs_int32 apart, code, vcode, err;
2996 afs_int32 aoverwrite = ASK;
2997 afs_int32 acreation = 0, alastupdate = 0;
2998 int restoreflags = 0;
2999 int readonly = 0, offline = 0, voltype = RWVOL;
3000 char afilename[MAXPATHLEN], avolname[VOLSER_MAXVOLNAME + 1], apartName[10];
3001 char volname[VOLSER_MAXVOLNAME + 1];
3002 struct nvldbentry entry;
3005 if (as->parms[4].items) {
3006 avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
3009 PrintError("", err);
3011 fprintf(STDERR, "vos: can't find volume '%s'\n",
3012 as->parms[4].items->data);
3018 if (as->parms[5].items) {
3019 if ((strcmp(as->parms[5].items->data, "a") == 0)
3020 || (strcmp(as->parms[5].items->data, "abort") == 0)) {
3022 } else if ((strcmp(as->parms[5].items->data, "f") == 0)
3023 || (strcmp(as->parms[5].items->data, "full") == 0)) {
3025 } else if ((strcmp(as->parms[5].items->data, "i") == 0)
3026 || (strcmp(as->parms[5].items->data, "inc") == 0)
3027 || (strcmp(as->parms[5].items->data, "increment") == 0)
3028 || (strcmp(as->parms[5].items->data, "incremental") == 0)) {
3031 fprintf(STDERR, "vos: %s is not a valid argument to -overwrite\n",
3032 as->parms[5].items->data);
3036 if (as->parms[6].items)
3038 if (as->parms[7].items) {
3043 if (as->parms[8].items) {
3044 if ((strcmp(as->parms[8].items->data, "d") == 0)
3045 || (strcmp(as->parms[8].items->data, "dump") == 0)) {
3046 acreation = TS_DUMP;
3047 } else if ((strcmp(as->parms[8].items->data, "k") == 0)
3048 || (strcmp(as->parms[8].items->data, "keep") == 0)) {
3049 acreation = TS_KEEP;
3050 } else if ((strcmp(as->parms[8].items->data, "n") == 0)
3051 || (strcmp(as->parms[8].items->data, "new") == 0)) {
3054 fprintf(STDERR, "vos: %s is not a valid argument to -creation\n",
3055 as->parms[8].items->data);
3060 if (as->parms[9].items) {
3061 if ((strcmp(as->parms[9].items->data, "d") == 0)
3062 || (strcmp(as->parms[9].items->data, "dump") == 0)) {
3063 alastupdate = TS_DUMP;
3064 } else if ((strcmp(as->parms[9].items->data, "k") == 0)
3065 || (strcmp(as->parms[9].items->data, "keep") == 0)) {
3066 alastupdate = TS_KEEP;
3067 } else if ((strcmp(as->parms[9].items->data, "n") == 0)
3068 || (strcmp(as->parms[9].items->data, "new") == 0)) {
3069 alastupdate = TS_NEW;
3071 fprintf(STDERR, "vos: %s is not a valid argument to -lastupdate\n",
3072 as->parms[9].items->data);
3077 aserver = GetServer(as->parms[0].items->data);
3079 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3080 as->parms[0].items->data);
3083 apart = volutil_GetPartitionID(as->parms[1].items->data);
3085 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3086 as->parms[1].items->data);
3089 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3091 PrintError("", code);
3094 "vos : partition %s does not exist on the server\n",
3095 as->parms[1].items->data);
3098 strcpy(avolname, as->parms[2].items->data);
3099 if (!ISNAMEVALID(avolname)) {
3101 "vos: the name of the volume %s exceeds the size limit\n",
3105 if (!VolNameOK(avolname)) {
3107 "Illegal volume name %s, should not end in .readonly or .backup\n",
3111 if (as->parms[3].items) {
3112 strcpy(afilename, as->parms[3].items->data);
3113 if (!FileExists(afilename)) {
3114 fprintf(STDERR, "Can't access file %s\n", afilename);
3118 strcpy(afilename, "");
3121 /* Check if volume exists or not */
3123 vsu_ExtractName(volname, avolname);
3124 vcode = VLDB_GetEntryByName(volname, &entry);
3125 if (vcode) { /* no volume - do a full restore */
3126 restoreflags = RV_FULLRST;
3127 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3129 "Volume does not exist; Will perform a full restore\n");
3132 else if ((!readonly && Lp_GetRwIndex(&entry) == -1) /* RW volume does not exist - do a full */
3133 ||(readonly && !Lp_ROMatch(0, 0, &entry))) { /* RO volume does not exist - do a full */
3134 restoreflags = RV_FULLRST;
3135 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3137 "%s Volume does not exist; Will perform a full restore\n",
3138 readonly ? "RO" : "RW");
3141 avolid = entry.volumeId[voltype];
3142 } else if (entry.volumeId[voltype] != 0
3143 && entry.volumeId[voltype] != avolid) {
3144 avolid = entry.volumeId[voltype];
3146 aparentid = entry.volumeId[RWVOL];
3149 else { /* volume exists - do we do a full incremental or abort */
3151 afs_int32 Opart, Otype, vol_elsewhere = 0;
3152 struct nvldbentry Oentry;
3156 avolid = entry.volumeId[voltype];
3157 } else if (entry.volumeId[voltype] != 0
3158 && entry.volumeId[voltype] != avolid) {
3159 avolid = entry.volumeId[voltype];
3161 aparentid = entry.volumeId[RWVOL];
3163 /* A file name was specified - check if volume is on another partition */
3164 vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
3168 vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
3171 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
3175 if (!vcode || (Opart != apart))
3178 if (aoverwrite == ASK) {
3179 if (strcmp(afilename, "") == 0) { /* The file is from standard in */
3181 "Volume exists and no -overwrite option specified; Aborting restore command\n");
3185 /* Ask what to do */
3186 if (vol_elsewhere) {
3188 "The volume %s %u already exists on a different server/part\n",
3189 volname, entry.volumeId[voltype]);
3191 "Do you want to do a full restore or abort? [fa](a): ");
3194 "The volume %s %u already exists in the VLDB\n",
3195 volname, entry.volumeId[voltype]);
3197 "Do you want to do a full/incremental restore or abort? [fia](a): ");
3200 while (!(dc == EOF || dc == '\n'))
3201 dc = getchar(); /* goto end of line */
3202 if ((c == 'f') || (c == 'F'))
3204 else if ((c == 'i') || (c == 'I'))
3210 if (aoverwrite == ABORT) {
3211 fprintf(STDERR, "Volume exists; Aborting restore command\n");
3213 } else if (aoverwrite == FULL) {
3214 restoreflags = RV_FULLRST;
3216 "Volume exists; Will delete and perform full restore\n");
3217 } else if (aoverwrite == INC) {
3219 if (vol_elsewhere) {
3221 "%s volume %lu already exists on a different server/part; not allowed\n",
3222 readonly ? "RO" : "RW", (unsigned long)avolid);
3228 restoreflags |= RV_OFFLINE;
3230 restoreflags |= RV_RDONLY;
3232 switch (acreation) {
3234 restoreflags |= RV_CRDUMP;
3237 restoreflags |= RV_CRKEEP;
3240 restoreflags |= RV_CRNEW;
3243 if (aoverwrite == FULL)
3244 restoreflags |= RV_CRNEW;
3246 restoreflags |= RV_CRKEEP;
3249 switch (alastupdate) {
3251 restoreflags |= RV_LUDUMP;
3254 restoreflags |= RV_LUKEEP;
3257 restoreflags |= RV_LUNEW;
3260 restoreflags |= RV_LUDUMP;
3262 if (as->parms[10].items) {
3263 restoreflags |= RV_NODEL;
3267 UV_RestoreVolume2(aserver, apart, avolid, aparentid,
3268 avolname, restoreflags, WriteData, afilename);
3270 PrintDiagnostics("restore", code);
3273 MapPartIdIntoName(apart, apartName);
3275 fprintf(STDOUT, "Restored volume %s on %s %s\n", avolname,
3276 as->parms[0].items->data, apartName);
3281 LockReleaseCmd(struct cmd_syndesc *as, void *arock)
3284 afs_int32 code, err;
3286 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
3289 PrintError("", err);
3291 fprintf(STDERR, "vos: can't find volume '%s'\n",
3292 as->parms[0].items->data);
3296 code = UV_LockRelease(avolid);
3298 PrintDiagnostics("unlock", code);
3301 fprintf(STDOUT, "Released lock on vldb entry for volume %s\n",
3302 as->parms[0].items->data);
3307 AddSite(struct cmd_syndesc *as, void *arock)
3311 afs_int32 apart, code, err, arovolid, valid = 0;
3312 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3314 vsu_ExtractName(avolname, as->parms[2].items->data);;
3315 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3318 PrintError("", err);
3320 fprintf(STDERR, "vos: can't find volume '%s'\n",
3321 as->parms[2].items->data);
3325 if (as->parms[3].items) {
3326 vsu_ExtractName(avolname, as->parms[3].items->data);
3327 arovolid = vsu_GetVolumeID(avolname, cstruct, &err);
3329 fprintf(STDERR, "vos: invalid ro volume id '%s'\n",
3330 as->parms[3].items->data);
3334 aserver = GetServer(as->parms[0].items->data);
3336 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3337 as->parms[0].items->data);
3340 apart = volutil_GetPartitionID(as->parms[1].items->data);
3342 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3343 as->parms[1].items->data);
3346 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3348 PrintError("", code);
3351 "vos : partition %s does not exist on the server\n",
3352 as->parms[1].items->data);
3355 if (as->parms[4].items) {
3358 code = UV_AddSite2(aserver, apart, avolid, arovolid, valid);
3360 PrintDiagnostics("addsite", code);
3363 MapPartIdIntoName(apart, apartName);
3364 fprintf(STDOUT, "Added replication site %s %s for volume %s\n",
3365 as->parms[0].items->data, apartName, as->parms[2].items->data);
3370 RemoveSite(struct cmd_syndesc *as, void *arock)
3375 afs_int32 apart, code, err;
3376 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3378 vsu_ExtractName(avolname, as->parms[2].items->data);
3379 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3382 PrintError("", err);
3384 fprintf(STDERR, "vos: can't find volume '%s'\n",
3385 as->parms[2].items->data);
3388 aserver = GetServer(as->parms[0].items->data);
3390 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3391 as->parms[0].items->data);
3394 apart = volutil_GetPartitionID(as->parms[1].items->data);
3396 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3397 as->parms[1].items->data);
3401 * The partition validity check is skipped, since it is possible that the
3402 * partition has already been decomissioned.
3405 code = UV_RemoveSite(aserver, apart, avolid);
3407 PrintDiagnostics("remsite", code);
3410 MapPartIdIntoName(apart, apartName);
3411 fprintf(STDOUT, "Removed replication site %s %s for volume %s\n",
3412 as->parms[0].items->data, apartName, as->parms[2].items->data);
3417 ChangeLocation(struct cmd_syndesc *as, void *arock)
3421 afs_int32 apart, code, err;
3424 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3427 PrintError("", err);
3429 fprintf(STDERR, "vos: can't find volume '%s'\n",
3430 as->parms[2].items->data);
3433 aserver = GetServer(as->parms[0].items->data);
3435 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3436 as->parms[0].items->data);
3439 apart = volutil_GetPartitionID(as->parms[1].items->data);
3441 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3442 as->parms[1].items->data);
3445 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3447 PrintError("", code);
3450 "vos : partition %s does not exist on the server\n",
3451 as->parms[1].items->data);
3454 code = UV_ChangeLocation(aserver, apart, avolid);
3456 PrintDiagnostics("changeloc", code);
3459 MapPartIdIntoName(apart, apartName);
3460 fprintf(STDOUT, "Changed location to %s %s for volume %s\n",
3461 as->parms[0].items->data, apartName, as->parms[2].items->data);
3466 ListPartitions(struct cmd_syndesc *as, void *arock)
3470 struct partList dummyPartList;
3475 aserver = GetServer(as->parms[0].items->data);
3477 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3478 as->parms[0].items->data);
3482 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3484 PrintDiagnostics("listpart", code);
3488 fprintf(STDOUT, "The partitions on the server are:\n");
3489 for (i = 0; i < cnt; i++) {
3490 if (dummyPartList.partFlags[i] & PARTVALID) {
3491 memset(pname, 0, sizeof(pname));
3492 MapPartIdIntoName(dummyPartList.partId[i], pname);
3493 fprintf(STDOUT, " %10s ", pname);
3495 if ((i % 5) == 0 && (i != 0))
3496 fprintf(STDOUT, "\n");
3499 fprintf(STDOUT, "\n");
3500 fprintf(STDOUT, "Total: %d\n", total);
3506 CompareVolName(const void *p1, const void *p2)
3508 volintInfo *arg1, *arg2;
3510 arg1 = (volintInfo *) p1;
3511 arg2 = (volintInfo *) p2;
3512 return (strcmp(arg1->name, arg2->name));
3516 /*------------------------------------------------------------------------
3517 * PRIVATE XCompareVolName
3520 * Comparison routine for volume names coming from an extended
3524 * a_obj1P : Char ptr to first extended vol info object
3525 * a_obj1P : Char ptr to second extended vol info object
3528 * The value of strcmp() on the volume names within the passed
3529 * objects (i,e., -1, 0, or 1).
3532 * Passed to qsort() as the designated comparison routine.
3536 *------------------------------------------------------------------------*/
3539 XCompareVolName(const void *a_obj1P, const void *a_obj2P)
3540 { /*XCompareVolName */
3543 (((struct volintXInfo *)(a_obj1P))->name,
3544 ((struct volintXInfo *)(a_obj2P))->name));
3546 } /*XCompareVolName */
3549 CompareVolID(const void *p1, const void *p2)
3551 volintInfo *arg1, *arg2;
3553 arg1 = (volintInfo *) p1;
3554 arg2 = (volintInfo *) p2;
3555 if (arg1->volid == arg2->volid)
3557 if (arg1->volid > arg2->volid)
3564 /*------------------------------------------------------------------------
3565 * PRIVATE XCompareVolID
3568 * Comparison routine for volume IDs coming from an extended
3572 * a_obj1P : Char ptr to first extended vol info object
3573 * a_obj1P : Char ptr to second extended vol info object
3576 * The value of strcmp() on the volume names within the passed
3577 * objects (i,e., -1, 0, or 1).
3580 * Passed to qsort() as the designated comparison routine.
3584 *------------------------------------------------------------------------*/
3587 XCompareVolID(const void *a_obj1P, const void *a_obj2P)
3588 { /*XCompareVolID */
3590 afs_int32 id1, id2; /*Volume IDs we're comparing */
3592 id1 = ((struct volintXInfo *)(a_obj1P))->volid;
3593 id2 = ((struct volintXInfo *)(a_obj2P))->volid;
3601 } /*XCompareVolID */
3603 /*------------------------------------------------------------------------
3604 * PRIVATE ListVolumes
3607 * Routine used to list volumes, contacting the Volume Server
3608 * directly, bypassing the VLDB.
3611 * as : Ptr to parsed command line arguments.
3614 * 0 Successful operation
3617 * Nothing interesting.
3621 *------------------------------------------------------------------------*/
3624 ListVolumes(struct cmd_syndesc *as, void *arock)
3626 afs_int32 apart, int32list, fast;
3630 volintInfo *oldpntr = NULL;
3634 volintXInfo *xInfoP;
3635 volintXInfo *origxInfoP = NULL; /*Ptr to current/orig extended vol info */
3636 int wantExtendedInfo; /*Do we want extended vol info? */
3639 struct partList dummyPartList;
3647 if (as->parms[3].items)
3649 if (as->parms[4].items)
3653 if (as->parms[2].items)