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>
14 #include <sys/types.h>
24 #include <netinet/in.h>
25 #include <arpa/inet.h>
29 #include <sys/statfs.h>
37 #include <rx/rx_globals.h>
39 #include <afs/vlserver.h>
40 #include <afs/cellconfig.h>
42 #include <afs/afsutil.h>
44 #include <afs/afsint.h>
49 #include <afs/ihandle.h>
50 #include <afs/vnode.h>
51 #include <afs/volume.h>
58 #include "volser_prototypes.h"
59 #include "vsutils_prototypes.h"
60 #include "lockprocs_prototypes.h"
62 #ifdef HAVE_POSIX_REGEX
66 /* Local Prototypes */
67 int PrintDiagnostics(char *astring, afs_int32 acode);
68 int GetVolumeInfo(afs_uint32 volid, afs_int32 *server, afs_int32 *part,
69 afs_int32 *voltype, struct nvldbentry *rentry);
81 #define COMMONPARMS cmd_Seek(ts, 12);\
82 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");\
83 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "don't authenticate");\
84 cmd_AddParm(ts, "-localauth",CMD_FLAG,CMD_OPTIONAL,"use server tickets");\
85 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose");\
86 cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL, "encrypt commands");\
87 cmd_AddParm(ts, "-noresolve", CMD_FLAG, CMD_OPTIONAL, "don't resolve addresses"); \
89 #define ERROR_EXIT(code) {error=(code); goto error_exit;}
92 struct rx_connection *tconn;
94 extern struct ubik_client *cstruct;
97 static struct tqHead busyHead, notokHead;
100 qInit(struct tqHead *ahead)
102 memset((char *)ahead, 0, sizeof(struct tqHead));
108 qPut(struct tqHead *ahead, afs_uint32 volid)
112 elem = (struct tqElem *)malloc(sizeof(struct tqElem));
113 elem->next = ahead->next;
121 qGet(struct tqHead *ahead, afs_uint32 *volid)
125 if (ahead->count <= 0)
127 *volid = ahead->next->volid;
129 ahead->next = tmp->next;
135 /* returns 1 if <filename> exists else 0 */
137 FileExists(char *filename)
143 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
147 code = USD_IOCTL(ufd, USD_IOCTL_GETSIZE, &size);
155 /* returns 1 if <name> doesnot end in .readonly or .backup, else 0 */
157 VolNameOK(char *name)
162 total = strlen(name);
163 if (!strcmp(&name[total - 9], ".readonly")) {
165 } else if (!strcmp(&name[total - 7], ".backup")) {
172 /* return 1 if name is a number else 0 */
174 IsNumeric(char *name)
182 for (i = 0; i < len; i++) {
183 if (*ptr < '0' || *ptr > '9') {
195 * Parse a server name/address and return the address in HOST BYTE order
198 GetServer(char *aname)
200 register struct hostent *th;
203 register afs_int32 code;
204 char hostname[MAXHOSTCHARS];
206 code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
208 addr = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
209 addr = ntohl(addr); /* convert to host order */
211 th = gethostbyname(aname);
214 memcpy(&addr, th->h_addr, sizeof(addr));
217 if (addr == htonl(0x7f000001)) { /* local host */
218 code = gethostname(hostname, MAXHOSTCHARS);
221 th = gethostbyname(hostname); /* returns host byte order */
224 memcpy(&addr, th->h_addr, sizeof(addr));
231 GetVolumeType(char *aname)
234 if (!strcmp(aname, "ro"))
236 else if (!strcmp(aname, "rw"))
238 else if (!strcmp(aname, "bk"))
245 IsPartValid(afs_int32 partId, afs_int32 server, afs_int32 *code)
247 struct partList dummyPartList;
253 *code = UV_ListPartitions(server, &dummyPartList, &cnt);
256 for (i = 0; i < cnt; i++) {
257 if (dummyPartList.partFlags[i] & PARTVALID)
258 if (dummyPartList.partId[i] == partId)
266 /*sends the contents of file associated with <fd> and <blksize> to Rx Stream
267 * associated with <call> */
269 SendFile(usd_handle_t ufd, register struct rx_call *call, long blksize)
271 char *buffer = (char *)0;
276 buffer = (char *)malloc(blksize);
278 fprintf(STDERR, "malloc failed\n");
282 while (!error && !done) {
283 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
286 FD_SET((int)(ufd->handle), &in);
287 /* don't timeout if read blocks */
288 #if defined(AFS_PTHREAD_ENV)
289 select(((int)(ufd->handle)) + 1, &in, 0, 0, 0);
291 IOMGR_Select(((int)(ufd->handle)) + 1, &in, 0, 0, 0);
294 error = USD_READ(ufd, buffer, blksize, &nbytes);
296 fprintf(STDERR, "File system read failed\n");
303 if (rx_Write(call, buffer, nbytes) != nbytes) {
313 /* function invoked by UV_RestoreVolume, reads the data from rx_trx_stream and
314 * writes it out to the volume. */
316 WriteData(struct rx_call *call, void *rock)
318 char *filename = (char *) rock;
321 afs_int32 error, code;
323 afs_hyper_t filesize, currOffset;
329 if (!filename || !*filename) {
330 usd_StandardInput(&ufd);
334 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
337 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
340 fprintf(STDERR, "Could not access file '%s'\n", filename);
344 /* test if we have a valid dump */
345 hset64(filesize, 0, 0);
346 USD_SEEK(ufd, filesize, SEEK_END, &currOffset);
347 hset64(filesize, hgethi(currOffset), hgetlo(currOffset)-sizeof(afs_uint32));
348 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
349 USD_READ(ufd, (char *)&buffer, sizeof(afs_uint32), &got);
350 if ((got != sizeof(afs_uint32)) || (ntohl(buffer) != DUMPENDMAGIC)) {
351 fprintf(STDERR, "Signature missing from end of file '%s'\n", filename);
355 /* rewind, we are done */
356 hset64(filesize, 0, 0);
357 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
359 code = SendFile(ufd, call, blksize);
366 code = USD_CLOSE(ufd);
368 fprintf(STDERR, "Could not close dump file %s\n",
369 (filename && *filename) ? filename : "STDOUT");
377 /* Receive data from <call> stream into file associated
378 * with <fd> <blksize>
381 ReceiveFile(usd_handle_t ufd, struct rx_call *call, long blksize)
385 afs_uint32 bytesleft, w;
388 buffer = (char *)malloc(blksize);
390 fprintf(STDERR, "memory allocation failed\n");
394 while ((bytesread = rx_Read(call, buffer, blksize)) > 0) {
395 for (bytesleft = bytesread; bytesleft; bytesleft -= w) {
396 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
399 FD_SET((int)(ufd->handle), &out);
400 /* don't timeout if write blocks */
401 #if defined(AFS_PTHREAD_ENV)
402 select(((int)(ufd->handle)) + 1, &out, 0, 0, 0);
404 IOMGR_Select(((int)(ufd->handle)) + 1, 0, &out, 0, 0);
408 USD_WRITE(ufd, &buffer[bytesread - bytesleft], bytesleft, &w);
410 fprintf(STDERR, "File system write failed\n");
423 DumpFunction(struct rx_call *call, void *rock)
425 char *filename = (char *)rock;
426 usd_handle_t ufd; /* default is to stdout */
427 afs_int32 error = 0, code;
432 /* Open the output file */
433 if (!filename || !*filename) {
434 usd_StandardOutput(&ufd);
439 usd_Open(filename, USD_OPEN_CREATE | USD_OPEN_RDWR, 0666, &ufd);
443 code = USD_IOCTL(ufd, USD_IOCTL_SETSIZE, &size);
446 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
449 fprintf(STDERR, "Could not create file '%s'\n", filename);
450 ERROR_EXIT(VOLSERBADOP);
454 code = ReceiveFile(ufd, call, blksize);
459 /* Close the output file */
461 code = USD_CLOSE(ufd);
463 fprintf(STDERR, "Could not close dump file %s\n",
464 (filename && *filename) ? filename : "STDIN");
474 vos_ctime(afs_int32 *timep)
481 DisplayFormat(volintInfo *pntr, afs_int32 server, afs_int32 part,
482 int *totalOK, int *totalNotOK, int *totalBusy, int fast,
483 int longlist, int disp)
488 fprintf(STDOUT, "%-10lu\n", (unsigned long)pntr->volid);
489 } else if (longlist) {
490 if (pntr->status == VOK) {
491 fprintf(STDOUT, "%-32s ", pntr->name);
492 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
494 fprintf(STDOUT, "RW ");
496 fprintf(STDOUT, "RO ");
498 fprintf(STDOUT, "BK ");
499 fprintf(STDOUT, "%10d K ", pntr->size);
500 if (pntr->inUse == 1) {
501 fprintf(STDOUT, "On-line");
504 fprintf(STDOUT, "Off-line");
507 if (pntr->needsSalvaged == 1)
508 fprintf(STDOUT, "**needs salvage**");
509 fprintf(STDOUT, "\n");
510 MapPartIdIntoName(part, pname);
511 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(server),
513 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
514 (unsigned long)pntr->parentID,
515 (unsigned long)pntr->cloneID,
516 (unsigned long)pntr->backupID);
517 fprintf(STDOUT, " MaxQuota %10d K \n", pntr->maxquota);
518 fprintf(STDOUT, " Creation %s",
519 vos_ctime(& pntr->creationDate));
520 #ifdef FULL_LISTVOL_SWITCH
521 fprintf(STDOUT, " Copy %s",
522 vos_ctime( & pntr->copyDate));
523 if (!pntr->backupDate)
524 fprintf(STDOUT, " Backup Never\n");
526 fprintf(STDOUT, " Backup %s",
527 vos_ctime( & pntr->backupDate));
528 if (pntr->accessDate)
529 fprintf(STDOUT, " Last Access %s",
530 vos_ctime( & pntr->accessDate));
532 if (!pntr->updateDate)
533 fprintf(STDOUT, " Last Update Never\n");
535 fprintf(STDOUT, " Last Update %s",
536 vos_ctime( & pntr->updateDate));
538 " %d accesses in the past day (i.e., vnode references)\n",
540 } else if (pntr->status == VBUSY) {
542 qPut(&busyHead, pntr->volid);
544 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
545 (unsigned long)pntr->volid);
548 qPut(¬okHead, pntr->volid);
550 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
551 (unsigned long)pntr->volid);
553 fprintf(STDOUT, "\n");
554 } else { /* default listing */
555 if (pntr->status == VOK) {
556 fprintf(STDOUT, "%-32s ", pntr->name);
557 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
559 fprintf(STDOUT, "RW ");
561 fprintf(STDOUT, "RO ");
563 fprintf(STDOUT, "BK ");
564 fprintf(STDOUT, "%10d K ", pntr->size);
565 if (pntr->inUse == 1) {
566 fprintf(STDOUT, "On-line");
569 fprintf(STDOUT, "Off-line");
572 if (pntr->needsSalvaged == 1)
573 fprintf(STDOUT, "**needs salvage**");
574 fprintf(STDOUT, "\n");
575 } else if (pntr->status == VBUSY) {
577 qPut(&busyHead, pntr->volid);
579 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
580 (unsigned long)pntr->volid);
583 qPut(¬okHead, pntr->volid);
585 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
586 (unsigned long)pntr->volid);
591 /*------------------------------------------------------------------------
592 * PRIVATE XDisplayFormat
595 * Display the contents of one extended volume info structure.
598 * a_xInfoP : Ptr to extended volume info struct to print.
599 * a_servID : Server ID to print.
600 * a_partID : Partition ID to print.
601 * a_totalOKP : Ptr to total-OK counter.
602 * a_totalNotOKP : Ptr to total-screwed counter.
603 * a_totalBusyP : Ptr to total-busy counter.
604 * a_fast : Fast listing?
605 * a_int32 : Int32 listing?
606 * a_showProblems : Show volume problems?
612 * Nothing interesting.
616 *------------------------------------------------------------------------*/
619 XDisplayFormat(volintXInfo *a_xInfoP, afs_int32 a_servID, afs_int32 a_partID,
620 int *a_totalOKP, int *a_totalNotOKP, int *a_totalBusyP,
621 int a_fast, int a_int32, int a_showProblems)
622 { /*XDisplayFormat */
630 fprintf(STDOUT, "%-10lu\n", (unsigned long)a_xInfoP->volid);
631 } else if (a_int32) {
633 * Fully-detailed listing.
635 if (a_xInfoP->status == VOK) {
637 * Volume's status is OK - all the fields are valid.
639 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
640 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
641 if (a_xInfoP->type == 0)
642 fprintf(STDOUT, "RW ");
643 if (a_xInfoP->type == 1)
644 fprintf(STDOUT, "RO ");
645 if (a_xInfoP->type == 2)
646 fprintf(STDOUT, "BK ");
647 fprintf(STDOUT, "%10d K used ", a_xInfoP->size);
648 fprintf(STDOUT, "%d files ", a_xInfoP->filecount);
649 if (a_xInfoP->inUse == 1) {
650 fprintf(STDOUT, "On-line");
653 fprintf(STDOUT, "Off-line");
656 fprintf(STDOUT, "\n");
657 MapPartIdIntoName(a_partID, pname);
658 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(a_servID),
660 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
661 (unsigned long)a_xInfoP->parentID,
662 (unsigned long)a_xInfoP->cloneID,
663 (unsigned long)a_xInfoP->backupID);
664 fprintf(STDOUT, " MaxQuota %10d K \n", a_xInfoP->maxquota);
665 fprintf(STDOUT, " Creation %s",
666 vos_ctime( & a_xInfoP->creationDate));
667 #ifdef FULL_LISTVOL_SWITCH
668 fprintf(STDOUT, " Copy %s",
669 vos_ctime( & a_xInfoP->copyDate));
670 if (!a_xInfoP->backupDate)
671 fprintf(STDOUT, " Backup Never\n");
673 fprintf(STDOUT, " Backup %s",
674 vos_ctime( & a_xInfoP->backupDate));
675 if (a_xInfoP->accessDate)
676 fprintf(STDOUT, " Last Access %s",
677 vos_ctime( & a_xInfoP->accessDate));
679 if (!a_xInfoP->updateDate)
680 fprintf(STDOUT, " Last Update Never\n");
682 fprintf(STDOUT, " Last Update %s",
683 vos_ctime( & a_xInfoP->updateDate));
685 " %d accesses in the past day (i.e., vnode references)\n",
689 * Print all the read/write and authorship stats.
691 fprintf(STDOUT, "\n Raw Read/Write Stats\n");
693 " |-------------------------------------------|\n");
695 " | Same Network | Diff Network |\n");
697 " |----------|----------|----------|----------|\n");
699 " | Total | Auth | Total | Auth |\n");
701 " |----------|----------|----------|----------|\n");
702 fprintf(STDOUT, "Reads | %8d | %8d | %8d | %8d |\n",
703 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET],
704 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH],
705 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET],
706 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
707 fprintf(STDOUT, "Writes | %8d | %8d | %8d | %8d |\n",
708 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET],
709 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH],
710 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET],
711 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
713 " |-------------------------------------------|\n\n");
716 " Writes Affecting Authorship\n");
718 " |-------------------------------------------|\n");
720 " | File Authorship | Directory Authorship|\n");
722 " |----------|----------|----------|----------|\n");
724 " | Same | Diff | Same | Diff |\n");
726 " |----------|----------|----------|----------|\n");
727 fprintf(STDOUT, "0-60 sec | %8d | %8d | %8d | %8d |\n",
728 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_0],
729 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0],
730 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0],
731 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]);
732 fprintf(STDOUT, "1-10 min | %8d | %8d | %8d | %8d |\n",
733 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1],
734 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1],
735 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1],
736 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]);
737 fprintf(STDOUT, "10min-1hr | %8d | %8d | %8d | %8d |\n",
738 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_2],
739 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_2],
740 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_2],
741 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_2]);
742 fprintf(STDOUT, "1hr-1day | %8d | %8d | %8d | %8d |\n",
743 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_3],
744 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_3],
745 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_3],
746 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_3]);
747 fprintf(STDOUT, "1day-1wk | %8d | %8d | %8d | %8d |\n",
748 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_4],
749 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_4],
750 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_4],
751 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_4]);
752 fprintf(STDOUT, "> 1wk | %8d | %8d | %8d | %8d |\n",
753 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_5],
754 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5],
755 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5],
756 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]);
758 " |-------------------------------------------|\n");
759 } /*Volume status OK */
760 else if (a_xInfoP->status == VBUSY) {
762 qPut(&busyHead, a_xInfoP->volid);
764 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
765 (unsigned long)a_xInfoP->volid);
769 qPut(¬okHead, a_xInfoP->volid);
771 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
772 (unsigned long)a_xInfoP->volid);
773 } /*Screwed volume */
774 fprintf(STDOUT, "\n");
780 if (a_xInfoP->status == VOK) {
781 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
782 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
783 if (a_xInfoP->type == 0)
784 fprintf(STDOUT, "RW ");
785 if (a_xInfoP->type == 1)
786 fprintf(STDOUT, "RO ");
787 if (a_xInfoP->type == 2)
788 fprintf(STDOUT, "BK ");
789 fprintf(STDOUT, "%10d K ", a_xInfoP->size);
790 if (a_xInfoP->inUse == 1) {
791 fprintf(STDOUT, "On-line");
794 fprintf(STDOUT, "Off-line");
797 fprintf(STDOUT, "\n");
799 else if (a_xInfoP->status == VBUSY) {
801 qPut(&busyHead, a_xInfoP->volid);
803 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
804 (unsigned long)a_xInfoP->volid);
808 qPut(¬okHead, a_xInfoP->volid);
810 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
811 (unsigned long)a_xInfoP->volid);
812 } /*Screwed volume */
813 } /*Default listing */
814 } /*XDisplayFormat */
816 #ifdef FULL_LISTVOL_SWITCH
817 /*------------------------------------------------------------------------
818 * PRIVATE XDisplayFormat2
821 * Display the formated contents of one extended volume info structure.
824 * a_xInfoP : Ptr to extended volume info struct to print.
825 * a_servID : Server ID to print.
826 * a_partID : Partition ID to print.
827 * a_totalOKP : Ptr to total-OK counter.
828 * a_totalNotOKP : Ptr to total-screwed counter.
829 * a_totalBusyP : Ptr to total-busy counter.
830 * a_fast : Fast listing?
831 * a_int32 : Int32 listing?
832 * a_showProblems : Show volume problems?
838 * Nothing interesting.
842 *------------------------------------------------------------------------*/
845 XDisplayFormat2(volintXInfo *a_xInfoP, afs_int32 a_servID, afs_int32 a_partID,
846 int *a_totalOKP, int *a_totalNotOKP, int *a_totalBusyP,
847 int a_fast, int a_int32, int a_showProblems)
848 { /*XDisplayFormat */
853 fprintf(STDOUT, "vold_id\t%-10lu\n", (unsigned long)a_xInfoP->volid);
854 } else if (a_int32) {
856 * Fully-detailed listing.
858 if (a_xInfoP->status == VOK) {
860 * Volume's status is OK - all the fields are valid.
863 static long server_cache = -1, partition_cache = -1;
864 static char hostname[256], address[32], pname[16];
865 int i,ai[] = {VOLINT_STATS_TIME_IDX_0,VOLINT_STATS_TIME_IDX_1,VOLINT_STATS_TIME_IDX_2,
866 VOLINT_STATS_TIME_IDX_3,VOLINT_STATS_TIME_IDX_4,VOLINT_STATS_TIME_IDX_5};
868 if (a_servID != server_cache) {
872 strcpy(hostname, hostutil_GetNameByINet(a_servID));
873 strcpy(address, inet_ntoa(s));
874 server_cache = a_servID;
876 if (a_partID != partition_cache) {
877 MapPartIdIntoName(a_partID, pname);
878 partition_cache = a_partID;
881 fprintf(STDOUT, "name\t\t%s\n", a_xInfoP->name);
882 fprintf(STDOUT, "id\t\t%lu\n", afs_printable_uint32_lu(a_xInfoP->volid));
883 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
884 fprintf(STDOUT, "part\t\t%s\n", pname);
885 switch (a_xInfoP->status) {
887 fprintf(STDOUT, "status\t\tOK\n");
890 fprintf(STDOUT, "status\t\tBUSY\n");
893 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
896 fprintf(STDOUT, "backupID\t%lu\n",
897 afs_printable_uint32_lu(a_xInfoP->backupID));
898 fprintf(STDOUT, "parentID\t%lu\n",
899 afs_printable_uint32_lu(a_xInfoP->parentID));
900 fprintf(STDOUT, "cloneID\t\t%lu\n",
901 afs_printable_uint32_lu(a_xInfoP->cloneID));
902 fprintf(STDOUT, "inUse\t\t%s\n", a_xInfoP->inUse ? "Y" : "N");
903 switch (a_xInfoP->type) {
905 fprintf(STDOUT, "type\t\tRW\n");
908 fprintf(STDOUT, "type\t\tRO\n");
911 fprintf(STDOUT, "type\t\tBK\n");
914 fprintf(STDOUT, "type\t\t?\n");
917 fprintf(STDOUT, "creationDate\t%-9lu\t%s",
918 afs_printable_uint32_lu(a_xInfoP->creationDate),
919 vos_ctime(&a_xInfoP->creationDate));
920 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
921 afs_printable_uint32_lu(a_xInfoP->accessDate),
922 vos_ctime(&a_xInfoP->accessDate));
923 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
924 afs_printable_uint32_lu(a_xInfoP->updateDate),
925 vos_ctime(&a_xInfoP->updateDate));
926 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
927 afs_printable_uint32_lu(a_xInfoP->backupDate),
928 vos_ctime(&a_xInfoP->backupDate));
929 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
930 afs_printable_uint32_lu(a_xInfoP->copyDate),
931 vos_ctime(&a_xInfoP->copyDate));
933 fprintf(STDOUT, "diskused\t%u\n", a_xInfoP->size);
934 fprintf(STDOUT, "maxquota\t%u\n", a_xInfoP->maxquota);
936 fprintf(STDOUT, "filecount\t%u\n", a_xInfoP->filecount);
937 fprintf(STDOUT, "dayUse\t\t%u\n", a_xInfoP->dayUse);
941 fprintf(STDOUT,"reads_same_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET]);
942 fprintf(STDOUT,"reads_same_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH]);
943 fprintf(STDOUT,"reads_diff_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET]);
944 fprintf(STDOUT,"reads_diff_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
946 fprintf(STDOUT,"writes_same_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET]);
947 fprintf(STDOUT,"writes_same_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH]);
948 fprintf(STDOUT,"writes_diff_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET]);
949 fprintf(STDOUT,"writes_diff_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
953 fprintf(STDOUT,"file_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileSameAuthor[ai[i]]);
954 fprintf(STDOUT,"file_diff_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileDiffAuthor[ai[i]]);
955 fprintf(STDOUT,"dir_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirSameAuthor[ai[i]]);
956 fprintf(STDOUT,"dir_dif_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirDiffAuthor[ai[i]]);
959 } /*Volume status OK */
960 else if (a_xInfoP->status == VBUSY) {
962 qPut(&busyHead, a_xInfoP->volid);
964 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
965 (unsigned long)a_xInfoP->volid);
969 qPut(¬okHead, a_xInfoP->volid);
971 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
972 (unsigned long)a_xInfoP->volid);
973 } /*Screwed volume */
979 if (a_xInfoP->status == VOK) {
980 fprintf(STDOUT, "name\t%-32s\n", a_xInfoP->name);
981 fprintf(STDOUT, "volID\t%10lu\n", (unsigned long)a_xInfoP->volid);
982 if (a_xInfoP->type == 0)
983 fprintf(STDOUT, "type\tRW\n");
984 if (a_xInfoP->type == 1)
985 fprintf(STDOUT, "type\tRO\n");
986 if (a_xInfoP->type == 2)
987 fprintf(STDOUT, "type\tBK\n");
988 fprintf(STDOUT, "size\t%10dK\n", a_xInfoP->size);
990 fprintf(STDOUT, "inUse\t%d\n",a_xInfoP->inUse);
991 if (a_xInfoP->inUse == 1)
997 else if (a_xInfoP->status == VBUSY) {
999 qPut(&busyHead, a_xInfoP->volid);
1001 fprintf(STDOUT, "VOLUME_BUSY\t%lu\n",
1002 (unsigned long)a_xInfoP->volid);
1006 qPut(¬okHead, a_xInfoP->volid);
1008 fprintf(STDOUT, "COULD_NOT_ATTACH_VOLUME\t%lu\n",
1009 (unsigned long)a_xInfoP->volid);
1010 } /*Screwed volume */
1011 } /*Default listing */
1012 } /*XDisplayFormat */
1013 #endif /*FULL_LISTVOL_SWITCH*/
1015 #ifdef FULL_LISTVOL_SWITCH
1017 DisplayFormat2(long server, long partition, volintInfo *pntr)
1019 static long server_cache = -1, partition_cache = -1;
1020 static char hostname[256], address[32], pname[16];
1022 if (server != server_cache) {
1026 strcpy(hostname, hostutil_GetNameByINet(server));
1027 strcpy(address, inet_ntoa(s));
1028 server_cache = server;
1030 if (partition != partition_cache) {
1031 MapPartIdIntoName(partition, pname);
1032 partition_cache = partition;
1034 fprintf(STDOUT, "name\t\t%s\n", pntr->name);
1035 fprintf(STDOUT, "id\t\t%lu\n",
1036 afs_printable_uint32_lu(pntr->volid));
1037 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
1038 fprintf(STDOUT, "part\t\t%s\n", pname);
1039 switch (pntr->status) {
1041 fprintf(STDOUT, "status\t\tOK\n");
1044 fprintf(STDOUT, "status\t\tBUSY\n");
1047 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
1050 fprintf(STDOUT, "backupID\t%lu\n",
1051 afs_printable_uint32_lu(pntr->backupID));
1052 fprintf(STDOUT, "parentID\t%lu\n",
1053 afs_printable_uint32_lu(pntr->parentID));
1054 fprintf(STDOUT, "cloneID\t\t%lu\n",
1055 afs_printable_uint32_lu(pntr->cloneID));
1056 fprintf(STDOUT, "inUse\t\t%s\n", pntr->inUse ? "Y" : "N");
1057 fprintf(STDOUT, "needsSalvaged\t%s\n", pntr->needsSalvaged ? "Y" : "N");
1058 /* 0xD3 is from afs/volume.h since I had trouble including the file */
1059 fprintf(STDOUT, "destroyMe\t%s\n", pntr->destroyMe == 0xD3 ? "Y" : "N");
1060 switch (pntr->type) {
1062 fprintf(STDOUT, "type\t\tRW\n");
1065 fprintf(STDOUT, "type\t\tRO\n");
1068 fprintf(STDOUT, "type\t\tBK\n");
1071 fprintf(STDOUT, "type\t\t?\n");
1074 fprintf(STDOUT, "creationDate\t%-9lu\t%s",
1075 afs_printable_uint32_lu(pntr->creationDate),
1076 vos_ctime(&pntr->creationDate));
1077 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
1078 afs_printable_uint32_lu(pntr->accessDate),
1079 vos_ctime(&pntr->accessDate));
1080 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
1081 afs_printable_uint32_lu(pntr->updateDate),
1082 vos_ctime(&pntr->updateDate));
1083 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
1084 afs_printable_uint32_lu(pntr->backupDate),
1085 vos_ctime(&pntr->backupDate));
1086 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
1087 afs_printable_uint32_lu(pntr->copyDate),
1088 vos_ctime(&pntr->copyDate));
1089 fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n",
1090 afs_printable_uint32_lu(pntr->flags));
1091 fprintf(STDOUT, "diskused\t%u\n", pntr->size);
1092 fprintf(STDOUT, "maxquota\t%u\n", pntr->maxquota);
1093 fprintf(STDOUT, "minquota\t%lu\t(Optional)\n",
1094 afs_printable_uint32_lu(pntr->spare0));
1095 fprintf(STDOUT, "filecount\t%u\n", pntr->filecount);
1096 fprintf(STDOUT, "dayUse\t\t%u\n", pntr->dayUse);
1097 fprintf(STDOUT, "weekUse\t\t%lu\t(Optional)\n",
1098 afs_printable_uint32_lu(pntr->spare1));
1099 fprintf(STDOUT, "spare2\t\t%lu\t(Optional)\n",
1100 afs_printable_uint32_lu(pntr->spare2));
1101 fprintf(STDOUT, "spare3\t\t%lu\t(Optional)\n",
1102 afs_printable_uint32_lu(pntr->spare3));
1107 DisplayVolumes2(long server, long partition, volintInfo *pntr, long count)
1111 for (i = 0; i < count; i++) {
1112 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1113 DisplayFormat2(server, partition, pntr);
1114 fprintf(STDOUT, "END_OF_ENTRY\n\n");
1119 #endif /* FULL_LISTVOL_SWITCH */
1122 DisplayVolumes(afs_int32 server, afs_int32 part, volintInfo *pntr,
1123 afs_int32 count, afs_int32 longlist, afs_int32 fast,
1126 int totalOK, totalNotOK, totalBusy, i;
1127 afs_uint32 volid = 0;
1134 for (i = 0; i < count; i++) {
1135 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy,
1140 while (busyHead.count) {
1141 qGet(&busyHead, &volid);
1142 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1143 (unsigned long)volid);
1147 while (notokHead.count) {
1148 qGet(¬okHead, &volid);
1149 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1150 (unsigned long)volid);
1154 fprintf(STDOUT, "\n");
1157 "Total volumes onLine %d ; Total volumes offLine %d ; Total busy %d\n\n",
1158 totalOK, totalNotOK, totalBusy);
1162 /*------------------------------------------------------------------------
1163 * PRIVATE XDisplayVolumes
1166 * Display extended volume information.
1169 * a_servID : Pointer to the Rx call we're performing.
1170 * a_partID : Partition for which we want the extended list.
1171 * a_xInfoP : Ptr to extended volume info.
1172 * a_count : Number of volume records contained above.
1173 * a_int32 : Int32 listing generated?
1174 * a_fast : Fast listing generated?
1175 * a_quiet : Quiet listing generated?
1181 * Nothing interesting.
1185 *------------------------------------------------------------------------*/
1188 XDisplayVolumes(afs_int32 a_servID, afs_int32 a_partID, volintXInfo *a_xInfoP,
1189 afs_int32 a_count, afs_int32 a_int32, afs_int32 a_fast,
1191 { /*XDisplayVolumes */
1193 int totalOK; /*Total OK volumes */
1194 int totalNotOK; /*Total screwed volumes */
1195 int totalBusy; /*Total busy volumes */
1196 int i; /*Loop variable */
1197 afs_uint32 volid = 0; /*Current volume ID */
1200 * Initialize counters and (global!!) queues.
1209 * Display each volume in the list.
1211 for (i = 0; i < a_count; i++) {
1212 XDisplayFormat(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1213 &totalBusy, a_fast, a_int32, 0);
1218 * If any volumes were found to be busy or screwed, display them.
1221 while (busyHead.count) {
1222 qGet(&busyHead, &volid);
1223 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1224 (unsigned long)volid);
1228 while (notokHead.count) {
1229 qGet(¬okHead, &volid);
1230 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1231 (unsigned long)volid);
1236 fprintf(STDOUT, "\n");
1239 "Total volumes: %d on-line, %d off-line, %d busyd\n\n",
1240 totalOK, totalNotOK, totalBusy);
1244 } /*XDisplayVolumes */
1245 #ifdef FULL_LISTVOL_SWITCH
1246 /*------------------------------------------------------------------------
1247 * PRIVATE XDisplayVolumes2
1250 * Display extended formated volume information.
1253 * a_servID : Pointer to the Rx call we're performing.
1254 * a_partID : Partition for which we want the extended list.
1255 * a_xInfoP : Ptr to extended volume info.
1256 * a_count : Number of volume records contained above.
1257 * a_int32 : Int32 listing generated?
1258 * a_fast : Fast listing generated?
1259 * a_quiet : Quiet listing generated?
1265 * Nothing interesting.
1269 *------------------------------------------------------------------------*/
1272 XDisplayVolumes2(afs_int32 a_servID, afs_int32 a_partID, volintXInfo *a_xInfoP,
1273 afs_int32 a_count, afs_int32 a_int32, afs_int32 a_fast,
1275 { /*XDisplayVolumes */
1277 int totalOK; /*Total OK volumes */
1278 int totalNotOK; /*Total screwed volumes */
1279 int totalBusy; /*Total busy volumes */
1280 int i; /*Loop variable */
1281 afs_uint32 volid = 0; /*Current volume ID */
1284 * Initialize counters and (global!!) queues.
1293 * Display each volume in the list.
1295 for (i = 0; i < a_count; i++) {
1296 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1297 XDisplayFormat2(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1298 &totalBusy, a_fast, a_int32, 0);
1299 fprintf(STDOUT, "END_OF_ENTRY\n");
1304 * If any volumes were found to be busy or screwed, display them.
1307 while (busyHead.count) {
1308 qGet(&busyHead, &volid);
1309 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
1310 (unsigned long)volid);
1314 while (notokHead.count) {
1315 qGet(¬okHead, &volid);
1316 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
1317 (unsigned long)volid);
1322 fprintf(STDOUT, "\n");
1325 "VOLUMES_ONLINE\t%d\nVOLUMES_OFFLINE\t%d\nVOLUMES_BUSY\t%d\n",
1326 totalOK, totalNotOK, totalBusy);
1330 } /*XDisplayVolumes2 */
1331 #endif /* FULL_LISTVOL_SWITCH */
1334 /* set <server> and <part> to the correct values depending on
1335 * <voltype> and <entry> */
1337 GetServerAndPart(struct nvldbentry *entry, int voltype, afs_int32 *server,
1338 afs_int32 *part, int *previdx)
1340 int i, istart, vtype;
1345 /* Doesn't check for non-existance of backup volume */
1346 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
1348 istart = 0; /* seach the entire entry */
1351 /* Seach from beginning of entry or pick up where we left off */
1352 istart = ((*previdx < 0) ? 0 : *previdx + 1);
1355 for (i = istart; i < entry->nServers; i++) {
1356 if (entry->serverFlags[i] & vtype) {
1357 *server = entry->serverNumber[i];
1358 *part = entry->serverPartition[i];
1364 /* Didn't find any, return -1 */
1370 PostVolumeStats(struct nvldbentry *entry)
1372 SubEnumerateEntry(entry);
1373 /* Check for VLOP_ALLOPERS */
1374 if (entry->flags & VLOP_ALLOPERS)
1375 fprintf(STDOUT, " Volume is currently LOCKED \n");
1379 /*------------------------------------------------------------------------
1380 * PRIVATE XVolumeStats
1383 * Display extended volume information.
1386 * a_xInfoP : Ptr to extended volume info.
1387 * a_entryP : Ptr to the volume's VLDB entry.
1388 * a_srvID : Server ID.
1389 * a_partID : Partition ID.
1390 * a_volType : Type of volume to print.
1396 * Nothing interesting.
1400 *------------------------------------------------------------------------*/
1403 XVolumeStats(volintXInfo *a_xInfoP, struct nvldbentry *a_entryP,
1404 afs_int32 a_srvID, afs_int32 a_partID, int a_volType)
1407 int totalOK, totalNotOK, totalBusy; /*Dummies - we don't really count here */
1409 XDisplayFormat(a_xInfoP, /*Ptr to extended volume info */
1410 a_srvID, /*Server ID to print */
1411 a_partID, /*Partition ID to print */
1412 &totalOK, /*Ptr to total-OK counter */
1413 &totalNotOK, /*Ptr to total-screwed counter */
1414 &totalBusy, /*Ptr to total-busy counter */
1415 0, /*Don't do a fast listing */
1416 1, /*Do a long listing */
1417 1); /*Show volume problems */
1423 VolumeStats_int(volintInfo *pntr, struct nvldbentry *entry, afs_int32 server,
1424 afs_int32 part, int voltype)
1426 int totalOK, totalNotOK, totalBusy;
1428 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy, 0, 1,
1433 /* command to forcibly remove a volume */
1435 NukeVolume(register struct cmd_syndesc *as)
1437 register afs_int32 code;
1444 server = GetServer(tp = as->parms[0].items->data);
1446 fprintf(STDERR, "vos: server '%s' not found in host table\n", tp);
1450 partID = volutil_GetPartitionID(tp = as->parms[1].items->data);
1452 fprintf(STDERR, "vos: could not parse '%s' as a partition name", tp);
1456 volID = vsu_GetVolumeID(tp = as->parms[2].items->data, cstruct, &err);
1459 PrintError("", err);
1462 "vos: could not parse '%s' as a numeric volume ID", tp);
1467 "vos: forcibly removing all traces of volume %d, please wait...",
1470 code = UV_NukeVolume(server, partID, volID);
1472 fprintf(STDOUT, "done.\n");
1474 fprintf(STDOUT, "failed with code %d.\n", code);
1479 /*------------------------------------------------------------------------
1480 * PRIVATE ExamineVolume
1483 * Routine used to examine a single volume, contacting the VLDB as
1484 * well as the Volume Server.
1487 * as : Ptr to parsed command line arguments.
1490 * 0 for a successful operation,
1491 * Otherwise, one of the ubik or VolServer error values.
1494 * Nothing interesting.
1498 *------------------------------------------------------------------------
1501 ExamineVolume(register struct cmd_syndesc *as, void *arock)
1503 struct nvldbentry entry;
1504 afs_int32 vcode = 0;
1505 volintInfo *pntr = (volintInfo *) 0;
1506 volintXInfo *xInfoP = (volintXInfo *) 0;
1508 afs_int32 code, err, error = 0;
1509 int voltype, foundserv = 0, foundentry = 0;
1510 afs_int32 aserver, apart;
1512 int wantExtendedInfo; /*Do we want extended vol info? */
1514 wantExtendedInfo = (as->parms[1].items ? 1 : 0); /* -extended */
1516 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1519 PrintError("", err);
1521 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1522 as->parms[0].items->data);
1527 fprintf(STDOUT, "Fetching VLDB entry for %lu .. ",
1528 (unsigned long)volid);
1531 vcode = VLDB_GetEntryByID(volid, -1, &entry);
1534 "Could not fetch the entry for volume number %lu from VLDB \n",
1535 (unsigned long)volid);
1539 fprintf(STDOUT, "done\n");
1540 MapHostToNetwork(&entry);
1542 if (entry.volumeId[RWVOL] == volid)
1544 else if (entry.volumeId[BACKVOL] == volid)
1546 else /* (entry.volumeId[ROVOL] == volid) */
1549 do { /* do {...} while (voltype == ROVOL) */
1550 /* Get the entry for the volume. If its a RW vol, get the RW entry.
1551 * It its a BK vol, get the RW entry (even if VLDB may say the BK doen't exist).
1552 * If its a RO vol, get the next RO entry.
1554 GetServerAndPart(&entry, ((voltype == ROVOL) ? ROVOL : RWVOL),
1555 &aserver, &apart, &previdx);
1556 if (previdx == -1) { /* searched all entries */
1558 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1559 as->parms[0].items->data);
1566 /* Get information about the volume from the server */
1568 fprintf(STDOUT, "Getting volume listing from the server %s .. ",
1569 hostutil_GetNameByINet(aserver));
1572 if (wantExtendedInfo)
1573 code = UV_XListOneVolume(aserver, apart, volid, &xInfoP);
1575 code = UV_ListOneVolume(aserver, apart, volid, &pntr);
1577 fprintf(STDOUT, "done\n");
1581 if (code == ENODEV) {
1582 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1583 /* The VLDB says there is no backup volume and its not on disk */
1584 fprintf(STDERR, "Volume %s does not exist\n",
1585 as->parms[0].items->data);
1589 "Volume does not exist on server %s as indicated by the VLDB\n",
1590 hostutil_GetNameByINet(aserver));
1593 PrintDiagnostics("examine", code);
1595 fprintf(STDOUT, "\n");
1598 if (wantExtendedInfo)
1599 XVolumeStats(xInfoP, &entry, aserver, apart, voltype);
1601 #ifdef FULL_LISTVOL_SWITCH
1602 if (as->parms[2].items) {
1603 DisplayFormat2(aserver, apart, pntr);
1604 EnumerateEntry(&entry);
1606 #endif /* FULL_LISTVOL_SWITCH */
1607 VolumeStats_int(pntr, &entry, aserver, apart, voltype);
1609 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1610 /* The VLDB says there is no backup volume yet we found one on disk */
1611 fprintf(STDERR, "Volume %s does not exist in VLDB\n",
1612 as->parms[0].items->data);
1621 } while (voltype == ROVOL);
1624 fprintf(STDERR, "Dump only information from VLDB\n\n");
1625 fprintf(STDOUT, "%s \n", entry.name); /* PostVolumeStats doesn't print name */
1627 PostVolumeStats(&entry);
1632 /*------------------------------------------------------------------------
1636 * Routine used to change the status of a single volume.
1639 * as : Ptr to parsed command line arguments.
1642 * 0 for a successful operation,
1643 * Otherwise, one of the ubik or VolServer error values.
1646 * Nothing interesting.
1650 *------------------------------------------------------------------------
1653 SetFields(register struct cmd_syndesc *as, void *arock)
1655 struct nvldbentry entry;
1658 afs_int32 code, err;
1659 afs_int32 aserver, apart;
1662 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1665 PrintError("", err);
1667 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1668 as->parms[0].items->data);
1672 code = VLDB_GetEntryByID(volid, RWVOL, &entry);
1675 "Could not fetch the entry for volume number %lu from VLDB \n",
1676 (unsigned long)volid);
1679 MapHostToNetwork(&entry);
1681 GetServerAndPart(&entry, RWVOL, &aserver, &apart, &previdx);
1682 if (previdx == -1) {
1683 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1684 as->parms[0].items->data);
1688 init_volintInfo(&info);
1692 if (as->parms[1].items) {
1694 code = util_GetInt32(as->parms[1].items->data, &info.maxquota);
1696 fprintf(STDERR, "invalid quota value\n");
1700 if (as->parms[2].items) {
1704 if (as->parms[3].items) {
1705 /* -clearVolUpCounter */
1708 code = UV_SetVolumeInfo(aserver, apart, volid, &info);
1711 "Could not update volume info fields for volume number %lu\n",
1712 (unsigned long)volid);
1716 /*------------------------------------------------------------------------
1720 * Brings a volume online.
1723 * as : Ptr to parsed command line arguments.
1726 * 0 for a successful operation,
1729 * Nothing interesting.
1733 *------------------------------------------------------------------------
1736 volOnline(register struct cmd_syndesc *as, void *arock)
1738 afs_int32 server, partition;
1740 afs_int32 code, err = 0;
1742 server = GetServer(as->parms[0].items->data);
1744 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1745 as->parms[0].items->data);
1749 partition = volutil_GetPartitionID(as->parms[1].items->data);
1750 if (partition < 0) {
1751 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1752 as->parms[1].items->data);
1756 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1759 PrintError("", err);
1761 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1762 as->parms[0].items->data);
1766 code = UV_SetVolume(server, partition, volid, ITOffline, 0 /*online */ ,
1769 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1776 /*------------------------------------------------------------------------
1777 * PRIVATE volOffline
1780 * Brings a volume offline.
1783 * as : Ptr to parsed command line arguments.
1786 * 0 for a successful operation,
1789 * Nothing interesting.
1793 *------------------------------------------------------------------------
1796 volOffline(register struct cmd_syndesc *as, void *arock)
1798 afs_int32 server, partition;
1800 afs_int32 code, err = 0;
1801 afs_int32 transflag, sleeptime, transdone;
1803 server = GetServer(as->parms[0].items->data);
1805 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1806 as->parms[0].items->data);
1810 partition = volutil_GetPartitionID(as->parms[1].items->data);
1811 if (partition < 0) {
1812 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1813 as->parms[1].items->data);
1817 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1820 PrintError("", err);
1822 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1823 as->parms[0].items->data);
1827 transflag = (as->parms[4].items ? ITBusy : ITOffline);
1828 sleeptime = (as->parms[3].items ? atol(as->parms[3].items->data) : 0);
1829 transdone = (sleeptime ? 0 /*online */ : VTOutOfService);
1830 if (as->parms[4].items && !as->parms[3].items) {
1831 fprintf(STDERR, "-sleep option must be used with -busy flag\n");
1836 UV_SetVolume(server, partition, volid, transflag, transdone,
1839 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1847 CreateVolume(register struct cmd_syndesc *as, void *arock)
1853 struct nvldbentry entry;
1858 tserver = GetServer(as->parms[0].items->data);
1860 fprintf(STDERR, "vos: host '%s' not found in host table\n",
1861 as->parms[0].items->data);
1864 pnum = volutil_GetPartitionID(as->parms[1].items->data);
1866 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1867 as->parms[1].items->data);
1870 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
1872 PrintError("", code);
1875 "vos : partition %s does not exist on the server\n",
1876 as->parms[1].items->data);
1879 if (!ISNAMEVALID(as->parms[2].items->data)) {
1881 "vos: the name of the root volume %s exceeds the size limit of %d\n",
1882 as->parms[2].items->data, VOLSER_OLDMAXVOLNAME - 10);
1885 if (!VolNameOK(as->parms[2].items->data)) {
1887 "Illegal volume name %s, should not end in .readonly or .backup\n",
1888 as->parms[2].items->data);
1891 if (IsNumeric(as->parms[2].items->data)) {
1892 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
1893 as->parms[2].items->data);
1896 vcode = VLDB_GetEntryByName(as->parms[2].items->data, &entry);
1898 fprintf(STDERR, "Volume %s already exists\n",
1899 as->parms[2].items->data);
1900 PrintDiagnostics("create", code);
1904 if (as->parms[3].items) {
1905 if (!IsNumeric(as->parms[3].items->data)) {
1906 fprintf(STDERR, "Initial quota %s should be numeric.\n",
1907 as->parms[3].items->data);
1911 code = util_GetInt32(as->parms[3].items->data, "a);
1913 fprintf(STDERR, "vos: bad integer specified for quota.\n");
1919 UV_CreateVolume2(tserver, pnum, as->parms[2].items->data, quota, 0,
1922 PrintDiagnostics("create", code);
1925 MapPartIdIntoName(pnum, part);
1926 fprintf(STDOUT, "Volume %lu created on partition %s of %s\n",
1927 (unsigned long)volid, part, as->parms[0].items->data);
1934 DeleteAll(struct nvldbentry *entry)
1937 afs_int32 error, code, curserver, curpart;
1940 MapHostToNetwork(entry);
1942 for (i = 0; i < entry->nServers; i++) {
1943 curserver = entry->serverNumber[i];
1944 curpart = entry->serverPartition[i];
1945 if (entry->serverFlags[i] & ITSROVOL) {
1946 volid = entry->volumeId[ROVOL];
1948 volid = entry->volumeId[RWVOL];
1950 code = UV_DeleteVolume(curserver, curpart, volid);
1959 DeleteVolume(struct cmd_syndesc *as, void *arock)
1961 afs_int32 err, code = 0;
1962 afs_int32 server = 0, partition = -1;
1967 if (as->parms[0].items) {
1968 server = GetServer(as->parms[0].items->data);
1970 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1971 as->parms[0].items->data);
1976 if (as->parms[1].items) {
1977 partition = volutil_GetPartitionID(as->parms[1].items->data);
1978 if (partition < 0) {
1979 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1980 as->parms[1].items->data);
1984 /* Check for validity of the partition */
1985 if (!IsPartValid(partition, server, &code)) {
1987 PrintError("", code);
1990 "vos : partition %s does not exist on the server\n",
1991 as->parms[1].items->data);
1997 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
1999 fprintf(STDERR, "Can't find volume name '%s' in VLDB\n",
2000 as->parms[2].items->data);
2002 PrintError("", err);
2006 /* If the server or partition option are not complete, try to fill
2007 * them in from the VLDB entry.
2009 if ((partition == -1) || !server) {
2010 struct nvldbentry entry;
2012 code = VLDB_GetEntryByID(volid, -1, &entry);
2015 "Could not fetch the entry for volume %lu from VLDB\n",
2016 (unsigned long)volid);
2017 PrintError("", code);
2021 if (((volid == entry.volumeId[RWVOL]) && (entry.flags & RW_EXISTS))
2022 || ((volid == entry.volumeId[BACKVOL])
2023 && (entry.flags & BACK_EXISTS))) {
2024 idx = Lp_GetRwIndex(&entry);
2025 if ((idx == -1) || (server && (server != entry.serverNumber[idx]))
2026 || ((partition != -1)
2027 && (partition != entry.serverPartition[idx]))) {
2028 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2029 as->parms[2].items->data);
2032 } else if ((volid == entry.volumeId[ROVOL])
2033 && (entry.flags & RO_EXISTS)) {
2034 for (idx = -1, j = 0; j < entry.nServers; j++) {
2035 if (entry.serverFlags[j] != ITSROVOL)
2038 if (((server == 0) || (server == entry.serverNumber[j]))
2039 && ((partition == -1)
2040 || (partition == entry.serverPartition[j]))) {
2043 "VLDB: Volume '%s' matches more than one RO\n",
2044 as->parms[2].items->data);
2051 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2052 as->parms[2].items->data);
2056 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2057 as->parms[2].items->data);
2061 server = htonl(entry.serverNumber[idx]);
2062 partition = entry.serverPartition[idx];
2066 code = UV_DeleteVolume(server, partition, volid);
2068 PrintDiagnostics("remove", code);
2072 MapPartIdIntoName(partition, pname);
2073 fprintf(STDOUT, "Volume %lu on partition %s server %s deleted\n",
2074 (unsigned long)volid, pname, hostutil_GetNameByINet(server));
2078 #define TESTM 0 /* set for move space tests, clear for production */
2080 MoveVolume(register struct cmd_syndesc *as, void *arock)
2084 afs_int32 fromserver, toserver, frompart, topart;
2085 afs_int32 flags, code, err;
2086 char fromPartName[10], toPartName[10];
2088 struct diskPartition64 partition; /* for space check */
2091 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2094 PrintError("", err);
2096 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2097 as->parms[0].items->data);
2100 fromserver = GetServer(as->parms[1].items->data);
2101 if (fromserver == 0) {
2102 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2103 as->parms[1].items->data);
2106 toserver = GetServer(as->parms[3].items->data);
2107 if (toserver == 0) {
2108 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2109 as->parms[3].items->data);
2112 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2114 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2115 as->parms[2].items->data);
2118 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2120 PrintError("", code);
2123 "vos : partition %s does not exist on the server\n",
2124 as->parms[2].items->data);
2127 topart = volutil_GetPartitionID(as->parms[4].items->data);
2129 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2130 as->parms[4].items->data);
2133 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2135 PrintError("", code);
2138 "vos : partition %s does not exist on the server\n",
2139 as->parms[4].items->data);
2144 if (as->parms[5].items) flags |= RV_NOCLONE;
2147 * check source partition for space to clone volume
2150 MapPartIdIntoName(topart, toPartName);
2151 MapPartIdIntoName(frompart, fromPartName);
2154 * check target partition for space to move volume
2157 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2159 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2163 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2166 p = (volintInfo *) 0;
2167 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2169 fprintf(STDERR, "vos:cannot access volume %lu\n",
2170 (unsigned long)volid);
2174 fprintf(STDOUT, "volume %lu size %d\n", (unsigned long)volid,
2176 if (partition.free <= p->size) {
2178 "vos: no space on target partition %s to move volume %lu\n",
2179 toPartName, (unsigned long)volid);
2186 fprintf(STDOUT, "size test - don't do move\n");
2190 /* successful move still not guaranteed but shoot for it */
2193 UV_MoveVolume2(volid, fromserver, frompart, toserver, topart, flags);
2195 PrintDiagnostics("move", code);
2198 MapPartIdIntoName(topart, toPartName);
2199 MapPartIdIntoName(frompart, fromPartName);
2200 fprintf(STDOUT, "Volume %lu moved from %s %s to %s %s \n",
2201 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2202 as->parms[3].items->data, toPartName);
2208 CopyVolume(register struct cmd_syndesc *as, void *arock)
2211 afs_int32 fromserver, toserver, frompart, topart, code, err, flags;
2212 char fromPartName[10], toPartName[10], *tovolume;
2213 struct nvldbentry entry;
2214 struct diskPartition64 partition; /* for space check */
2217 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2220 PrintError("", err);
2222 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2223 as->parms[0].items->data);
2226 fromserver = GetServer(as->parms[1].items->data);
2227 if (fromserver == 0) {
2228 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2229 as->parms[1].items->data);
2233 toserver = GetServer(as->parms[4].items->data);
2234 if (toserver == 0) {
2235 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2236 as->parms[4].items->data);
2240 tovolume = as->parms[3].items->data;
2241 if (!ISNAMEVALID(tovolume)) {
2243 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2244 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2247 if (!VolNameOK(tovolume)) {
2249 "Illegal volume name %s, should not end in .readonly or .backup\n",
2253 if (IsNumeric(tovolume)) {
2254 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
2258 code = VLDB_GetEntryByName(tovolume, &entry);
2260 fprintf(STDERR, "Volume %s already exists\n", tovolume);
2261 PrintDiagnostics("copy", code);
2265 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2267 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2268 as->parms[2].items->data);
2271 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2273 PrintError("", code);
2276 "vos : partition %s does not exist on the server\n",
2277 as->parms[2].items->data);
2281 topart = volutil_GetPartitionID(as->parms[5].items->data);
2283 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2284 as->parms[5].items->data);
2287 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2289 PrintError("", code);
2292 "vos : partition %s does not exist on the server\n",
2293 as->parms[5].items->data);
2298 if (as->parms[6].items) flags |= RV_OFFLINE;
2299 if (as->parms[7].items) flags |= RV_RDONLY;
2300 if (as->parms[8].items) flags |= RV_NOCLONE;
2302 MapPartIdIntoName(topart, toPartName);
2303 MapPartIdIntoName(frompart, fromPartName);
2306 * check target partition for space to move volume
2309 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2311 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2315 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2318 p = (volintInfo *) 0;
2319 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2321 fprintf(STDERR, "vos:cannot access volume %lu\n",
2322 (unsigned long)volid);
2326 if (partition.free <= p->size) {
2328 "vos: no space on target partition %s to copy volume %lu\n",
2329 toPartName, (unsigned long)volid);
2335 /* successful copy still not guaranteed but shoot for it */
2338 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2341 PrintDiagnostics("copy", code);
2344 MapPartIdIntoName(topart, toPartName);
2345 MapPartIdIntoName(frompart, fromPartName);
2346 fprintf(STDOUT, "Volume %lu copied from %s %s to %s on %s %s \n",
2347 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2348 tovolume, as->parms[4].items->data, toPartName);
2355 ShadowVolume(register struct cmd_syndesc *as, void *arock)
2357 afs_uint32 volid, tovolid;
2358 afs_int32 fromserver, toserver, frompart, topart;
2359 afs_int32 code, err, flags;
2360 char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
2361 struct diskPartition64 partition; /* for space check */
2364 p = (volintInfo *) 0;
2365 q = (volintInfo *) 0;
2367 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2370 PrintError("", err);
2372 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2373 as->parms[0].items->data);
2376 fromserver = GetServer(as->parms[1].items->data);
2377 if (fromserver == 0) {
2378 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2379 as->parms[1].items->data);
2383 toserver = GetServer(as->parms[3].items->data);
2384 if (toserver == 0) {
2385 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2386 as->parms[3].items->data);
2390 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2392 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2393 as->parms[2].items->data);
2396 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2398 PrintError("", code);
2401 "vos : partition %s does not exist on the server\n",
2402 as->parms[2].items->data);
2406 topart = volutil_GetPartitionID(as->parms[4].items->data);
2408 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2409 as->parms[4].items->data);
2412 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2414 PrintError("", code);
2417 "vos : partition %s does not exist on the server\n",
2418 as->parms[4].items->data);
2422 if (as->parms[5].items) {
2423 tovolume = as->parms[5].items->data;
2424 if (!ISNAMEVALID(tovolume)) {
2426 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2427 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2430 if (!VolNameOK(tovolume)) {
2432 "Illegal volume name %s, should not end in .readonly or .backup\n",
2436 if (IsNumeric(tovolume)) {
2438 "Illegal volume name %s, should not be a number\n",
2443 /* use actual name of source volume */
2444 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2446 fprintf(STDERR, "vos:cannot access volume %lu\n",
2447 (unsigned long)volid);
2450 strcpy(toVolName, p->name);
2451 tovolume = toVolName;
2452 /* save p for size checks later */
2455 if (as->parms[6].items) {
2456 tovolid = vsu_GetVolumeID(as->parms[6].items->data, cstruct, &err);
2459 PrintError("", err);
2461 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2462 as->parms[6].items->data);
2468 tovolid = vsu_GetVolumeID(tovolume, cstruct, &err);
2471 PrintError("", err);
2473 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2482 if (as->parms[7].items) flags |= RV_OFFLINE;
2483 if (as->parms[8].items) flags |= RV_RDONLY;
2484 if (as->parms[9].items) flags |= RV_NOCLONE;
2485 if (as->parms[10].items) flags |= RV_CPINCR;
2487 MapPartIdIntoName(topart, toPartName);
2488 MapPartIdIntoName(frompart, fromPartName);
2491 * check target partition for space to move volume
2494 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2496 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2500 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2503 /* Don't do this again if we did it above */
2505 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2507 fprintf(STDERR, "vos:cannot access volume %lu\n",
2508 (unsigned long)volid);
2513 /* OK if this fails */
2514 code = UV_ListOneVolume(toserver, topart, tovolid, &q);
2516 /* Treat existing volume size as "free" */
2518 p->size = (q->size < p->size) ? p->size - q->size : 0;
2520 if (partition.free <= p->size) {
2522 "vos: no space on target partition %s to copy volume %lu\n",
2523 toPartName, (unsigned long)volid);
2531 /* successful copy still not guaranteed but shoot for it */
2534 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2535 topart, tovolid, flags);
2537 PrintDiagnostics("shadow", code);
2540 MapPartIdIntoName(topart, toPartName);
2541 MapPartIdIntoName(frompart, fromPartName);
2542 fprintf(STDOUT, "Volume %lu shadowed from %s %s to %s %s \n",
2543 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2544 as->parms[3].items->data, toPartName);
2551 CloneVolume(register struct cmd_syndesc *as, void *arock)
2553 afs_uint32 volid, cloneid;
2554 afs_int32 server, part, voltype;
2555 char partName[10], *volname;
2556 afs_int32 code, err, flags;
2557 struct nvldbentry entry;
2559 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2562 PrintError("", err);
2564 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2565 as->parms[0].items->data);
2569 if (as->parms[1].items || as->parms[2].items) {
2570 if (!as->parms[1].items || !as->parms[2].items) {
2572 "Must specify both -server and -partition options\n");
2575 server = GetServer(as->parms[1].items->data);
2577 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2578 as->parms[1].items->data);
2581 part = volutil_GetPartitionID(as->parms[2].items->data);
2583 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2584 as->parms[2].items->data);
2587 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
2589 PrintError("", code);
2592 "vos : partition %s does not exist on the server\n",
2593 as->parms[2].items->data);
2597 code = GetVolumeInfo(volid, &server, &part, &voltype, &entry);
2603 if (as->parms[3].items) {
2604 volname = as->parms[3].items->data;
2605 if (strlen(volname) > VOLSER_OLDMAXVOLNAME - 1) {
2607 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2608 volname, VOLSER_OLDMAXVOLNAME - 1);
2613 * In order that you be able to make clones of RO or BK, this
2614 * check must be omitted.
2616 if (!VolNameOK(volname)) {
2618 "Illegal volume name %s, should not end in .readonly or .backup\n",
2623 if (IsNumeric(volname)) {
2625 "Illegal volume name %s, should not be a number\n",
2632 if (as->parms[4].items) {
2633 cloneid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2636 PrintError("", err);
2638 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2639 as->parms[4].items->data);
2645 if (as->parms[5].items) flags |= RV_OFFLINE;
2646 if (as->parms[6].items) flags |= RV_RDONLY;
2650 UV_CloneVolume(server, part, volid, cloneid, volname, flags);
2653 PrintDiagnostics("clone", code);
2656 MapPartIdIntoName(part, partName);
2657 fprintf(STDOUT, "Created clone for volume %s\n",
2658 as->parms[0].items->data);
2665 BackupVolume(register struct cmd_syndesc *as, void *arock)
2668 afs_int32 aserver, apart, vtype, code, err;
2669 struct nvldbentry entry;
2672 afs_int32 buserver, bupart, butype;
2673 struct nvldbentry buentry;
2675 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2678 PrintError("", err);
2680 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2681 as->parms[0].items->data);
2684 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2688 /* verify this is a readwrite volume */
2690 if (vtype != RWVOL) {
2691 fprintf(STDERR, "%s not RW volume\n", as->parms[0].items->data);
2695 /* is there a backup volume already? */
2697 if (entry.flags & BACK_EXISTS) {
2698 /* yep, where is it? */
2700 buvolid = entry.volumeId[BACKVOL];
2701 code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
2706 code = VLDB_IsSameAddrs(buserver, aserver, &err);
2709 "Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
2715 "FATAL ERROR: backup volume %lu exists on server %lu\n",
2716 (unsigned long)buvolid, (unsigned long)buserver);
2721 /* nope, carry on */
2723 code = UV_BackupVolume(aserver, apart, avolid);
2726 PrintDiagnostics("backup", code);
2729 fprintf(STDOUT, "Created backup volume for %s \n",
2730 as->parms[0].items->data);
2735 ReleaseVolume(register struct cmd_syndesc *as, void *arock)
2738 struct nvldbentry entry;
2740 afs_int32 aserver, apart, vtype, code, err;
2743 if (as->parms[1].items)
2745 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2748 PrintError("", err);
2750 fprintf(STDERR, "vos: can't find volume '%s'\n",
2751 as->parms[0].items->data);
2754 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2758 if (vtype != RWVOL) {
2759 fprintf(STDERR, "%s not a RW volume\n", as->parms[0].items->data);
2763 if (!ISNAMEVALID(entry.name)) {
2765 "Volume name %s is too long, rename before releasing\n",
2770 code = UV_ReleaseVolume(avolid, aserver, apart, force);
2772 PrintDiagnostics("release", code);
2775 fprintf(STDOUT, "Released volume %s successfully\n",
2776 as->parms[0].items->data);
2781 DumpVolumeCmd(register struct cmd_syndesc *as, void *arock)
2784 afs_int32 aserver, apart, voltype, fromdate = 0, code, err, i, flags;
2785 char filename[MAXPATHLEN];
2786 struct nvldbentry entry;
2788 rx_SetRxDeadTime(60 * 10);
2789 for (i = 0; i < MAXSERVERS; i++) {
2790 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
2793 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
2794 if (rxConn->service)
2795 rxConn->service->connDeadTime = rx_connDeadTime;
2798 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2801 PrintError("", err);
2803 fprintf(STDERR, "vos: can't find volume '%s'\n",
2804 as->parms[0].items->data);
2808 if (as->parms[3].items || as->parms[4].items) {
2809 if (!as->parms[3].items || !as->parms[4].items) {
2811 "Must specify both -server and -partition options\n");
2814 aserver = GetServer(as->parms[3].items->data);
2816 fprintf(STDERR, "Invalid server name\n");
2819 apart = volutil_GetPartitionID(as->parms[4].items->data);
2821 fprintf(STDERR, "Invalid partition name\n");
2825 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
2830 if (as->parms[1].items && strcmp(as->parms[1].items->data, "0")) {
2831 code = ktime_DateToInt32(as->parms[1].items->data, &fromdate);
2833 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
2834 as->parms[1].items->data, code);
2838 if (as->parms[2].items) {
2839 strcpy(filename, as->parms[2].items->data);
2841 strcpy(filename, "");
2844 flags = as->parms[6].items ? VOLDUMPV2_OMITDIRS : 0;
2846 if (as->parms[5].items) {
2848 UV_DumpClonedVolume(avolid, aserver, apart, fromdate,
2849 DumpFunction, filename, flags);
2852 UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction,
2855 if ((code == RXGEN_OPCODE) && (as->parms[6].items)) {
2856 flags &= ~VOLDUMPV2_OMITDIRS;
2860 PrintDiagnostics("dump", code);
2863 if (strcmp(filename, ""))
2864 fprintf(STDERR, "Dumped volume %s in file %s\n",
2865 as->parms[0].items->data, filename);
2867 fprintf(STDERR, "Dumped volume %s in stdout \n",
2868 as->parms[0].items->data);
2882 RestoreVolumeCmd(register struct cmd_syndesc *as, void *arock)
2884 afs_uint32 avolid, aparentid;
2885 afs_int32 aserver, apart, code, vcode, err;
2886 afs_int32 aoverwrite = ASK;
2887 afs_int32 acreation = 0, alastupdate = 0;
2888 int restoreflags = 0;
2889 int readonly = 0, offline = 0, voltype = RWVOL;
2891 char afilename[MAXPATHLEN], avolname[VOLSER_MAXVOLNAME + 1], apartName[10];
2892 char volname[VOLSER_MAXVOLNAME + 1];
2893 struct nvldbentry entry;
2898 if (as->parms[4].items) {
2899 avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2902 PrintError("", err);
2904 fprintf(STDERR, "vos: can't find volume '%s'\n",
2905 as->parms[4].items->data);
2911 if (as->parms[5].items) {
2912 if ((strcmp(as->parms[5].items->data, "a") == 0)
2913 || (strcmp(as->parms[5].items->data, "abort") == 0)) {
2915 } else if ((strcmp(as->parms[5].items->data, "f") == 0)
2916 || (strcmp(as->parms[5].items->data, "full") == 0)) {
2918 } else if ((strcmp(as->parms[5].items->data, "i") == 0)
2919 || (strcmp(as->parms[5].items->data, "inc") == 0)
2920 || (strcmp(as->parms[5].items->data, "increment") == 0)
2921 || (strcmp(as->parms[5].items->data, "incremental") == 0)) {
2924 fprintf(STDERR, "vos: %s is not a valid argument to -overwrite\n",
2925 as->parms[5].items->data);
2929 if (as->parms[6].items)
2931 if (as->parms[7].items) {
2936 if (as->parms[8].items) {
2937 if ((strcmp(as->parms[8].items->data, "d") == 0)
2938 || (strcmp(as->parms[8].items->data, "dump") == 0)) {
2939 acreation = TS_DUMP;
2940 } else if ((strcmp(as->parms[8].items->data, "k") == 0)
2941 || (strcmp(as->parms[8].items->data, "keep") == 0)) {
2942 acreation = TS_KEEP;
2943 } else if ((strcmp(as->parms[8].items->data, "n") == 0)
2944 || (strcmp(as->parms[8].items->data, "new") == 0)) {
2947 fprintf(STDERR, "vos: %s is not a valid argument to -creation\n",
2948 as->parms[8].items->data);
2953 if (as->parms[9].items) {
2954 if ((strcmp(as->parms[9].items->data, "d") == 0)
2955 || (strcmp(as->parms[9].items->data, "dump") == 0)) {
2956 alastupdate = TS_DUMP;
2957 } else if ((strcmp(as->parms[9].items->data, "k") == 0)
2958 || (strcmp(as->parms[9].items->data, "keep") == 0)) {
2959 alastupdate = TS_KEEP;
2960 } else if ((strcmp(as->parms[9].items->data, "n") == 0)
2961 || (strcmp(as->parms[9].items->data, "new") == 0)) {
2962 alastupdate = TS_NEW;
2964 fprintf(STDERR, "vos: %s is not a valid argument to -lastupdate\n",
2965 as->parms[9].items->data);
2970 aserver = GetServer(as->parms[0].items->data);
2972 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2973 as->parms[0].items->data);
2976 apart = volutil_GetPartitionID(as->parms[1].items->data);
2978 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2979 as->parms[1].items->data);
2982 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
2984 PrintError("", code);
2987 "vos : partition %s does not exist on the server\n",
2988 as->parms[1].items->data);
2991 strcpy(avolname, as->parms[2].items->data);
2992 if (!ISNAMEVALID(avolname)) {
2994 "vos: the name of the volume %s exceeds the size limit\n",
2998 if (!VolNameOK(avolname)) {
3000 "Illegal volume name %s, should not end in .readonly or .backup\n",
3004 if (as->parms[3].items) {
3005 strcpy(afilename, as->parms[3].items->data);
3006 if (!FileExists(afilename)) {
3007 fprintf(STDERR, "Can't access file %s\n", afilename);
3011 strcpy(afilename, "");
3014 /* Check if volume exists or not */
3016 vsu_ExtractName(volname, avolname);
3017 vcode = VLDB_GetEntryByName(volname, &entry);
3018 if (vcode) { /* no volume - do a full restore */
3019 restoreflags = RV_FULLRST;
3020 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3022 "Volume does not exist; Will perform a full restore\n");
3025 else if ((!readonly && Lp_GetRwIndex(&entry) == -1) /* RW volume does not exist - do a full */
3026 ||(readonly && !Lp_ROMatch(0, 0, &entry))) { /* RO volume does not exist - do a full */
3027 restoreflags = RV_FULLRST;
3028 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3030 "%s Volume does not exist; Will perform a full restore\n",
3031 readonly ? "RO" : "RW");
3034 avolid = entry.volumeId[voltype];
3035 } else if (entry.volumeId[voltype] != 0
3036 && entry.volumeId[voltype] != avolid) {
3037 avolid = entry.volumeId[voltype];
3039 aparentid = entry.volumeId[RWVOL];
3042 else { /* volume exists - do we do a full incremental or abort */
3043 int Oserver, Opart, Otype, vol_elsewhere = 0;
3044 struct nvldbentry Oentry;
3048 avolid = entry.volumeId[voltype];
3049 } else if (entry.volumeId[voltype] != 0
3050 && entry.volumeId[voltype] != avolid) {
3051 avolid = entry.volumeId[voltype];
3053 aparentid = entry.volumeId[RWVOL];
3055 /* A file name was specified - check if volume is on another partition */
3056 vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
3060 vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
3063 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
3067 if (!vcode || (Opart != apart))
3070 if (aoverwrite == ASK) {
3071 if (strcmp(afilename, "") == 0) { /* The file is from standard in */
3073 "Volume exists and no -overwrite option specified; Aborting restore command\n");
3077 /* Ask what to do */
3078 if (vol_elsewhere) {
3080 "The volume %s %u already exists on a different server/part\n",
3081 volname, entry.volumeId[voltype]);
3083 "Do you want to do a full restore or abort? [fa](a): ");
3086 "The volume %s %u already exists in the VLDB\n",
3087 volname, entry.volumeId[voltype]);
3089 "Do you want to do a full/incremental restore or abort? [fia](a): ");
3092 while (!(dc == EOF || dc == '\n'))
3093 dc = getchar(); /* goto end of line */
3094 if ((c == 'f') || (c == 'F'))
3096 else if ((c == 'i') || (c == 'I'))
3102 if (aoverwrite == ABORT) {
3103 fprintf(STDERR, "Volume exists; Aborting restore command\n");
3105 } else if (aoverwrite == FULL) {
3106 restoreflags = RV_FULLRST;
3108 "Volume exists; Will delete and perform full restore\n");
3109 } else if (aoverwrite == INC) {
3111 if (vol_elsewhere) {
3113 "%s volume %lu already exists on a different server/part; not allowed\n",
3114 readonly ? "RO" : "RW", (unsigned long)avolid);
3120 restoreflags |= RV_OFFLINE;
3122 restoreflags |= RV_RDONLY;
3124 switch (acreation) {
3126 restoreflags |= RV_CRDUMP;
3129 restoreflags |= RV_CRKEEP;
3132 restoreflags |= RV_CRNEW;
3135 if (aoverwrite == FULL)
3136 restoreflags |= RV_CRNEW;
3138 restoreflags |= RV_CRKEEP;
3141 switch (alastupdate) {
3143 restoreflags |= RV_LUDUMP;
3146 restoreflags |= RV_LUKEEP;
3149 restoreflags |= RV_LUNEW;
3152 restoreflags |= RV_LUDUMP;
3154 if (as->parms[10].items) {
3155 restoreflags |= RV_NODEL;
3160 UV_RestoreVolume2(aserver, apart, avolid, aparentid,
3161 avolname, restoreflags, WriteData, afilename);
3163 PrintDiagnostics("restore", code);
3166 MapPartIdIntoName(apart, apartName);
3169 * patch typo here - originally "parms[1]", should be "parms[0]"
3172 fprintf(STDOUT, "Restored volume %s on %s %s\n", avolname,
3173 as->parms[0].items->data, apartName);
3178 LockReleaseCmd(register struct cmd_syndesc *as, void *arock)
3181 afs_int32 code, err;
3183 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
3186 PrintError("", err);
3188 fprintf(STDERR, "vos: can't find volume '%s'\n",
3189 as->parms[0].items->data);
3193 code = UV_LockRelease(avolid);
3195 PrintDiagnostics("unlock", code);
3198 fprintf(STDOUT, "Released lock on vldb entry for volume %s\n",
3199 as->parms[0].items->data);
3204 AddSite(register struct cmd_syndesc *as, void *arock)
3207 afs_int32 aserver, apart, code, err, valid = 0;
3208 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3210 vsu_ExtractName(avolname, as->parms[2].items->data);;
3211 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3214 PrintError("", err);
3216 fprintf(STDERR, "vos: can't find volume '%s'\n",
3217 as->parms[2].items->data);
3220 aserver = GetServer(as->parms[0].items->data);
3222 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3223 as->parms[0].items->data);
3226 apart = volutil_GetPartitionID(as->parms[1].items->data);
3228 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3229 as->parms[1].items->data);
3232 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3234 PrintError("", code);
3237 "vos : partition %s does not exist on the server\n",
3238 as->parms[1].items->data);
3241 if (as->parms[3].items) {
3244 code = UV_AddSite(aserver, apart, avolid, valid);
3246 PrintDiagnostics("addsite", code);
3249 MapPartIdIntoName(apart, apartName);
3250 fprintf(STDOUT, "Added replication site %s %s for volume %s\n",
3251 as->parms[0].items->data, apartName, as->parms[2].items->data);
3256 RemoveSite(register struct cmd_syndesc *as, void *arock)
3260 afs_int32 aserver, apart, code, err;
3261 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3263 vsu_ExtractName(avolname, as->parms[2].items->data);
3264 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3267 PrintError("", err);
3269 fprintf(STDERR, "vos: can't find volume '%s'\n",
3270 as->parms[2].items->data);
3273 aserver = GetServer(as->parms[0].items->data);
3275 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3276 as->parms[0].items->data);
3279 apart = volutil_GetPartitionID(as->parms[1].items->data);
3281 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3282 as->parms[1].items->data);
3286 *skip the partition validity check, since it is possible that the partition
3287 *has since been decomissioned.
3290 if (!IsPartValid(apart,aserver,&code)){
3291 if(code) PrintError("",code);
3292 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
3296 code = UV_RemoveSite(aserver, apart, avolid);
3298 PrintDiagnostics("remsite", code);
3301 MapPartIdIntoName(apart, apartName);
3302 fprintf(STDOUT, "Removed replication site %s %s for volume %s\n",
3303 as->parms[0].items->data, apartName, as->parms[2].items->data);
3308 ChangeLocation(register struct cmd_syndesc *as, void *arock)
3311 afs_int32 aserver, apart, code, err;
3314 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3317 PrintError("", err);
3319 fprintf(STDERR, "vos: can't find volume '%s'\n",
3320 as->parms[2].items->data);
3323 aserver = GetServer(as->parms[0].items->data);
3325 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3326 as->parms[0].items->data);
3329 apart = volutil_GetPartitionID(as->parms[1].items->data);
3331 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3332 as->parms[1].items->data);
3335 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3337 PrintError("", code);
3340 "vos : partition %s does not exist on the server\n",
3341 as->parms[1].items->data);
3344 code = UV_ChangeLocation(aserver, apart, avolid);
3346 PrintDiagnostics("addsite", code);
3349 MapPartIdIntoName(apart, apartName);
3350 fprintf(STDOUT, "Changed location to %s %s for volume %s\n",
3351 as->parms[0].items->data, apartName, as->parms[2].items->data);
3356 ListPartitions(register struct cmd_syndesc *as, void *arock)
3358 afs_int32 aserver, code;
3359 struct partList dummyPartList;
3364 aserver = GetServer(as->parms[0].items->data);
3366 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3367 as->parms[0].items->data);
3372 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3374 PrintDiagnostics("listpart", code);
3378 fprintf(STDOUT, "The partitions on the server are:\n");
3379 for (i = 0; i < cnt; i++) {
3380 if (dummyPartList.partFlags[i] & PARTVALID) {
3381 memset(pname, 0, sizeof(pname));
3382 MapPartIdIntoName(dummyPartList.partId[i], pname);
3383 fprintf(STDOUT, " %10s ", pname);
3385 if ((i % 5) == 0 && (i != 0))
3386 fprintf(STDOUT, "\n");
3389 fprintf(STDOUT, "\n");
3390 fprintf(STDOUT, "Total: %d\n", total);
3396 CompareVolName(const void *p1, const void *p2)
3398 volintInfo *arg1, *arg2;
3400 arg1 = (volintInfo *) p1;
3401 arg2 = (volintInfo *) p2;
3402 return (strcmp(arg1->name, arg2->name));
3406 /*------------------------------------------------------------------------
3407 * PRIVATE XCompareVolName
3410 * Comparison routine for volume names coming from an extended
3414 * a_obj1P : Char ptr to first extended vol info object
3415 * a_obj1P : Char ptr to second extended vol info object
3418 * The value of strcmp() on the volume names within the passed
3419 * objects (i,e., -1, 0, or 1).
3422 * Passed to qsort() as the designated comparison routine.
3426 *------------------------------------------------------------------------*/
3429 XCompareVolName(const void *a_obj1P, const void *a_obj2P)
3430 { /*XCompareVolName */
3433 (((struct volintXInfo *)(a_obj1P))->name,
3434 ((struct volintXInfo *)(a_obj2P))->name));
3436 } /*XCompareVolName */
3439 CompareVolID(const void *p1, const void *p2)
3441 volintInfo *arg1, *arg2;
3443 arg1 = (volintInfo *) p1;
3444 arg2 = (volintInfo *) p2;
3445 if (arg1->volid == arg2->volid)
3447 if (arg1->volid > arg2->volid)
3454 /*------------------------------------------------------------------------
3455 * PRIVATE XCompareVolID
3458 * Comparison routine for volume IDs coming from an extended
3462 * a_obj1P : Char ptr to first extended vol info object
3463 * a_obj1P : Char ptr to second extended vol info object
3466 * The value of strcmp() on the volume names within the passed
3467 * objects (i,e., -1, 0, or 1).
3470 * Passed to qsort() as the designated comparison routine.
3474 *------------------------------------------------------------------------*/
3477 XCompareVolID(const void *a_obj1P, const void *a_obj2P)
3478 { /*XCompareVolID */
3480 afs_int32 id1, id2; /*Volume IDs we're comparing */
3482 id1 = ((struct volintXInfo *)(a_obj1P))->volid;
3483 id2 = ((struct volintXInfo *)(a_obj2P))->volid;
3491 } /*XCompareVolID */
3493 /*------------------------------------------------------------------------
3494 * PRIVATE ListVolumes
3497 * Routine used to list volumes, contacting the Volume Server
3498 * directly, bypassing the VLDB.
3501 * as : Ptr to parsed command line arguments.
3504 * 0 Successful operation
3507 * Nothing interesting.
3511 *------------------------------------------------------------------------*/
3514 ListVolumes(register struct cmd_syndesc *as, void *arock)
3516 afs_int32 apart, int32list, fast;
3517 afs_int32 aserver, code;
3519 volintInfo *oldpntr = NULL;
3523 volintXInfo *xInfoP;
3524 volintXInfo *origxInfoP = NULL; /*Ptr to current/orig extended vol info */
3525 int wantExtendedInfo; /*Do we want extended vol info? */
3528 struct partList dummyPartList;
3536 if (as->parms[3].items)
3538 if (as->parms[4].items)
3542 if (as->parms[2].items)
3548 if (as->parms[5].items) {
3550 * We can't coexist with the fast flag.
3554 "vos: Can't use the -fast and -extended flags together\n");
3559 * We need to turn on ``long'' listings to get the full effect.
3561 wantExtendedInfo = 1;
3564 wantExtendedInfo = 0;
3565 if (as->parms[1].items) {
3566 apart = volutil_GetPartitionID(as->parms[1].items->data);
3568 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3569 as->parms[1].items->data);
3572 dummyPartList.partId[0] = apart;
3573 dummyPartList.partFlags[0] = PARTVALID;
3576 aserver = GetServer(as->parms[0].items->data);
3578 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3579 as->parms[0].items->data);
3584 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3586 PrintError("", code);
3589 "vos : partition %s does not exist on the server\n",
3590 as->parms[1].items->data);
3594 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3596 PrintDiagnostics("listvol", code);
3600 for (i = 0; i < cnt; i++) {
3601 if (dummyPartList.partFlags[i] & PARTVALID) {
3602 if (wantExtendedInfo)
3604 UV_XListVolumes(aserver, dummyPartList.partId[i], all,
3608 UV_ListVolumes(aserver, dummyPartList.partId[i], all,
3611 PrintDiagnostics("listvol", code);
3616 if (wantExtendedInfo) {
3617 origxInfoP = xInfoP;
3618 base = (char *)xInfoP;
3621 base = (char *)pntr;
3625 if (wantExtendedInfo)
3626 qsort(base, count, sizeof(volintXInfo), XCompareVolName);
3628 qsort(base, count, sizeof(volintInfo), CompareVolName);
3630 if (wantExtendedInfo)
3631 qsort(base, count, sizeof(volintXInfo), XCompareVolID);
3633 qsort(base, count, sizeof(volintInfo), CompareVolID);
3635 MapPartIdIntoName(dummyPartList.partId[i], pname);
3638 "Total number of volumes on server %s partition %s: %lu \n",
3639 as->parms[0].items->data, pname,
3640 (unsigned long)count);
3641 if (wantExtendedInfo) {
3642 #ifdef FULL_LISTVOL_SWITCH
3643 if (as->parms[6].items)
3644 XDisplayVolumes2(aserver, dummyPartList.partId[i], origxInfoP,
3645 count, int32list, fast, quiet);
3647 #endif /* FULL_LISTVOL_SWITCH */
3648 XDisplayVolumes(aserver, dummyPartList.partId[i], origxInfoP,
3649 count, int32list, fast, quiet);