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_GetHumanInt32(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 code = util_GetHumanInt32(as->parms[3].items->data, "a);
1907 fprintf(STDERR, "vos: bad integer specified for quota.\n");
1913 UV_CreateVolume2(tserver, pnum, as->parms[2].items->data, quota, 0,
1916 PrintDiagnostics("create", code);
1919 MapPartIdIntoName(pnum, part);
1920 fprintf(STDOUT, "Volume %lu created on partition %s of %s\n",
1921 (unsigned long)volid, part, as->parms[0].items->data);
1928 DeleteAll(struct nvldbentry *entry)
1931 afs_int32 error, code, curserver, curpart;
1934 MapHostToNetwork(entry);
1936 for (i = 0; i < entry->nServers; i++) {
1937 curserver = entry->serverNumber[i];
1938 curpart = entry->serverPartition[i];
1939 if (entry->serverFlags[i] & ITSROVOL) {
1940 volid = entry->volumeId[ROVOL];
1942 volid = entry->volumeId[RWVOL];
1944 code = UV_DeleteVolume(curserver, curpart, volid);
1953 DeleteVolume(struct cmd_syndesc *as, void *arock)
1955 afs_int32 err, code = 0;
1956 afs_int32 server = 0, partition = -1;
1961 if (as->parms[0].items) {
1962 server = GetServer(as->parms[0].items->data);
1964 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1965 as->parms[0].items->data);
1970 if (as->parms[1].items) {
1971 partition = volutil_GetPartitionID(as->parms[1].items->data);
1972 if (partition < 0) {
1973 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1974 as->parms[1].items->data);
1978 /* Check for validity of the partition */
1979 if (!IsPartValid(partition, server, &code)) {
1981 PrintError("", code);
1984 "vos : partition %s does not exist on the server\n",
1985 as->parms[1].items->data);
1991 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
1993 fprintf(STDERR, "Can't find volume name '%s' in VLDB\n",
1994 as->parms[2].items->data);
1996 PrintError("", err);
2000 /* If the server or partition option are not complete, try to fill
2001 * them in from the VLDB entry.
2003 if ((partition == -1) || !server) {
2004 struct nvldbentry entry;
2006 code = VLDB_GetEntryByID(volid, -1, &entry);
2009 "Could not fetch the entry for volume %lu from VLDB\n",
2010 (unsigned long)volid);
2011 PrintError("", code);
2015 if (((volid == entry.volumeId[RWVOL]) && (entry.flags & RW_EXISTS))
2016 || ((volid == entry.volumeId[BACKVOL])
2017 && (entry.flags & BACK_EXISTS))) {
2018 idx = Lp_GetRwIndex(&entry);
2019 if ((idx == -1) || (server && (server != entry.serverNumber[idx]))
2020 || ((partition != -1)
2021 && (partition != entry.serverPartition[idx]))) {
2022 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2023 as->parms[2].items->data);
2026 } else if ((volid == entry.volumeId[ROVOL])
2027 && (entry.flags & RO_EXISTS)) {
2028 for (idx = -1, j = 0; j < entry.nServers; j++) {
2029 if (entry.serverFlags[j] != ITSROVOL)
2032 if (((server == 0) || (server == entry.serverNumber[j]))
2033 && ((partition == -1)
2034 || (partition == entry.serverPartition[j]))) {
2037 "VLDB: Volume '%s' matches more than one RO\n",
2038 as->parms[2].items->data);
2045 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2046 as->parms[2].items->data);
2050 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2051 as->parms[2].items->data);
2055 server = htonl(entry.serverNumber[idx]);
2056 partition = entry.serverPartition[idx];
2060 code = UV_DeleteVolume(server, partition, volid);
2062 PrintDiagnostics("remove", code);
2066 MapPartIdIntoName(partition, pname);
2067 fprintf(STDOUT, "Volume %lu on partition %s server %s deleted\n",
2068 (unsigned long)volid, pname, hostutil_GetNameByINet(server));
2072 #define TESTM 0 /* set for move space tests, clear for production */
2074 MoveVolume(register struct cmd_syndesc *as, void *arock)
2078 afs_int32 fromserver, toserver, frompart, topart;
2079 afs_int32 flags, code, err;
2080 char fromPartName[10], toPartName[10];
2082 struct diskPartition64 partition; /* for space check */
2085 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2088 PrintError("", err);
2090 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2091 as->parms[0].items->data);
2094 fromserver = GetServer(as->parms[1].items->data);
2095 if (fromserver == 0) {
2096 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2097 as->parms[1].items->data);
2100 toserver = GetServer(as->parms[3].items->data);
2101 if (toserver == 0) {
2102 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2103 as->parms[3].items->data);
2106 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2108 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2109 as->parms[2].items->data);
2112 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2114 PrintError("", code);
2117 "vos : partition %s does not exist on the server\n",
2118 as->parms[2].items->data);
2121 topart = volutil_GetPartitionID(as->parms[4].items->data);
2123 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2124 as->parms[4].items->data);
2127 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2129 PrintError("", code);
2132 "vos : partition %s does not exist on the server\n",
2133 as->parms[4].items->data);
2138 if (as->parms[5].items) flags |= RV_NOCLONE;
2141 * check source partition for space to clone volume
2144 MapPartIdIntoName(topart, toPartName);
2145 MapPartIdIntoName(frompart, fromPartName);
2148 * check target partition for space to move volume
2151 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2153 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2157 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2160 p = (volintInfo *) 0;
2161 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2163 fprintf(STDERR, "vos:cannot access volume %lu\n",
2164 (unsigned long)volid);
2168 fprintf(STDOUT, "volume %lu size %d\n", (unsigned long)volid,
2170 if (partition.free <= p->size) {
2172 "vos: no space on target partition %s to move volume %lu\n",
2173 toPartName, (unsigned long)volid);
2180 fprintf(STDOUT, "size test - don't do move\n");
2184 /* successful move still not guaranteed but shoot for it */
2187 UV_MoveVolume2(volid, fromserver, frompart, toserver, topart, flags);
2189 PrintDiagnostics("move", code);
2192 MapPartIdIntoName(topart, toPartName);
2193 MapPartIdIntoName(frompart, fromPartName);
2194 fprintf(STDOUT, "Volume %lu moved from %s %s to %s %s \n",
2195 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2196 as->parms[3].items->data, toPartName);
2202 CopyVolume(register struct cmd_syndesc *as, void *arock)
2205 afs_int32 fromserver, toserver, frompart, topart, code, err, flags;
2206 char fromPartName[10], toPartName[10], *tovolume;
2207 struct nvldbentry entry;
2208 struct diskPartition64 partition; /* for space check */
2211 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2214 PrintError("", err);
2216 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2217 as->parms[0].items->data);
2220 fromserver = GetServer(as->parms[1].items->data);
2221 if (fromserver == 0) {
2222 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2223 as->parms[1].items->data);
2227 toserver = GetServer(as->parms[4].items->data);
2228 if (toserver == 0) {
2229 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2230 as->parms[4].items->data);
2234 tovolume = as->parms[3].items->data;
2235 if (!ISNAMEVALID(tovolume)) {
2237 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2238 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2241 if (!VolNameOK(tovolume)) {
2243 "Illegal volume name %s, should not end in .readonly or .backup\n",
2247 if (IsNumeric(tovolume)) {
2248 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
2252 code = VLDB_GetEntryByName(tovolume, &entry);
2254 fprintf(STDERR, "Volume %s already exists\n", tovolume);
2255 PrintDiagnostics("copy", code);
2259 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2261 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2262 as->parms[2].items->data);
2265 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2267 PrintError("", code);
2270 "vos : partition %s does not exist on the server\n",
2271 as->parms[2].items->data);
2275 topart = volutil_GetPartitionID(as->parms[5].items->data);
2277 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2278 as->parms[5].items->data);
2281 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2283 PrintError("", code);
2286 "vos : partition %s does not exist on the server\n",
2287 as->parms[5].items->data);
2292 if (as->parms[6].items) flags |= RV_OFFLINE;
2293 if (as->parms[7].items) flags |= RV_RDONLY;
2294 if (as->parms[8].items) flags |= RV_NOCLONE;
2296 MapPartIdIntoName(topart, toPartName);
2297 MapPartIdIntoName(frompart, fromPartName);
2300 * check target partition for space to move volume
2303 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2305 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2309 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2312 p = (volintInfo *) 0;
2313 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2315 fprintf(STDERR, "vos:cannot access volume %lu\n",
2316 (unsigned long)volid);
2320 if (partition.free <= p->size) {
2322 "vos: no space on target partition %s to copy volume %lu\n",
2323 toPartName, (unsigned long)volid);
2329 /* successful copy still not guaranteed but shoot for it */
2332 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2335 PrintDiagnostics("copy", code);
2338 MapPartIdIntoName(topart, toPartName);
2339 MapPartIdIntoName(frompart, fromPartName);
2340 fprintf(STDOUT, "Volume %lu copied from %s %s to %s on %s %s \n",
2341 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2342 tovolume, as->parms[4].items->data, toPartName);
2349 ShadowVolume(register struct cmd_syndesc *as, void *arock)
2351 afs_uint32 volid, tovolid;
2352 afs_int32 fromserver, toserver, frompart, topart;
2353 afs_int32 code, err, flags;
2354 char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
2355 struct diskPartition64 partition; /* for space check */
2358 p = (volintInfo *) 0;
2359 q = (volintInfo *) 0;
2361 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2364 PrintError("", err);
2366 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2367 as->parms[0].items->data);
2370 fromserver = GetServer(as->parms[1].items->data);
2371 if (fromserver == 0) {
2372 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2373 as->parms[1].items->data);
2377 toserver = GetServer(as->parms[3].items->data);
2378 if (toserver == 0) {
2379 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2380 as->parms[3].items->data);
2384 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2386 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2387 as->parms[2].items->data);
2390 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2392 PrintError("", code);
2395 "vos : partition %s does not exist on the server\n",
2396 as->parms[2].items->data);
2400 topart = volutil_GetPartitionID(as->parms[4].items->data);
2402 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2403 as->parms[4].items->data);
2406 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2408 PrintError("", code);
2411 "vos : partition %s does not exist on the server\n",
2412 as->parms[4].items->data);
2416 if (as->parms[5].items) {
2417 tovolume = as->parms[5].items->data;
2418 if (!ISNAMEVALID(tovolume)) {
2420 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2421 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2424 if (!VolNameOK(tovolume)) {
2426 "Illegal volume name %s, should not end in .readonly or .backup\n",
2430 if (IsNumeric(tovolume)) {
2432 "Illegal volume name %s, should not be a number\n",
2437 /* use actual name of source volume */
2438 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2440 fprintf(STDERR, "vos:cannot access volume %lu\n",
2441 (unsigned long)volid);
2444 strcpy(toVolName, p->name);
2445 tovolume = toVolName;
2446 /* save p for size checks later */
2449 if (as->parms[6].items) {
2450 tovolid = vsu_GetVolumeID(as->parms[6].items->data, cstruct, &err);
2453 PrintError("", err);
2455 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2456 as->parms[6].items->data);
2462 tovolid = vsu_GetVolumeID(tovolume, cstruct, &err);
2465 PrintError("", err);
2467 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2476 if (as->parms[7].items) flags |= RV_OFFLINE;
2477 if (as->parms[8].items) flags |= RV_RDONLY;
2478 if (as->parms[9].items) flags |= RV_NOCLONE;
2479 if (as->parms[10].items) flags |= RV_CPINCR;
2481 MapPartIdIntoName(topart, toPartName);
2482 MapPartIdIntoName(frompart, fromPartName);
2485 * check target partition for space to move volume
2488 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2490 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2494 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2497 /* Don't do this again if we did it above */
2499 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2501 fprintf(STDERR, "vos:cannot access volume %lu\n",
2502 (unsigned long)volid);
2507 /* OK if this fails */
2508 code = UV_ListOneVolume(toserver, topart, tovolid, &q);
2510 /* Treat existing volume size as "free" */
2512 p->size = (q->size < p->size) ? p->size - q->size : 0;
2514 if (partition.free <= p->size) {
2516 "vos: no space on target partition %s to copy volume %lu\n",
2517 toPartName, (unsigned long)volid);
2525 /* successful copy still not guaranteed but shoot for it */
2528 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2529 topart, tovolid, flags);
2531 PrintDiagnostics("shadow", code);
2534 MapPartIdIntoName(topart, toPartName);
2535 MapPartIdIntoName(frompart, fromPartName);
2536 fprintf(STDOUT, "Volume %lu shadowed from %s %s to %s %s \n",
2537 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2538 as->parms[3].items->data, toPartName);
2545 CloneVolume(register struct cmd_syndesc *as, void *arock)
2547 afs_uint32 volid, cloneid;
2548 afs_int32 server, part, voltype;
2549 char partName[10], *volname;
2550 afs_int32 code, err, flags;
2551 struct nvldbentry entry;
2553 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2556 PrintError("", err);
2558 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2559 as->parms[0].items->data);
2563 if (as->parms[1].items || as->parms[2].items) {
2564 if (!as->parms[1].items || !as->parms[2].items) {
2566 "Must specify both -server and -partition options\n");
2569 server = GetServer(as->parms[1].items->data);
2571 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2572 as->parms[1].items->data);
2575 part = volutil_GetPartitionID(as->parms[2].items->data);
2577 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2578 as->parms[2].items->data);
2581 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
2583 PrintError("", code);
2586 "vos : partition %s does not exist on the server\n",
2587 as->parms[2].items->data);
2591 code = GetVolumeInfo(volid, &server, &part, &voltype, &entry);
2597 if (as->parms[3].items) {
2598 volname = as->parms[3].items->data;
2599 if (strlen(volname) > VOLSER_OLDMAXVOLNAME - 1) {
2601 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2602 volname, VOLSER_OLDMAXVOLNAME - 1);
2607 * In order that you be able to make clones of RO or BK, this
2608 * check must be omitted.
2610 if (!VolNameOK(volname)) {
2612 "Illegal volume name %s, should not end in .readonly or .backup\n",
2617 if (IsNumeric(volname)) {
2619 "Illegal volume name %s, should not be a number\n",
2626 if (as->parms[4].items) {
2627 cloneid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2630 PrintError("", err);
2632 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2633 as->parms[4].items->data);
2639 if (as->parms[5].items) flags |= RV_OFFLINE;
2640 if (as->parms[6].items) flags |= RV_RDONLY;
2644 UV_CloneVolume(server, part, volid, cloneid, volname, flags);
2647 PrintDiagnostics("clone", code);
2650 MapPartIdIntoName(part, partName);
2651 fprintf(STDOUT, "Created clone for volume %s\n",
2652 as->parms[0].items->data);
2659 BackupVolume(register struct cmd_syndesc *as, void *arock)
2662 afs_int32 aserver, apart, vtype, code, err;
2663 struct nvldbentry entry;
2666 afs_int32 buserver, bupart, butype;
2667 struct nvldbentry buentry;
2669 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2672 PrintError("", err);
2674 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2675 as->parms[0].items->data);
2678 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2682 /* verify this is a readwrite volume */
2684 if (vtype != RWVOL) {
2685 fprintf(STDERR, "%s not RW volume\n", as->parms[0].items->data);
2689 /* is there a backup volume already? */
2691 if (entry.flags & BACK_EXISTS) {
2692 /* yep, where is it? */
2694 buvolid = entry.volumeId[BACKVOL];
2695 code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
2700 code = VLDB_IsSameAddrs(buserver, aserver, &err);
2703 "Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
2709 "FATAL ERROR: backup volume %lu exists on server %lu\n",
2710 (unsigned long)buvolid, (unsigned long)buserver);
2715 /* nope, carry on */
2717 code = UV_BackupVolume(aserver, apart, avolid);
2720 PrintDiagnostics("backup", code);
2723 fprintf(STDOUT, "Created backup volume for %s \n",
2724 as->parms[0].items->data);
2729 ReleaseVolume(register struct cmd_syndesc *as, void *arock)
2732 struct nvldbentry entry;
2734 afs_int32 aserver, apart, vtype, code, err;
2737 if (as->parms[1].items)
2739 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2742 PrintError("", err);
2744 fprintf(STDERR, "vos: can't find volume '%s'\n",
2745 as->parms[0].items->data);
2748 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2752 if (vtype != RWVOL) {
2753 fprintf(STDERR, "%s not a RW volume\n", as->parms[0].items->data);
2757 if (!ISNAMEVALID(entry.name)) {
2759 "Volume name %s is too long, rename before releasing\n",
2764 code = UV_ReleaseVolume(avolid, aserver, apart, force);
2766 PrintDiagnostics("release", code);
2769 fprintf(STDOUT, "Released volume %s successfully\n",
2770 as->parms[0].items->data);
2775 DumpVolumeCmd(register struct cmd_syndesc *as, void *arock)
2778 afs_int32 aserver, apart, voltype, fromdate = 0, code, err, i, flags;
2779 char filename[MAXPATHLEN];
2780 struct nvldbentry entry;
2782 rx_SetRxDeadTime(60 * 10);
2783 for (i = 0; i < MAXSERVERS; i++) {
2784 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
2787 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
2788 if (rxConn->service)
2789 rxConn->service->connDeadTime = rx_connDeadTime;
2792 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2795 PrintError("", err);
2797 fprintf(STDERR, "vos: can't find volume '%s'\n",
2798 as->parms[0].items->data);
2802 if (as->parms[3].items || as->parms[4].items) {
2803 if (!as->parms[3].items || !as->parms[4].items) {
2805 "Must specify both -server and -partition options\n");
2808 aserver = GetServer(as->parms[3].items->data);
2810 fprintf(STDERR, "Invalid server name\n");
2813 apart = volutil_GetPartitionID(as->parms[4].items->data);
2815 fprintf(STDERR, "Invalid partition name\n");
2819 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
2824 if (as->parms[1].items && strcmp(as->parms[1].items->data, "0")) {
2825 code = ktime_DateToInt32(as->parms[1].items->data, &fromdate);
2827 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
2828 as->parms[1].items->data, code);
2832 if (as->parms[2].items) {
2833 strcpy(filename, as->parms[2].items->data);
2835 strcpy(filename, "");
2838 flags = as->parms[6].items ? VOLDUMPV2_OMITDIRS : 0;
2840 if (as->parms[5].items) {
2842 UV_DumpClonedVolume(avolid, aserver, apart, fromdate,
2843 DumpFunction, filename, flags);
2846 UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction,
2849 if ((code == RXGEN_OPCODE) && (as->parms[6].items)) {
2850 flags &= ~VOLDUMPV2_OMITDIRS;
2854 PrintDiagnostics("dump", code);
2857 if (strcmp(filename, ""))
2858 fprintf(STDERR, "Dumped volume %s in file %s\n",
2859 as->parms[0].items->data, filename);
2861 fprintf(STDERR, "Dumped volume %s in stdout \n",
2862 as->parms[0].items->data);
2876 RestoreVolumeCmd(register struct cmd_syndesc *as, void *arock)
2878 afs_uint32 avolid, aparentid;
2879 afs_int32 aserver, apart, code, vcode, err;
2880 afs_int32 aoverwrite = ASK;
2881 afs_int32 acreation = 0, alastupdate = 0;
2882 int restoreflags = 0;
2883 int readonly = 0, offline = 0, voltype = RWVOL;
2885 char afilename[MAXPATHLEN], avolname[VOLSER_MAXVOLNAME + 1], apartName[10];
2886 char volname[VOLSER_MAXVOLNAME + 1];
2887 struct nvldbentry entry;
2892 if (as->parms[4].items) {
2893 avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2896 PrintError("", err);
2898 fprintf(STDERR, "vos: can't find volume '%s'\n",
2899 as->parms[4].items->data);
2905 if (as->parms[5].items) {
2906 if ((strcmp(as->parms[5].items->data, "a") == 0)
2907 || (strcmp(as->parms[5].items->data, "abort") == 0)) {
2909 } else if ((strcmp(as->parms[5].items->data, "f") == 0)
2910 || (strcmp(as->parms[5].items->data, "full") == 0)) {
2912 } else if ((strcmp(as->parms[5].items->data, "i") == 0)
2913 || (strcmp(as->parms[5].items->data, "inc") == 0)
2914 || (strcmp(as->parms[5].items->data, "increment") == 0)
2915 || (strcmp(as->parms[5].items->data, "incremental") == 0)) {
2918 fprintf(STDERR, "vos: %s is not a valid argument to -overwrite\n",
2919 as->parms[5].items->data);
2923 if (as->parms[6].items)
2925 if (as->parms[7].items) {
2930 if (as->parms[8].items) {
2931 if ((strcmp(as->parms[8].items->data, "d") == 0)
2932 || (strcmp(as->parms[8].items->data, "dump") == 0)) {
2933 acreation = TS_DUMP;
2934 } else if ((strcmp(as->parms[8].items->data, "k") == 0)
2935 || (strcmp(as->parms[8].items->data, "keep") == 0)) {
2936 acreation = TS_KEEP;
2937 } else if ((strcmp(as->parms[8].items->data, "n") == 0)
2938 || (strcmp(as->parms[8].items->data, "new") == 0)) {
2941 fprintf(STDERR, "vos: %s is not a valid argument to -creation\n",
2942 as->parms[8].items->data);
2947 if (as->parms[9].items) {
2948 if ((strcmp(as->parms[9].items->data, "d") == 0)
2949 || (strcmp(as->parms[9].items->data, "dump") == 0)) {
2950 alastupdate = TS_DUMP;
2951 } else if ((strcmp(as->parms[9].items->data, "k") == 0)
2952 || (strcmp(as->parms[9].items->data, "keep") == 0)) {
2953 alastupdate = TS_KEEP;
2954 } else if ((strcmp(as->parms[9].items->data, "n") == 0)
2955 || (strcmp(as->parms[9].items->data, "new") == 0)) {
2956 alastupdate = TS_NEW;
2958 fprintf(STDERR, "vos: %s is not a valid argument to -lastupdate\n",
2959 as->parms[9].items->data);
2964 aserver = GetServer(as->parms[0].items->data);
2966 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2967 as->parms[0].items->data);
2970 apart = volutil_GetPartitionID(as->parms[1].items->data);
2972 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2973 as->parms[1].items->data);
2976 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
2978 PrintError("", code);
2981 "vos : partition %s does not exist on the server\n",
2982 as->parms[1].items->data);
2985 strcpy(avolname, as->parms[2].items->data);
2986 if (!ISNAMEVALID(avolname)) {
2988 "vos: the name of the volume %s exceeds the size limit\n",
2992 if (!VolNameOK(avolname)) {
2994 "Illegal volume name %s, should not end in .readonly or .backup\n",
2998 if (as->parms[3].items) {
2999 strcpy(afilename, as->parms[3].items->data);
3000 if (!FileExists(afilename)) {
3001 fprintf(STDERR, "Can't access file %s\n", afilename);
3005 strcpy(afilename, "");
3008 /* Check if volume exists or not */
3010 vsu_ExtractName(volname, avolname);
3011 vcode = VLDB_GetEntryByName(volname, &entry);
3012 if (vcode) { /* no volume - do a full restore */
3013 restoreflags = RV_FULLRST;
3014 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3016 "Volume does not exist; Will perform a full restore\n");
3019 else if ((!readonly && Lp_GetRwIndex(&entry) == -1) /* RW volume does not exist - do a full */
3020 ||(readonly && !Lp_ROMatch(0, 0, &entry))) { /* RO volume does not exist - do a full */
3021 restoreflags = RV_FULLRST;
3022 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3024 "%s Volume does not exist; Will perform a full restore\n",
3025 readonly ? "RO" : "RW");
3028 avolid = entry.volumeId[voltype];
3029 } else if (entry.volumeId[voltype] != 0
3030 && entry.volumeId[voltype] != avolid) {
3031 avolid = entry.volumeId[voltype];
3033 aparentid = entry.volumeId[RWVOL];
3036 else { /* volume exists - do we do a full incremental or abort */
3037 int Oserver, Opart, Otype, vol_elsewhere = 0;
3038 struct nvldbentry Oentry;
3042 avolid = entry.volumeId[voltype];
3043 } else if (entry.volumeId[voltype] != 0
3044 && entry.volumeId[voltype] != avolid) {
3045 avolid = entry.volumeId[voltype];
3047 aparentid = entry.volumeId[RWVOL];
3049 /* A file name was specified - check if volume is on another partition */
3050 vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
3054 vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
3057 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
3061 if (!vcode || (Opart != apart))
3064 if (aoverwrite == ASK) {
3065 if (strcmp(afilename, "") == 0) { /* The file is from standard in */
3067 "Volume exists and no -overwrite option specified; Aborting restore command\n");
3071 /* Ask what to do */
3072 if (vol_elsewhere) {
3074 "The volume %s %u already exists on a different server/part\n",
3075 volname, entry.volumeId[voltype]);
3077 "Do you want to do a full restore or abort? [fa](a): ");
3080 "The volume %s %u already exists in the VLDB\n",
3081 volname, entry.volumeId[voltype]);
3083 "Do you want to do a full/incremental restore or abort? [fia](a): ");
3086 while (!(dc == EOF || dc == '\n'))
3087 dc = getchar(); /* goto end of line */
3088 if ((c == 'f') || (c == 'F'))
3090 else if ((c == 'i') || (c == 'I'))
3096 if (aoverwrite == ABORT) {
3097 fprintf(STDERR, "Volume exists; Aborting restore command\n");
3099 } else if (aoverwrite == FULL) {
3100 restoreflags = RV_FULLRST;
3102 "Volume exists; Will delete and perform full restore\n");
3103 } else if (aoverwrite == INC) {
3105 if (vol_elsewhere) {
3107 "%s volume %lu already exists on a different server/part; not allowed\n",
3108 readonly ? "RO" : "RW", (unsigned long)avolid);
3114 restoreflags |= RV_OFFLINE;
3116 restoreflags |= RV_RDONLY;
3118 switch (acreation) {
3120 restoreflags |= RV_CRDUMP;
3123 restoreflags |= RV_CRKEEP;
3126 restoreflags |= RV_CRNEW;
3129 if (aoverwrite == FULL)
3130 restoreflags |= RV_CRNEW;
3132 restoreflags |= RV_CRKEEP;
3135 switch (alastupdate) {
3137 restoreflags |= RV_LUDUMP;
3140 restoreflags |= RV_LUKEEP;
3143 restoreflags |= RV_LUNEW;
3146 restoreflags |= RV_LUDUMP;
3148 if (as->parms[10].items) {
3149 restoreflags |= RV_NODEL;
3154 UV_RestoreVolume2(aserver, apart, avolid, aparentid,
3155 avolname, restoreflags, WriteData, afilename);
3157 PrintDiagnostics("restore", code);
3160 MapPartIdIntoName(apart, apartName);
3163 * patch typo here - originally "parms[1]", should be "parms[0]"
3166 fprintf(STDOUT, "Restored volume %s on %s %s\n", avolname,
3167 as->parms[0].items->data, apartName);
3172 LockReleaseCmd(register struct cmd_syndesc *as, void *arock)
3175 afs_int32 code, err;
3177 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
3180 PrintError("", err);
3182 fprintf(STDERR, "vos: can't find volume '%s'\n",
3183 as->parms[0].items->data);
3187 code = UV_LockRelease(avolid);
3189 PrintDiagnostics("unlock", code);
3192 fprintf(STDOUT, "Released lock on vldb entry for volume %s\n",
3193 as->parms[0].items->data);
3198 AddSite(register struct cmd_syndesc *as, void *arock)
3201 afs_int32 aserver, apart, code, err, valid = 0;
3202 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3204 vsu_ExtractName(avolname, as->parms[2].items->data);;
3205 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3208 PrintError("", err);
3210 fprintf(STDERR, "vos: can't find volume '%s'\n",
3211 as->parms[2].items->data);
3214 aserver = GetServer(as->parms[0].items->data);
3216 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3217 as->parms[0].items->data);
3220 apart = volutil_GetPartitionID(as->parms[1].items->data);
3222 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3223 as->parms[1].items->data);
3226 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3228 PrintError("", code);
3231 "vos : partition %s does not exist on the server\n",
3232 as->parms[1].items->data);
3235 if (as->parms[3].items) {
3238 code = UV_AddSite(aserver, apart, avolid, valid);
3240 PrintDiagnostics("addsite", code);
3243 MapPartIdIntoName(apart, apartName);
3244 fprintf(STDOUT, "Added replication site %s %s for volume %s\n",
3245 as->parms[0].items->data, apartName, as->parms[2].items->data);
3250 RemoveSite(register struct cmd_syndesc *as, void *arock)
3254 afs_int32 aserver, apart, code, err;
3255 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3257 vsu_ExtractName(avolname, as->parms[2].items->data);
3258 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3261 PrintError("", err);
3263 fprintf(STDERR, "vos: can't find volume '%s'\n",
3264 as->parms[2].items->data);
3267 aserver = GetServer(as->parms[0].items->data);
3269 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3270 as->parms[0].items->data);
3273 apart = volutil_GetPartitionID(as->parms[1].items->data);
3275 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3276 as->parms[1].items->data);
3280 *skip the partition validity check, since it is possible that the partition
3281 *has since been decomissioned.
3284 if (!IsPartValid(apart,aserver,&code)){
3285 if(code) PrintError("",code);
3286 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
3290 code = UV_RemoveSite(aserver, apart, avolid);
3292 PrintDiagnostics("remsite", code);
3295 MapPartIdIntoName(apart, apartName);
3296 fprintf(STDOUT, "Removed replication site %s %s for volume %s\n",
3297 as->parms[0].items->data, apartName, as->parms[2].items->data);
3302 ChangeLocation(register struct cmd_syndesc *as, void *arock)
3305 afs_int32 aserver, apart, code, err;
3308 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3311 PrintError("", err);
3313 fprintf(STDERR, "vos: can't find volume '%s'\n",
3314 as->parms[2].items->data);
3317 aserver = GetServer(as->parms[0].items->data);
3319 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3320 as->parms[0].items->data);
3323 apart = volutil_GetPartitionID(as->parms[1].items->data);
3325 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3326 as->parms[1].items->data);
3329 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3331 PrintError("", code);
3334 "vos : partition %s does not exist on the server\n",
3335 as->parms[1].items->data);
3338 code = UV_ChangeLocation(aserver, apart, avolid);
3340 PrintDiagnostics("addsite", code);
3343 MapPartIdIntoName(apart, apartName);
3344 fprintf(STDOUT, "Changed location to %s %s for volume %s\n",
3345 as->parms[0].items->data, apartName, as->parms[2].items->data);
3350 ListPartitions(register struct cmd_syndesc *as, void *arock)
3352 afs_int32 aserver, code;
3353 struct partList dummyPartList;
3358 aserver = GetServer(as->parms[0].items->data);
3360 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3361 as->parms[0].items->data);
3366 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3368 PrintDiagnostics("listpart", code);
3372 fprintf(STDOUT, "The partitions on the server are:\n");
3373 for (i = 0; i < cnt; i++) {
3374 if (dummyPartList.partFlags[i] & PARTVALID) {
3375 memset(pname, 0, sizeof(pname));
3376 MapPartIdIntoName(dummyPartList.partId[i], pname);
3377 fprintf(STDOUT, " %10s ", pname);
3379 if ((i % 5) == 0 && (i != 0))
3380 fprintf(STDOUT, "\n");
3383 fprintf(STDOUT, "\n");
3384 fprintf(STDOUT, "Total: %d\n", total);
3390 CompareVolName(const void *p1, const void *p2)
3392 volintInfo *arg1, *arg2;
3394 arg1 = (volintInfo *) p1;
3395 arg2 = (volintInfo *) p2;
3396 return (strcmp(arg1->name, arg2->name));
3400 /*------------------------------------------------------------------------
3401 * PRIVATE XCompareVolName
3404 * Comparison routine for volume names coming from an extended
3408 * a_obj1P : Char ptr to first extended vol info object
3409 * a_obj1P : Char ptr to second extended vol info object
3412 * The value of strcmp() on the volume names within the passed
3413 * objects (i,e., -1, 0, or 1).
3416 * Passed to qsort() as the designated comparison routine.
3420 *------------------------------------------------------------------------*/
3423 XCompareVolName(const void *a_obj1P, const void *a_obj2P)
3424 { /*XCompareVolName */
3427 (((struct volintXInfo *)(a_obj1P))->name,
3428 ((struct volintXInfo *)(a_obj2P))->name));
3430 } /*XCompareVolName */
3433 CompareVolID(const void *p1, const void *p2)
3435 volintInfo *arg1, *arg2;
3437 arg1 = (volintInfo *) p1;
3438 arg2 = (volintInfo *) p2;
3439 if (arg1->volid == arg2->volid)
3441 if (arg1->volid > arg2->volid)
3448 /*------------------------------------------------------------------------
3449 * PRIVATE XCompareVolID
3452 * Comparison routine for volume IDs coming from an extended
3456 * a_obj1P : Char ptr to first extended vol info object
3457 * a_obj1P : Char ptr to second extended vol info object
3460 * The value of strcmp() on the volume names within the passed
3461 * objects (i,e., -1, 0, or 1).
3464 * Passed to qsort() as the designated comparison routine.
3468 *------------------------------------------------------------------------*/
3471 XCompareVolID(const void *a_obj1P, const void *a_obj2P)
3472 { /*XCompareVolID */
3474 afs_int32 id1, id2; /*Volume IDs we're comparing */
3476 id1 = ((struct volintXInfo *)(a_obj1P))->volid;
3477 id2 = ((struct volintXInfo *)(a_obj2P))->volid;
3485 } /*XCompareVolID */
3487 /*------------------------------------------------------------------------
3488 * PRIVATE ListVolumes
3491 * Routine used to list volumes, contacting the Volume Server
3492 * directly, bypassing the VLDB.
3495 * as : Ptr to parsed command line arguments.
3498 * 0 Successful operation
3501 * Nothing interesting.
3505 *------------------------------------------------------------------------*/
3508 ListVolumes(register struct cmd_syndesc *as, void *arock)
3510 afs_int32 apart, int32list, fast;
3511 afs_int32 aserver, code;
3513 volintInfo *oldpntr = NULL;
3517 volintXInfo *xInfoP;
3518 volintXInfo *origxInfoP = NULL; /*Ptr to current/orig extended vol info */
3519 int wantExtendedInfo; /*Do we want extended vol info? */
3522 struct partList dummyPartList;
3530 if (as->parms[3].items)
3532 if (as->parms[4].items)
3536 if (as->parms[2].items)
3542 if (as->parms[5].items) {
3544 * We can't coexist with the fast flag.
3548 "vos: Can't use the -fast and -extended flags together\n");
3553 * We need to turn on ``long'' listings to get the full effect.
3555 wantExtendedInfo = 1;
3558 wantExtendedInfo = 0;
3559 if (as->parms[1].items) {
3560 apart = volutil_GetPartitionID(as->parms[1].items->data);
3562 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3563 as->parms[1].items->data);
3566 dummyPartList.partId[0] = apart;
3567 dummyPartList.partFlags[0] = PARTVALID;
3570 aserver = GetServer(as->parms[0].items->data);
3572 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3573 as->parms[0].items->data);
3578 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3580 PrintError("", code);
3583 "vos : partition %s does not exist on the server\n",
3584 as->parms[1].items->data);
3588 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3590 PrintDiagnostics("listvol", code);
3594 for (i = 0; i < cnt; i++) {
3595 if (dummyPartList.partFlags[i] & PARTVALID) {
3596 if (wantExtendedInfo)
3598 UV_XListVolumes(aserver, dummyPartList.partId[i], all,
3602 UV_ListVolumes(aserver, dummyPartList.partId[i], all,
3605 PrintDiagnostics("listvol", code);
3610 if (wantExtendedInfo) {
3611 origxInfoP = xInfoP;
3612 base = (char *)xInfoP;
3615 base = (char *)pntr;
3619 if (wantExtendedInfo)
3620 qsort(base, count, sizeof(volintXInfo), XCompareVolName);
3622 qsort(base, count, sizeof(volintInfo), CompareVolName);
3624 if (wantExtendedInfo)
3625 qsort(base, count, sizeof(volintXInfo), XCompareVolID);
3627 qsort(base, count, sizeof(volintInfo), CompareVolID);
3629 MapPartIdIntoName(dummyPartList.partId[i], pname);
3632 "Total number of volumes on server %s partition %s: %lu \n",
3633 as->parms[0].items->data, pname,
3634 (unsigned long)count);
3635 if (wantExtendedInfo) {
3636 #ifdef FULL_LISTVOL_SWITCH
3637 if (as->parms[6].items)
3638 XDisplayVolumes2(aserver, dummyPartList.partId[i], origxInfoP,
3639 count, int32list, fast, quiet);
3641 #endif /* FULL_LISTVOL_SWITCH */
3642 XDisplayVolumes(aserver, dummyPartList.partId[i], origxInfoP,
3643 count, int32list, fast, quiet);
3646 xInfoP = (volintXInfo *) 0;