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_int32 *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, char *rock)
321 afs_int32 error, code;
323 afs_hyper_t filesize, currOffset;
330 if (!filename || !*filename) {
331 usd_StandardInput(&ufd);
335 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
338 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
341 fprintf(STDERR, "Could not access file '%s'\n", filename);
345 /* test if we have a valid dump */
346 hset64(filesize, 0, 0);
347 USD_SEEK(ufd, filesize, SEEK_END, &currOffset);
348 hset64(filesize, hgethi(currOffset), hgetlo(currOffset)-sizeof(afs_uint32));
349 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
350 USD_READ(ufd, (char *)&buffer, sizeof(afs_uint32), &got);
351 if ((got != sizeof(afs_uint32)) || (ntohl(buffer) != DUMPENDMAGIC)) {
352 fprintf(STDERR, "Signature missing from end of file '%s'\n", filename);
356 /* rewind, we are done */
357 hset64(filesize, 0, 0);
358 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
360 code = SendFile(ufd, call, blksize);
367 code = USD_CLOSE(ufd);
369 fprintf(STDERR, "Could not close dump file %s\n",
370 (filename && *filename) ? filename : "STDOUT");
378 /* Receive data from <call> stream into file associated
379 * with <fd> <blksize>
382 ReceiveFile(usd_handle_t ufd, struct rx_call *call, long blksize)
386 afs_uint32 bytesleft, w;
389 buffer = (char *)malloc(blksize);
391 fprintf(STDERR, "memory allocation failed\n");
395 while ((bytesread = rx_Read(call, buffer, blksize)) > 0) {
396 for (bytesleft = bytesread; bytesleft; bytesleft -= w) {
397 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
400 FD_SET((int)(ufd->handle), &out);
401 /* don't timeout if write blocks */
402 #if defined(AFS_PTHREAD_ENV)
403 select(((int)(ufd->handle)) + 1, &out, 0, 0, 0);
405 IOMGR_Select(((int)(ufd->handle)) + 1, 0, &out, 0, 0);
409 USD_WRITE(ufd, &buffer[bytesread - bytesleft], bytesleft, &w);
411 fprintf(STDERR, "File system write failed\n");
424 DumpFunction(struct rx_call *call, char *filename)
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(pntr, server, part, totalOK, totalNotOK, totalBusy, fast,
484 afs_int32 server, part;
485 int *totalOK, *totalNotOK, *totalBusy;
486 int fast, longlist, disp;
491 fprintf(STDOUT, "%-10lu\n", (unsigned long)pntr->volid);
492 } else if (longlist) {
493 if (pntr->status == VOK) {
494 fprintf(STDOUT, "%-32s ", pntr->name);
495 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
497 fprintf(STDOUT, "RW ");
499 fprintf(STDOUT, "RO ");
501 fprintf(STDOUT, "BK ");
502 fprintf(STDOUT, "%10d K ", pntr->size);
503 if (pntr->inUse == 1) {
504 fprintf(STDOUT, "On-line");
507 fprintf(STDOUT, "Off-line");
510 if (pntr->needsSalvaged == 1)
511 fprintf(STDOUT, "**needs salvage**");
512 fprintf(STDOUT, "\n");
513 MapPartIdIntoName(part, pname);
514 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(server),
516 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
517 (unsigned long)pntr->parentID,
518 (unsigned long)pntr->cloneID,
519 (unsigned long)pntr->backupID);
520 fprintf(STDOUT, " MaxQuota %10d K \n", pntr->maxquota);
521 fprintf(STDOUT, " Creation %s",
522 vos_ctime(& pntr->creationDate));
523 #ifdef FULL_LISTVOL_SWITCH
524 fprintf(STDOUT, " Copy %s",
525 vos_ctime( & pntr->copyDate));
526 if (!pntr->backupDate)
527 fprintf(STDOUT, " Backup Never\n");
529 fprintf(STDOUT, " Backup %s",
530 vos_ctime( & pntr->backupDate));
531 if (pntr->accessDate)
532 fprintf(STDOUT, " Last Access %s",
533 vos_ctime( & pntr->accessDate));
535 if (!pntr->updateDate)
536 fprintf(STDOUT, " Last Update Never\n");
538 fprintf(STDOUT, " Last Update %s",
539 vos_ctime( & pntr->updateDate));
541 " %d accesses in the past day (i.e., vnode references)\n",
543 } else if (pntr->status == VBUSY) {
545 qPut(&busyHead, pntr->volid);
547 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
548 (unsigned long)pntr->volid);
551 qPut(¬okHead, pntr->volid);
553 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
554 (unsigned long)pntr->volid);
556 fprintf(STDOUT, "\n");
557 } else { /* default listing */
558 if (pntr->status == VOK) {
559 fprintf(STDOUT, "%-32s ", pntr->name);
560 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
562 fprintf(STDOUT, "RW ");
564 fprintf(STDOUT, "RO ");
566 fprintf(STDOUT, "BK ");
567 fprintf(STDOUT, "%10d K ", pntr->size);
568 if (pntr->inUse == 1) {
569 fprintf(STDOUT, "On-line");
572 fprintf(STDOUT, "Off-line");
575 if (pntr->needsSalvaged == 1)
576 fprintf(STDOUT, "**needs salvage**");
577 fprintf(STDOUT, "\n");
578 } else if (pntr->status == VBUSY) {
580 qPut(&busyHead, pntr->volid);
582 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
583 (unsigned long)pntr->volid);
586 qPut(¬okHead, pntr->volid);
588 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
589 (unsigned long)pntr->volid);
594 /*------------------------------------------------------------------------
595 * PRIVATE XDisplayFormat
598 * Display the contents of one extended volume info structure.
601 * a_xInfoP : Ptr to extended volume info struct to print.
602 * a_servID : Server ID to print.
603 * a_partID : Partition ID to print.
604 * a_totalOKP : Ptr to total-OK counter.
605 * a_totalNotOKP : Ptr to total-screwed counter.
606 * a_totalBusyP : Ptr to total-busy counter.
607 * a_fast : Fast listing?
608 * a_int32 : Int32 listing?
609 * a_showProblems : Show volume problems?
615 * Nothing interesting.
619 *------------------------------------------------------------------------*/
622 XDisplayFormat(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
623 a_totalBusyP, a_fast, a_int32, a_showProblems)
624 volintXInfo *a_xInfoP;
634 { /*XDisplayFormat */
642 fprintf(STDOUT, "%-10lu\n", (unsigned long)a_xInfoP->volid);
643 } else if (a_int32) {
645 * Fully-detailed listing.
647 if (a_xInfoP->status == VOK) {
649 * Volume's status is OK - all the fields are valid.
651 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
652 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
653 if (a_xInfoP->type == 0)
654 fprintf(STDOUT, "RW ");
655 if (a_xInfoP->type == 1)
656 fprintf(STDOUT, "RO ");
657 if (a_xInfoP->type == 2)
658 fprintf(STDOUT, "BK ");
659 fprintf(STDOUT, "%10d K used ", a_xInfoP->size);
660 fprintf(STDOUT, "%d files ", a_xInfoP->filecount);
661 if (a_xInfoP->inUse == 1) {
662 fprintf(STDOUT, "On-line");
665 fprintf(STDOUT, "Off-line");
668 fprintf(STDOUT, "\n");
669 MapPartIdIntoName(a_partID, pname);
670 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(a_servID),
672 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
673 (unsigned long)a_xInfoP->parentID,
674 (unsigned long)a_xInfoP->cloneID,
675 (unsigned long)a_xInfoP->backupID);
676 fprintf(STDOUT, " MaxQuota %10d K \n", a_xInfoP->maxquota);
677 fprintf(STDOUT, " Creation %s",
678 vos_ctime( & a_xInfoP->creationDate));
679 #ifdef FULL_LISTVOL_SWITCH
680 fprintf(STDOUT, " Copy %s",
681 vos_ctime( & a_xInfoP->copyDate));
682 if (!a_xInfoP->backupDate)
683 fprintf(STDOUT, " Backup Never\n");
685 fprintf(STDOUT, " Backup %s",
686 vos_ctime( & a_xInfoP->backupDate));
687 if (a_xInfoP->accessDate)
688 fprintf(STDOUT, " Last Access %s",
689 vos_ctime( & a_xInfoP->accessDate));
691 if (!a_xInfoP->updateDate)
692 fprintf(STDOUT, " Last Update Never\n");
694 fprintf(STDOUT, " Last Update %s",
695 vos_ctime( & a_xInfoP->updateDate));
697 " %d accesses in the past day (i.e., vnode references)\n",
701 * Print all the read/write and authorship stats.
703 fprintf(STDOUT, "\n Raw Read/Write Stats\n");
705 " |-------------------------------------------|\n");
707 " | Same Network | Diff Network |\n");
709 " |----------|----------|----------|----------|\n");
711 " | Total | Auth | Total | Auth |\n");
713 " |----------|----------|----------|----------|\n");
714 fprintf(STDOUT, "Reads | %8d | %8d | %8d | %8d |\n",
715 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET],
716 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH],
717 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET],
718 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
719 fprintf(STDOUT, "Writes | %8d | %8d | %8d | %8d |\n",
720 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET],
721 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH],
722 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET],
723 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
725 " |-------------------------------------------|\n\n");
728 " Writes Affecting Authorship\n");
730 " |-------------------------------------------|\n");
732 " | File Authorship | Directory Authorship|\n");
734 " |----------|----------|----------|----------|\n");
736 " | Same | Diff | Same | Diff |\n");
738 " |----------|----------|----------|----------|\n");
739 fprintf(STDOUT, "0-60 sec | %8d | %8d | %8d | %8d |\n",
740 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_0],
741 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0],
742 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0],
743 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]);
744 fprintf(STDOUT, "1-10 min | %8d | %8d | %8d | %8d |\n",
745 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1],
746 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1],
747 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1],
748 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]);
749 fprintf(STDOUT, "10min-1hr | %8d | %8d | %8d | %8d |\n",
750 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_2],
751 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_2],
752 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_2],
753 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_2]);
754 fprintf(STDOUT, "1hr-1day | %8d | %8d | %8d | %8d |\n",
755 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_3],
756 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_3],
757 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_3],
758 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_3]);
759 fprintf(STDOUT, "1day-1wk | %8d | %8d | %8d | %8d |\n",
760 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_4],
761 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_4],
762 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_4],
763 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_4]);
764 fprintf(STDOUT, "> 1wk | %8d | %8d | %8d | %8d |\n",
765 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_5],
766 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5],
767 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5],
768 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]);
770 " |-------------------------------------------|\n");
771 } /*Volume status OK */
772 else if (a_xInfoP->status == VBUSY) {
774 qPut(&busyHead, a_xInfoP->volid);
776 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
777 (unsigned long)a_xInfoP->volid);
781 qPut(¬okHead, a_xInfoP->volid);
783 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
784 (unsigned long)a_xInfoP->volid);
785 } /*Screwed volume */
786 fprintf(STDOUT, "\n");
792 if (a_xInfoP->status == VOK) {
793 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
794 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
795 if (a_xInfoP->type == 0)
796 fprintf(STDOUT, "RW ");
797 if (a_xInfoP->type == 1)
798 fprintf(STDOUT, "RO ");
799 if (a_xInfoP->type == 2)
800 fprintf(STDOUT, "BK ");
801 fprintf(STDOUT, "%10d K ", a_xInfoP->size);
802 if (a_xInfoP->inUse == 1) {
803 fprintf(STDOUT, "On-line");
806 fprintf(STDOUT, "Off-line");
809 fprintf(STDOUT, "\n");
811 else if (a_xInfoP->status == VBUSY) {
813 qPut(&busyHead, a_xInfoP->volid);
815 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
816 (unsigned long)a_xInfoP->volid);
820 qPut(¬okHead, a_xInfoP->volid);
822 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
823 (unsigned long)a_xInfoP->volid);
824 } /*Screwed volume */
825 } /*Default listing */
826 } /*XDisplayFormat */
828 #ifdef FULL_LISTVOL_SWITCH
829 /*------------------------------------------------------------------------
830 * PRIVATE XDisplayFormat2
833 * Display the formated contents of one extended volume info structure.
836 * a_xInfoP : Ptr to extended volume info struct to print.
837 * a_servID : Server ID to print.
838 * a_partID : Partition ID to print.
839 * a_totalOKP : Ptr to total-OK counter.
840 * a_totalNotOKP : Ptr to total-screwed counter.
841 * a_totalBusyP : Ptr to total-busy counter.
842 * a_fast : Fast listing?
843 * a_int32 : Int32 listing?
844 * a_showProblems : Show volume problems?
850 * Nothing interesting.
854 *------------------------------------------------------------------------*/
857 XDisplayFormat2(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
858 a_totalBusyP, a_fast, a_int32, a_showProblems)
859 volintXInfo *a_xInfoP;
869 { /*XDisplayFormat */
874 fprintf(STDOUT, "vold_id\t%-10lu\n", (unsigned long)a_xInfoP->volid);
875 } else if (a_int32) {
877 * Fully-detailed listing.
879 if (a_xInfoP->status == VOK) {
881 * Volume's status is OK - all the fields are valid.
884 static long server_cache = -1, partition_cache = -1;
885 static char hostname[256], address[32], pname[16];
886 int i,ai[] = {VOLINT_STATS_TIME_IDX_0,VOLINT_STATS_TIME_IDX_1,VOLINT_STATS_TIME_IDX_2,
887 VOLINT_STATS_TIME_IDX_3,VOLINT_STATS_TIME_IDX_4,VOLINT_STATS_TIME_IDX_5};
889 if (a_servID != server_cache) {
893 strcpy(hostname, hostutil_GetNameByINet(a_servID));
894 strcpy(address, inet_ntoa(s));
895 server_cache = a_servID;
897 if (a_partID != partition_cache) {
898 MapPartIdIntoName(a_partID, pname);
899 partition_cache = a_partID;
902 fprintf(STDOUT, "name\t\t%s\n", a_xInfoP->name);
903 fprintf(STDOUT, "id\t\t%lu\n", afs_cast_uint32(a_xInfoP->volid));
904 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
905 fprintf(STDOUT, "part\t\t%s\n", pname);
906 switch (a_xInfoP->status) {
908 fprintf(STDOUT, "status\t\tOK\n");
911 fprintf(STDOUT, "status\t\tBUSY\n");
914 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
917 fprintf(STDOUT, "backupID\t%lu\n",
918 afs_cast_uint32(a_xInfoP->backupID));
919 fprintf(STDOUT, "parentID\t%lu\n",
920 afs_cast_uint32(a_xInfoP->parentID));
921 fprintf(STDOUT, "cloneID\t\t%lu\n",
922 afs_cast_uint32(a_xInfoP->cloneID));
923 fprintf(STDOUT, "inUse\t\t%s\n", a_xInfoP->inUse ? "Y" : "N");
924 switch (a_xInfoP->type) {
926 fprintf(STDOUT, "type\t\tRW\n");
929 fprintf(STDOUT, "type\t\tRO\n");
932 fprintf(STDOUT, "type\t\tBK\n");
935 fprintf(STDOUT, "type\t\t?\n");
938 fprintf(STDOUT, "creationDate\t%-9lu\t%s",
939 afs_cast_uint32(a_xInfoP->creationDate),
940 vos_ctime(&a_xInfoP->creationDate));
941 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
942 afs_cast_uint32(a_xInfoP->accessDate),
943 vos_ctime(&a_xInfoP->accessDate));
944 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
945 afs_cast_uint32(a_xInfoP->updateDate),
946 vos_ctime(&a_xInfoP->updateDate));
947 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
948 afs_cast_uint32(a_xInfoP->backupDate),
949 vos_ctime(&a_xInfoP->backupDate));
950 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
951 afs_cast_uint32(a_xInfoP->copyDate),
952 vos_ctime(&a_xInfoP->copyDate));
954 fprintf(STDOUT, "diskused\t%u\n", a_xInfoP->size);
955 fprintf(STDOUT, "maxquota\t%u\n", a_xInfoP->maxquota);
957 fprintf(STDOUT, "filecount\t%u\n", a_xInfoP->filecount);
958 fprintf(STDOUT, "dayUse\t\t%u\n", a_xInfoP->dayUse);
962 fprintf(STDOUT,"reads_same_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET]);
963 fprintf(STDOUT,"reads_same_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH]);
964 fprintf(STDOUT,"reads_diff_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET]);
965 fprintf(STDOUT,"reads_diff_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
967 fprintf(STDOUT,"writes_same_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET]);
968 fprintf(STDOUT,"writes_same_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH]);
969 fprintf(STDOUT,"writes_diff_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET]);
970 fprintf(STDOUT,"writes_diff_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
974 fprintf(STDOUT,"file_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileSameAuthor[ai[i]]);
975 fprintf(STDOUT,"file_diff_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileDiffAuthor[ai[i]]);
976 fprintf(STDOUT,"dir_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirSameAuthor[ai[i]]);
977 fprintf(STDOUT,"dir_dif_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirDiffAuthor[ai[i]]);
980 } /*Volume status OK */
981 else if (a_xInfoP->status == VBUSY) {
983 qPut(&busyHead, a_xInfoP->volid);
985 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
986 (unsigned long)a_xInfoP->volid);
990 qPut(¬okHead, a_xInfoP->volid);
992 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
993 (unsigned long)a_xInfoP->volid);
994 } /*Screwed volume */
1000 if (a_xInfoP->status == VOK) {
1001 fprintf(STDOUT, "name\t%-32s\n", a_xInfoP->name);
1002 fprintf(STDOUT, "volID\t%10lu\n", (unsigned long)a_xInfoP->volid);
1003 if (a_xInfoP->type == 0)
1004 fprintf(STDOUT, "type\tRW\n");
1005 if (a_xInfoP->type == 1)
1006 fprintf(STDOUT, "type\tRO\n");
1007 if (a_xInfoP->type == 2)
1008 fprintf(STDOUT, "type\tBK\n");
1009 fprintf(STDOUT, "size\t%10dK\n", a_xInfoP->size);
1011 fprintf(STDOUT, "inUse\t%d\n",a_xInfoP->inUse);
1012 if (a_xInfoP->inUse == 1)
1018 else if (a_xInfoP->status == VBUSY) {
1020 qPut(&busyHead, a_xInfoP->volid);
1022 fprintf(STDOUT, "VOLUME_BUSY\t%lu\n",
1023 (unsigned long)a_xInfoP->volid);
1027 qPut(¬okHead, a_xInfoP->volid);
1029 fprintf(STDOUT, "COULD_NOT_ATTACH_VOLUME\t%lu\n",
1030 (unsigned long)a_xInfoP->volid);
1031 } /*Screwed volume */
1032 } /*Default listing */
1033 } /*XDisplayFormat */
1034 #endif /*FULL_LISTVOL_SWITCH*/
1036 #ifdef FULL_LISTVOL_SWITCH
1038 DisplayFormat2(server, partition, pntr)
1039 long server, partition;
1042 static long server_cache = -1, partition_cache = -1;
1043 static char hostname[256], address[32], pname[16];
1045 if (server != server_cache) {
1049 strcpy(hostname, hostutil_GetNameByINet(server));
1050 strcpy(address, inet_ntoa(s));
1051 server_cache = server;
1053 if (partition != partition_cache) {
1054 MapPartIdIntoName(partition, pname);
1055 partition_cache = partition;
1057 fprintf(STDOUT, "name\t\t%s\n", pntr->name);
1058 fprintf(STDOUT, "id\t\t%lu\n",
1059 afs_cast_uint32(pntr->volid));
1060 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
1061 fprintf(STDOUT, "part\t\t%s\n", pname);
1062 switch (pntr->status) {
1064 fprintf(STDOUT, "status\t\tOK\n");
1067 fprintf(STDOUT, "status\t\tBUSY\n");
1070 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
1073 fprintf(STDOUT, "backupID\t%lu\n",
1074 afs_cast_uint32(pntr->backupID));
1075 fprintf(STDOUT, "parentID\t%lu\n",
1076 afs_cast_uint32(pntr->parentID));
1077 fprintf(STDOUT, "cloneID\t\t%lu\n",
1078 afs_cast_uint32(pntr->cloneID));
1079 fprintf(STDOUT, "inUse\t\t%s\n", pntr->inUse ? "Y" : "N");
1080 fprintf(STDOUT, "needsSalvaged\t%s\n", pntr->needsSalvaged ? "Y" : "N");
1081 /* 0xD3 is from afs/volume.h since I had trouble including the file */
1082 fprintf(STDOUT, "destroyMe\t%s\n", pntr->destroyMe == 0xD3 ? "Y" : "N");
1083 switch (pntr->type) {
1085 fprintf(STDOUT, "type\t\tRW\n");
1088 fprintf(STDOUT, "type\t\tRO\n");
1091 fprintf(STDOUT, "type\t\tBK\n");
1094 fprintf(STDOUT, "type\t\t?\n");
1097 fprintf(STDOUT, "creationDate\t%-9lu\t%s",
1098 afs_cast_uint32(pntr->creationDate),
1099 vos_ctime(&pntr->creationDate));
1100 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
1101 afs_cast_uint32(pntr->accessDate),
1102 vos_ctime(&pntr->accessDate));
1103 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
1104 afs_cast_uint32(pntr->updateDate),
1105 vos_ctime(&pntr->updateDate));
1106 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
1107 afs_cast_uint32(pntr->backupDate),
1108 vos_ctime(&pntr->backupDate));
1109 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
1110 afs_cast_uint32(pntr->copyDate),
1111 vos_ctime(&pntr->copyDate));
1112 fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n",
1113 afs_cast_uint32(pntr->flags));
1114 fprintf(STDOUT, "diskused\t%u\n", pntr->size);
1115 fprintf(STDOUT, "maxquota\t%u\n", pntr->maxquota);
1116 fprintf(STDOUT, "minquota\t%lu\t(Optional)\n",
1117 afs_cast_uint32(pntr->spare0));
1118 fprintf(STDOUT, "filecount\t%u\n", pntr->filecount);
1119 fprintf(STDOUT, "dayUse\t\t%u\n", pntr->dayUse);
1120 fprintf(STDOUT, "weekUse\t\t%lu\t(Optional)\n",
1121 afs_cast_uint32(pntr->spare1));
1122 fprintf(STDOUT, "spare2\t\t%lu\t(Optional)\n",
1123 afs_cast_uint32(pntr->spare2));
1124 fprintf(STDOUT, "spare3\t\t%lu\t(Optional)\n",
1125 afs_cast_uint32(pntr->spare3));
1130 DisplayVolumes2(server, partition, pntr, count)
1132 long server, partition, count;
1136 for (i = 0; i < count; i++) {
1137 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1138 DisplayFormat2(server, partition, pntr);
1139 fprintf(STDOUT, "END_OF_ENTRY\n\n");
1144 #endif /* FULL_LISTVOL_SWITCH */
1147 DisplayVolumes(server, part, pntr, count, longlist, fast, quiet)
1148 afs_int32 server, part;
1150 afs_int32 count, longlist, fast;
1153 int totalOK, totalNotOK, totalBusy, i;
1154 afs_uint32 volid = 0;
1161 for (i = 0; i < count; i++) {
1162 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy,
1167 while (busyHead.count) {
1168 qGet(&busyHead, &volid);
1169 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1170 (unsigned long)volid);
1174 while (notokHead.count) {
1175 qGet(¬okHead, &volid);
1176 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1177 (unsigned long)volid);
1181 fprintf(STDOUT, "\n");
1184 "Total volumes onLine %d ; Total volumes offLine %d ; Total busy %d\n\n",
1185 totalOK, totalNotOK, totalBusy);
1189 /*------------------------------------------------------------------------
1190 * PRIVATE XDisplayVolumes
1193 * Display extended volume information.
1196 * a_servID : Pointer to the Rx call we're performing.
1197 * a_partID : Partition for which we want the extended list.
1198 * a_xInfoP : Ptr to extended volume info.
1199 * a_count : Number of volume records contained above.
1200 * a_int32 : Int32 listing generated?
1201 * a_fast : Fast listing generated?
1202 * a_quiet : Quiet listing generated?
1208 * Nothing interesting.
1212 *------------------------------------------------------------------------*/
1215 XDisplayVolumes(a_servID, a_partID, a_xInfoP, a_count, a_int32, a_fast,
1219 volintXInfo *a_xInfoP;
1225 { /*XDisplayVolumes */
1227 int totalOK; /*Total OK volumes */
1228 int totalNotOK; /*Total screwed volumes */
1229 int totalBusy; /*Total busy volumes */
1230 int i; /*Loop variable */
1231 afs_uint32 volid = 0; /*Current volume ID */
1234 * Initialize counters and (global!!) queues.
1243 * Display each volume in the list.
1245 for (i = 0; i < a_count; i++) {
1246 XDisplayFormat(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1247 &totalBusy, a_fast, a_int32, 0);
1252 * If any volumes were found to be busy or screwed, display them.
1255 while (busyHead.count) {
1256 qGet(&busyHead, &volid);
1257 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1258 (unsigned long)volid);
1262 while (notokHead.count) {
1263 qGet(¬okHead, &volid);
1264 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1265 (unsigned long)volid);
1270 fprintf(STDOUT, "\n");
1273 "Total volumes: %d on-line, %d off-line, %d busyd\n\n",
1274 totalOK, totalNotOK, totalBusy);
1278 } /*XDisplayVolumes */
1279 #ifdef FULL_LISTVOL_SWITCH
1280 /*------------------------------------------------------------------------
1281 * PRIVATE XDisplayVolumes2
1284 * Display extended formated volume information.
1287 * a_servID : Pointer to the Rx call we're performing.
1288 * a_partID : Partition for which we want the extended list.
1289 * a_xInfoP : Ptr to extended volume info.
1290 * a_count : Number of volume records contained above.
1291 * a_int32 : Int32 listing generated?
1292 * a_fast : Fast listing generated?
1293 * a_quiet : Quiet listing generated?
1299 * Nothing interesting.
1303 *------------------------------------------------------------------------*/
1306 XDisplayVolumes2(a_servID, a_partID, a_xInfoP, a_count, a_int32, a_fast,
1310 volintXInfo *a_xInfoP;
1316 { /*XDisplayVolumes */
1318 int totalOK; /*Total OK volumes */
1319 int totalNotOK; /*Total screwed volumes */
1320 int totalBusy; /*Total busy volumes */
1321 int i; /*Loop variable */
1322 afs_uint32 volid = 0; /*Current volume ID */
1325 * Initialize counters and (global!!) queues.
1334 * Display each volume in the list.
1336 for (i = 0; i < a_count; i++) {
1337 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1338 XDisplayFormat2(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1339 &totalBusy, a_fast, a_int32, 0);
1340 fprintf(STDOUT, "END_OF_ENTRY\n");
1345 * If any volumes were found to be busy or screwed, display them.
1348 while (busyHead.count) {
1349 qGet(&busyHead, &volid);
1350 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
1351 (unsigned long)volid);
1355 while (notokHead.count) {
1356 qGet(¬okHead, &volid);
1357 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
1358 (unsigned long)volid);
1363 fprintf(STDOUT, "\n");
1366 "VOLUMES_ONLINE\t%d\nVOLUMES_OFFLINE\t%d\nVOLUMES_BUSY\t%d\n",
1367 totalOK, totalNotOK, totalBusy);
1371 } /*XDisplayVolumes2 */
1372 #endif /* FULL_LISTVOL_SWITCH */
1375 /* set <server> and <part> to the correct values depending on
1376 * <voltype> and <entry> */
1378 GetServerAndPart(entry, voltype, server, part, previdx)
1379 struct nvldbentry *entry;
1380 afs_int32 *server, *part;
1384 int i, istart, vtype;
1389 /* Doesn't check for non-existance of backup volume */
1390 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
1392 istart = 0; /* seach the entire entry */
1395 /* Seach from beginning of entry or pick up where we left off */
1396 istart = ((*previdx < 0) ? 0 : *previdx + 1);
1399 for (i = istart; i < entry->nServers; i++) {
1400 if (entry->serverFlags[i] & vtype) {
1401 *server = entry->serverNumber[i];
1402 *part = entry->serverPartition[i];
1408 /* Didn't find any, return -1 */
1414 PostVolumeStats(struct nvldbentry *entry)
1416 SubEnumerateEntry(entry);
1417 /* Check for VLOP_ALLOPERS */
1418 if (entry->flags & VLOP_ALLOPERS)
1419 fprintf(STDOUT, " Volume is currently LOCKED \n");
1423 /*------------------------------------------------------------------------
1424 * PRIVATE XVolumeStats
1427 * Display extended volume information.
1430 * a_xInfoP : Ptr to extended volume info.
1431 * a_entryP : Ptr to the volume's VLDB entry.
1432 * a_srvID : Server ID.
1433 * a_partID : Partition ID.
1434 * a_volType : Type of volume to print.
1440 * Nothing interesting.
1444 *------------------------------------------------------------------------*/
1447 XVolumeStats(a_xInfoP, a_entryP, a_srvID, a_partID, a_volType)
1448 volintXInfo *a_xInfoP;
1449 struct nvldbentry *a_entryP;
1456 int totalOK, totalNotOK, totalBusy; /*Dummies - we don't really count here */
1458 XDisplayFormat(a_xInfoP, /*Ptr to extended volume info */
1459 a_srvID, /*Server ID to print */
1460 a_partID, /*Partition ID to print */
1461 &totalOK, /*Ptr to total-OK counter */
1462 &totalNotOK, /*Ptr to total-screwed counter */
1463 &totalBusy, /*Ptr to total-busy counter */
1464 0, /*Don't do a fast listing */
1465 1, /*Do a long listing */
1466 1); /*Show volume problems */
1472 VolumeStats_int(volintInfo *pntr, struct nvldbentry *entry, afs_int32 server,
1473 afs_int32 part, int voltype)
1475 int totalOK, totalNotOK, totalBusy;
1477 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy, 0, 1,
1482 /* command to forcibly remove a volume */
1484 NukeVolume(register struct cmd_syndesc *as)
1486 register afs_int32 code;
1493 server = GetServer(tp = as->parms[0].items->data);
1495 fprintf(STDERR, "vos: server '%s' not found in host table\n", tp);
1499 partID = volutil_GetPartitionID(tp = as->parms[1].items->data);
1501 fprintf(STDERR, "vos: could not parse '%s' as a partition name", tp);
1505 volID = vsu_GetVolumeID(tp = as->parms[2].items->data, cstruct, &err);
1508 PrintError("", err);
1511 "vos: could not parse '%s' as a numeric volume ID", tp);
1516 "vos: forcibly removing all traces of volume %d, please wait...",
1519 code = UV_NukeVolume(server, partID, volID);
1521 fprintf(STDOUT, "done.\n");
1523 fprintf(STDOUT, "failed with code %d.\n", code);
1528 /*------------------------------------------------------------------------
1529 * PRIVATE ExamineVolume
1532 * Routine used to examine a single volume, contacting the VLDB as
1533 * well as the Volume Server.
1536 * as : Ptr to parsed command line arguments.
1539 * 0 for a successful operation,
1540 * Otherwise, one of the ubik or VolServer error values.
1543 * Nothing interesting.
1547 *------------------------------------------------------------------------
1550 ExamineVolume(register struct cmd_syndesc *as, void *arock)
1552 struct nvldbentry entry;
1553 afs_int32 vcode = 0;
1554 volintInfo *pntr = (volintInfo *) 0;
1555 volintXInfo *xInfoP = (volintXInfo *) 0;
1557 afs_int32 code, err, error = 0;
1558 int voltype, foundserv = 0, foundentry = 0;
1559 afs_int32 aserver, apart;
1561 int wantExtendedInfo; /*Do we want extended vol info? */
1563 wantExtendedInfo = (as->parms[1].items ? 1 : 0); /* -extended */
1565 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1568 PrintError("", err);
1570 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1571 as->parms[0].items->data);
1576 fprintf(STDOUT, "Fetching VLDB entry for %lu .. ",
1577 (unsigned long)volid);
1580 vcode = VLDB_GetEntryByID(volid, -1, &entry);
1583 "Could not fetch the entry for volume number %lu from VLDB \n",
1584 (unsigned long)volid);
1588 fprintf(STDOUT, "done\n");
1589 MapHostToNetwork(&entry);
1591 if (entry.volumeId[RWVOL] == volid)
1593 else if (entry.volumeId[BACKVOL] == volid)
1595 else /* (entry.volumeId[ROVOL] == volid) */
1598 do { /* do {...} while (voltype == ROVOL) */
1599 /* Get the entry for the volume. If its a RW vol, get the RW entry.
1600 * It its a BK vol, get the RW entry (even if VLDB may say the BK doen't exist).
1601 * If its a RO vol, get the next RO entry.
1603 GetServerAndPart(&entry, ((voltype == ROVOL) ? ROVOL : RWVOL),
1604 &aserver, &apart, &previdx);
1605 if (previdx == -1) { /* searched all entries */
1607 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1608 as->parms[0].items->data);
1615 /* Get information about the volume from the server */
1617 fprintf(STDOUT, "Getting volume listing from the server %s .. ",
1618 hostutil_GetNameByINet(aserver));
1621 if (wantExtendedInfo)
1622 code = UV_XListOneVolume(aserver, apart, volid, &xInfoP);
1624 code = UV_ListOneVolume(aserver, apart, volid, &pntr);
1626 fprintf(STDOUT, "done\n");
1630 if (code == ENODEV) {
1631 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1632 /* The VLDB says there is no backup volume and its not on disk */
1633 fprintf(STDERR, "Volume %s does not exist\n",
1634 as->parms[0].items->data);
1638 "Volume does not exist on server %s as indicated by the VLDB\n",
1639 hostutil_GetNameByINet(aserver));
1642 PrintDiagnostics("examine", code);
1644 fprintf(STDOUT, "\n");
1647 if (wantExtendedInfo)
1648 XVolumeStats(xInfoP, &entry, aserver, apart, voltype);
1650 #ifdef FULL_LISTVOL_SWITCH
1651 if (as->parms[2].items) {
1652 DisplayFormat2(aserver, apart, pntr);
1653 EnumerateEntry(&entry);
1655 #endif /* FULL_LISTVOL_SWITCH */
1656 VolumeStats_int(pntr, &entry, aserver, apart, voltype);
1658 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1659 /* The VLDB says there is no backup volume yet we found one on disk */
1660 fprintf(STDERR, "Volume %s does not exist in VLDB\n",
1661 as->parms[0].items->data);
1670 } while (voltype == ROVOL);
1673 fprintf(STDERR, "Dump only information from VLDB\n\n");
1674 fprintf(STDOUT, "%s \n", entry.name); /* PostVolumeStats doesn't print name */
1676 PostVolumeStats(&entry);
1681 /*------------------------------------------------------------------------
1685 * Routine used to change the status of a single volume.
1688 * as : Ptr to parsed command line arguments.
1691 * 0 for a successful operation,
1692 * Otherwise, one of the ubik or VolServer error values.
1695 * Nothing interesting.
1699 *------------------------------------------------------------------------
1702 SetFields(register struct cmd_syndesc *as, void *arock)
1704 struct nvldbentry entry;
1705 afs_int32 vcode = 0;
1708 afs_int32 code, err;
1709 afs_int32 aserver, apart;
1712 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1715 PrintError("", err);
1717 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1718 as->parms[0].items->data);
1722 code = VLDB_GetEntryByID(volid, RWVOL, &entry);
1725 "Could not fetch the entry for volume number %lu from VLDB \n",
1726 (unsigned long)volid);
1729 MapHostToNetwork(&entry);
1731 GetServerAndPart(&entry, RWVOL, &aserver, &apart, &previdx);
1732 if (previdx == -1) {
1733 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1734 as->parms[0].items->data);
1738 init_volintInfo(&info);
1742 if (as->parms[1].items) {
1744 code = util_GetInt32(as->parms[1].items->data, &info.maxquota);
1746 fprintf(STDERR, "invalid quota value\n");
1750 if (as->parms[2].items) {
1754 if (as->parms[3].items) {
1755 /* -clearVolUpCounter */
1758 code = UV_SetVolumeInfo(aserver, apart, volid, &info);
1761 "Could not update volume info fields for volume number %lu\n",
1762 (unsigned long)volid);
1766 /*------------------------------------------------------------------------
1770 * Brings a volume online.
1773 * as : Ptr to parsed command line arguments.
1776 * 0 for a successful operation,
1779 * Nothing interesting.
1783 *------------------------------------------------------------------------
1786 volOnline(register struct cmd_syndesc *as, void *arock)
1788 afs_int32 server, partition;
1790 afs_int32 code, err = 0;
1792 server = GetServer(as->parms[0].items->data);
1794 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1795 as->parms[0].items->data);
1799 partition = volutil_GetPartitionID(as->parms[1].items->data);
1800 if (partition < 0) {
1801 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1802 as->parms[1].items->data);
1806 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1809 PrintError("", err);
1811 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1812 as->parms[0].items->data);
1816 code = UV_SetVolume(server, partition, volid, ITOffline, 0 /*online */ ,
1819 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1826 /*------------------------------------------------------------------------
1827 * PRIVATE volOffline
1830 * Brings a volume offline.
1833 * as : Ptr to parsed command line arguments.
1836 * 0 for a successful operation,
1839 * Nothing interesting.
1843 *------------------------------------------------------------------------
1846 volOffline(register struct cmd_syndesc *as, void *arock)
1848 afs_int32 server, partition;
1850 afs_int32 code, err = 0;
1851 afs_int32 transflag, sleeptime, transdone;
1853 server = GetServer(as->parms[0].items->data);
1855 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1856 as->parms[0].items->data);
1860 partition = volutil_GetPartitionID(as->parms[1].items->data);
1861 if (partition < 0) {
1862 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1863 as->parms[1].items->data);
1867 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1870 PrintError("", err);
1872 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1873 as->parms[0].items->data);
1877 transflag = (as->parms[4].items ? ITBusy : ITOffline);
1878 sleeptime = (as->parms[3].items ? atol(as->parms[3].items->data) : 0);
1879 transdone = (sleeptime ? 0 /*online */ : VTOutOfService);
1880 if (as->parms[4].items && !as->parms[3].items) {
1881 fprintf(STDERR, "-sleep option must be used with -busy flag\n");
1886 UV_SetVolume(server, partition, volid, transflag, transdone,
1889 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1897 CreateVolume(register struct cmd_syndesc *as, void *arock)
1903 struct nvldbentry entry;
1908 tserver = GetServer(as->parms[0].items->data);
1910 fprintf(STDERR, "vos: host '%s' not found in host table\n",
1911 as->parms[0].items->data);
1914 pnum = volutil_GetPartitionID(as->parms[1].items->data);
1916 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1917 as->parms[1].items->data);
1920 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
1922 PrintError("", code);
1925 "vos : partition %s does not exist on the server\n",
1926 as->parms[1].items->data);
1929 if (!ISNAMEVALID(as->parms[2].items->data)) {
1931 "vos: the name of the root volume %s exceeds the size limit of %d\n",
1932 as->parms[2].items->data, VOLSER_OLDMAXVOLNAME - 10);
1935 if (!VolNameOK(as->parms[2].items->data)) {
1937 "Illegal volume name %s, should not end in .readonly or .backup\n",
1938 as->parms[2].items->data);
1941 if (IsNumeric(as->parms[2].items->data)) {
1942 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
1943 as->parms[2].items->data);
1946 vcode = VLDB_GetEntryByName(as->parms[2].items->data, &entry);
1948 fprintf(STDERR, "Volume %s already exists\n",
1949 as->parms[2].items->data);
1950 PrintDiagnostics("create", code);
1954 if (as->parms[3].items) {
1955 if (!IsNumeric(as->parms[3].items->data)) {
1956 fprintf(STDERR, "Initial quota %s should be numeric.\n",
1957 as->parms[3].items->data);
1961 code = util_GetInt32(as->parms[3].items->data, "a);
1963 fprintf(STDERR, "vos: bad integer specified for quota.\n");
1969 UV_CreateVolume2(tserver, pnum, as->parms[2].items->data, quota, 0,
1972 PrintDiagnostics("create", code);
1975 MapPartIdIntoName(pnum, part);
1976 fprintf(STDOUT, "Volume %lu created on partition %s of %s\n",
1977 (unsigned long)volid, part, as->parms[0].items->data);
1984 struct nvldbentry *entry;
1987 afs_int32 error, code, curserver, curpart;
1990 MapHostToNetwork(entry);
1992 for (i = 0; i < entry->nServers; i++) {
1993 curserver = entry->serverNumber[i];
1994 curpart = entry->serverPartition[i];
1995 if (entry->serverFlags[i] & ITSROVOL) {
1996 volid = entry->volumeId[ROVOL];
1998 volid = entry->volumeId[RWVOL];
2000 code = UV_DeleteVolume(curserver, curpart, volid);
2008 DeleteVolume(struct cmd_syndesc *as, void *arock)
2010 afs_int32 err, code = 0;
2011 afs_int32 server = 0, partition = -1;
2016 if (as->parms[0].items) {
2017 server = GetServer(as->parms[0].items->data);
2019 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2020 as->parms[0].items->data);
2025 if (as->parms[1].items) {
2026 partition = volutil_GetPartitionID(as->parms[1].items->data);
2027 if (partition < 0) {
2028 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2029 as->parms[1].items->data);
2033 /* Check for validity of the partition */
2034 if (!IsPartValid(partition, server, &code)) {
2036 PrintError("", code);
2039 "vos : partition %s does not exist on the server\n",
2040 as->parms[1].items->data);
2046 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
2048 fprintf(STDERR, "Can't find volume name '%s' in VLDB\n",
2049 as->parms[2].items->data);
2051 PrintError("", err);
2055 /* If the server or partition option are not complete, try to fill
2056 * them in from the VLDB entry.
2058 if ((partition == -1) || !server) {
2059 struct nvldbentry entry;
2061 code = VLDB_GetEntryByID(volid, -1, &entry);
2064 "Could not fetch the entry for volume %lu from VLDB\n",
2065 (unsigned long)volid);
2066 PrintError("", code);
2070 if (((volid == entry.volumeId[RWVOL]) && (entry.flags & RW_EXISTS))
2071 || ((volid == entry.volumeId[BACKVOL])
2072 && (entry.flags & BACK_EXISTS))) {
2073 idx = Lp_GetRwIndex(&entry);
2074 if ((idx == -1) || (server && (server != entry.serverNumber[idx]))
2075 || ((partition != -1)
2076 && (partition != entry.serverPartition[idx]))) {
2077 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2078 as->parms[2].items->data);
2081 } else if ((volid == entry.volumeId[ROVOL])
2082 && (entry.flags & RO_EXISTS)) {
2083 for (idx = -1, j = 0; j < entry.nServers; j++) {
2084 if (entry.serverFlags[j] != ITSROVOL)
2087 if (((server == 0) || (server == entry.serverNumber[j]))
2088 && ((partition == -1)
2089 || (partition == entry.serverPartition[j]))) {
2092 "VLDB: Volume '%s' matches more than one RO\n",
2093 as->parms[2].items->data);
2100 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2101 as->parms[2].items->data);
2105 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2106 as->parms[2].items->data);
2110 server = htonl(entry.serverNumber[idx]);
2111 partition = entry.serverPartition[idx];
2115 code = UV_DeleteVolume(server, partition, volid);
2117 PrintDiagnostics("remove", code);
2121 MapPartIdIntoName(partition, pname);
2122 fprintf(STDOUT, "Volume %lu on partition %s server %s deleted\n",
2123 (unsigned long)volid, pname, hostutil_GetNameByINet(server));
2127 #define TESTM 0 /* set for move space tests, clear for production */
2129 MoveVolume(register struct cmd_syndesc *as, void *arock)
2133 afs_int32 fromserver, toserver, frompart, topart;
2134 afs_int32 flags, code, err;
2135 char fromPartName[10], toPartName[10];
2137 struct diskPartition64 partition; /* for space check */
2140 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2143 PrintError("", err);
2145 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2146 as->parms[0].items->data);
2149 fromserver = GetServer(as->parms[1].items->data);
2150 if (fromserver == 0) {
2151 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2152 as->parms[1].items->data);
2155 toserver = GetServer(as->parms[3].items->data);
2156 if (toserver == 0) {
2157 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2158 as->parms[3].items->data);
2161 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2163 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2164 as->parms[2].items->data);
2167 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2169 PrintError("", code);
2172 "vos : partition %s does not exist on the server\n",
2173 as->parms[2].items->data);
2176 topart = volutil_GetPartitionID(as->parms[4].items->data);
2178 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2179 as->parms[4].items->data);
2182 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2184 PrintError("", code);
2187 "vos : partition %s does not exist on the server\n",
2188 as->parms[4].items->data);
2193 if (as->parms[5].items) flags |= RV_NOCLONE;
2196 * check source partition for space to clone volume
2199 MapPartIdIntoName(topart, toPartName);
2200 MapPartIdIntoName(frompart, fromPartName);
2203 * check target partition for space to move volume
2206 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2208 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2212 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2215 p = (volintInfo *) 0;
2216 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2218 fprintf(STDERR, "vos:cannot access volume %lu\n",
2219 (unsigned long)volid);
2223 fprintf(STDOUT, "volume %lu size %d\n", (unsigned long)volid,
2225 if (partition.free <= p->size) {
2227 "vos: no space on target partition %s to move volume %lu\n",
2228 toPartName, (unsigned long)volid);
2235 fprintf(STDOUT, "size test - don't do move\n");
2239 /* successful move still not guaranteed but shoot for it */
2242 UV_MoveVolume2(volid, fromserver, frompart, toserver, topart, flags);
2244 PrintDiagnostics("move", code);
2247 MapPartIdIntoName(topart, toPartName);
2248 MapPartIdIntoName(frompart, fromPartName);
2249 fprintf(STDOUT, "Volume %lu moved from %s %s to %s %s \n",
2250 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2251 as->parms[3].items->data, toPartName);
2257 CopyVolume(register struct cmd_syndesc *as, void *arock)
2260 afs_int32 fromserver, toserver, frompart, topart, code, err, flags;
2261 char fromPartName[10], toPartName[10], *tovolume;
2262 struct nvldbentry entry;
2263 struct diskPartition64 partition; /* for space check */
2266 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2269 PrintError("", err);
2271 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2272 as->parms[0].items->data);
2275 fromserver = GetServer(as->parms[1].items->data);
2276 if (fromserver == 0) {
2277 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2278 as->parms[1].items->data);
2282 toserver = GetServer(as->parms[4].items->data);
2283 if (toserver == 0) {
2284 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2285 as->parms[4].items->data);
2289 tovolume = as->parms[3].items->data;
2290 if (!ISNAMEVALID(tovolume)) {
2292 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2293 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2296 if (!VolNameOK(tovolume)) {
2298 "Illegal volume name %s, should not end in .readonly or .backup\n",
2302 if (IsNumeric(tovolume)) {
2303 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
2307 code = VLDB_GetEntryByName(tovolume, &entry);
2309 fprintf(STDERR, "Volume %s already exists\n", tovolume);
2310 PrintDiagnostics("copy", code);
2314 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2316 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2317 as->parms[2].items->data);
2320 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2322 PrintError("", code);
2325 "vos : partition %s does not exist on the server\n",
2326 as->parms[2].items->data);
2330 topart = volutil_GetPartitionID(as->parms[5].items->data);
2332 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2333 as->parms[5].items->data);
2336 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2338 PrintError("", code);
2341 "vos : partition %s does not exist on the server\n",
2342 as->parms[5].items->data);
2347 if (as->parms[6].items) flags |= RV_OFFLINE;
2348 if (as->parms[7].items) flags |= RV_RDONLY;
2349 if (as->parms[8].items) flags |= RV_NOCLONE;
2351 MapPartIdIntoName(topart, toPartName);
2352 MapPartIdIntoName(frompart, fromPartName);
2355 * check target partition for space to move volume
2358 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2360 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2364 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2367 p = (volintInfo *) 0;
2368 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2370 fprintf(STDERR, "vos:cannot access volume %lu\n",
2371 (unsigned long)volid);
2375 if (partition.free <= p->size) {
2377 "vos: no space on target partition %s to copy volume %lu\n",
2378 toPartName, (unsigned long)volid);
2384 /* successful copy still not guaranteed but shoot for it */
2387 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2390 PrintDiagnostics("copy", code);
2393 MapPartIdIntoName(topart, toPartName);
2394 MapPartIdIntoName(frompart, fromPartName);
2395 fprintf(STDOUT, "Volume %lu copied from %s %s to %s on %s %s \n",
2396 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2397 tovolume, as->parms[4].items->data, toPartName);
2404 ShadowVolume(register struct cmd_syndesc *as, void *arock)
2406 afs_uint32 volid, tovolid;
2407 afs_int32 fromserver, toserver, frompart, topart;
2408 afs_int32 code, err, flags;
2409 char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
2410 struct diskPartition64 partition; /* for space check */
2413 p = (volintInfo *) 0;
2414 q = (volintInfo *) 0;
2416 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2419 PrintError("", err);
2421 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2422 as->parms[0].items->data);
2425 fromserver = GetServer(as->parms[1].items->data);
2426 if (fromserver == 0) {
2427 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2428 as->parms[1].items->data);
2432 toserver = GetServer(as->parms[3].items->data);
2433 if (toserver == 0) {
2434 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2435 as->parms[3].items->data);
2439 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2441 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2442 as->parms[2].items->data);
2445 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2447 PrintError("", code);
2450 "vos : partition %s does not exist on the server\n",
2451 as->parms[2].items->data);
2455 topart = volutil_GetPartitionID(as->parms[4].items->data);
2457 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2458 as->parms[4].items->data);
2461 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2463 PrintError("", code);
2466 "vos : partition %s does not exist on the server\n",
2467 as->parms[4].items->data);
2471 if (as->parms[5].items) {
2472 tovolume = as->parms[5].items->data;
2473 if (!ISNAMEVALID(tovolume)) {
2475 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2476 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2479 if (!VolNameOK(tovolume)) {
2481 "Illegal volume name %s, should not end in .readonly or .backup\n",
2485 if (IsNumeric(tovolume)) {
2487 "Illegal volume name %s, should not be a number\n",
2492 /* use actual name of source volume */
2493 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2495 fprintf(STDERR, "vos:cannot access volume %lu\n",
2496 (unsigned long)volid);
2499 strcpy(toVolName, p->name);
2500 tovolume = toVolName;
2501 /* save p for size checks later */
2504 if (as->parms[6].items) {
2505 tovolid = vsu_GetVolumeID(as->parms[6].items->data, cstruct, &err);
2508 PrintError("", err);
2510 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2511 as->parms[6].items->data);
2517 tovolid = vsu_GetVolumeID(tovolume, cstruct, &err);
2520 PrintError("", err);
2522 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2531 if (as->parms[7].items) flags |= RV_OFFLINE;
2532 if (as->parms[8].items) flags |= RV_RDONLY;
2533 if (as->parms[9].items) flags |= RV_NOCLONE;
2534 if (as->parms[10].items) flags |= RV_CPINCR;
2536 MapPartIdIntoName(topart, toPartName);
2537 MapPartIdIntoName(frompart, fromPartName);
2540 * check target partition for space to move volume
2543 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2545 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2549 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2552 /* Don't do this again if we did it above */
2554 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2556 fprintf(STDERR, "vos:cannot access volume %lu\n",
2557 (unsigned long)volid);
2562 /* OK if this fails */
2563 code = UV_ListOneVolume(toserver, topart, tovolid, &q);
2565 /* Treat existing volume size as "free" */
2567 p->size = (q->size < p->size) ? p->size - q->size : 0;
2569 if (partition.free <= p->size) {
2571 "vos: no space on target partition %s to copy volume %lu\n",
2572 toPartName, (unsigned long)volid);
2580 /* successful copy still not guaranteed but shoot for it */
2583 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2584 topart, tovolid, flags);
2586 PrintDiagnostics("shadow", code);
2589 MapPartIdIntoName(topart, toPartName);
2590 MapPartIdIntoName(frompart, fromPartName);
2591 fprintf(STDOUT, "Volume %lu shadowed from %s %s to %s %s \n",
2592 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2593 as->parms[3].items->data, toPartName);
2600 CloneVolume(register struct cmd_syndesc *as, void *arock)
2602 afs_uint32 volid, cloneid;
2603 afs_int32 server, part, voltype;
2604 char partName[10], *volname;
2605 afs_int32 code, err, flags;
2606 struct nvldbentry entry;
2608 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2611 PrintError("", err);
2613 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2614 as->parms[0].items->data);
2618 if (as->parms[1].items || as->parms[2].items) {
2619 if (!as->parms[1].items || !as->parms[2].items) {
2621 "Must specify both -server and -partition options\n");
2624 server = GetServer(as->parms[1].items->data);
2626 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2627 as->parms[1].items->data);
2630 part = volutil_GetPartitionID(as->parms[2].items->data);
2632 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2633 as->parms[2].items->data);
2636 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
2638 PrintError("", code);
2641 "vos : partition %s does not exist on the server\n",
2642 as->parms[2].items->data);
2646 code = GetVolumeInfo(volid, &server, &part, &voltype, &entry);
2652 if (as->parms[3].items) {
2653 volname = as->parms[3].items->data;
2654 if (strlen(volname) > VOLSER_OLDMAXVOLNAME - 1) {
2656 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2657 volname, VOLSER_OLDMAXVOLNAME - 1);
2662 * In order that you be able to make clones of RO or BK, this
2663 * check must be omitted.
2665 if (!VolNameOK(volname)) {
2667 "Illegal volume name %s, should not end in .readonly or .backup\n",
2672 if (IsNumeric(volname)) {
2674 "Illegal volume name %s, should not be a number\n",
2681 if (as->parms[4].items) {
2682 cloneid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2685 PrintError("", err);
2687 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2688 as->parms[4].items->data);
2694 if (as->parms[5].items) flags |= RV_OFFLINE;
2695 if (as->parms[6].items) flags |= RV_RDONLY;
2699 UV_CloneVolume(server, part, volid, cloneid, volname, flags);
2702 PrintDiagnostics("clone", code);
2705 MapPartIdIntoName(part, partName);
2706 fprintf(STDOUT, "Created clone for volume %s\n",
2707 as->parms[0].items->data);
2714 BackupVolume(register struct cmd_syndesc *as, void *arock)
2717 afs_int32 aserver, apart, vtype, code, err;
2718 struct nvldbentry entry;
2721 afs_int32 buserver, bupart, butype;
2722 struct nvldbentry buentry;
2724 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2727 PrintError("", err);
2729 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2730 as->parms[0].items->data);
2733 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2737 /* verify this is a readwrite volume */
2739 if (vtype != RWVOL) {
2740 fprintf(STDERR, "%s not RW volume\n", as->parms[0].items->data);
2744 /* is there a backup volume already? */
2746 if (entry.flags & BACK_EXISTS) {
2747 /* yep, where is it? */
2749 buvolid = entry.volumeId[BACKVOL];
2750 code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
2755 code = VLDB_IsSameAddrs(buserver, aserver, &err);
2758 "Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
2764 "FATAL ERROR: backup volume %lu exists on server %lu\n",
2765 (unsigned long)buvolid, (unsigned long)buserver);
2770 /* nope, carry on */
2772 code = UV_BackupVolume(aserver, apart, avolid);
2775 PrintDiagnostics("backup", code);
2778 fprintf(STDOUT, "Created backup volume for %s \n",
2779 as->parms[0].items->data);
2784 ReleaseVolume(register struct cmd_syndesc *as, void *arock)
2787 struct nvldbentry entry;
2789 afs_int32 aserver, apart, vtype, code, err;
2792 if (as->parms[1].items)
2794 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2797 PrintError("", err);
2799 fprintf(STDERR, "vos: can't find volume '%s'\n",
2800 as->parms[0].items->data);
2803 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2807 if (vtype != RWVOL) {
2808 fprintf(STDERR, "%s not a RW volume\n", as->parms[0].items->data);
2812 if (!ISNAMEVALID(entry.name)) {
2814 "Volume name %s is too long, rename before releasing\n",
2819 code = UV_ReleaseVolume(avolid, aserver, apart, force);
2821 PrintDiagnostics("release", code);
2824 fprintf(STDOUT, "Released volume %s successfully\n",
2825 as->parms[0].items->data);
2830 DumpVolume(register struct cmd_syndesc *as, void *arock)
2833 afs_int32 aserver, apart, voltype, fromdate = 0, code, err, i, flags;
2834 char filename[MAXPATHLEN];
2835 struct nvldbentry entry;
2837 rx_SetRxDeadTime(60 * 10);
2838 for (i = 0; i < MAXSERVERS; i++) {
2839 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
2842 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
2843 if (rxConn->service)
2844 rxConn->service->connDeadTime = rx_connDeadTime;
2847 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2850 PrintError("", err);
2852 fprintf(STDERR, "vos: can't find volume '%s'\n",
2853 as->parms[0].items->data);
2857 if (as->parms[3].items || as->parms[4].items) {
2858 if (!as->parms[3].items || !as->parms[4].items) {
2860 "Must specify both -server and -partition options\n");
2863 aserver = GetServer(as->parms[3].items->data);
2865 fprintf(STDERR, "Invalid server name\n");
2868 apart = volutil_GetPartitionID(as->parms[4].items->data);
2870 fprintf(STDERR, "Invalid partition name\n");
2874 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
2879 if (as->parms[1].items && strcmp(as->parms[1].items->data, "0")) {
2880 code = ktime_DateToInt32(as->parms[1].items->data, &fromdate);
2882 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
2883 as->parms[1].items->data, code);
2887 if (as->parms[2].items) {
2888 strcpy(filename, as->parms[2].items->data);
2890 strcpy(filename, "");
2893 flags = as->parms[6].items ? VOLDUMPV2_OMITDIRS : 0;
2895 if (as->parms[5].items) {
2897 UV_DumpClonedVolume(avolid, aserver, apart, fromdate,
2898 DumpFunction, filename, flags);
2901 UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction,
2904 if ((code == RXGEN_OPCODE) && (as->parms[6].items)) {
2905 flags &= ~VOLDUMPV2_OMITDIRS;
2909 PrintDiagnostics("dump", code);
2912 if (strcmp(filename, ""))
2913 fprintf(STDERR, "Dumped volume %s in file %s\n",
2914 as->parms[0].items->data, filename);
2916 fprintf(STDERR, "Dumped volume %s in stdout \n",
2917 as->parms[0].items->data);
2931 RestoreVolume(register struct cmd_syndesc *as, void *arock)
2933 afs_uint32 avolid, aparentid;
2934 afs_int32 aserver, apart, code, vcode, err;
2935 afs_int32 aoverwrite = ASK;
2936 afs_int32 acreation = 0, alastupdate = 0;
2937 int restoreflags = 0;
2938 int readonly = 0, offline = 0, voltype = RWVOL;
2940 char afilename[MAXPATHLEN], avolname[VOLSER_MAXVOLNAME + 1], apartName[10];
2941 char volname[VOLSER_MAXVOLNAME + 1];
2942 struct nvldbentry entry;
2947 if (as->parms[4].items) {
2948 avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2951 PrintError("", err);
2953 fprintf(STDERR, "vos: can't find volume '%s'\n",
2954 as->parms[4].items->data);
2960 if (as->parms[5].items) {
2961 if ((strcmp(as->parms[5].items->data, "a") == 0)
2962 || (strcmp(as->parms[5].items->data, "abort") == 0)) {
2964 } else if ((strcmp(as->parms[5].items->data, "f") == 0)
2965 || (strcmp(as->parms[5].items->data, "full") == 0)) {
2967 } else if ((strcmp(as->parms[5].items->data, "i") == 0)
2968 || (strcmp(as->parms[5].items->data, "inc") == 0)
2969 || (strcmp(as->parms[5].items->data, "increment") == 0)
2970 || (strcmp(as->parms[5].items->data, "incremental") == 0)) {
2973 fprintf(STDERR, "vos: %s is not a valid argument to -overwrite\n",
2974 as->parms[5].items->data);
2978 if (as->parms[6].items)
2980 if (as->parms[7].items) {
2985 if (as->parms[8].items) {
2986 if ((strcmp(as->parms[8].items->data, "d") == 0)
2987 || (strcmp(as->parms[8].items->data, "dump") == 0)) {
2988 acreation = TS_DUMP;
2989 } else if ((strcmp(as->parms[8].items->data, "k") == 0)
2990 || (strcmp(as->parms[8].items->data, "keep") == 0)) {
2991 acreation = TS_KEEP;
2992 } else if ((strcmp(as->parms[8].items->data, "n") == 0)
2993 || (strcmp(as->parms[8].items->data, "new") == 0)) {
2996 fprintf(STDERR, "vos: %s is not a valid argument to -creation\n",
2997 as->parms[8].items->data);
3002 if (as->parms[9].items) {
3003 if ((strcmp(as->parms[9].items->data, "d") == 0)
3004 || (strcmp(as->parms[9].items->data, "dump") == 0)) {
3005 alastupdate = TS_DUMP;
3006 } else if ((strcmp(as->parms[9].items->data, "k") == 0)
3007 || (strcmp(as->parms[9].items->data, "keep") == 0)) {
3008 alastupdate = TS_KEEP;
3009 } else if ((strcmp(as->parms[9].items->data, "n") == 0)
3010 || (strcmp(as->parms[9].items->data, "new") == 0)) {
3011 alastupdate = TS_NEW;
3013 fprintf(STDERR, "vos: %s is not a valid argument to -lastupdate\n",
3014 as->parms[9].items->data);
3019 aserver = GetServer(as->parms[0].items->data);
3021 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3022 as->parms[0].items->data);
3025 apart = volutil_GetPartitionID(as->parms[1].items->data);
3027 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3028 as->parms[1].items->data);
3031 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3033 PrintError("", code);
3036 "vos : partition %s does not exist on the server\n",
3037 as->parms[1].items->data);
3040 strcpy(avolname, as->parms[2].items->data);
3041 if (!ISNAMEVALID(avolname)) {
3043 "vos: the name of the volume %s exceeds the size limit\n",
3047 if (!VolNameOK(avolname)) {
3049 "Illegal volume name %s, should not end in .readonly or .backup\n",
3053 if (as->parms[3].items) {
3054 strcpy(afilename, as->parms[3].items->data);
3055 if (!FileExists(afilename)) {
3056 fprintf(STDERR, "Can't access file %s\n", afilename);
3060 strcpy(afilename, "");
3063 /* Check if volume exists or not */
3065 vsu_ExtractName(volname, avolname);
3066 vcode = VLDB_GetEntryByName(volname, &entry);
3067 if (vcode) { /* no volume - do a full restore */
3068 restoreflags = RV_FULLRST;
3069 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3071 "Volume does not exist; Will perform a full restore\n");
3074 else if ((!readonly && Lp_GetRwIndex(&entry) == -1) /* RW volume does not exist - do a full */
3075 ||(readonly && !Lp_ROMatch(0, 0, &entry))) { /* RO volume does not exist - do a full */
3076 restoreflags = RV_FULLRST;
3077 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3079 "%s Volume does not exist; Will perform a full restore\n",
3080 readonly ? "RO" : "RW");
3083 avolid = entry.volumeId[voltype];
3084 } else if (entry.volumeId[voltype] != 0
3085 && entry.volumeId[voltype] != avolid) {
3086 avolid = entry.volumeId[voltype];
3088 aparentid = entry.volumeId[RWVOL];
3091 else { /* volume exists - do we do a full incremental or abort */
3092 int Oserver, Opart, Otype, vol_elsewhere = 0;
3093 struct nvldbentry Oentry;
3097 avolid = entry.volumeId[voltype];
3098 } else if (entry.volumeId[voltype] != 0
3099 && entry.volumeId[voltype] != avolid) {
3100 avolid = entry.volumeId[voltype];
3102 aparentid = entry.volumeId[RWVOL];
3104 /* A file name was specified - check if volume is on another partition */
3105 vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
3109 vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
3112 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
3116 if (!vcode || (Opart != apart))
3119 if (aoverwrite == ASK) {
3120 if (strcmp(afilename, "") == 0) { /* The file is from standard in */
3122 "Volume exists and no -overwrite option specified; Aborting restore command\n");
3126 /* Ask what to do */
3127 if (vol_elsewhere) {
3129 "The volume %s %u already exists on a different server/part\n",
3130 volname, entry.volumeId[voltype]);
3132 "Do you want to do a full restore or abort? [fa](a): ");
3135 "The volume %s %u already exists in the VLDB\n",
3136 volname, entry.volumeId[voltype]);
3138 "Do you want to do a full/incremental restore or abort? [fia](a): ");
3141 while (!(dc == EOF || dc == '\n'))
3142 dc = getchar(); /* goto end of line */
3143 if ((c == 'f') || (c == 'F'))
3145 else if ((c == 'i') || (c == 'I'))
3151 if (aoverwrite == ABORT) {
3152 fprintf(STDERR, "Volume exists; Aborting restore command\n");
3154 } else if (aoverwrite == FULL) {
3155 restoreflags = RV_FULLRST;
3157 "Volume exists; Will delete and perform full restore\n");
3158 } else if (aoverwrite == INC) {
3160 if (vol_elsewhere) {
3162 "%s volume %lu already exists on a different server/part; not allowed\n",
3163 readonly ? "RO" : "RW", (unsigned long)avolid);
3169 restoreflags |= RV_OFFLINE;
3171 restoreflags |= RV_RDONLY;
3173 switch (acreation) {
3175 restoreflags |= RV_CRDUMP;
3178 restoreflags |= RV_CRKEEP;
3181 restoreflags |= RV_CRNEW;
3184 if (aoverwrite == FULL)
3185 restoreflags |= RV_CRNEW;
3187 restoreflags |= RV_CRKEEP;
3190 switch (alastupdate) {
3192 restoreflags |= RV_LUDUMP;
3195 restoreflags |= RV_LUKEEP;
3198 restoreflags |= RV_LUNEW;
3201 restoreflags |= RV_LUDUMP;
3203 if (as->parms[10].items) {
3204 restoreflags |= RV_NODEL;
3209 UV_RestoreVolume2(aserver, apart, avolid, aparentid,
3210 avolname, restoreflags, WriteData, afilename);
3212 PrintDiagnostics("restore", code);
3215 MapPartIdIntoName(apart, apartName);
3218 * patch typo here - originally "parms[1]", should be "parms[0]"
3221 fprintf(STDOUT, "Restored volume %s on %s %s\n", avolname,
3222 as->parms[0].items->data, apartName);
3227 LockReleaseCmd(register struct cmd_syndesc *as, void *arock)
3230 afs_int32 code, err;
3232 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
3235 PrintError("", err);
3237 fprintf(STDERR, "vos: can't find volume '%s'\n",
3238 as->parms[0].items->data);
3242 code = UV_LockRelease(avolid);
3244 PrintDiagnostics("unlock", code);
3247 fprintf(STDOUT, "Released lock on vldb entry for volume %s\n",
3248 as->parms[0].items->data);
3253 AddSite(register struct cmd_syndesc *as, void *arock)
3256 afs_int32 aserver, apart, code, err, valid = 0;
3257 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3259 vsu_ExtractName(avolname, as->parms[2].items->data);;
3260 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3263 PrintError("", err);
3265 fprintf(STDERR, "vos: can't find volume '%s'\n",
3266 as->parms[2].items->data);
3269 aserver = GetServer(as->parms[0].items->data);
3271 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3272 as->parms[0].items->data);
3275 apart = volutil_GetPartitionID(as->parms[1].items->data);
3277 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3278 as->parms[1].items->data);
3281 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3283 PrintError("", code);
3286 "vos : partition %s does not exist on the server\n",
3287 as->parms[1].items->data);
3290 if (as->parms[3].items) {
3293 code = UV_AddSite(aserver, apart, avolid, valid);
3295 PrintDiagnostics("addsite", code);
3298 MapPartIdIntoName(apart, apartName);
3299 fprintf(STDOUT, "Added replication site %s %s for volume %s\n",
3300 as->parms[0].items->data, apartName, as->parms[2].items->data);
3305 RemoveSite(register struct cmd_syndesc *as, void *arock)
3309 afs_int32 aserver, apart, code, err;
3310 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3312 vsu_ExtractName(avolname, as->parms[2].items->data);
3313 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3316 PrintError("", err);
3318 fprintf(STDERR, "vos: can't find volume '%s'\n",
3319 as->parms[2].items->data);
3322 aserver = GetServer(as->parms[0].items->data);
3324 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3325 as->parms[0].items->data);
3328 apart = volutil_GetPartitionID(as->parms[1].items->data);
3330 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3331 as->parms[1].items->data);
3335 *skip the partition validity check, since it is possible that the partition
3336 *has since been decomissioned.
3339 if (!IsPartValid(apart,aserver,&code)){
3340 if(code) PrintError("",code);
3341 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
3345 code = UV_RemoveSite(aserver, apart, avolid);
3347 PrintDiagnostics("remsite", code);
3350 MapPartIdIntoName(apart, apartName);
3351 fprintf(STDOUT, "Removed replication site %s %s for volume %s\n",
3352 as->parms[0].items->data, apartName, as->parms[2].items->data);
3357 ChangeLocation(register struct cmd_syndesc *as, void *arock)
3360 afs_int32 aserver, apart, code, err;
3363 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3366 PrintError("", err);
3368 fprintf(STDERR, "vos: can't find volume '%s'\n",
3369 as->parms[2].items->data);
3372 aserver = GetServer(as->parms[0].items->data);
3374 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3375 as->parms[0].items->data);
3378 apart = volutil_GetPartitionID(as->parms[1].items->data);
3380 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3381 as->parms[1].items->data);
3384 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3386 PrintError("", code);
3389 "vos : partition %s does not exist on the server\n",
3390 as->parms[1].items->data);
3393 code = UV_ChangeLocation(aserver, apart, avolid);
3395 PrintDiagnostics("addsite", code);
3398 MapPartIdIntoName(apart, apartName);
3399 fprintf(STDOUT, "Changed location to %s %s for volume %s\n",
3400 as->parms[0].items->data, apartName, as->parms[2].items->data);
3405 ListPartitions(register struct cmd_syndesc *as, void *arock)
3407 afs_int32 aserver, code;
3408 struct partList dummyPartList;
3413 aserver = GetServer(as->parms[0].items->data);
3415 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3416 as->parms[0].items->data);
3421 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3423 PrintDiagnostics("listpart", code);
3427 fprintf(STDOUT, "The partitions on the server are:\n");
3428 for (i = 0; i < cnt; i++) {
3429 if (dummyPartList.partFlags[i] & PARTVALID) {
3430 memset(pname, 0, sizeof(pname));
3431 MapPartIdIntoName(dummyPartList.partId[i], pname);
3432 fprintf(STDOUT, " %10s ", pname);
3434 if ((i % 5) == 0 && (i != 0))
3435 fprintf(STDOUT, "\n");
3438 fprintf(STDOUT, "\n");
3439 fprintf(STDOUT, "Total: %d\n", total);
3445 CompareVolName(p1, p2)
3448 volintInfo *arg1, *arg2;
3450 arg1 = (volintInfo *) p1;
3451 arg2 = (volintInfo *) p2;
3452 return (strcmp(arg1->name, arg2->name));
3456 /*------------------------------------------------------------------------
3457 * PRIVATE XCompareVolName
3460 * Comparison routine for volume names coming from an extended
3464 * a_obj1P : Char ptr to first extended vol info object
3465 * a_obj1P : Char ptr to second extended vol info object
3468 * The value of strcmp() on the volume names within the passed
3469 * objects (i,e., -1, 0, or 1).
3472 * Passed to qsort() as the designated comparison routine.
3476 *------------------------------------------------------------------------*/
3479 XCompareVolName(a_obj1P, a_obj2P)
3480 char *a_obj1P, *a_obj2P;
3482 { /*XCompareVolName */
3485 (((struct volintXInfo *)(a_obj1P))->name,
3486 ((struct volintXInfo *)(a_obj2P))->name));
3488 } /*XCompareVolName */
3491 CompareVolID(p1, p2)
3494 volintInfo *arg1, *arg2;
3496 arg1 = (volintInfo *) p1;
3497 arg2 = (volintInfo *) p2;
3498 if (arg1->volid == arg2->volid)
3500 if (arg1->volid > arg2->volid)
3507 /*------------------------------------------------------------------------
3508 * PRIVATE XCompareVolID
3511 * Comparison routine for volume IDs coming from an extended
3515 * a_obj1P : Char ptr to first extended vol info object
3516 * a_obj1P : Char ptr to second extended vol info object
3519 * The value of strcmp() on the volume names within the passed
3520 * objects (i,e., -1, 0, or 1).
3523 * Passed to qsort() as the designated comparison routine.
3527 *------------------------------------------------------------------------*/
3530 XCompareVolID(a_obj1P, a_obj2P)
3531 char *a_obj1P, *a_obj2P;
3533 { /*XCompareVolID */
3535 afs_int32 id1, id2; /*Volume IDs we're comparing */
3537 id1 = ((struct volintXInfo *)(a_obj1P))->volid;
3538 id2 = ((struct volintXInfo *)(a_obj2P))->volid;
3546 } /*XCompareVolID */
3548 /*------------------------------------------------------------------------
3549 * PRIVATE ListVolumes
3552 * Routine used to list volumes, contacting the Volume Server
3553 * directly, bypassing the VLDB.
3556 * as : Ptr to parsed command line arguments.
3559 * 0 Successful operation
3562 * Nothing interesting.
3566 *------------------------------------------------------------------------*/
3569 ListVolumes(register struct cmd_syndesc *as, void *arock)
3571 afs_int32 apart, int32list, fast;
3572 afs_int32 aserver, code;
3574 volintInfo *oldpntr = NULL;
3578 volintXInfo *xInfoP;
3579 volintXInfo *origxInfoP = NULL; /*Ptr to current/orig extended vol info */
3580 int wantExtendedInfo; /*Do we want extended vol info? */
3583 struct partList dummyPartList;
3591 if (as->parms[3].items)
3593 if (as->parms[4].items)
3597 if (as->parms[2].items)
3603 if (as->parms[5].items) {
3605 * We can't coexist with the fast flag.
3609 "vos: Can't use the -fast and -extended flags together\n");
3614 * We need to turn on ``long'' listings to get the full effect.
3616 wantExtendedInfo = 1;
3619 wantExtendedInfo = 0;
3620 if (as->parms[1].items) {
3621 apart = volutil_GetPartitionID(as->parms[1].items->data);
3623 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3624 as->parms[1].items->data);
3627 dummyPartList.partId[0] = apart;
3628 dummyPartList.partFlags[0] = PARTVALID;
3631 aserver = GetServer(as->parms[0].items->data);
3633 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3634 as->parms[0].items->data);
3639 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3641 PrintError("", code);
3644 "vos : partition %s does not exist on the server\n",
3645 as->parms[1].items->data);
3649 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3651 PrintDiagnostics("listvol", code);
3655 for (i = 0; i < cnt; i++) {
3656 if (dummyPartList.partFlags[i] & PARTVALID) {
3657 if (wantExtendedInfo)
3659 UV_XListVolumes(aserver, dummyPartList.partId[i], all,
3663 UV_ListVolumes(aserver, dummyPartList.partId[i], all,
3666 PrintDiagnostics("listvol", code);
3671 if (wantExtendedInfo) {
3672 origxInfoP = xInfoP;
3673 base = (char *)xInfoP;
3676 base = (char *)pntr;
3680 if (wantExtendedInfo)
3681 qsort(base, count, sizeof(volintXInfo), XCompareVolName);
3683 qsort(base, count, sizeof(volintInfo), CompareVolName);
3685 if (wantExtendedInfo)
3686 qsort(base, count, sizeof(volintXInfo), XCompareVolID);
3688 qsort(base, count, sizeof(volintInfo), CompareVolID);
3690 MapPartIdIntoName(dummyPartList.partId[i], pname);
3693 "Total number of volumes on server %s partition %s: %lu \n",
3694 as->parms[0].items->data, pname,
3695 (unsigned long)count);
3696 if (wantExtendedInfo) {
3697 #ifdef FULL_LISTVOL_SWITCH
3698 if (as->parms[6].items)
3699 XDisplayVolumes2(aserver, dummyPartList.partId[i], origxInfoP,
3700 count, int32list, fast, quiet);
3702 #endif /* FULL_LISTVOL_SWITCH */
3703 XDisplayVolumes(aserver, dummyPartList.partId[i], origxInfoP,
3704 count, int32list, fast, quiet);
3707 xInfoP = (volintXInfo *) 0;
3709 #ifdef FULL_LISTVOL_SWITCH
3710 if (as->parms[6].items)
3711 DisplayVolumes2(aserver, dummyPartList.partId[i], oldpntr,
3714 #endif /* FULL_LISTVOL_SWITCH */
3715 DisplayVolumes(aserver, dummyPartList.partId[i], oldpntr,
3716 count, int32list, fast, quiet);
3719 pntr = (volintInfo *) 0;
3727 SyncVldb(register struct cmd_syndesc *as, void *arock)
3729 afs_int32 pnum = 0, code; /* part name */
3735 if (as->parms[0].items) {
3736 tserver = GetServer(as->parms[0].items->data);
3738 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3739 as->parms[0].items->data);
3744 if (as->parms[1].items) {
3745 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3747 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3748 as->parms[1].items->data);
3751 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3753 PrintError("", code);
3756 "vos: partition %s does not exist on the server\n",
3757 as->parms[1].items->data);
3764 "The -partition option requires a -server option\n");
3769 if (as->parms[3].items) {
3770 flags |= 2; /* don't update */
3773 if (as->parms[2].items) {
3774 /* Synchronize an individual volume */
3775 volname = as->parms[2].items->data;
3776 code = UV_SyncVolume(tserver, pnum, volname, flags);
3780 "Without a -volume option, the -server option is required\n");
3783 code = UV_SyncVldb(tserver, pnum, flags, 0 /*unused */ );
3787 PrintDiagnostics("syncvldb", code);
3791 /* Print a summary of what we did */
3793 fprintf(STDOUT, "VLDB volume %s synchronized", volname);
3795 fprintf(STDOUT, "VLDB synchronized");
3797 fprintf(STDOUT, " with state of server %s", as->parms[0].items->data);
3800 MapPartIdIntoName(pnum, part);
3801 fprintf(STDOUT, " partition %s\n", part);
3803 fprintf(STDOUT, "\n");
3809 SyncServer(register struct cmd_syndesc *as, void *arock)
3811 afs_int32 pnum, code; /* part name */
3816 tserver = GetServer(as->parms[0].items->data);
3818 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3819 as->parms[0].items->data);
3822 if (as->parms[1].items) {
3823 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3825 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3826 as->parms[1].items->data);
3829 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3831 PrintError("", code);
3834 "vos : partition %s does not exist on the server\n",
3835 as->parms[1].items->data);
3843 if (as->parms[2].items) {
3844 flags |= 2; /* don't update */
3846 code = UV_SyncServer(tserver, pnum, flags, 0 /*unused */ );
3848 PrintDiagnostics("syncserv", code);
3852 MapPartIdIntoName(pnum, part);
3853 fprintf(STDOUT, "Server %s partition %s synchronized with VLDB\n",
3854 as->parms[0].items->data, part);
3856 fprintf(STDOUT, "Server %s synchronized with VLDB\n",
3857 as->parms[0].items->data);
3866 struct nvldbentry entry;
3869 /* The vlserver will handle names with the .readonly
3870 * and .backup extension as well as volume ids.
3872 vcode = VLDB_GetEntryByName(name, &entry);
3874 PrintError("", vcode);
3877 MapHostToNetwork(&entry);
3878 EnumerateEntry(&entry);
3880 /* Defect #3027: grubby check to handle locked volume.
3881 * If VLOP_ALLOPERS is set, the entry is locked.
3882 * Leave this routine as is, but put in correct check.
3884 if (entry.flags & VLOP_ALLOPERS)
3885 fprintf(STDOUT, " Volume is currently LOCKED \n");
3891 VolumeZap(register struct cmd_syndesc *as, void *arock)
3893 struct nvldbentry entry;
3894 afs_uint32 volid, zapbackupid = 0, backupid = 0;
3895 afs_int32 code, server, part, err;
3897 if (as->parms[3].items) {
3898 /* force flag is on, use the other version */
3899 return NukeVolume(as);
3902 if (as->parms[4].items) {
3906 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3909 PrintError("", err);
3911 fprintf(STDERR, "vos: can't find volume '%s'\n",
3912 as->parms[2].items->data);
3915 part = volutil_GetPartitionID(as->parms[1].items->data);
3917 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3918 as->parms[1].items->data);
3921 server = GetServer(as->parms[0].items->data);
3923 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3924 as->parms[0].items->data);
3927 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
3929 PrintError("", code);
3932 "vos : partition %s does not exist on the server\n",
3933 as->parms[1].items->data);
3936 code = VLDB_GetEntryByID(volid, -1, &entry);
3938 if (volid == entry.volumeId[RWVOL])
3939 backupid = entry.volumeId[BACKVOL];
3941 "Warning: Entry for volume number %lu exists in VLDB (but we're zapping it anyway!)\n",
3942 (unsigned long)volid);
3945 volintInfo *pntr = (volintInfo *) 0;
3948 code = UV_ListOneVolume(server, part, volid, &pntr);
3950 if (volid == pntr->parentID)
3951 backupid = pntr->backupID;
3957 code = UV_VolumeZap(server, part, backupid);
3959 PrintDiagnostics("zap", code);
3962 fprintf(STDOUT, "Backup Volume %lu deleted\n",
3963 (unsigned long)backupid);
3966 code = UV_VolumeZap(server, part, volid);
3968 PrintDiagnostics("zap", code);
3971 fprintf(STDOUT, "Volume %lu deleted\n", (unsigned long)volid);
3977 VolserStatus(register struct cmd_syndesc *as, void *arock)
3979 afs_int32 server, code;
3980 transDebugInfo *pntr, *oldpntr;
3985 server = GetServer(as->parms[0].items->data);
3987 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3988 as->parms[0].items->data);
3991 code = UV_VolserStatus(server, &pntr, &count);
3993 PrintDiagnostics("status", code);
3998 fprintf(STDOUT, "No active transactions on %s\n",
3999 as->parms[0].items->data);
4001 fprintf(STDOUT, "Total transactions: %d\n", count);
4003 for (i = 0; i < count; i++) {
4004 /*print out the relevant info */
4005 fprintf(STDOUT, "--------------------------------------\n");
4006 fprintf(STDOUT, "transaction: %lu created: %s",
4007 (unsigned long)pntr->tid, vos_ctime( & pntr->time));
4008 if (pntr->returnCode) {
4009 fprintf(STDOUT, "returnCode: %lu\n",
4010 (unsigned long)pntr->returnCode);
4013 fprintf(STDOUT, "attachFlags: ");
4014 switch (pntr->iflags) {
4016 fprintf(STDOUT, "offline ");
4019 fprintf(STDOUT, "busy ");
4022 fprintf(STDOUT, "readonly ");
4025 fprintf(STDOUT, "create ");
4028 fprintf(STDOUT, "create volid ");
4031 fprintf(STDOUT, "\n");
4034 fprintf(STDOUT, "volumeStatus: ");
4035 switch (pntr->vflags) {
4036 case VTDeleteOnSalvage:
4037 fprintf(STDOUT, "deleteOnSalvage ");
4038 case VTOutOfService:
4039 fprintf(STDOUT, "outOfService ");
4041 fprintf(STDOUT, "deleted ");
4043 fprintf(STDOUT, "\n");
4046 fprintf(STDOUT, "transactionFlags: ");
4047 fprintf(STDOUT, "delete\n");
4049 MapPartIdIntoName(pntr->partition, pname);
4050 fprintf(STDOUT, "volume: %lu partition: %s procedure: %s\n",
4051 (unsigned long)pntr->volid, pname, pntr->lastProcName);
4052 if (pntr->callValid) {
4054 "packetRead: %lu lastReceiveTime: %d packetSend: %lu lastSendTime: %d\n",
4055 (unsigned long)pntr->readNext, pntr->lastReceiveTime,
4056 (unsigned long)pntr->transmitNext, pntr->lastSendTime);
4059 fprintf(STDOUT, "--------------------------------------\n");
4060 fprintf(STDOUT, "\n");
4068 RenameVolume(register struct cmd_syndesc *as, void *arock)
4070 afs_int32 code1, code2, code;
4071 struct nvldbentry entry;
4073 code1 = VLDB_GetEntryByName(as->parms[0].items->data, &entry);
4075 fprintf(STDERR, "vos: Could not find entry for volume %s\n",
4076 as->parms[0].items->data);
4079 code2 = VLDB_GetEntryByName(as->parms[1].items->data, &entry);
4080 if ((!code1) && (!code2)) { /*the newname already exists */
4081 fprintf(STDERR, "vos: volume %s already exists\n",
4082 as->parms[1].items->data);
4086 if (code1 && code2) {
4087 fprintf(STDERR, "vos: Could not find entry for volume %s or %s\n",
4088 as->parms[0].items->data, as->parms[1].items->data);
4091 if (!VolNameOK(as->parms[0].items->data)) {
4093 "Illegal volume name %s, should not end in .readonly or .backup\n",
4094 as->parms[0].items->data);
4097 if (!ISNAMEVALID(as->parms[1].items->data)) {
4099 "vos: the new volume name %s exceeds the size limit of %d\n",
4100 as->parms[1].items->data, VOLSER_OLDMAXVOLNAME - 10);
4103 if (!VolNameOK(as->parms[1].items->data)) {
4105 "Illegal volume name %s, should not end in .readonly or .backup\n",
4106 as->parms[1].items->data);
4109 if (IsNumeric(as->parms[1].items->data)) {
4110 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
4111 as->parms[1].items->data);
4114 MapHostToNetwork(&entry);
4116 UV_RenameVolume(&entry, as->parms[0].items->data,
4117 as->parms[1].items->data);
4119 PrintDiagnostics("rename", code);
4122 fprintf(STDOUT, "Renamed volume %s to %s\n", as->parms[0].items->data,
4123 as->parms[1].items->data);
4128 GetVolumeInfo(afs_uint32 volid, afs_int32 *server, afs_int32 *part, afs_int32 *voltype,
4129 struct nvldbentry *rentry)
4134 vcode = VLDB_GetEntryByID(volid, -1, rentry);
4137 "Could not fetch the entry for volume %lu from VLDB \n",
4138 (unsigned long)volid);
4139 PrintError("", vcode);
4142 MapHostToNetwork(rentry);
4143 if (volid == rentry->volumeId[ROVOL]) {
4145 for (i = 0; i < rentry->nServers; i++) {
4146 if ((index == -1) && (rentry->serverFlags[i] & ITSROVOL)
4147 && !(rentry->serverFlags[i] & RO_DONTUSE))
4152 "RO volume is not found in VLDB entry for volume %lu\n",
4153 (unsigned long)volid);
4157 *server = rentry->serverNumber[index];
4158 *part = rentry->serverPartition[index];
4162 index = Lp_GetRwIndex(rentry);
4165 "RW Volume is not found in VLDB entry for volume %lu\n",
4166 (unsigned long)volid);
4169 if (volid == rentry->volumeId[RWVOL]) {
4171 *server = rentry->serverNumber[index];
4172 *part = rentry->serverPartition[index];
4175 if (volid == rentry->volumeId[BACKVOL]) {
4177 *server = rentry->serverNumber[index];
4178 *part = rentry->serverPartition[index];
4182 "unexpected volume type for volume %lu\n",
4183 (unsigned long)volid);
4188 DeleteEntry(register struct cmd_syndesc *as, void *arock)
4190 afs_int32 apart = 0;
4193 struct VldbListByAttributes attributes;
4194 nbulkentries arrayEntries;
4195 register struct nvldbentry *vllist;
4196 struct cmd_item *itp;
4199 char prefix[VOLSER_MAXVOLNAME + 1];
4201 afs_int32 totalBack = 0, totalFail = 0, err;
4203 if (as->parms[0].items) { /* -id */
4204 if (as->parms[1].items || as->parms[2].items || as->parms[3].items) {
4206 "You cannot use -server, -partition, or -prefix with the -id argument\n");
4209 for (itp = as->parms[0].items; itp; itp = itp->next) {
4210 avolid = vsu_GetVolumeID(itp->data, cstruct, &err);
4213 PrintError("", err);
4215 fprintf(STDERR, "vos: can't find volume '%s'\n",
4219 if (as->parms[4].items) { /* -noexecute */
4220 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4225 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4227 fprintf(STDERR, "Could not delete entry for volume %s\n",
4230 "You must specify a RW volume name or ID "
4231 "(the entire VLDB entry will be deleted)\n");
4232 PrintError("", vcode);
4238 fprintf(STDOUT, "Deleted %d VLDB entries\n", totalBack);
4242 if (!as->parms[1].items && !as->parms[2].items && !as->parms[3].items) {
4243 fprintf(STDERR, "You must specify an option\n");
4247 /* Zero out search attributes */
4248 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4250 if (as->parms[1].items) { /* -prefix */
4251 strncpy(prefix, as->parms[1].items->data, VOLSER_MAXVOLNAME);
4253 if (!as->parms[2].items && !as->parms[3].items) { /* a single entry only */
4255 "You must provide -server with the -prefix argument\n");
4260 if (as->parms[2].items) { /* -server */
4262 aserver = GetServer(as->parms[2].items->data);
4264 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4265 as->parms[2].items->data);
4268 attributes.server = ntohl(aserver);
4269 attributes.Mask |= VLLIST_SERVER;
4272 if (as->parms[3].items) { /* -partition */
4273 if (!as->parms[2].items) {
4275 "You must provide -server with the -partition argument\n");
4278 apart = volutil_GetPartitionID(as->parms[3].items->data);
4280 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4281 as->parms[3].items->data);
4284 attributes.partition = apart;
4285 attributes.Mask |= VLLIST_PARTITION;
4288 /* Print status line of what we are doing */
4289 fprintf(STDOUT, "Deleting VLDB entries for ");
4290 if (as->parms[2].items) {
4291 fprintf(STDOUT, "server %s ", as->parms[2].items->data);
4293 if (as->parms[3].items) {
4295 MapPartIdIntoName(apart, pname);
4296 fprintf(STDOUT, "partition %s ", pname);
4299 fprintf(STDOUT, "which are prefixed with %s ", prefix);
4301 fprintf(STDOUT, "\n");
4304 /* Get all the VLDB entries on a server and/or partition */
4305 memset(&arrayEntries, 0, sizeof(arrayEntries));
4306 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4308 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4309 PrintError("", vcode);
4313 /* Process each entry */
4314 for (j = 0; j < nentries; j++) {
4315 vllist = &arrayEntries.nbulkentries_val[j];
4317 /* It only deletes the RW volumes */
4318 if (strncmp(vllist->name, prefix, strlen(prefix))) {
4321 "Omitting to delete %s due to prefix %s mismatch\n",
4322 vllist->name, prefix);
4329 if (as->parms[4].items) { /* -noexecute */
4330 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4336 /* Only matches the RW volume name */
4337 avolid = vllist->volumeId[RWVOL];
4338 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4340 fprintf(STDOUT, "Could not delete VDLB entry for %s\n",
4343 PrintError("", vcode);
4348 fprintf(STDOUT, "Deleted VLDB entry for %s \n", vllist->name);
4353 fprintf(STDOUT, "----------------------\n");
4355 "Total VLDB entries deleted: %lu; failed to delete: %lu\n",
4356 (unsigned long)totalBack, (unsigned long)totalFail);
4357 if (arrayEntries.nbulkentries_val)
4358 free(arrayEntries.nbulkentries_val);
4364 CompareVldbEntryByName(p1, p2)
4367 struct nvldbentry *arg1, *arg2;
4369 arg1 = (struct nvldbentry *)p1;
4370 arg2 = (struct nvldbentry *)p2;
4371 return (strcmp(arg1->name, arg2->name));
4375 static int CompareVldbEntry(p1,p2)
4378 struct nvldbentry *arg1,*arg2;
4381 char comp1[100],comp2[100];
4382 char temp1[20],temp2[20];
4384 arg1 = (struct nvldbentry *)p1;
4385 arg2 = (struct nvldbentry *)p2;
4389 for(i = 0; i < arg1->nServers; i++)
4390 if(arg1->serverFlags[i] & ITSRWVOL) pos1 = i;
4391 for(i = 0; i < arg2->nServers; i++)
4392 if(arg2->serverFlags[i] & ITSRWVOL) pos2 = i;
4393 if(pos1 == -1 || pos2 == -1){
4397 sprintf(comp1,"%10u",arg1->serverNumber[pos1]);
4398 sprintf(comp2,"%10u",arg2->serverNumber[pos2]);
4399 sprintf(temp1,"%10u",arg1->serverPartition[pos1]);
4400 sprintf(temp2,"%10u",arg2->serverPartition[pos2]);
4401 strcat(comp1,temp1);
4402 strcat(comp2,temp2);
4403 strcat(comp1,arg1->name);
4404 strcat(comp1,arg2->name);
4405 return(strcmp(comp1,comp2));
4411 ListVLDB(struct cmd_syndesc *as, void *arock)
4414 afs_int32 aserver, code;
4416 struct VldbListByAttributes attributes;
4417 nbulkentries arrayEntries;
4418 struct nvldbentry *vllist, *tarray = 0, *ttarray;
4419 afs_int32 centries, nentries = 0;
4420 afs_int32 tarraysize = 0;
4421 afs_int32 parraysize;
4424 int quiet, sort, lock;
4425 afs_int32 thisindex, nextindex;
4430 attributes.Mask = 0;
4431 lock = (as->parms[3].items ? 1 : 0); /* -lock flag */
4432 quiet = (as->parms[4].items ? 1 : 0); /* -quit flag */
4433 sort = (as->parms[5].items ? 0 : 1); /* -nosort flag */
4435 /* If the volume name is given, Use VolumeInfoCmd to look it up
4436 * and not ListAttributes.
4438 if (as->parms[0].items) {
4441 "vos: illegal use of '-locked' switch, need to specify server and/or partition\n");
4444 code = VolumeInfoCmd(as->parms[0].items->data);
4446 PrintError("", code);
4452 /* Server specified */
4453 if (as->parms[1].items) {
4454 aserver = GetServer(as->parms[1].items->data);
4456 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4457 as->parms[1].items->data);
4460 attributes.server = ntohl(aserver);
4461 attributes.Mask |= VLLIST_SERVER;
4464 /* Partition specified */
4465 if (as->parms[2].items) {
4466 apart = volutil_GetPartitionID(as->parms[2].items->data);
4468 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4469 as->parms[2].items->data);
4472 attributes.partition = apart;
4473 attributes.Mask |= VLLIST_PARTITION;
4477 attributes.Mask |= VLLIST_FLAG;
4478 attributes.flag = VLOP_ALLOPERS;
4481 /* Print header information */
4483 MapPartIdIntoName(apart, pname);
4484 fprintf(STDOUT, "VLDB entries for %s %s%s%s %s\n",
4485 (as->parms[1].items ? "server" : "all"),
4486 (as->parms[1].items ? as->parms[1].items->data : "servers"),
4487 (as->parms[2].items ? " partition " : ""),
4488 (as->parms[2].items ? pname : ""),
4489 (lock ? "which are locked:" : ""));
4492 for (thisindex = 0; (thisindex != -1); thisindex = nextindex) {
4493 memset(&arrayEntries, 0, sizeof(arrayEntries));
4498 VLDB_ListAttributesN2(&attributes, 0, thisindex, ¢ries,
4499 &arrayEntries, &nextindex);
4500 if (vcode == RXGEN_OPCODE) {
4501 /* Vlserver not running with ListAttributesN2. Fall back */
4503 VLDB_ListAttributes(&attributes, ¢ries, &arrayEntries);
4507 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4508 PrintError("", vcode);
4511 nentries += centries;
4513 /* We don't sort, so just print the entries now */
4515 for (j = 0; j < centries; j++) { /* process each entry */
4516 vllist = &arrayEntries.nbulkentries_val[j];
4517 MapHostToNetwork(vllist);
4518 EnumerateEntry(vllist);
4520 if (vllist->flags & VLOP_ALLOPERS)
4521 fprintf(STDOUT, " Volume is currently LOCKED \n");
4525 /* So we sort. First we must collect all the entries and keep
4528 else if (centries > 0) {
4530 /* steal away the first bulk entries array */
4531 tarray = (struct nvldbentry *)arrayEntries.nbulkentries_val;
4532 tarraysize = centries * sizeof(struct nvldbentry);
4533 arrayEntries.nbulkentries_val = 0;
4535 /* Grow the tarray to keep the extra entries */
4536 parraysize = (centries * sizeof(struct nvldbentry));
4538 (struct nvldbentry *)realloc(tarray,
4539 tarraysize + parraysize);
4542 "Could not allocate enough space for the VLDB entries\n");
4548 memcpy(((char *)tarray) + tarraysize,
4549 (char *)arrayEntries.nbulkentries_val, parraysize);
4550 tarraysize += parraysize;
4554 /* Free the bulk array */
4555 if (arrayEntries.nbulkentries_val) {
4556 free(arrayEntries.nbulkentries_val);
4557 arrayEntries.nbulkentries_val = 0;
4561 /* Here is where we now sort all the entries and print them */
4562 if (sort && (nentries > 0)) {
4563 qsort((char *)tarray, nentries, sizeof(struct nvldbentry),
4564 CompareVldbEntryByName);
4565 for (vllist = tarray, j = 0; j < nentries; j++, vllist++) {
4566 MapHostToNetwork(vllist);
4567 EnumerateEntry(vllist);
4569 if (vllist->flags & VLOP_ALLOPERS)
4570 fprintf(STDOUT, " Volume is currently LOCKED \n");
4576 fprintf(STDOUT, "\nTotal entries: %lu\n", (unsigned long)nentries);
4583 BackSys(register struct cmd_syndesc *as, void *arock)
4586 afs_int32 apart = 0;
4587 afs_int32 aserver = 0, code, aserver1, apart1;
4589 struct VldbListByAttributes attributes;
4590 nbulkentries arrayEntries;
4591 register struct nvldbentry *vllist;
4595 int seenprefix, seenxprefix, exclude, ex, exp, noaction;
4596 afs_int32 totalBack = 0;
4597 afs_int32 totalFail = 0;
4598 int previdx = -1, error, same;
4600 struct cmd_item *ti;
4604 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4605 attributes.Mask = 0;
4607 seenprefix = (as->parms[0].items ? 1 : 0);
4608 exclude = (as->parms[3].items ? 1 : 0);
4609 seenxprefix = (as->parms[4].items ? 1 : 0);
4610 noaction = (as->parms[5].items ? 1 : 0);
4612 if (as->parms[1].items) { /* -server */
4613 aserver = GetServer(as->parms[1].items->data);
4615 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4616 as->parms[1].items->data);
4619 attributes.server = ntohl(aserver);
4620 attributes.Mask |= VLLIST_SERVER;
4623 if (as->parms[2].items) { /* -partition */
4624 apart = volutil_GetPartitionID(as->parms[2].items->data);
4626 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4627 as->parms[2].items->data);
4630 attributes.partition = apart;
4631 attributes.Mask |= VLLIST_PARTITION;
4634 /* Check to make sure the prefix and xprefix expressions compile ok */
4636 for (ti = as->parms[0].items; ti; ti = ti->next) {
4637 if (strncmp(ti->data, "^", 1) == 0) {
4638 #ifdef HAVE_POSIX_REGEX
4642 code = regcomp(&re, ti->data, REG_NOSUB);
4644 regerror(code, &re, errbuf, sizeof errbuf);
4646 "Unrecognizable -prefix regular expression: '%s': %s\n",
4652 ccode = (char *)re_comp(ti->data);
4655 "Unrecognizable -prefix regular expression: '%s': %s\n",
4664 for (ti = as->parms[4].items; ti; ti = ti->next) {
4665 if (strncmp(ti->data, "^", 1) == 0) {
4666 #ifdef HAVE_POSIX_REGEX
4670 code = regcomp(&re, ti->data, REG_NOSUB);
4672 regerror(code, &re, errbuf, sizeof errbuf);
4674 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4680 ccode = (char *)re_comp(ti->data);
4683 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4692 memset(&arrayEntries, 0, sizeof(arrayEntries)); /* initialize to hint the stub to alloc space */
4693 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4695 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4696 PrintError("", vcode);
4700 if (as->parms[1].items || as->parms[2].items || verbose) {
4701 fprintf(STDOUT, "%s up volumes",
4702 (noaction ? "Would have backed" : "Backing"));
4704 if (as->parms[1].items) {
4705 fprintf(STDOUT, " on server %s", as->parms[1].items->data);
4706 } else if (as->parms[2].items) {
4707 fprintf(STDOUT, " for all servers");
4710 if (as->parms[2].items) {
4711 MapPartIdIntoName(apart, pname);
4712 fprintf(STDOUT, " partition %s", pname);
4715 if (seenprefix || (!seenprefix && seenxprefix)) {
4716 ti = (seenprefix ? as->parms[0].items : as->parms[4].items);
4717 ex = (seenprefix ? exclude : !exclude);
4718 exp = (strncmp(ti->data, "^", 1) == 0);
4719 fprintf(STDOUT, " which %smatch %s '%s'", (ex ? "do not " : ""),
4720 (exp ? "expression" : "prefix"), ti->data);
4721 for (ti = ti->next; ti; ti = ti->next) {
4722 exp = (strncmp(ti->data, "^", 1) == 0);
4723 printf(" %sor %s '%s'", (ex ? "n" : ""),
4724 (exp ? "expression" : "prefix"), ti->data);
4728 if (seenprefix && seenxprefix) {
4729 ti = as->parms[4].items;
4730 exp = (strncmp(ti->data, "^", 1) == 0);
4731 fprintf(STDOUT, " %swhich match %s '%s'",
4732 (exclude ? "adding those " : "removing those "),
4733 (exp ? "expression" : "prefix"), ti->data);
4734 for (ti = ti->next; ti; ti = ti->next) {
4735 exp = (strncmp(ti->data, "^", 1) == 0);
4736 printf(" or %s '%s'", (exp ? "expression" : "prefix"),
4740 fprintf(STDOUT, " .. ");
4742 fprintf(STDOUT, "\n");
4746 for (j = 0; j < nentries; j++) { /* process each vldb entry */
4747 vllist = &arrayEntries.nbulkentries_val[j];
4750 for (ti = as->parms[0].items; ti; ti = ti->next) {
4751 if (strncmp(ti->data, "^", 1) == 0) {
4752 #ifdef HAVE_POSIX_REGEX
4756 /* XXX -- should just do the compile once! */
4757 code = regcomp(&re, ti->data, REG_NOSUB);
4759 regerror(code, &re, errbuf, sizeof errbuf);
4761 "Error in -prefix regular expression: '%s': %s\n",
4765 match = (regexec(&re, vllist->name, 0, NULL, 0) == 0);
4768 ccode = (char *)re_comp(ti->data);
4771 "Error in -prefix regular expression: '%s': %s\n",
4775 match = (re_exec(vllist->name) == 1);
4779 (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4789 /* Without the -exclude flag: If it matches the prefix, then
4790 * check if we want to exclude any from xprefix.
4791 * With the -exclude flag: If it matches the prefix, then
4792 * check if we want to add any from xprefix.
4794 if (match && seenxprefix) {
4795 for (ti = as->parms[4].items; ti; ti = ti->next) {
4796 if (strncmp(ti->data, "^", 1) == 0) {
4797 #ifdef HAVE_POSIX_REGEX
4801 /* XXX -- should just do the compile once! */
4802 code = regcomp(&re, ti->data, REG_NOSUB);
4804 regerror(code, &re, errbuf, sizeof errbuf);
4806 "Error in -xprefix regular expression: '%s': %s\n",
4810 if (regexec(&re, vllist->name, 0, NULL, 0) == 0)
4814 ccode = (char *)re_comp(ti->data);
4817 "Error in -xprefix regular expression: '%s': %s\n",
4821 if (re_exec(vllist->name) == 1) {
4827 if (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4837 match = !match; /* -exclude will reverse the match */
4839 continue; /* Skip if no match */
4841 /* Print list of volumes to backup */
4843 fprintf(STDOUT, " %s\n", vllist->name);
4847 if (!(vllist->flags & RW_EXISTS)) {
4850 "Omitting to backup %s since RW volume does not exist \n",
4852 fprintf(STDOUT, "\n");
4858 avolid = vllist->volumeId[RWVOL];
4859 MapHostToNetwork(vllist);
4860 GetServerAndPart(vllist, RWVOL, &aserver1, &apart1, &previdx);
4861 if (aserver1 == -1 || apart1 == -1) {
4862 fprintf(STDOUT, "could not backup %s, invalid VLDB entry\n",
4868 same = VLDB_IsSameAddrs(aserver, aserver1, &error);
4871 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
4877 if ((aserver && !same) || (apart && (apart != apart1))) {
4880 "Omitting to backup %s since the RW is in a different location\n",
4886 time_t now = time(0);
4887 fprintf(STDOUT, "Creating backup volume for %s on %s",
4888 vllist->name, ctime(&now));
4892 code = UV_BackupVolume(aserver1, apart1, avolid);
4894 fprintf(STDOUT, "Could not backup %s\n", vllist->name);
4900 fprintf(STDOUT, "\n");
4902 } /* process each vldb entry */
4903 fprintf(STDOUT, "done\n");
4904 fprintf(STDOUT, "Total volumes backed up: %lu; failed to backup: %lu\n",
4905 (unsigned long)totalBack, (unsigned long)totalFail);
4907 if (arrayEntries.nbulkentries_val)
4908 free(arrayEntries.nbulkentries_val);
4913 UnlockVLDB(register struct cmd_syndesc *as, void *arock)
4916 afs_int32 aserver = NULL;
4919 struct VldbListByAttributes attributes;
4920 nbulkentries arrayEntries;
4921 register struct nvldbentry *vllist;
4930 attributes.Mask = 0;
4932 if (as->parms[0].items) { /* server specified */
4933 aserver = GetServer(as->parms[0].items->data);
4935 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4936 as->parms[0].items->data);
4939 attributes.server = ntohl(aserver);
4940 attributes.Mask |= VLLIST_SERVER;
4942 if (as->parms[1].items) { /* partition specified */
4943 apart = volutil_GetPartitionID(as->parms[1].items->data);
4945 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4946 as->parms[1].items->data);
4949 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
4951 PrintError("", code);
4954 "vos : partition %s does not exist on the server\n",
4955 as->parms[1].items->data);
4958 attributes.partition = apart;
4959 attributes.Mask |= VLLIST_PARTITION;
4961 attributes.flag = VLOP_ALLOPERS;
4962 attributes.Mask |= VLLIST_FLAG;
4963 memset(&arrayEntries, 0, sizeof(arrayEntries)); /*initialize to hint the stub to alloc space */
4964 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4966 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4967 PrintError("", vcode);
4970 for (j = 0; j < nentries; j++) { /* process each entry */
4971 vllist = &arrayEntries.nbulkentries_val[j];
4972 volid = vllist->volumeId[RWVOL];
4974 ubik_VL_ReleaseLock(cstruct, 0, volid, -1,
4975 LOCKREL_OPCODE | LOCKREL_AFSID |
4978 fprintf(STDERR, "Could not unlock entry for volume %s\n",
4980 PrintError("", vcode);
4985 MapPartIdIntoName(apart, pname);
4988 "Could not lock %lu VLDB entries of %lu locked entries\n",
4989 (unsigned long)totalE, (unsigned long)nentries);
4991 if (as->parms[0].items) {
4993 "Unlocked all the VLDB entries for volumes on server %s ",
4994 as->parms[0].items->data);
4995 if (as->parms[1].items) {
4996 MapPartIdIntoName(apart, pname);
4997 fprintf(STDOUT, "partition %s\n", pname);
4999 fprintf(STDOUT, "\n");
5001 } else if (as->parms[1].items) {
5002 MapPartIdIntoName(apart, pname);
5004 "Unlocked all the VLDB entries for volumes on partition %s on all servers\n",
5009 if (arrayEntries.nbulkentries_val)
5010 free(arrayEntries.nbulkentries_val);
5015 PrintInt64Size(afs_uint64 in)
5017 register afs_uint32 hi, lo;
5018 register char * units;
5019 static char output[16];
5021 SplitInt64(in,hi,lo);
5025 } else if (!(hi & 0xFFFFFC00)) {
5027 lo = (hi << 22) | (lo >> 10);
5028 } else if (!(hi & 0xFFF00000)) {
5030 lo = (hi << 12) | (lo >> 20);
5031 } else if (!(hi & 0xC0000000)) {
5033 lo = (hi << 2) | (lo >> 30);
5038 sprintf(output,"%u %s", lo, units);
5043 PartitionInfo(register struct cmd_syndesc *as, void *arock)
5046 afs_int32 aserver, code;
5048 struct diskPartition64 partition;
5049 struct partList dummyPartList;
5051 int printSummary=0, sumPartitions=0;
5052 afs_uint64 sumFree, sumStorage;
5055 ZeroInt64(sumStorage);
5057 aserver = GetServer(as->parms[0].items->data);
5059 fprintf(STDERR, "vos: server '%s' not found in host table\n",
5060 as->parms[0].items->data);
5063 if (as->parms[1].items) {
5064 apart = volutil_GetPartitionID(as->parms[1].items->data);
5066 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5067 as->parms[1].items->data);
5070 dummyPartList.partId[0] = apart;
5071 dummyPartList.partFlags[0] = PARTVALID;
5074 if (as->parms[2].items) {
5078 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
5080 PrintError("", code);
5083 "vos : partition %s does not exist on the server\n",
5084 as->parms[1].items->data);
5088 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
5090 PrintDiagnostics("listpart", code);
5094 for (i = 0; i < cnt; i++) {
5095 if (dummyPartList.partFlags[i] & PARTVALID) {
5096 MapPartIdIntoName(dummyPartList.partId[i], pname);
5097 code = UV_PartitionInfo64(aserver, pname, &partition);
5099 fprintf(STDERR, "Could not get information on partition %s\n",
5101 PrintError("", code);
5105 "Free space on partition %s: %" AFS_INT64_FMT " K blocks out of total %" AFS_INT64_FMT "\n",
5106 pname, partition.free, partition.minFree);
5108 AddUInt64(sumFree,partition.free,&sumFree);
5109 AddUInt64(sumStorage,partition.minFree,&sumStorage);
5114 "Summary: %s free out of ",
5115 PrintInt64Size(sumFree));
5117 "%s on %d partitions\n",
5118 PrintInt64Size(sumStorage),
5125 ChangeAddr(register struct cmd_syndesc *as, void *arock)
5127 afs_int32 ip1, ip2, vcode;
5130 ip1 = GetServer(as->parms[0].items->data);
5132 fprintf(STDERR, "vos: invalid host address\n");
5136 if ((as->parms[1].items && as->parms[2].items)
5137 || (!as->parms[1].items && !as->parms[2].items)) {
5139 "vos: Must specify either '-newaddr <addr>' or '-remove' flag\n");
5143 if (as->parms[1].items) {
5144 ip2 = GetServer(as->parms[1].items->data);
5146 fprintf(STDERR, "vos: invalid host address\n");
5150 /* Play a trick here. If we are removing an address, ip1 will be -1
5151 * and ip2 will be the original address. This switch prevents an
5152 * older revision vlserver from removing the IP address.
5159 vcode = ubik_Call_New(VL_ChangeAddr, cstruct, 0, ntohl(ip1), ntohl(ip2));
5162 fprintf(STDERR, "Could not remove server %s from the VLDB\n",
5163 as->parms[0].items->data);
5164 if (vcode == VL_NOENT) {
5166 "vlserver does not support the remove flag or ");
5169 fprintf(STDERR, "Could not change server %s to server %s\n",
5170 as->parms[0].items->data, as->parms[1].items->data);
5172 PrintError("", vcode);
5177 fprintf(STDOUT, "Removed server %s from the VLDB\n",
5178 as->parms[0].items->data);
5180 fprintf(STDOUT, "Changed server %s to server %s\n",
5181 as->parms[0].items->data, as->parms[1].items->data);
5187 print_addrs(const bulkaddrs * addrs, const afsUUID * m_uuid, int nentries,
5192 struct VLCallBack vlcb;
5195 ListAddrByAttributes m_attrs;
5196 afs_int32 m_nentries, *m_addrp;
5197 afs_int32 base, index;
5201 afsUUID_to_string(m_uuid, buf, sizeof(buf));
5202 printf("UUID: %s\n", buf);
5205 /* print out the list of all the server */
5206 addrp = (afs_int32 *) addrs->bulkaddrs_val;
5207 for (i = 0; i < nentries; i++, addrp++) {
5208 /* If it is a multihomed address, then we will need to
5209 * get the addresses for this multihomed server from
5210 * the vlserver and print them.
5212 if (((*addrp & 0xff000000) == 0xff000000) && ((*addrp) & 0xffff)) {
5213 /* Get the list of multihomed fileservers */
5214 base = (*addrp >> 16) & 0xff;
5215 index = (*addrp) & 0xffff;
5217 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
5218 && (index <= VL_MHSRV_PERBLK)) {
5219 m_attrs.Mask = VLADDR_INDEX;
5220 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
5222 m_addrs.bulkaddrs_val = 0;
5223 m_addrs.bulkaddrs_len = 0;
5225 ubik_VL_GetAddrsU(cstruct, 0, &m_attrs, &m_uuid,
5226 (afs_int32 *)&vlcb, &m_nentries, &m_addrs);
5229 "vos: could not list the multi-homed server addresses\n");
5230 PrintError("", vcode);
5233 /* Print the list */
5234 m_addrp = (afs_int32 *) m_addrs.bulkaddrs_val;
5235 for (j = 0; j < m_nentries; j++, m_addrp++) {
5236 *m_addrp = htonl(*m_addrp);
5239 printf("%s ", afs_inet_ntoa_r(*m_addrp, hoststr));
5241 printf("%s ", hostutil_GetNameByINet(*m_addrp));
5245 printf("<unknown>\n");
5254 /* Otherwise, it is a non-multihomed entry and contains
5255 * the IP address of the server - print it.
5257 *addrp = htonl(*addrp);
5260 printf("%s\n", afs_inet_ntoa_r(*addrp, hoststr));
5262 printf("%s\n", hostutil_GetNameByINet(*addrp));
5273 ListAddrs(register struct cmd_syndesc *as, void *arock)
5276 afs_int32 i, printuuid = 0;
5277 struct VLCallBack vlcb;
5280 ListAddrByAttributes m_attrs;
5281 afsUUID m_uuid, askuuid;
5282 afs_int32 m_nentries;
5284 memset(&m_attrs, 0, sizeof(struct ListAddrByAttributes));
5285 m_attrs.Mask = VLADDR_INDEX;
5287 memset(&m_addrs, 0, sizeof(bulkaddrs));
5288 memset(&askuuid, 0, sizeof(afsUUID));
5289 if (as->parms[0].items) {
5291 if (afsUUID_from_string(as->parms[0].items->data, &askuuid) < 0) {
5292 fprintf(STDERR, "vos: invalid UUID '%s'\n",
5293 as->parms[0].items->data);
5296 m_attrs.Mask = VLADDR_UUID;
5297 m_attrs.uuid = askuuid;
5299 if (as->parms[1].items) {
5303 he = hostutil_GetHostByName((char *)as->parms[1].items->data);
5305 fprintf(STDERR, "vos: Can't get host info for '%s'\n",
5306 as->parms[1].items->data);
5309 memcpy(&saddr, he->h_addr, 4);
5310 m_attrs.Mask = VLADDR_IPADDR;
5311 m_attrs.ipaddr = ntohl(saddr);
5313 if (as->parms[2].items) {
5317 m_addrs.bulkaddrs_val = 0;
5318 m_addrs.bulkaddrs_len = 0;
5321 ubik_Call_New(VL_GetAddrs, cstruct, 0, 0, 0, &vlcb, &nentries,
5324 fprintf(STDERR, "vos: could not list the server addresses\n");
5325 PrintError("", vcode);
5330 m_addrs.bulkaddrs_val = 0;
5331 m_addrs.bulkaddrs_len = 0;
5337 ubik_Call_New(VL_GetAddrsU, cstruct, 0, &m_attrs, &m_uuid,
5338 &vlcb, &m_nentries, &m_addrs);
5340 if (vcode == VL_NOENT) {
5341 if (m_attrs.Mask == VLADDR_UUID) {
5342 fprintf(STDERR, "vos: no entry for UUID '%s' found in VLDB\n",
5343 as->parms[0].items->data);
5345 } else if (m_attrs.Mask == VLADDR_IPADDR) {
5346 fprintf(STDERR, "vos: no entry for host '%s' [0x%08x] found in VLDB\n",
5347 as->parms[1].items->data, m_attrs.ipaddr);
5356 if (vcode == VL_INDEXERANGE) {
5361 fprintf(STDERR, "vos: could not list the server addresses\n");
5362 PrintError("", vcode);
5366 print_addrs(&m_addrs, &m_uuid, m_nentries, printuuid);
5369 if ((as->parms[1].items) || (as->parms[0].items) || (i > nentries))
5377 LockEntry(register struct cmd_syndesc *as, void *arock)
5380 afs_int32 vcode, err;
5382 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5385 PrintError("", err);
5387 fprintf(STDERR, "vos: can't find volume '%s'\n",
5388 as->parms[0].items->data);
5391 vcode = ubik_VL_SetLock(cstruct, 0, avolid, -1, VLOP_DELETE);
5393 fprintf(STDERR, "Could not lock VLDB entry for volume %s\n",
5394 as->parms[0].items->data);
5395 PrintError("", vcode);
5398 fprintf(STDOUT, "Locked VLDB entry for volume %s\n",
5399 as->parms[0].items->data);
5404 ConvertRO(register struct cmd_syndesc *as, void *arock)
5406 afs_int32 partition = -1;
5408 afs_int32 server, code, i, same;
5409 struct nvldbentry entry, storeEntry;
5411 afs_int32 rwindex = 0;
5412 afs_int32 rwserver = 0;
5413 afs_int32 rwpartition = 0;
5414 afs_int32 roindex = 0;
5415 afs_int32 roserver = 0;
5416 afs_int32 ropartition = 0;
5418 struct rx_connection *aconn;
5421 server = GetServer(as->parms[0].items->data);
5423 fprintf(STDERR, "vos: host '%s' not found in host table\n",
5424 as->parms[0].items->data);
5427 partition = volutil_GetPartitionID(as->parms[1].items->data);
5428 if (partition < 0) {
5429 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5430 as->parms[1].items->data);
5433 if (!IsPartValid(partition, server, &code)) {
5435 PrintError("", code);
5438 "vos : partition %s does not exist on the server\n",
5439 as->parms[1].items->data);
5442 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &code);
5445 PrintError("", code);
5447 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
5448 as->parms[0].items->data);
5451 if (as->parms[3].items)
5454 vcode = VLDB_GetEntryByID(volid, -1, &entry);
5457 "Could not fetch the entry for volume %lu from VLDB\n",
5458 (unsigned long)volid);
5459 PrintError("convertROtoRW", code);
5463 /* use RO volid even if user specified RW or BK volid */
5465 if (volid != entry.volumeId[ROVOL])
5466 volid = entry.volumeId[ROVOL];
5468 MapHostToNetwork(&entry);
5469 for (i = 0; i < entry.nServers; i++) {
5470 if (entry.serverFlags[i] & ITSRWVOL) {
5472 rwserver = entry.serverNumber[i];
5473 rwpartition = entry.serverPartition[i];
5475 if (entry.serverFlags[i] & ITSROVOL) {
5476 same = VLDB_IsSameAddrs(server, entry.serverNumber[i], &code);
5479 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
5485 roserver = entry.serverNumber[i];
5486 ropartition = entry.serverPartition[i];
5492 fprintf(STDERR, "Warning: RO volume didn't exist in vldb!\n");
5494 if (ropartition != partition) {
5496 "Warning: RO volume should be in partition %d instead of %d (vldb)\n",
5497 ropartition, partition);
5502 "VLDB indicates that a RW volume exists already on %s in partition %s.\n",
5503 hostutil_GetNameByINet(rwserver),
5504 volutil_PartitionName(rwpartition));
5506 fprintf(STDERR, "Overwrite this VLDB entry? [y|n] (n)\n");
5508 while (!(dc == EOF || dc == '\n'))
5509 dc = getchar(); /* goto end of line */
5510 if ((c != 'y') && (c != 'Y')) {
5511 fprintf(STDERR, "aborted.\n");
5518 ubik_VL_SetLock(cstruct, 0, entry.volumeId[RWVOL], RWVOL,
5520 aconn = UV_Bind(server, AFSCONF_VOLUMEPORT);
5521 code = AFSVolConvertROtoRWvolume(aconn, partition, volid);
5524 "Converting RO volume %lu to RW volume failed with code %d\n",
5525 (unsigned long)volid, code);
5526 PrintError("convertROtoRW ", code);
5529 entry.serverFlags[roindex] = ITSRWVOL;
5530 entry.flags |= RW_EXISTS;
5531 entry.flags &= ~BACK_EXISTS;
5534 if (rwindex != entry.nServers) {
5535 entry.serverNumber[rwindex] = entry.serverNumber[entry.nServers];
5536 entry.serverPartition[rwindex] =
5537 entry.serverPartition[entry.nServers];
5538 entry.serverFlags[rwindex] = entry.serverFlags[entry.nServers];
5539 entry.serverNumber[entry.nServers] = 0;
5540 entry.serverPartition[entry.nServers] = 0;
5541 entry.serverFlags[entry.nServers] = 0;
5544 entry.flags &= ~RO_EXISTS;
5545 for (i = 0; i < entry.nServers; i++) {
5546 if (entry.serverFlags[i] & ITSROVOL) {
5547 if (!(entry.serverFlags[i] & (RO_DONTUSE | NEW_REPSITE)))
5548 entry.flags |= RO_EXISTS;
5551 MapNetworkToHost(&entry, &storeEntry);
5553 VLDB_ReplaceEntry(entry.volumeId[RWVOL], RWVOL, &storeEntry,
5554 (LOCKREL_OPCODE | LOCKREL_AFSID |
5555 LOCKREL_TIMESTAMP));
5558 "Warning: volume converted, but vldb update failed with code %d!\n",
5561 vcode = UV_LockRelease(entry.volumeId[RWVOL]);
5563 PrintDiagnostics("unlock", vcode);
5569 Sizes(register struct cmd_syndesc *as, void *arock)
5572 afs_int32 aserver, apart, voltype, fromdate = 0, code, err, i;
5573 struct nvldbentry entry;
5574 volintSize vol_size;
5576 rx_SetRxDeadTime(60 * 10);
5577 for (i = 0; i < MAXSERVERS; i++) {
5578 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
5581 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
5582 if (rxConn->service)
5583 rxConn->service->connDeadTime = rx_connDeadTime;
5586 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5589 PrintError("", err);
5591 fprintf(STDERR, "vos: can't find volume '%s'\n",
5592 as->parms[0].items->data);
5596 if (as->parms[1].items || as->parms[2].items) {
5597 if (!as->parms[1].items || !as->parms[2].items) {
5599 "Must specify both -server and -partition options\n");
5602 aserver = GetServer(as->parms[2].items->data);
5604 fprintf(STDERR, "Invalid server name\n");
5607 apart = volutil_GetPartitionID(as->parms[1].items->data);
5609 fprintf(STDERR, "Invalid partition name\n");
5613 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
5620 if (as->parms[4].items && strcmp(as->parms[4].items->data, "0")) {
5621 code = ktime_DateToInt32(as->parms[4].items->data, &fromdate);
5623 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
5624 as->parms[4].items->data, code);
5629 fprintf(STDOUT, "Volume: %s\n", as->parms[0].items->data);
5631 if (as->parms[3].items) { /* do the dump estimate */
5632 #ifdef AFS_64BIT_ENV
5633 vol_size.dump_size = 0;
5635 FillInt64(vol_size.dump_size,0, 1);
5637 code = UV_GetSize(avolid, aserver, apart, fromdate, &vol_size);
5639 PrintDiagnostics("size", code);
5642 /* presumably the size info is now gathered in pntr */
5643 /* now we display it */
5645 fprintf(STDOUT, "dump_size: %llu\n", vol_size.dump_size);
5654 PrintDiagnostics(char *astring, afs_int32 acode)
5656 if (acode == EACCES) {
5658 "You are not authorized to perform the 'vos %s' command (%d)\n",
5661 fprintf(STDERR, "Error in vos %s command.\n", astring);
5662 PrintError("", acode);
5669 MyBeforeProc(struct cmd_syndesc *as, void *arock)
5671 register char *tcell;
5672 register afs_int32 code;
5673 register afs_int32 sauth;
5675 /* Initialize the ubik_client connection */
5676 rx_SetRxDeadTime(90);
5677 cstruct = (struct ubik_client *)0;
5681 if (as->parms[12].items) /* if -cell specified */
5682 tcell = as->parms[12].items->data;
5683 if (as->parms[14].items) /* -serverauth specified */
5685 if (as->parms[16].items) /* -crypt specified */
5688 vsu_ClientInit((as->parms[13].items != 0), confdir, tcell, sauth,
5689 &cstruct, UV_SetSecurity))) {
5690 fprintf(STDERR, "could not initialize VLDB library (code=%lu) \n",
5691 (unsigned long)code);
5695 if (as->parms[15].items) /* -verbose flag set */
5699 if (as->parms[17].items) /* -noresolve flag set */
5709 /* this sucks but it works for now.
5714 #include "AFS_component_version_number.c"
5720 register afs_int32 code;
5722 register struct cmd_syndesc *ts;
5724 #ifdef AFS_AIX32_ENV
5726 * The following signal action for AIX is necessary so that in case of a
5727 * crash (i.e. core is generated) we can include the user's data section
5728 * in the core dump. Unfortunately, by default, only a partial core is
5729 * generated which, in many cases, isn't too useful.
5731 struct sigaction nsa;
5733 sigemptyset(&nsa.sa_mask);
5734 nsa.sa_handler = SIG_DFL;
5735 nsa.sa_flags = SA_FULLDUMP;
5736 sigaction(SIGSEGV, &nsa, NULL);
5739 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
5741 cmd_SetBeforeProc(MyBeforeProc, NULL);
5743 ts = cmd_CreateSyntax("create", CreateVolume, NULL, "create a new volume");
5744 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5745 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5746 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "volume name");
5747 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL,
5748 "initial quota (KB)");
5750 cmd_AddParm(ts, "-minquota", CMD_SINGLE, CMD_OPTIONAL, "");
5754 ts = cmd_CreateSyntax("remove", DeleteVolume, NULL, "delete a volume");
5755 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5756 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5757 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5761 ts = cmd_CreateSyntax("move", MoveVolume, NULL, "move a volume");
5762 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5763 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5764 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5765 "partition name on source");
5766 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5767 "machine name on destination");
5768 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5769 "partition name on destination");
5770 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5771 "copy live volume without cloning");
5774 ts = cmd_CreateSyntax("copy", CopyVolume, NULL, "copy a volume");
5775 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5776 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5777 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5778 "partition name on source");
5779 cmd_AddParm(ts, "-toname", CMD_SINGLE, 0, "volume name on destination");
5780 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5781 "machine name on destination");
5782 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5783 "partition name on destination");
5784 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5785 "leave new volume offline");
5786 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5787 "make new volume read-only");
5788 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5789 "copy live volume without cloning");
5792 ts = cmd_CreateSyntax("shadow", ShadowVolume, NULL,
5793 "make or update a shadow volume");
5794 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5795 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5796 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5797 "partition name on source");
5798 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5799 "machine name on destination");
5800 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5801 "partition name on destination");
5802 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5803 "volume name on destination");
5804 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5805 "volume ID on destination");
5806 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5807 "leave shadow volume offline");
5808 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5809 "make shadow volume read-only");
5810 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5811 "copy live volume without cloning");
5812 cmd_AddParm(ts, "-incremental", CMD_FLAG, CMD_OPTIONAL,
5813 "do incremental update if target exists");
5816 ts = cmd_CreateSyntax("backup", BackupVolume, NULL,
5817 "make backup of a volume");
5818 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5821 ts = cmd_CreateSyntax("clone", CloneVolume, NULL,
5822 "make clone of a volume");
5823 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5824 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5825 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5826 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5827 "volume name on destination");
5828 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5829 "volume ID on destination");
5830 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5831 "leave clone volume offline");
5832 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5833 "make clone volume read-only, not readwrite");
5836 ts = cmd_CreateSyntax("release", ReleaseVolume, NULL, "release a volume");
5837 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5838 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5839 "force a complete release");
5842 ts = cmd_CreateSyntax("dump", DumpVolume, NULL, "dump a volume");
5843 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5844 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
5845 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5846 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5847 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5848 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL,
5849 "dump a clone of the volume");
5850 cmd_AddParm(ts, "-omitdirs", CMD_FLAG, CMD_OPTIONAL,
5851 "omit unchanged directories from an incremental dump");
5854 ts = cmd_CreateSyntax("restore", RestoreVolume, NULL, "restore a volume");
5855 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5856 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5857 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of volume to be restored");
5858 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5859 cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_OPTIONAL, "volume ID");
5860 cmd_AddParm(ts, "-overwrite", CMD_SINGLE, CMD_OPTIONAL,
5861 "abort | full | incremental");
5862 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5863 "leave restored volume offline");
5864 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5865 "make restored volume read-only");
5866 cmd_AddParm(ts, "-creation", CMD_SINGLE, CMD_OPTIONAL,
5867 "dump | keep | new");
5868 cmd_AddParm(ts, "-lastupdate", CMD_SINGLE, CMD_OPTIONAL,
5869 "dump | keep | new");
5870 cmd_AddParm(ts, "-nodelete", CMD_FLAG, CMD_OPTIONAL,
5871 "do not delete old site when restoring to a new site");
5874 ts = cmd_CreateSyntax("unlock", LockReleaseCmd, NULL,
5875 "release lock on VLDB entry for a volume");
5876 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5879 ts = cmd_CreateSyntax("changeloc", ChangeLocation, NULL,
5880 "change an RW volume's location in the VLDB");
5881 cmd_AddParm(ts, "-server", CMD_SINGLE, 0,
5882 "machine name for new location");
5883 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5884 "partition name for new location");
5885 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5888 ts = cmd_CreateSyntax("addsite", AddSite, NULL, "add a replication site");
5889 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name for new site");
5890 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5891 "partition name for new site");
5892 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5893 cmd_AddParm(ts, "-valid", CMD_FLAG, CMD_OPTIONAL, "publish as an up-to-date site in VLDB");
5896 ts = cmd_CreateSyntax("remsite", RemoveSite, NULL,
5897 "remove a replication site");
5898 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5899 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5900 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5903 ts = cmd_CreateSyntax("listpart", ListPartitions, NULL, "list partitions");
5904 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5907 ts = cmd_CreateSyntax("listvol", ListVolumes, NULL,
5908 "list volumes on server (bypass VLDB)");
5909 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5910 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5911 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "minimal listing");
5912 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL,
5913 "list all normal volume fields");
5914 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5915 "generate minimal information");
5916 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5917 "list extended volume fields");
5918 #ifdef FULL_LISTVOL_SWITCH
5919 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5920 "machine readable format");
5921 #endif /* FULL_LISTVOL_SWITCH */
5924 ts = cmd_CreateSyntax("syncvldb", SyncVldb, NULL,
5925 "synchronize VLDB with server");
5926 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5927 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5928 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5929 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
5932 ts = cmd_CreateSyntax("syncserv", SyncServer, NULL,
5933 "synchronize server with VLDB");
5934 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5935 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5936 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
5939 ts = cmd_CreateSyntax("examine", ExamineVolume, NULL,
5940 "everything about the volume");
5941 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5942 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5943 "list extended volume fields");
5944 #ifdef FULL_LISTVOL_SWITCH
5945 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5946 "machine readable format");
5947 #endif /* FULL_LISTVOL_SWITCH */
5949 cmd_CreateAlias(ts, "volinfo");
5951 ts = cmd_CreateSyntax("setfields", SetFields, NULL,
5952 "change volume info fields");
5953 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5954 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL, "quota (KB)");
5955 cmd_AddParm(ts, "-clearuse", CMD_FLAG, CMD_OPTIONAL, "clear dayUse");
5956 cmd_AddParm(ts, "-clearVolUpCounter", CMD_FLAG, CMD_OPTIONAL, "clear volUpdateCounter");
5959 ts = cmd_CreateSyntax("offline", volOffline, NULL, "force the volume status to offline");
5960 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5961 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5962 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5963 cmd_AddParm(ts, "-sleep", CMD_SINGLE, CMD_OPTIONAL, "seconds to sleep");
5964 cmd_AddParm(ts, "-busy", CMD_FLAG, CMD_OPTIONAL, "busy volume");
5967 ts = cmd_CreateSyntax("online", volOnline, NULL, "force the volume status to online");
5968 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5969 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5970 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5973 ts = cmd_CreateSyntax("zap", VolumeZap, NULL,
5974 "delete the volume, don't bother with VLDB");
5975 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5976 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5977 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume ID");
5978 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5979 "force deletion of bad volumes");
5980 cmd_AddParm(ts, "-backup", CMD_FLAG, CMD_OPTIONAL,
5981 "also delete backup volume if one is found");
5984 ts = cmd_CreateSyntax("status", VolserStatus, NULL,
5985 "report on volser status");
5986 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5989 ts = cmd_CreateSyntax("rename", RenameVolume, NULL, "rename a volume");
5990 cmd_AddParm(ts, "-oldname", CMD_SINGLE, 0, "old volume name ");
5991 cmd_AddParm(ts, "-newname", CMD_SINGLE, 0, "new volume name ");
5994 ts = cmd_CreateSyntax("listvldb", ListVLDB, NULL,
5995 "list volumes in the VLDB");
5996 cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5997 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5998 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5999 cmd_AddParm(ts, "-locked", CMD_FLAG, CMD_OPTIONAL, "locked volumes only");
6000 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
6001 "generate minimal information");
6002 cmd_AddParm(ts, "-nosort", CMD_FLAG, CMD_OPTIONAL,
6003 "do not alphabetically sort the volume names");
6006 ts = cmd_CreateSyntax("backupsys", BackSys, NULL, "en masse backups");
6007 cmd_AddParm(ts, "-prefix", CMD_LIST, CMD_OPTIONAL,
6008 "common prefix on volume(s)");
6009 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6010 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6011 cmd_AddParm(ts, "-exclude", CMD_FLAG, CMD_OPTIONAL,
6012 "exclude common prefix volumes");
6013 cmd_AddParm(ts, "-xprefix", CMD_LIST, CMD_OPTIONAL,
6014 "negative prefix on volume(s)");
6015 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "no action");
6018 ts = cmd_CreateSyntax("delentry", DeleteEntry, NULL,
6019 "delete VLDB entry for a volume");
6020 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL, "volume name or ID");
6021 cmd_AddParm(ts, "-prefix", CMD_SINGLE, CMD_OPTIONAL,
6022 "prefix of the volume whose VLDB entry is to be deleted");
6023 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6024 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6025 cmd_AddParm(ts, "-noexecute", CMD_FLAG, CMD_OPTIONAL,
6029 ts = cmd_CreateSyntax("partinfo", PartitionInfo, NULL,
6030 "list partition information");
6031 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
6032 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6033 cmd_AddParm(ts, "-summary", CMD_FLAG, CMD_OPTIONAL,
6034 "print storage summary");
6037 ts = cmd_CreateSyntax("unlockvldb", UnlockVLDB, NULL,
6038 "unlock all the locked entries in the VLDB");
6039 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6040 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6043 ts = cmd_CreateSyntax("lock", LockEntry, NULL,
6044 "lock VLDB entry for a volume");
6045 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6048 ts = cmd_CreateSyntax("changeaddr", ChangeAddr, NULL,
6049 "change the IP address of a file server");
6050 cmd_AddParm(ts, "-oldaddr", CMD_SINGLE, 0, "original IP address");
6051 cmd_AddParm(ts, "-newaddr", CMD_SINGLE, CMD_OPTIONAL, "new IP address");
6052 cmd_AddParm(ts, "-remove", CMD_FLAG, CMD_OPTIONAL,
6053 "remove the IP address from the VLDB");
6056 ts = cmd_CreateSyntax("listaddrs", ListAddrs, NULL,
6057 "list the IP address of all file servers registered in the VLDB");
6058 cmd_AddParm(ts, "-uuid", CMD_SINGLE, CMD_OPTIONAL, "uuid of server");
6059 cmd_AddParm(ts, "-host", CMD_SINGLE, CMD_OPTIONAL, "address of host");
6060 cmd_AddParm(ts, "-printuuid", CMD_FLAG, CMD_OPTIONAL,
6061 "print uuid of hosts");
6064 ts = cmd_CreateSyntax("convertROtoRW", ConvertRO, NULL,
6065 "convert a RO volume into a RW volume (after loss of old RW volume)");
6066 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
6067 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
6068 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6069 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, "don't ask");
6072 ts = cmd_CreateSyntax("size", Sizes, NULL,
6073 "obtain various sizes of the volume.");
6074 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6075 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6076 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6077 cmd_AddParm(ts, "-dump", CMD_FLAG, CMD_OPTIONAL,
6078 "Obtain the size of the dump");
6079 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
6082 code = cmd_Dispatch(argc, argv);
6084 /* Shut down the ubik_client and rx connections */
6086 (void)ubik_ClientDestroy(cstruct);
6092 exit((code ? -1 : 0));