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_cast_uint32(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_cast_uint32(a_xInfoP->backupID));
898 fprintf(STDOUT, "parentID\t%lu\n",
899 afs_cast_uint32(a_xInfoP->parentID));
900 fprintf(STDOUT, "cloneID\t\t%lu\n",
901 afs_cast_uint32(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_cast_uint32(a_xInfoP->creationDate),
919 vos_ctime(&a_xInfoP->creationDate));
920 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
921 afs_cast_uint32(a_xInfoP->accessDate),
922 vos_ctime(&a_xInfoP->accessDate));
923 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
924 afs_cast_uint32(a_xInfoP->updateDate),
925 vos_ctime(&a_xInfoP->updateDate));
926 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
927 afs_cast_uint32(a_xInfoP->backupDate),
928 vos_ctime(&a_xInfoP->backupDate));
929 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
930 afs_cast_uint32(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_cast_uint32(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_cast_uint32(pntr->backupID));
1052 fprintf(STDOUT, "parentID\t%lu\n",
1053 afs_cast_uint32(pntr->parentID));
1054 fprintf(STDOUT, "cloneID\t\t%lu\n",
1055 afs_cast_uint32(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_cast_uint32(pntr->creationDate),
1076 vos_ctime(&pntr->creationDate));
1077 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
1078 afs_cast_uint32(pntr->accessDate),
1079 vos_ctime(&pntr->accessDate));
1080 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
1081 afs_cast_uint32(pntr->updateDate),
1082 vos_ctime(&pntr->updateDate));
1083 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
1084 afs_cast_uint32(pntr->backupDate),
1085 vos_ctime(&pntr->backupDate));
1086 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
1087 afs_cast_uint32(pntr->copyDate),
1088 vos_ctime(&pntr->copyDate));
1089 fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n",
1090 afs_cast_uint32(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_cast_uint32(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_cast_uint32(pntr->spare1));
1099 fprintf(STDOUT, "spare2\t\t%lu\t(Optional)\n",
1100 afs_cast_uint32(pntr->spare2));
1101 fprintf(STDOUT, "spare3\t\t%lu\t(Optional)\n",
1102 afs_cast_uint32(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);
3652 xInfoP = (volintXInfo *) 0;
3654 #ifdef FULL_LISTVOL_SWITCH
3655 if (as->parms[6].items)
3656 DisplayVolumes2(aserver, dummyPartList.partId[i], oldpntr,
3659 #endif /* FULL_LISTVOL_SWITCH */
3660 DisplayVolumes(aserver, dummyPartList.partId[i], oldpntr,
3661 count, int32list, fast, quiet);
3664 pntr = (volintInfo *) 0;
3672 SyncVldb(register struct cmd_syndesc *as, void *arock)
3674 afs_int32 pnum = 0, code; /* part name */
3680 if (as->parms[0].items) {
3681 tserver = GetServer(as->parms[0].items->data);
3683 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3684 as->parms[0].items->data);
3689 if (as->parms[1].items) {
3690 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3692 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3693 as->parms[1].items->data);
3696 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3698 PrintError("", code);
3701 "vos: partition %s does not exist on the server\n",
3702 as->parms[1].items->data);
3709 "The -partition option requires a -server option\n");
3714 if (as->parms[3].items) {
3715 flags |= 2; /* don't update */
3718 if (as->parms[2].items) {
3719 /* Synchronize an individual volume */
3720 volname = as->parms[2].items->data;
3721 code = UV_SyncVolume(tserver, pnum, volname, flags);
3725 "Without a -volume option, the -server option is required\n");
3728 code = UV_SyncVldb(tserver, pnum, flags, 0 /*unused */ );
3732 PrintDiagnostics("syncvldb", code);
3736 /* Print a summary of what we did */
3738 fprintf(STDOUT, "VLDB volume %s synchronized", volname);
3740 fprintf(STDOUT, "VLDB synchronized");
3742 fprintf(STDOUT, " with state of server %s", as->parms[0].items->data);
3745 MapPartIdIntoName(pnum, part);
3746 fprintf(STDOUT, " partition %s\n", part);
3748 fprintf(STDOUT, "\n");
3754 SyncServer(register struct cmd_syndesc *as, void *arock)
3756 afs_int32 pnum, code; /* part name */
3761 tserver = GetServer(as->parms[0].items->data);
3763 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3764 as->parms[0].items->data);
3767 if (as->parms[1].items) {
3768 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3770 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3771 as->parms[1].items->data);
3774 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3776 PrintError("", code);
3779 "vos : partition %s does not exist on the server\n",
3780 as->parms[1].items->data);
3788 if (as->parms[2].items) {
3789 flags |= 2; /* don't update */
3791 code = UV_SyncServer(tserver, pnum, flags, 0 /*unused */ );
3793 PrintDiagnostics("syncserv", code);
3797 MapPartIdIntoName(pnum, part);
3798 fprintf(STDOUT, "Server %s partition %s synchronized with VLDB\n",
3799 as->parms[0].items->data, part);
3801 fprintf(STDOUT, "Server %s synchronized with VLDB\n",
3802 as->parms[0].items->data);
3808 VolumeInfoCmd(char *name)
3810 struct nvldbentry entry;
3813 /* The vlserver will handle names with the .readonly
3814 * and .backup extension as well as volume ids.
3816 vcode = VLDB_GetEntryByName(name, &entry);
3818 PrintError("", vcode);
3821 MapHostToNetwork(&entry);
3822 EnumerateEntry(&entry);
3824 /* Defect #3027: grubby check to handle locked volume.
3825 * If VLOP_ALLOPERS is set, the entry is locked.
3826 * Leave this routine as is, but put in correct check.
3828 if (entry.flags & VLOP_ALLOPERS)
3829 fprintf(STDOUT, " Volume is currently LOCKED \n");
3835 VolumeZap(register struct cmd_syndesc *as, void *arock)
3837 struct nvldbentry entry;
3838 afs_uint32 volid, zapbackupid = 0, backupid = 0;
3839 afs_int32 code, server, part, err;
3841 if (as->parms[3].items) {
3842 /* force flag is on, use the other version */
3843 return NukeVolume(as);
3846 if (as->parms[4].items) {
3850 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3853 PrintError("", err);
3855 fprintf(STDERR, "vos: can't find volume '%s'\n",
3856 as->parms[2].items->data);
3859 part = volutil_GetPartitionID(as->parms[1].items->data);
3861 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3862 as->parms[1].items->data);
3865 server = GetServer(as->parms[0].items->data);
3867 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3868 as->parms[0].items->data);
3871 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
3873 PrintError("", code);
3876 "vos : partition %s does not exist on the server\n",
3877 as->parms[1].items->data);
3880 code = VLDB_GetEntryByID(volid, -1, &entry);
3882 if (volid == entry.volumeId[RWVOL])
3883 backupid = entry.volumeId[BACKVOL];
3885 "Warning: Entry for volume number %lu exists in VLDB (but we're zapping it anyway!)\n",
3886 (unsigned long)volid);
3889 volintInfo *pntr = (volintInfo *) 0;
3892 code = UV_ListOneVolume(server, part, volid, &pntr);
3894 if (volid == pntr->parentID)
3895 backupid = pntr->backupID;
3901 code = UV_VolumeZap(server, part, backupid);
3903 PrintDiagnostics("zap", code);
3906 fprintf(STDOUT, "Backup Volume %lu deleted\n",
3907 (unsigned long)backupid);
3910 code = UV_VolumeZap(server, part, volid);
3912 PrintDiagnostics("zap", code);
3915 fprintf(STDOUT, "Volume %lu deleted\n", (unsigned long)volid);
3921 VolserStatus(register struct cmd_syndesc *as, void *arock)
3923 afs_int32 server, code;
3924 transDebugInfo *pntr, *oldpntr;
3929 server = GetServer(as->parms[0].items->data);
3931 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3932 as->parms[0].items->data);
3935 code = UV_VolserStatus(server, &pntr, &count);
3937 PrintDiagnostics("status", code);
3942 fprintf(STDOUT, "No active transactions on %s\n",
3943 as->parms[0].items->data);
3945 fprintf(STDOUT, "Total transactions: %d\n", count);
3947 for (i = 0; i < count; i++) {
3948 /*print out the relevant info */
3949 fprintf(STDOUT, "--------------------------------------\n");
3950 fprintf(STDOUT, "transaction: %lu created: %s",
3951 (unsigned long)pntr->tid, vos_ctime( & pntr->time));
3952 if (pntr->returnCode) {
3953 fprintf(STDOUT, "returnCode: %lu\n",
3954 (unsigned long)pntr->returnCode);
3957 fprintf(STDOUT, "attachFlags: ");
3958 switch (pntr->iflags) {
3960 fprintf(STDOUT, "offline ");
3963 fprintf(STDOUT, "busy ");
3966 fprintf(STDOUT, "readonly ");
3969 fprintf(STDOUT, "create ");
3972 fprintf(STDOUT, "create volid ");
3975 fprintf(STDOUT, "\n");
3978 fprintf(STDOUT, "volumeStatus: ");
3979 switch (pntr->vflags) {
3980 case VTDeleteOnSalvage:
3981 fprintf(STDOUT, "deleteOnSalvage ");
3982 case VTOutOfService:
3983 fprintf(STDOUT, "outOfService ");
3985 fprintf(STDOUT, "deleted ");
3987 fprintf(STDOUT, "\n");
3990 fprintf(STDOUT, "transactionFlags: ");
3991 fprintf(STDOUT, "delete\n");
3993 MapPartIdIntoName(pntr->partition, pname);
3994 fprintf(STDOUT, "volume: %lu partition: %s procedure: %s\n",
3995 (unsigned long)pntr->volid, pname, pntr->lastProcName);
3996 if (pntr->callValid) {
3998 "packetRead: %lu lastReceiveTime: %d packetSend: %lu lastSendTime: %d\n",
3999 (unsigned long)pntr->readNext, pntr->lastReceiveTime,
4000 (unsigned long)pntr->transmitNext, pntr->lastSendTime);
4003 fprintf(STDOUT, "--------------------------------------\n");
4004 fprintf(STDOUT, "\n");
4012 RenameVolume(register struct cmd_syndesc *as, void *arock)
4014 afs_int32 code1, code2, code;
4015 struct nvldbentry entry;
4017 code1 = VLDB_GetEntryByName(as->parms[0].items->data, &entry);
4019 fprintf(STDERR, "vos: Could not find entry for volume %s\n",
4020 as->parms[0].items->data);
4023 code2 = VLDB_GetEntryByName(as->parms[1].items->data, &entry);
4024 if ((!code1) && (!code2)) { /*the newname already exists */
4025 fprintf(STDERR, "vos: volume %s already exists\n",
4026 as->parms[1].items->data);
4030 if (code1 && code2) {
4031 fprintf(STDERR, "vos: Could not find entry for volume %s or %s\n",
4032 as->parms[0].items->data, as->parms[1].items->data);
4035 if (!VolNameOK(as->parms[0].items->data)) {
4037 "Illegal volume name %s, should not end in .readonly or .backup\n",
4038 as->parms[0].items->data);
4041 if (!ISNAMEVALID(as->parms[1].items->data)) {
4043 "vos: the new volume name %s exceeds the size limit of %d\n",
4044 as->parms[1].items->data, VOLSER_OLDMAXVOLNAME - 10);
4047 if (!VolNameOK(as->parms[1].items->data)) {
4049 "Illegal volume name %s, should not end in .readonly or .backup\n",
4050 as->parms[1].items->data);
4053 if (IsNumeric(as->parms[1].items->data)) {
4054 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
4055 as->parms[1].items->data);
4058 MapHostToNetwork(&entry);
4060 UV_RenameVolume(&entry, as->parms[0].items->data,
4061 as->parms[1].items->data);
4063 PrintDiagnostics("rename", code);
4066 fprintf(STDOUT, "Renamed volume %s to %s\n", as->parms[0].items->data,
4067 as->parms[1].items->data);
4072 GetVolumeInfo(afs_uint32 volid, afs_int32 *server, afs_int32 *part, afs_int32 *voltype,
4073 struct nvldbentry *rentry)
4078 vcode = VLDB_GetEntryByID(volid, -1, rentry);
4081 "Could not fetch the entry for volume %lu from VLDB \n",
4082 (unsigned long)volid);
4083 PrintError("", vcode);
4086 MapHostToNetwork(rentry);
4087 if (volid == rentry->volumeId[ROVOL]) {
4089 for (i = 0; i < rentry->nServers; i++) {
4090 if ((index == -1) && (rentry->serverFlags[i] & ITSROVOL)
4091 && !(rentry->serverFlags[i] & RO_DONTUSE))
4096 "RO volume is not found in VLDB entry for volume %lu\n",
4097 (unsigned long)volid);
4101 *server = rentry->serverNumber[index];
4102 *part = rentry->serverPartition[index];
4106 index = Lp_GetRwIndex(rentry);
4109 "RW Volume is not found in VLDB entry for volume %lu\n",
4110 (unsigned long)volid);
4113 if (volid == rentry->volumeId[RWVOL]) {
4115 *server = rentry->serverNumber[index];
4116 *part = rentry->serverPartition[index];
4119 if (volid == rentry->volumeId[BACKVOL]) {
4121 *server = rentry->serverNumber[index];
4122 *part = rentry->serverPartition[index];
4126 "unexpected volume type for volume %lu\n",
4127 (unsigned long)volid);
4132 DeleteEntry(register struct cmd_syndesc *as, void *arock)
4134 afs_int32 apart = 0;
4137 struct VldbListByAttributes attributes;
4138 nbulkentries arrayEntries;
4139 register struct nvldbentry *vllist;
4140 struct cmd_item *itp;
4143 char prefix[VOLSER_MAXVOLNAME + 1];
4145 afs_int32 totalBack = 0, totalFail = 0, err;
4147 if (as->parms[0].items) { /* -id */
4148 if (as->parms[1].items || as->parms[2].items || as->parms[3].items) {
4150 "You cannot use -server, -partition, or -prefix with the -id argument\n");
4153 for (itp = as->parms[0].items; itp; itp = itp->next) {
4154 avolid = vsu_GetVolumeID(itp->data, cstruct, &err);
4157 PrintError("", err);
4159 fprintf(STDERR, "vos: can't find volume '%s'\n",
4163 if (as->parms[4].items) { /* -noexecute */
4164 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4169 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4171 fprintf(STDERR, "Could not delete entry for volume %s\n",
4174 "You must specify a RW volume name or ID "
4175 "(the entire VLDB entry will be deleted)\n");
4176 PrintError("", vcode);
4182 fprintf(STDOUT, "Deleted %d VLDB entries\n", totalBack);
4186 if (!as->parms[1].items && !as->parms[2].items && !as->parms[3].items) {
4187 fprintf(STDERR, "You must specify an option\n");
4191 /* Zero out search attributes */
4192 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4194 if (as->parms[1].items) { /* -prefix */
4195 strncpy(prefix, as->parms[1].items->data, VOLSER_MAXVOLNAME);
4197 if (!as->parms[2].items && !as->parms[3].items) { /* a single entry only */
4199 "You must provide -server with the -prefix argument\n");
4204 if (as->parms[2].items) { /* -server */
4206 aserver = GetServer(as->parms[2].items->data);
4208 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4209 as->parms[2].items->data);
4212 attributes.server = ntohl(aserver);
4213 attributes.Mask |= VLLIST_SERVER;
4216 if (as->parms[3].items) { /* -partition */
4217 if (!as->parms[2].items) {
4219 "You must provide -server with the -partition argument\n");
4222 apart = volutil_GetPartitionID(as->parms[3].items->data);
4224 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4225 as->parms[3].items->data);
4228 attributes.partition = apart;
4229 attributes.Mask |= VLLIST_PARTITION;
4232 /* Print status line of what we are doing */
4233 fprintf(STDOUT, "Deleting VLDB entries for ");
4234 if (as->parms[2].items) {
4235 fprintf(STDOUT, "server %s ", as->parms[2].items->data);
4237 if (as->parms[3].items) {
4239 MapPartIdIntoName(apart, pname);
4240 fprintf(STDOUT, "partition %s ", pname);
4243 fprintf(STDOUT, "which are prefixed with %s ", prefix);
4245 fprintf(STDOUT, "\n");
4248 /* Get all the VLDB entries on a server and/or partition */
4249 memset(&arrayEntries, 0, sizeof(arrayEntries));
4250 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4252 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4253 PrintError("", vcode);
4257 /* Process each entry */
4258 for (j = 0; j < nentries; j++) {
4259 vllist = &arrayEntries.nbulkentries_val[j];
4261 /* It only deletes the RW volumes */
4262 if (strncmp(vllist->name, prefix, strlen(prefix))) {
4265 "Omitting to delete %s due to prefix %s mismatch\n",
4266 vllist->name, prefix);
4273 if (as->parms[4].items) { /* -noexecute */
4274 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4280 /* Only matches the RW volume name */
4281 avolid = vllist->volumeId[RWVOL];
4282 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4284 fprintf(STDOUT, "Could not delete VDLB entry for %s\n",
4287 PrintError("", vcode);
4292 fprintf(STDOUT, "Deleted VLDB entry for %s \n", vllist->name);
4297 fprintf(STDOUT, "----------------------\n");
4299 "Total VLDB entries deleted: %lu; failed to delete: %lu\n",
4300 (unsigned long)totalBack, (unsigned long)totalFail);
4301 if (arrayEntries.nbulkentries_val)
4302 free(arrayEntries.nbulkentries_val);
4308 CompareVldbEntryByName(const void *p1, const void *p2)
4310 struct nvldbentry *arg1, *arg2;
4312 arg1 = (struct nvldbentry *)p1;
4313 arg2 = (struct nvldbentry *)p2;
4314 return (strcmp(arg1->name, arg2->name));
4318 static int CompareVldbEntry(char *p1, char *p2)
4320 struct nvldbentry *arg1,*arg2;
4323 char comp1[100],comp2[100];
4324 char temp1[20],temp2[20];
4326 arg1 = (struct nvldbentry *)p1;
4327 arg2 = (struct nvldbentry *)p2;
4331 for(i = 0; i < arg1->nServers; i++)
4332 if(arg1->serverFlags[i] & ITSRWVOL) pos1 = i;
4333 for(i = 0; i < arg2->nServers; i++)
4334 if(arg2->serverFlags[i] & ITSRWVOL) pos2 = i;
4335 if(pos1 == -1 || pos2 == -1){
4339 sprintf(comp1,"%10u",arg1->serverNumber[pos1]);
4340 sprintf(comp2,"%10u",arg2->serverNumber[pos2]);
4341 sprintf(temp1,"%10u",arg1->serverPartition[pos1]);
4342 sprintf(temp2,"%10u",arg2->serverPartition[pos2]);
4343 strcat(comp1,temp1);
4344 strcat(comp2,temp2);
4345 strcat(comp1,arg1->name);
4346 strcat(comp1,arg2->name);
4347 return(strcmp(comp1,comp2));
4353 ListVLDB(struct cmd_syndesc *as, void *arock)
4356 afs_int32 aserver, code;
4358 struct VldbListByAttributes attributes;
4359 nbulkentries arrayEntries;
4360 struct nvldbentry *vllist, *tarray = 0, *ttarray;
4361 afs_int32 centries, nentries = 0;
4362 afs_int32 tarraysize = 0;
4363 afs_int32 parraysize;
4366 int quiet, sort, lock;
4367 afs_int32 thisindex, nextindex;
4372 attributes.Mask = 0;
4373 lock = (as->parms[3].items ? 1 : 0); /* -lock flag */
4374 quiet = (as->parms[4].items ? 1 : 0); /* -quit flag */
4375 sort = (as->parms[5].items ? 0 : 1); /* -nosort flag */
4377 /* If the volume name is given, Use VolumeInfoCmd to look it up
4378 * and not ListAttributes.
4380 if (as->parms[0].items) {
4383 "vos: illegal use of '-locked' switch, need to specify server and/or partition\n");
4386 code = VolumeInfoCmd(as->parms[0].items->data);
4388 PrintError("", code);
4394 /* Server specified */
4395 if (as->parms[1].items) {
4396 aserver = GetServer(as->parms[1].items->data);
4398 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4399 as->parms[1].items->data);
4402 attributes.server = ntohl(aserver);
4403 attributes.Mask |= VLLIST_SERVER;
4406 /* Partition specified */
4407 if (as->parms[2].items) {
4408 apart = volutil_GetPartitionID(as->parms[2].items->data);
4410 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4411 as->parms[2].items->data);
4414 attributes.partition = apart;
4415 attributes.Mask |= VLLIST_PARTITION;
4419 attributes.Mask |= VLLIST_FLAG;
4420 attributes.flag = VLOP_ALLOPERS;
4423 /* Print header information */
4425 MapPartIdIntoName(apart, pname);
4426 fprintf(STDOUT, "VLDB entries for %s %s%s%s %s\n",
4427 (as->parms[1].items ? "server" : "all"),
4428 (as->parms[1].items ? as->parms[1].items->data : "servers"),
4429 (as->parms[2].items ? " partition " : ""),
4430 (as->parms[2].items ? pname : ""),
4431 (lock ? "which are locked:" : ""));
4434 for (thisindex = 0; (thisindex != -1); thisindex = nextindex) {
4435 memset(&arrayEntries, 0, sizeof(arrayEntries));
4440 VLDB_ListAttributesN2(&attributes, 0, thisindex, ¢ries,
4441 &arrayEntries, &nextindex);
4442 if (vcode == RXGEN_OPCODE) {
4443 /* Vlserver not running with ListAttributesN2. Fall back */
4445 VLDB_ListAttributes(&attributes, ¢ries, &arrayEntries);
4449 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4450 PrintError("", vcode);
4453 nentries += centries;
4455 /* We don't sort, so just print the entries now */
4457 for (j = 0; j < centries; j++) { /* process each entry */
4458 vllist = &arrayEntries.nbulkentries_val[j];
4459 MapHostToNetwork(vllist);
4460 EnumerateEntry(vllist);
4462 if (vllist->flags & VLOP_ALLOPERS)
4463 fprintf(STDOUT, " Volume is currently LOCKED \n");
4467 /* So we sort. First we must collect all the entries and keep
4470 else if (centries > 0) {
4472 /* steal away the first bulk entries array */
4473 tarray = (struct nvldbentry *)arrayEntries.nbulkentries_val;
4474 tarraysize = centries * sizeof(struct nvldbentry);
4475 arrayEntries.nbulkentries_val = 0;
4477 /* Grow the tarray to keep the extra entries */
4478 parraysize = (centries * sizeof(struct nvldbentry));
4480 (struct nvldbentry *)realloc(tarray,
4481 tarraysize + parraysize);
4484 "Could not allocate enough space for the VLDB entries\n");
4490 memcpy(((char *)tarray) + tarraysize,
4491 (char *)arrayEntries.nbulkentries_val, parraysize);
4492 tarraysize += parraysize;
4496 /* Free the bulk array */
4497 if (arrayEntries.nbulkentries_val) {
4498 free(arrayEntries.nbulkentries_val);
4499 arrayEntries.nbulkentries_val = 0;
4503 /* Here is where we now sort all the entries and print them */
4504 if (sort && (nentries > 0)) {
4505 qsort((char *)tarray, nentries, sizeof(struct nvldbentry),
4506 CompareVldbEntryByName);
4507 for (vllist = tarray, j = 0; j < nentries; j++, vllist++) {
4508 MapHostToNetwork(vllist);
4509 EnumerateEntry(vllist);
4511 if (vllist->flags & VLOP_ALLOPERS)
4512 fprintf(STDOUT, " Volume is currently LOCKED \n");
4518 fprintf(STDOUT, "\nTotal entries: %lu\n", (unsigned long)nentries);
4525 BackSys(register struct cmd_syndesc *as, void *arock)
4528 afs_int32 apart = 0;
4529 afs_int32 aserver = 0, code, aserver1, apart1;
4531 struct VldbListByAttributes attributes;
4532 nbulkentries arrayEntries;
4533 register struct nvldbentry *vllist;
4537 int seenprefix, seenxprefix, exclude, ex, exp, noaction;
4538 afs_int32 totalBack = 0;
4539 afs_int32 totalFail = 0;
4543 struct cmd_item *ti;
4545 #ifndef HAVE_POSIX_REGEX
4549 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4550 attributes.Mask = 0;
4552 seenprefix = (as->parms[0].items ? 1 : 0);
4553 exclude = (as->parms[3].items ? 1 : 0);
4554 seenxprefix = (as->parms[4].items ? 1 : 0);
4555 noaction = (as->parms[5].items ? 1 : 0);
4557 if (as->parms[1].items) { /* -server */
4558 aserver = GetServer(as->parms[1].items->data);
4560 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4561 as->parms[1].items->data);
4564 attributes.server = ntohl(aserver);
4565 attributes.Mask |= VLLIST_SERVER;
4568 if (as->parms[2].items) { /* -partition */
4569 apart = volutil_GetPartitionID(as->parms[2].items->data);
4571 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4572 as->parms[2].items->data);
4575 attributes.partition = apart;
4576 attributes.Mask |= VLLIST_PARTITION;
4579 /* Check to make sure the prefix and xprefix expressions compile ok */
4581 for (ti = as->parms[0].items; ti; ti = ti->next) {
4582 if (strncmp(ti->data, "^", 1) == 0) {
4583 #ifdef HAVE_POSIX_REGEX
4587 code = regcomp(&re, ti->data, REG_NOSUB);
4589 regerror(code, &re, errbuf, sizeof errbuf);
4591 "Unrecognizable -prefix regular expression: '%s': %s\n",
4597 ccode = (char *)re_comp(ti->data);
4600 "Unrecognizable -prefix regular expression: '%s': %s\n",
4609 for (ti = as->parms[4].items; ti; ti = ti->next) {
4610 if (strncmp(ti->data, "^", 1) == 0) {
4611 #ifdef HAVE_POSIX_REGEX
4615 code = regcomp(&re, ti->data, REG_NOSUB);
4617 regerror(code, &re, errbuf, sizeof errbuf);
4619 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4625 ccode = (char *)re_comp(ti->data);
4628 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4637 memset(&arrayEntries, 0, sizeof(arrayEntries)); /* initialize to hint the stub to alloc space */
4638 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4640 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4641 PrintError("", vcode);
4645 if (as->parms[1].items || as->parms[2].items || verbose) {
4646 fprintf(STDOUT, "%s up volumes",
4647 (noaction ? "Would have backed" : "Backing"));
4649 if (as->parms[1].items) {
4650 fprintf(STDOUT, " on server %s", as->parms[1].items->data);
4651 } else if (as->parms[2].items) {
4652 fprintf(STDOUT, " for all servers");
4655 if (as->parms[2].items) {
4656 MapPartIdIntoName(apart, pname);
4657 fprintf(STDOUT, " partition %s", pname);
4660 if (seenprefix || (!seenprefix && seenxprefix)) {
4661 ti = (seenprefix ? as->parms[0].items : as->parms[4].items);
4662 ex = (seenprefix ? exclude : !exclude);
4663 exp = (strncmp(ti->data, "^", 1) == 0);
4664 fprintf(STDOUT, " which %smatch %s '%s'", (ex ? "do not " : ""),
4665 (exp ? "expression" : "prefix"), ti->data);
4666 for (ti = ti->next; ti; ti = ti->next) {
4667 exp = (strncmp(ti->data, "^", 1) == 0);
4668 printf(" %sor %s '%s'", (ex ? "n" : ""),
4669 (exp ? "expression" : "prefix"), ti->data);
4673 if (seenprefix && seenxprefix) {
4674 ti = as->parms[4].items;
4675 exp = (strncmp(ti->data, "^", 1) == 0);
4676 fprintf(STDOUT, " %swhich match %s '%s'",
4677 (exclude ? "adding those " : "removing those "),
4678 (exp ? "expression" : "prefix"), ti->data);
4679 for (ti = ti->next; ti; ti = ti->next) {
4680 exp = (strncmp(ti->data, "^", 1) == 0);
4681 printf(" or %s '%s'", (exp ? "expression" : "prefix"),
4685 fprintf(STDOUT, " .. ");
4687 fprintf(STDOUT, "\n");
4691 for (j = 0; j < nentries; j++) { /* process each vldb entry */
4692 vllist = &arrayEntries.nbulkentries_val[j];
4695 for (ti = as->parms[0].items; ti; ti = ti->next) {
4696 if (strncmp(ti->data, "^", 1) == 0) {
4697 #ifdef HAVE_POSIX_REGEX
4701 /* XXX -- should just do the compile once! */
4702 code = regcomp(&re, ti->data, REG_NOSUB);
4704 regerror(code, &re, errbuf, sizeof errbuf);
4706 "Error in -prefix regular expression: '%s': %s\n",
4710 match = (regexec(&re, vllist->name, 0, NULL, 0) == 0);
4713 ccode = (char *)re_comp(ti->data);
4716 "Error in -prefix regular expression: '%s': %s\n",
4720 match = (re_exec(vllist->name) == 1);
4724 (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4734 /* Without the -exclude flag: If it matches the prefix, then
4735 * check if we want to exclude any from xprefix.
4736 * With the -exclude flag: If it matches the prefix, then
4737 * check if we want to add any from xprefix.
4739 if (match && seenxprefix) {
4740 for (ti = as->parms[4].items; ti; ti = ti->next) {
4741 if (strncmp(ti->data, "^", 1) == 0) {
4742 #ifdef HAVE_POSIX_REGEX
4746 /* XXX -- should just do the compile once! */
4747 code = regcomp(&re, ti->data, REG_NOSUB);
4749 regerror(code, &re, errbuf, sizeof errbuf);
4751 "Error in -xprefix regular expression: '%s': %s\n",
4755 if (regexec(&re, vllist->name, 0, NULL, 0) == 0)
4759 ccode = (char *)re_comp(ti->data);
4762 "Error in -xprefix regular expression: '%s': %s\n",
4766 if (re_exec(vllist->name) == 1) {
4772 if (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4782 match = !match; /* -exclude will reverse the match */
4784 continue; /* Skip if no match */
4786 /* Print list of volumes to backup */
4788 fprintf(STDOUT, " %s\n", vllist->name);
4792 if (!(vllist->flags & RW_EXISTS)) {
4795 "Omitting to backup %s since RW volume does not exist \n",
4797 fprintf(STDOUT, "\n");
4803 avolid = vllist->volumeId[RWVOL];
4804 MapHostToNetwork(vllist);
4805 GetServerAndPart(vllist, RWVOL, &aserver1, &apart1, &previdx);
4806 if (aserver1 == -1 || apart1 == -1) {
4807 fprintf(STDOUT, "could not backup %s, invalid VLDB entry\n",
4813 same = VLDB_IsSameAddrs(aserver, aserver1, &error);
4816 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
4822 if ((aserver && !same) || (apart && (apart != apart1))) {
4825 "Omitting to backup %s since the RW is in a different location\n",
4831 time_t now = time(0);
4832 fprintf(STDOUT, "Creating backup volume for %s on %s",
4833 vllist->name, ctime(&now));
4837 code = UV_BackupVolume(aserver1, apart1, avolid);
4839 fprintf(STDOUT, "Could not backup %s\n", vllist->name);
4845 fprintf(STDOUT, "\n");
4847 } /* process each vldb entry */
4848 fprintf(STDOUT, "done\n");
4849 fprintf(STDOUT, "Total volumes backed up: %lu; failed to backup: %lu\n",
4850 (unsigned long)totalBack, (unsigned long)totalFail);
4852 if (arrayEntries.nbulkentries_val)
4853 free(arrayEntries.nbulkentries_val);
4858 UnlockVLDB(register struct cmd_syndesc *as, void *arock)
4861 afs_int32 aserver = 0;
4864 struct VldbListByAttributes attributes;
4865 nbulkentries arrayEntries;
4866 register struct nvldbentry *vllist;
4875 attributes.Mask = 0;
4877 if (as->parms[0].items) { /* server specified */
4878 aserver = GetServer(as->parms[0].items->data);
4880 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4881 as->parms[0].items->data);
4884 attributes.server = ntohl(aserver);
4885 attributes.Mask |= VLLIST_SERVER;
4887 if (as->parms[1].items) { /* partition specified */
4888 apart = volutil_GetPartitionID(as->parms[1].items->data);
4890 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4891 as->parms[1].items->data);
4894 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
4896 PrintError("", code);
4899 "vos : partition %s does not exist on the server\n",
4900 as->parms[1].items->data);
4903 attributes.partition = apart;
4904 attributes.Mask |= VLLIST_PARTITION;
4906 attributes.flag = VLOP_ALLOPERS;
4907 attributes.Mask |= VLLIST_FLAG;
4908 memset(&arrayEntries, 0, sizeof(arrayEntries)); /*initialize to hint the stub to alloc space */
4909 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4911 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4912 PrintError("", vcode);
4915 for (j = 0; j < nentries; j++) { /* process each entry */
4916 vllist = &arrayEntries.nbulkentries_val[j];
4917 volid = vllist->volumeId[RWVOL];
4919 ubik_VL_ReleaseLock(cstruct, 0, volid, -1,
4920 LOCKREL_OPCODE | LOCKREL_AFSID |
4923 fprintf(STDERR, "Could not unlock entry for volume %s\n",
4925 PrintError("", vcode);
4930 MapPartIdIntoName(apart, pname);
4933 "Could not lock %lu VLDB entries of %lu locked entries\n",
4934 (unsigned long)totalE, (unsigned long)nentries);
4936 if (as->parms[0].items) {
4938 "Unlocked all the VLDB entries for volumes on server %s ",
4939 as->parms[0].items->data);
4940 if (as->parms[1].items) {
4941 MapPartIdIntoName(apart, pname);
4942 fprintf(STDOUT, "partition %s\n", pname);
4944 fprintf(STDOUT, "\n");
4946 } else if (as->parms[1].items) {
4947 MapPartIdIntoName(apart, pname);
4949 "Unlocked all the VLDB entries for volumes on partition %s on all servers\n",
4954 if (arrayEntries.nbulkentries_val)
4955 free(arrayEntries.nbulkentries_val);
4960 PrintInt64Size(afs_uint64 in)
4962 register afs_uint32 hi, lo;
4963 register char * units;
4964 static char output[16];
4966 SplitInt64(in,hi,lo);
4970 } else if (!(hi & 0xFFFFFC00)) {
4972 lo = (hi << 22) | (lo >> 10);
4973 } else if (!(hi & 0xFFF00000)) {
4975 lo = (hi << 12) | (lo >> 20);
4976 } else if (!(hi & 0xC0000000)) {
4978 lo = (hi << 2) | (lo >> 30);
4983 sprintf(output,"%u %s", lo, units);
4988 PartitionInfo(register struct cmd_syndesc *as, void *arock)
4991 afs_int32 aserver, code;
4993 struct diskPartition64 partition;
4994 struct partList dummyPartList;
4996 int printSummary=0, sumPartitions=0;
4997 afs_uint64 sumFree, sumStorage;
5000 ZeroInt64(sumStorage);
5002 aserver = GetServer(as->parms[0].items->data);
5004 fprintf(STDERR, "vos: server '%s' not found in host table\n",
5005 as->parms[0].items->data);
5008 if (as->parms[1].items) {
5009 apart = volutil_GetPartitionID(as->parms[1].items->data);
5011 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5012 as->parms[1].items->data);
5015 dummyPartList.partId[0] = apart;
5016 dummyPartList.partFlags[0] = PARTVALID;
5019 if (as->parms[2].items) {
5023 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
5025 PrintError("", code);
5028 "vos : partition %s does not exist on the server\n",
5029 as->parms[1].items->data);
5033 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
5035 PrintDiagnostics("listpart", code);
5039 for (i = 0; i < cnt; i++) {
5040 if (dummyPartList.partFlags[i] & PARTVALID) {
5041 MapPartIdIntoName(dummyPartList.partId[i], pname);
5042 code = UV_PartitionInfo64(aserver, pname, &partition);
5044 fprintf(STDERR, "Could not get information on partition %s\n",
5046 PrintError("", code);
5050 "Free space on partition %s: %" AFS_INT64_FMT " K blocks out of total %" AFS_INT64_FMT "\n",
5051 pname, partition.free, partition.minFree);
5053 AddUInt64(sumFree,partition.free,&sumFree);
5054 AddUInt64(sumStorage,partition.minFree,&sumStorage);
5059 "Summary: %s free out of ",
5060 PrintInt64Size(sumFree));
5062 "%s on %d partitions\n",
5063 PrintInt64Size(sumStorage),
5070 ChangeAddr(register struct cmd_syndesc *as, void *arock)
5072 afs_int32 ip1, ip2, vcode;
5075 ip1 = GetServer(as->parms[0].items->data);
5077 fprintf(STDERR, "vos: invalid host address\n");
5081 if ((as->parms[1].items && as->parms[2].items)
5082 || (!as->parms[1].items && !as->parms[2].items)) {
5084 "vos: Must specify either '-newaddr <addr>' or '-remove' flag\n");
5088 if (as->parms[1].items) {
5089 ip2 = GetServer(as->parms[1].items->data);
5091 fprintf(STDERR, "vos: invalid host address\n");
5095 /* Play a trick here. If we are removing an address, ip1 will be -1
5096 * and ip2 will be the original address. This switch prevents an
5097 * older revision vlserver from removing the IP address.
5104 vcode = ubik_Call_New(VL_ChangeAddr, cstruct, 0, ntohl(ip1), ntohl(ip2));
5107 fprintf(STDERR, "Could not remove server %s from the VLDB\n",
5108 as->parms[0].items->data);
5109 if (vcode == VL_NOENT) {
5111 "vlserver does not support the remove flag or ");
5114 fprintf(STDERR, "Could not change server %s to server %s\n",
5115 as->parms[0].items->data, as->parms[1].items->data);
5117 PrintError("", vcode);
5122 fprintf(STDOUT, "Removed server %s from the VLDB\n",
5123 as->parms[0].items->data);
5125 fprintf(STDOUT, "Changed server %s to server %s\n",
5126 as->parms[0].items->data, as->parms[1].items->data);
5132 print_addrs(const bulkaddrs * addrs, const afsUUID * m_uuid, int nentries,
5137 struct VLCallBack vlcb;
5140 ListAddrByAttributes m_attrs;
5141 afs_int32 m_nentries, *m_addrp;
5142 afs_int32 base, index;
5146 afsUUID_to_string(m_uuid, buf, sizeof(buf));
5147 printf("UUID: %s\n", buf);
5150 /* print out the list of all the server */
5151 addrp = (afs_int32 *) addrs->bulkaddrs_val;
5152 for (i = 0; i < nentries; i++, addrp++) {
5153 /* If it is a multihomed address, then we will need to
5154 * get the addresses for this multihomed server from
5155 * the vlserver and print them.
5157 if (((*addrp & 0xff000000) == 0xff000000) && ((*addrp) & 0xffff)) {
5158 /* Get the list of multihomed fileservers */
5159 base = (*addrp >> 16) & 0xff;
5160 index = (*addrp) & 0xffff;
5162 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
5163 && (index <= VL_MHSRV_PERBLK)) {
5164 m_attrs.Mask = VLADDR_INDEX;
5165 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
5167 m_addrs.bulkaddrs_val = 0;
5168 m_addrs.bulkaddrs_len = 0;
5170 ubik_VL_GetAddrsU(cstruct, 0, &m_attrs, &m_uuid,
5171 (afs_int32 *)&vlcb, &m_nentries, &m_addrs);
5174 "vos: could not list the multi-homed server addresses\n");
5175 PrintError("", vcode);
5178 /* Print the list */
5179 m_addrp = (afs_int32 *) m_addrs.bulkaddrs_val;
5180 for (j = 0; j < m_nentries; j++, m_addrp++) {
5181 *m_addrp = htonl(*m_addrp);
5184 printf("%s ", afs_inet_ntoa_r(*m_addrp, hoststr));
5186 printf("%s ", hostutil_GetNameByINet(*m_addrp));
5190 printf("<unknown>\n");
5199 /* Otherwise, it is a non-multihomed entry and contains
5200 * the IP address of the server - print it.
5202 *addrp = htonl(*addrp);
5205 printf("%s\n", afs_inet_ntoa_r(*addrp, hoststr));
5207 printf("%s\n", hostutil_GetNameByINet(*addrp));
5218 ListAddrs(register struct cmd_syndesc *as, void *arock)
5221 afs_int32 i, printuuid = 0;
5222 struct VLCallBack vlcb;
5225 ListAddrByAttributes m_attrs;
5226 afsUUID m_uuid, askuuid;
5227 afs_int32 m_nentries;
5229 memset(&m_attrs, 0, sizeof(struct ListAddrByAttributes));
5230 m_attrs.Mask = VLADDR_INDEX;
5232 memset(&m_addrs, 0, sizeof(bulkaddrs));
5233 memset(&askuuid, 0, sizeof(afsUUID));
5234 if (as->parms[0].items) {
5236 if (afsUUID_from_string(as->parms[0].items->data, &askuuid) < 0) {
5237 fprintf(STDERR, "vos: invalid UUID '%s'\n",
5238 as->parms[0].items->data);
5241 m_attrs.Mask = VLADDR_UUID;
5242 m_attrs.uuid = askuuid;
5244 if (as->parms[1].items) {
5248 he = hostutil_GetHostByName((char *)as->parms[1].items->data);
5250 fprintf(STDERR, "vos: Can't get host info for '%s'\n",
5251 as->parms[1].items->data);
5254 memcpy(&saddr, he->h_addr, 4);
5255 m_attrs.Mask = VLADDR_IPADDR;
5256 m_attrs.ipaddr = ntohl(saddr);
5258 if (as->parms[2].items) {
5262 m_addrs.bulkaddrs_val = 0;
5263 m_addrs.bulkaddrs_len = 0;
5266 ubik_Call_New(VL_GetAddrs, cstruct, 0, 0, 0, &vlcb, &nentries,
5269 fprintf(STDERR, "vos: could not list the server addresses\n");
5270 PrintError("", vcode);
5275 m_addrs.bulkaddrs_val = 0;
5276 m_addrs.bulkaddrs_len = 0;
5282 ubik_Call_New(VL_GetAddrsU, cstruct, 0, &m_attrs, &m_uuid,
5283 &vlcb, &m_nentries, &m_addrs);
5285 if (vcode == VL_NOENT) {
5286 if (m_attrs.Mask == VLADDR_UUID) {
5287 fprintf(STDERR, "vos: no entry for UUID '%s' found in VLDB\n",
5288 as->parms[0].items->data);
5290 } else if (m_attrs.Mask == VLADDR_IPADDR) {
5291 fprintf(STDERR, "vos: no entry for host '%s' [0x%08x] found in VLDB\n",
5292 as->parms[1].items->data, m_attrs.ipaddr);
5301 if (vcode == VL_INDEXERANGE) {
5306 fprintf(STDERR, "vos: could not list the server addresses\n");
5307 PrintError("", vcode);
5311 print_addrs(&m_addrs, &m_uuid, m_nentries, printuuid);
5314 if ((as->parms[1].items) || (as->parms[0].items) || (i > nentries))
5322 LockEntry(register struct cmd_syndesc *as, void *arock)
5325 afs_int32 vcode, err;
5327 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5330 PrintError("", err);
5332 fprintf(STDERR, "vos: can't find volume '%s'\n",
5333 as->parms[0].items->data);
5336 vcode = ubik_VL_SetLock(cstruct, 0, avolid, -1, VLOP_DELETE);
5338 fprintf(STDERR, "Could not lock VLDB entry for volume %s\n",
5339 as->parms[0].items->data);
5340 PrintError("", vcode);
5343 fprintf(STDOUT, "Locked VLDB entry for volume %s\n",
5344 as->parms[0].items->data);
5349 ConvertRO(register struct cmd_syndesc *as, void *arock)
5351 afs_int32 partition = -1;
5353 afs_int32 server, code, i, same;
5354 struct nvldbentry entry, storeEntry;
5356 afs_int32 rwindex = 0;
5357 afs_int32 rwserver = 0;
5358 afs_int32 rwpartition = 0;
5359 afs_int32 roindex = 0;
5360 afs_int32 roserver = 0;
5361 afs_int32 ropartition = 0;
5363 struct rx_connection *aconn;
5366 server = GetServer(as->parms[0].items->data);
5368 fprintf(STDERR, "vos: host '%s' not found in host table\n",
5369 as->parms[0].items->data);
5372 partition = volutil_GetPartitionID(as->parms[1].items->data);
5373 if (partition < 0) {
5374 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5375 as->parms[1].items->data);
5378 if (!IsPartValid(partition, server, &code)) {
5380 PrintError("", code);
5383 "vos : partition %s does not exist on the server\n",
5384 as->parms[1].items->data);
5387 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &code);
5390 PrintError("", code);
5392 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
5393 as->parms[0].items->data);
5396 if (as->parms[3].items)
5399 vcode = VLDB_GetEntryByID(volid, -1, &entry);
5402 "Could not fetch the entry for volume %lu from VLDB\n",
5403 (unsigned long)volid);
5404 PrintError("convertROtoRW", code);
5408 /* use RO volid even if user specified RW or BK volid */
5410 if (volid != entry.volumeId[ROVOL])
5411 volid = entry.volumeId[ROVOL];
5413 MapHostToNetwork(&entry);
5414 for (i = 0; i < entry.nServers; i++) {
5415 if (entry.serverFlags[i] & ITSRWVOL) {
5417 rwserver = entry.serverNumber[i];
5418 rwpartition = entry.serverPartition[i];
5420 if (entry.serverFlags[i] & ITSROVOL) {
5421 same = VLDB_IsSameAddrs(server, entry.serverNumber[i], &code);
5424 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
5430 roserver = entry.serverNumber[i];
5431 ropartition = entry.serverPartition[i];
5437 fprintf(STDERR, "Warning: RO volume didn't exist in vldb!\n");
5439 if (ropartition != partition) {
5441 "Warning: RO volume should be in partition %d instead of %d (vldb)\n",
5442 ropartition, partition);
5447 "VLDB indicates that a RW volume exists already on %s in partition %s.\n",
5448 hostutil_GetNameByINet(rwserver),
5449 volutil_PartitionName(rwpartition));
5451 fprintf(STDERR, "Overwrite this VLDB entry? [y|n] (n)\n");
5453 while (!(dc == EOF || dc == '\n'))
5454 dc = getchar(); /* goto end of line */
5455 if ((c != 'y') && (c != 'Y')) {
5456 fprintf(STDERR, "aborted.\n");
5463 ubik_VL_SetLock(cstruct, 0, entry.volumeId[RWVOL], RWVOL,
5465 aconn = UV_Bind(server, AFSCONF_VOLUMEPORT);
5466 code = AFSVolConvertROtoRWvolume(aconn, partition, volid);
5469 "Converting RO volume %lu to RW volume failed with code %d\n",
5470 (unsigned long)volid, code);
5471 PrintError("convertROtoRW ", code);
5474 entry.serverFlags[roindex] = ITSRWVOL;
5475 entry.flags |= RW_EXISTS;
5476 entry.flags &= ~BACK_EXISTS;
5479 if (rwindex != entry.nServers) {
5480 entry.serverNumber[rwindex] = entry.serverNumber[entry.nServers];
5481 entry.serverPartition[rwindex] =
5482 entry.serverPartition[entry.nServers];
5483 entry.serverFlags[rwindex] = entry.serverFlags[entry.nServers];
5484 entry.serverNumber[entry.nServers] = 0;
5485 entry.serverPartition[entry.nServers] = 0;
5486 entry.serverFlags[entry.nServers] = 0;
5489 entry.flags &= ~RO_EXISTS;
5490 for (i = 0; i < entry.nServers; i++) {
5491 if (entry.serverFlags[i] & ITSROVOL) {
5492 if (!(entry.serverFlags[i] & (RO_DONTUSE | NEW_REPSITE)))
5493 entry.flags |= RO_EXISTS;
5496 MapNetworkToHost(&entry, &storeEntry);
5498 VLDB_ReplaceEntry(entry.volumeId[RWVOL], RWVOL, &storeEntry,
5499 (LOCKREL_OPCODE | LOCKREL_AFSID |
5500 LOCKREL_TIMESTAMP));
5503 "Warning: volume converted, but vldb update failed with code %d!\n",
5506 vcode = UV_LockRelease(entry.volumeId[RWVOL]);
5508 PrintDiagnostics("unlock", vcode);
5514 Sizes(register struct cmd_syndesc *as, void *arock)
5517 afs_int32 aserver, apart, voltype, fromdate = 0, code, err, i;
5518 struct nvldbentry entry;
5519 volintSize vol_size;
5521 rx_SetRxDeadTime(60 * 10);
5522 for (i = 0; i < MAXSERVERS; i++) {
5523 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
5526 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
5527 if (rxConn->service)
5528 rxConn->service->connDeadTime = rx_connDeadTime;
5531 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5534 PrintError("", err);
5536 fprintf(STDERR, "vos: can't find volume '%s'\n",
5537 as->parms[0].items->data);
5541 if (as->parms[1].items || as->parms[2].items) {
5542 if (!as->parms[1].items || !as->parms[2].items) {
5544 "Must specify both -server and -partition options\n");
5547 aserver = GetServer(as->parms[2].items->data);
5549 fprintf(STDERR, "Invalid server name\n");
5552 apart = volutil_GetPartitionID(as->parms[1].items->data);
5554 fprintf(STDERR, "Invalid partition name\n");
5558 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
5565 if (as->parms[4].items && strcmp(as->parms[4].items->data, "0")) {
5566 code = ktime_DateToInt32(as->parms[4].items->data, &fromdate);
5568 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
5569 as->parms[4].items->data, code);
5574 fprintf(STDOUT, "Volume: %s\n", as->parms[0].items->data);
5576 if (as->parms[3].items) { /* do the dump estimate */
5577 #ifdef AFS_64BIT_ENV
5578 vol_size.dump_size = 0;
5580 FillInt64(vol_size.dump_size,0, 1);
5582 code = UV_GetSize(avolid, aserver, apart, fromdate, &vol_size);
5584 PrintDiagnostics("size", code);
5587 /* presumably the size info is now gathered in pntr */
5588 /* now we display it */
5590 fprintf(STDOUT, "dump_size: %llu\n", vol_size.dump_size);
5599 PrintDiagnostics(char *astring, afs_int32 acode)
5601 if (acode == EACCES) {
5603 "You are not authorized to perform the 'vos %s' command (%d)\n",
5606 fprintf(STDERR, "Error in vos %s command.\n", astring);
5607 PrintError("", acode);
5614 MyBeforeProc(struct cmd_syndesc *as, void *arock)
5616 register char *tcell;
5617 register afs_int32 code;
5618 register afs_int32 sauth;
5620 /* Initialize the ubik_client connection */
5621 rx_SetRxDeadTime(90);
5622 cstruct = (struct ubik_client *)0;
5626 if (as->parms[12].items) /* if -cell specified */
5627 tcell = as->parms[12].items->data;
5628 if (as->parms[14].items) /* -serverauth specified */
5630 if (as->parms[16].items) /* -crypt specified */
5633 vsu_ClientInit((as->parms[13].items != 0), confdir, tcell, sauth,
5634 &cstruct, UV_SetSecurity))) {
5635 fprintf(STDERR, "could not initialize VLDB library (code=%lu) \n",
5636 (unsigned long)code);
5640 if (as->parms[15].items) /* -verbose flag set */
5644 if (as->parms[17].items) /* -noresolve flag set */
5654 /* this sucks but it works for now.
5659 #include "AFS_component_version_number.c"
5662 main(int argc, char **argv)
5664 register afs_int32 code;
5666 register struct cmd_syndesc *ts;
5668 #ifdef AFS_AIX32_ENV
5670 * The following signal action for AIX is necessary so that in case of a
5671 * crash (i.e. core is generated) we can include the user's data section
5672 * in the core dump. Unfortunately, by default, only a partial core is
5673 * generated which, in many cases, isn't too useful.
5675 struct sigaction nsa;
5677 sigemptyset(&nsa.sa_mask);
5678 nsa.sa_handler = SIG_DFL;
5679 nsa.sa_flags = SA_FULLDUMP;
5680 sigaction(SIGSEGV, &nsa, NULL);
5683 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
5685 cmd_SetBeforeProc(MyBeforeProc, NULL);
5687 ts = cmd_CreateSyntax("create", CreateVolume, NULL, "create a new volume");
5688 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5689 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5690 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "volume name");
5691 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL,
5692 "initial quota (KB)");
5694 cmd_AddParm(ts, "-minquota", CMD_SINGLE, CMD_OPTIONAL, "");
5698 ts = cmd_CreateSyntax("remove", DeleteVolume, NULL, "delete a volume");
5699 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5700 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5701 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5705 ts = cmd_CreateSyntax("move", MoveVolume, NULL, "move a volume");
5706 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5707 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5708 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5709 "partition name on source");
5710 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5711 "machine name on destination");
5712 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5713 "partition name on destination");
5714 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5715 "copy live volume without cloning");
5718 ts = cmd_CreateSyntax("copy", CopyVolume, NULL, "copy a volume");
5719 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5720 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5721 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5722 "partition name on source");
5723 cmd_AddParm(ts, "-toname", CMD_SINGLE, 0, "volume name on destination");
5724 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5725 "machine name on destination");
5726 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5727 "partition name on destination");
5728 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5729 "leave new volume offline");
5730 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5731 "make new volume read-only");
5732 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5733 "copy live volume without cloning");
5736 ts = cmd_CreateSyntax("shadow", ShadowVolume, NULL,
5737 "make or update a shadow volume");
5738 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5739 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5740 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5741 "partition name on source");
5742 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5743 "machine name on destination");
5744 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5745 "partition name on destination");
5746 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5747 "volume name on destination");
5748 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5749 "volume ID on destination");
5750 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5751 "leave shadow volume offline");
5752 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5753 "make shadow volume read-only");
5754 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5755 "copy live volume without cloning");
5756 cmd_AddParm(ts, "-incremental", CMD_FLAG, CMD_OPTIONAL,
5757 "do incremental update if target exists");
5760 ts = cmd_CreateSyntax("backup", BackupVolume, NULL,
5761 "make backup of a volume");
5762 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5765 ts = cmd_CreateSyntax("clone", CloneVolume, NULL,
5766 "make clone of a volume");
5767 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5768 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5769 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5770 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5771 "volume name on destination");
5772 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5773 "volume ID on destination");
5774 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5775 "leave clone volume offline");
5776 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5777 "make clone volume read-only, not readwrite");
5780 ts = cmd_CreateSyntax("release", ReleaseVolume, NULL, "release a volume");
5781 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5782 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5783 "force a complete release");
5786 ts = cmd_CreateSyntax("dump", DumpVolumeCmd, NULL, "dump a volume");
5787 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5788 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
5789 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5790 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5791 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5792 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL,
5793 "dump a clone of the volume");
5794 cmd_AddParm(ts, "-omitdirs", CMD_FLAG, CMD_OPTIONAL,
5795 "omit unchanged directories from an incremental dump");
5798 ts = cmd_CreateSyntax("restore", RestoreVolumeCmd, NULL,
5799 "restore a volume");
5800 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5801 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5802 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of volume to be restored");
5803 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5804 cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_OPTIONAL, "volume ID");
5805 cmd_AddParm(ts, "-overwrite", CMD_SINGLE, CMD_OPTIONAL,
5806 "abort | full | incremental");
5807 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5808 "leave restored volume offline");
5809 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5810 "make restored volume read-only");
5811 cmd_AddParm(ts, "-creation", CMD_SINGLE, CMD_OPTIONAL,
5812 "dump | keep | new");
5813 cmd_AddParm(ts, "-lastupdate", CMD_SINGLE, CMD_OPTIONAL,
5814 "dump | keep | new");
5815 cmd_AddParm(ts, "-nodelete", CMD_FLAG, CMD_OPTIONAL,
5816 "do not delete old site when restoring to a new site");
5819 ts = cmd_CreateSyntax("unlock", LockReleaseCmd, NULL,
5820 "release lock on VLDB entry for a volume");
5821 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5824 ts = cmd_CreateSyntax("changeloc", ChangeLocation, NULL,
5825 "change an RW volume's location in the VLDB");
5826 cmd_AddParm(ts, "-server", CMD_SINGLE, 0,
5827 "machine name for new location");
5828 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5829 "partition name for new location");
5830 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5833 ts = cmd_CreateSyntax("addsite", AddSite, NULL, "add a replication site");
5834 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name for new site");
5835 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5836 "partition name for new site");
5837 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5838 cmd_AddParm(ts, "-valid", CMD_FLAG, CMD_OPTIONAL, "publish as an up-to-date site in VLDB");
5841 ts = cmd_CreateSyntax("remsite", RemoveSite, NULL,
5842 "remove a replication site");
5843 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5844 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5845 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5848 ts = cmd_CreateSyntax("listpart", ListPartitions, NULL, "list partitions");
5849 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5852 ts = cmd_CreateSyntax("listvol", ListVolumes, NULL,
5853 "list volumes on server (bypass VLDB)");
5854 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5855 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5856 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "minimal listing");
5857 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL,
5858 "list all normal volume fields");
5859 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5860 "generate minimal information");
5861 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5862 "list extended volume fields");
5863 #ifdef FULL_LISTVOL_SWITCH
5864 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5865 "machine readable format");
5866 #endif /* FULL_LISTVOL_SWITCH */
5869 ts = cmd_CreateSyntax("syncvldb", SyncVldb, NULL,
5870 "synchronize VLDB with server");
5871 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5872 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5873 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5874 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
5877 ts = cmd_CreateSyntax("syncserv", SyncServer, NULL,
5878 "synchronize server with VLDB");
5879 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5880 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5881 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
5884 ts = cmd_CreateSyntax("examine", ExamineVolume, NULL,
5885 "everything about the volume");
5886 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5887 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5888 "list extended volume fields");
5889 #ifdef FULL_LISTVOL_SWITCH
5890 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5891 "machine readable format");
5892 #endif /* FULL_LISTVOL_SWITCH */
5894 cmd_CreateAlias(ts, "volinfo");
5896 ts = cmd_CreateSyntax("setfields", SetFields, NULL,
5897 "change volume info fields");
5898 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5899 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL, "quota (KB)");
5900 cmd_AddParm(ts, "-clearuse", CMD_FLAG, CMD_OPTIONAL, "clear dayUse");
5901 cmd_AddParm(ts, "-clearVolUpCounter", CMD_FLAG, CMD_OPTIONAL, "clear volUpdateCounter");
5904 ts = cmd_CreateSyntax("offline", volOffline, NULL, "force the volume status to offline");
5905 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5906 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5907 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5908 cmd_AddParm(ts, "-sleep", CMD_SINGLE, CMD_OPTIONAL, "seconds to sleep");
5909 cmd_AddParm(ts, "-busy", CMD_FLAG, CMD_OPTIONAL, "busy volume");
5912 ts = cmd_CreateSyntax("online", volOnline, NULL, "force the volume status to online");
5913 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5914 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5915 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5918 ts = cmd_CreateSyntax("zap", VolumeZap, NULL,
5919 "delete the volume, don't bother with VLDB");
5920 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5921 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5922 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume ID");
5923 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5924 "force deletion of bad volumes");
5925 cmd_AddParm(ts, "-backup", CMD_FLAG, CMD_OPTIONAL,
5926 "also delete backup volume if one is found");
5929 ts = cmd_CreateSyntax("status", VolserStatus, NULL,
5930 "report on volser status");
5931 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5934 ts = cmd_CreateSyntax("rename", RenameVolume, NULL, "rename a volume");
5935 cmd_AddParm(ts, "-oldname", CMD_SINGLE, 0, "old volume name ");
5936 cmd_AddParm(ts, "-newname", CMD_SINGLE, 0, "new volume name ");
5939 ts = cmd_CreateSyntax("listvldb", ListVLDB, NULL,
5940 "list volumes in the VLDB");
5941 cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5942 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5943 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5944 cmd_AddParm(ts, "-locked", CMD_FLAG, CMD_OPTIONAL, "locked volumes only");
5945 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5946 "generate minimal information");
5947 cmd_AddParm(ts, "-nosort", CMD_FLAG, CMD_OPTIONAL,
5948 "do not alphabetically sort the volume names");
5951 ts = cmd_CreateSyntax("backupsys", BackSys, NULL, "en masse backups");
5952 cmd_AddParm(ts, "-prefix", CMD_LIST, CMD_OPTIONAL,
5953 "common prefix on volume(s)");
5954 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5955 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5956 cmd_AddParm(ts, "-exclude", CMD_FLAG, CMD_OPTIONAL,
5957 "exclude common prefix volumes");
5958 cmd_AddParm(ts, "-xprefix", CMD_LIST, CMD_OPTIONAL,
5959 "negative prefix on volume(s)");
5960 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "no action");
5963 ts = cmd_CreateSyntax("delentry", DeleteEntry, NULL,
5964 "delete VLDB entry for a volume");
5965 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL, "volume name or ID");
5966 cmd_AddParm(ts, "-prefix", CMD_SINGLE, CMD_OPTIONAL,
5967 "prefix of the volume whose VLDB entry is to be deleted");
5968 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5969 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5970 cmd_AddParm(ts, "-noexecute", CMD_FLAG, CMD_OPTIONAL,
5974 ts = cmd_CreateSyntax("partinfo", PartitionInfo, NULL,
5975 "list partition information");
5976 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5977 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5978 cmd_AddParm(ts, "-summary", CMD_FLAG, CMD_OPTIONAL,
5979 "print storage summary");
5982 ts = cmd_CreateSyntax("unlockvldb", UnlockVLDB, NULL,
5983 "unlock all the locked entries in the VLDB");
5984 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5985 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5988 ts = cmd_CreateSyntax("lock", LockEntry, NULL,
5989 "lock VLDB entry for a volume");
5990 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5993 ts = cmd_CreateSyntax("changeaddr", ChangeAddr, NULL,
5994 "change the IP address of a file server");
5995 cmd_AddParm(ts, "-oldaddr", CMD_SINGLE, 0, "original IP address");
5996 cmd_AddParm(ts, "-newaddr", CMD_SINGLE, CMD_OPTIONAL, "new IP address");
5997 cmd_AddParm(ts, "-remove", CMD_FLAG, CMD_OPTIONAL,
5998 "remove the IP address from the VLDB");
6001 ts = cmd_CreateSyntax("listaddrs", ListAddrs, NULL,
6002 "list the IP address of all file servers registered in the VLDB");
6003 cmd_AddParm(ts, "-uuid", CMD_SINGLE, CMD_OPTIONAL, "uuid of server");
6004 cmd_AddParm(ts, "-host", CMD_SINGLE, CMD_OPTIONAL, "address of host");
6005 cmd_AddParm(ts, "-printuuid", CMD_FLAG, CMD_OPTIONAL,
6006 "print uuid of hosts");
6009 ts = cmd_CreateSyntax("convertROtoRW", ConvertRO, NULL,
6010 "convert a RO volume into a RW volume (after loss of old RW volume)");
6011 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
6012 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
6013 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6014 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, "don't ask");
6017 ts = cmd_CreateSyntax("size", Sizes, NULL,
6018 "obtain various sizes of the volume.");
6019 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6020 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6021 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6022 cmd_AddParm(ts, "-dump", CMD_FLAG, CMD_OPTIONAL,
6023 "Obtain the size of the dump");
6024 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
6027 code = cmd_Dispatch(argc, argv);
6029 /* Shut down the ubik_client and rx connections */
6031 (void)ubik_ClientDestroy(cstruct);
6037 exit((code ? -1 : 0));