2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
14 #include <sys/types.h>
24 #include <netinet/in.h>
25 #include <arpa/inet.h>
29 #include <sys/statfs.h>
37 #include <rx/rx_globals.h>
39 #include <afs/vlserver.h>
40 #include <afs/cellconfig.h>
42 #include <afs/afsutil.h>
44 #include <afs/afsint.h>
49 #include <afs/ihandle.h>
50 #include <afs/vnode.h>
51 #include <afs/volume.h>
58 #include "volser_prototypes.h"
59 #include "vsutils_prototypes.h"
60 #include "lockprocs_prototypes.h"
62 #ifdef HAVE_POSIX_REGEX
66 /* Local Prototypes */
67 int PrintDiagnostics(char *astring, afs_int32 acode);
68 int GetVolumeInfo(afs_uint32 volid, afs_int32 *server, afs_int32 *part,
69 afs_int32 *voltype, struct nvldbentry *rentry);
81 #define COMMONPARMS cmd_Seek(ts, 12);\
82 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");\
83 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "don't authenticate");\
84 cmd_AddParm(ts, "-localauth",CMD_FLAG,CMD_OPTIONAL,"use server tickets");\
85 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose");\
86 cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL, "encrypt commands");\
87 cmd_AddParm(ts, "-noresolve", CMD_FLAG, CMD_OPTIONAL, "don't resolve addresses"); \
89 #define ERROR_EXIT(code) {error=(code); goto error_exit;}
92 struct rx_connection *tconn;
94 extern struct ubik_client *cstruct;
97 static struct tqHead busyHead, notokHead;
100 qInit(struct tqHead *ahead)
102 memset((char *)ahead, 0, sizeof(struct tqHead));
108 qPut(struct tqHead *ahead, afs_uint32 volid)
112 elem = (struct tqElem *)malloc(sizeof(struct tqElem));
113 elem->next = ahead->next;
121 qGet(struct tqHead *ahead, afs_uint32 *volid)
125 if (ahead->count <= 0)
127 *volid = ahead->next->volid;
129 ahead->next = tmp->next;
135 /* returns 1 if <filename> exists else 0 */
137 FileExists(char *filename)
143 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
147 code = USD_IOCTL(ufd, USD_IOCTL_GETSIZE, &size);
155 /* returns 1 if <name> doesnot end in .readonly or .backup, else 0 */
157 VolNameOK(char *name)
162 total = strlen(name);
163 if (!strcmp(&name[total - 9], ".readonly")) {
165 } else if (!strcmp(&name[total - 7], ".backup")) {
172 /* return 1 if name is a number else 0 */
174 IsNumeric(char *name)
182 for (i = 0; i < len; i++) {
183 if (*ptr < '0' || *ptr > '9') {
195 * Parse a server name/address and return the address in HOST BYTE order
198 GetServer(char *aname)
200 register struct hostent *th;
203 register afs_int32 code;
204 char hostname[MAXHOSTCHARS];
206 code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
208 addr = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
209 addr = ntohl(addr); /* convert to host order */
211 th = gethostbyname(aname);
214 memcpy(&addr, th->h_addr, sizeof(addr));
217 if (addr == htonl(0x7f000001)) { /* local host */
218 code = gethostname(hostname, MAXHOSTCHARS);
221 th = gethostbyname(hostname); /* returns host byte order */
224 memcpy(&addr, th->h_addr, sizeof(addr));
231 GetVolumeType(char *aname)
234 if (!strcmp(aname, "ro"))
236 else if (!strcmp(aname, "rw"))
238 else if (!strcmp(aname, "bk"))
245 IsPartValid(afs_int32 partId, afs_int32 server, afs_int32 *code)
247 struct partList dummyPartList;
253 *code = UV_ListPartitions(server, &dummyPartList, &cnt);
256 for (i = 0; i < cnt; i++) {
257 if (dummyPartList.partFlags[i] & PARTVALID)
258 if (dummyPartList.partId[i] == partId)
266 /*sends the contents of file associated with <fd> and <blksize> to Rx Stream
267 * associated with <call> */
269 SendFile(usd_handle_t ufd, register struct rx_call *call, long blksize)
271 char *buffer = (char *)0;
276 buffer = (char *)malloc(blksize);
278 fprintf(STDERR, "malloc failed\n");
282 while (!error && !done) {
283 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
286 FD_SET((int)(ufd->handle), &in);
287 /* don't timeout if read blocks */
288 #if defined(AFS_PTHREAD_ENV)
289 select(((int)(ufd->handle)) + 1, &in, 0, 0, 0);
291 IOMGR_Select(((int)(ufd->handle)) + 1, &in, 0, 0, 0);
294 error = USD_READ(ufd, buffer, blksize, &nbytes);
296 fprintf(STDERR, "File system read failed\n");
303 if (rx_Write(call, buffer, nbytes) != nbytes) {
313 /* function invoked by UV_RestoreVolume, reads the data from rx_trx_stream and
314 * writes it out to the volume. */
316 WriteData(struct rx_call *call, void *rock)
318 char *filename = (char *) rock;
321 afs_int32 error, code;
323 afs_hyper_t filesize, currOffset;
329 if (!filename || !*filename) {
330 usd_StandardInput(&ufd);
334 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
337 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
340 fprintf(STDERR, "Could not access file '%s'\n", filename);
344 /* test if we have a valid dump */
345 hset64(filesize, 0, 0);
346 USD_SEEK(ufd, filesize, SEEK_END, &currOffset);
347 hset64(filesize, hgethi(currOffset), hgetlo(currOffset)-sizeof(afs_uint32));
348 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
349 USD_READ(ufd, (char *)&buffer, sizeof(afs_uint32), &got);
350 if ((got != sizeof(afs_uint32)) || (ntohl(buffer) != DUMPENDMAGIC)) {
351 fprintf(STDERR, "Signature missing from end of file '%s'\n", filename);
355 /* rewind, we are done */
356 hset64(filesize, 0, 0);
357 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
359 code = SendFile(ufd, call, blksize);
366 code = USD_CLOSE(ufd);
368 fprintf(STDERR, "Could not close dump file %s\n",
369 (filename && *filename) ? filename : "STDOUT");
377 /* Receive data from <call> stream into file associated
378 * with <fd> <blksize>
381 ReceiveFile(usd_handle_t ufd, struct rx_call *call, long blksize)
385 afs_uint32 bytesleft, w;
388 buffer = (char *)malloc(blksize);
390 fprintf(STDERR, "memory allocation failed\n");
394 while ((bytesread = rx_Read(call, buffer, blksize)) > 0) {
395 for (bytesleft = bytesread; bytesleft; bytesleft -= w) {
396 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
399 FD_SET((int)(ufd->handle), &out);
400 /* don't timeout if write blocks */
401 #if defined(AFS_PTHREAD_ENV)
402 select(((int)(ufd->handle)) + 1, &out, 0, 0, 0);
404 IOMGR_Select(((int)(ufd->handle)) + 1, 0, &out, 0, 0);
408 USD_WRITE(ufd, &buffer[bytesread - bytesleft], bytesleft, &w);
410 fprintf(STDERR, "File system write failed\n");
423 DumpFunction(struct rx_call *call, void *rock)
425 char *filename = (char *)rock;
426 usd_handle_t ufd; /* default is to stdout */
427 afs_int32 error = 0, code;
432 /* Open the output file */
433 if (!filename || !*filename) {
434 usd_StandardOutput(&ufd);
439 usd_Open(filename, USD_OPEN_CREATE | USD_OPEN_RDWR, 0666, &ufd);
443 code = USD_IOCTL(ufd, USD_IOCTL_SETSIZE, &size);
446 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
449 fprintf(STDERR, "Could not create file '%s'\n", filename);
450 ERROR_EXIT(VOLSERBADOP);
454 code = ReceiveFile(ufd, call, blksize);
459 /* Close the output file */
461 code = USD_CLOSE(ufd);
463 fprintf(STDERR, "Could not close dump file %s\n",
464 (filename && *filename) ? filename : "STDIN");
474 DisplayFormat(volintInfo *pntr, afs_int32 server, afs_int32 part,
475 int *totalOK, int *totalNotOK, int *totalBusy, int fast,
476 int longlist, int disp)
482 fprintf(STDOUT, "%-10lu\n", (unsigned long)pntr->volid);
483 } else if (longlist) {
484 if (pntr->status == VOK) {
485 fprintf(STDOUT, "%-32s ", pntr->name);
486 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
488 fprintf(STDOUT, "RW ");
490 fprintf(STDOUT, "RO ");
492 fprintf(STDOUT, "BK ");
493 fprintf(STDOUT, "%10d K ", pntr->size);
494 if (pntr->inUse == 1) {
495 fprintf(STDOUT, "On-line");
498 fprintf(STDOUT, "Off-line");
501 if (pntr->needsSalvaged == 1)
502 fprintf(STDOUT, "**needs salvage**");
503 fprintf(STDOUT, "\n");
504 MapPartIdIntoName(part, pname);
505 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(server),
507 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
508 (unsigned long)pntr->parentID,
509 (unsigned long)pntr->cloneID,
510 (unsigned long)pntr->backupID);
511 fprintf(STDOUT, " MaxQuota %10d K \n", pntr->maxquota);
512 t = pntr->creationDate;
513 fprintf(STDOUT, " Creation %s",
515 #ifdef FULL_LISTVOL_SWITCH
517 fprintf(STDOUT, " Copy %s",
520 t = pntr->backupDate;
522 fprintf(STDOUT, " Backup Never\n");
524 fprintf(STDOUT, " Backup %s",
527 t = pntr->accessDate;
529 fprintf(STDOUT, " Last Access %s",
532 t = pntr->updateDate;
534 fprintf(STDOUT, " Last Update Never\n");
536 fprintf(STDOUT, " Last Update %s",
539 " %d accesses in the past day (i.e., vnode references)\n",
541 } else if (pntr->status == VBUSY) {
543 qPut(&busyHead, pntr->volid);
545 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
546 (unsigned long)pntr->volid);
549 qPut(¬okHead, pntr->volid);
551 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
552 (unsigned long)pntr->volid);
554 fprintf(STDOUT, "\n");
555 } else { /* default listing */
556 if (pntr->status == VOK) {
557 fprintf(STDOUT, "%-32s ", pntr->name);
558 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
560 fprintf(STDOUT, "RW ");
562 fprintf(STDOUT, "RO ");
564 fprintf(STDOUT, "BK ");
565 fprintf(STDOUT, "%10d K ", pntr->size);
566 if (pntr->inUse == 1) {
567 fprintf(STDOUT, "On-line");
570 fprintf(STDOUT, "Off-line");
573 if (pntr->needsSalvaged == 1)
574 fprintf(STDOUT, "**needs salvage**");
575 fprintf(STDOUT, "\n");
576 } else if (pntr->status == VBUSY) {
578 qPut(&busyHead, pntr->volid);
580 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
581 (unsigned long)pntr->volid);
584 qPut(¬okHead, pntr->volid);
586 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
587 (unsigned long)pntr->volid);
592 /*------------------------------------------------------------------------
593 * PRIVATE XDisplayFormat
596 * Display the contents of one extended volume info structure.
599 * a_xInfoP : Ptr to extended volume info struct to print.
600 * a_servID : Server ID to print.
601 * a_partID : Partition ID to print.
602 * a_totalOKP : Ptr to total-OK counter.
603 * a_totalNotOKP : Ptr to total-screwed counter.
604 * a_totalBusyP : Ptr to total-busy counter.
605 * a_fast : Fast listing?
606 * a_int32 : Int32 listing?
607 * a_showProblems : Show volume problems?
613 * Nothing interesting.
617 *------------------------------------------------------------------------*/
620 XDisplayFormat(volintXInfo *a_xInfoP, afs_int32 a_servID, afs_int32 a_partID,
621 int *a_totalOKP, int *a_totalNotOKP, int *a_totalBusyP,
622 int a_fast, int a_int32, int a_showProblems)
623 { /*XDisplayFormat */
631 fprintf(STDOUT, "%-10lu\n", (unsigned long)a_xInfoP->volid);
632 } else if (a_int32) {
634 * Fully-detailed listing.
636 if (a_xInfoP->status == VOK) {
638 * Volume's status is OK - all the fields are valid.
640 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
641 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
642 if (a_xInfoP->type == 0)
643 fprintf(STDOUT, "RW ");
644 if (a_xInfoP->type == 1)
645 fprintf(STDOUT, "RO ");
646 if (a_xInfoP->type == 2)
647 fprintf(STDOUT, "BK ");
648 fprintf(STDOUT, "%10d K used ", a_xInfoP->size);
649 fprintf(STDOUT, "%d files ", a_xInfoP->filecount);
650 if (a_xInfoP->inUse == 1) {
651 fprintf(STDOUT, "On-line");
654 fprintf(STDOUT, "Off-line");
657 fprintf(STDOUT, "\n");
658 MapPartIdIntoName(a_partID, pname);
659 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(a_servID),
661 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
662 (unsigned long)a_xInfoP->parentID,
663 (unsigned long)a_xInfoP->cloneID,
664 (unsigned long)a_xInfoP->backupID);
665 fprintf(STDOUT, " MaxQuota %10d K \n", a_xInfoP->maxquota);
667 t = a_xInfoP->creationDate;
668 fprintf(STDOUT, " Creation %s",
670 #ifdef FULL_LISTVOL_SWITCH
671 t = a_xInfoP->copyDate;
672 fprintf(STDOUT, " Copy %s",
675 t = a_xInfoP->backupDate;
677 fprintf(STDOUT, " Backup Never\n");
679 fprintf(STDOUT, " Backup %s",
682 t = a_xInfoP->accessDate;
684 fprintf(STDOUT, " Last Access %s",
687 t = a_xInfoP->updateDate;
689 fprintf(STDOUT, " Last Update Never\n");
691 fprintf(STDOUT, " Last Update %s",
694 " %d accesses in the past day (i.e., vnode references)\n",
698 * Print all the read/write and authorship stats.
700 fprintf(STDOUT, "\n Raw Read/Write Stats\n");
702 " |-------------------------------------------|\n");
704 " | Same Network | Diff Network |\n");
706 " |----------|----------|----------|----------|\n");
708 " | Total | Auth | Total | Auth |\n");
710 " |----------|----------|----------|----------|\n");
711 fprintf(STDOUT, "Reads | %8d | %8d | %8d | %8d |\n",
712 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET],
713 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH],
714 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET],
715 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
716 fprintf(STDOUT, "Writes | %8d | %8d | %8d | %8d |\n",
717 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET],
718 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH],
719 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET],
720 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
722 " |-------------------------------------------|\n\n");
725 " Writes Affecting Authorship\n");
727 " |-------------------------------------------|\n");
729 " | File Authorship | Directory Authorship|\n");
731 " |----------|----------|----------|----------|\n");
733 " | Same | Diff | Same | Diff |\n");
735 " |----------|----------|----------|----------|\n");
736 fprintf(STDOUT, "0-60 sec | %8d | %8d | %8d | %8d |\n",
737 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_0],
738 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0],
739 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0],
740 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]);
741 fprintf(STDOUT, "1-10 min | %8d | %8d | %8d | %8d |\n",
742 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1],
743 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1],
744 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1],
745 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]);
746 fprintf(STDOUT, "10min-1hr | %8d | %8d | %8d | %8d |\n",
747 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_2],
748 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_2],
749 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_2],
750 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_2]);
751 fprintf(STDOUT, "1hr-1day | %8d | %8d | %8d | %8d |\n",
752 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_3],
753 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_3],
754 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_3],
755 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_3]);
756 fprintf(STDOUT, "1day-1wk | %8d | %8d | %8d | %8d |\n",
757 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_4],
758 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_4],
759 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_4],
760 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_4]);
761 fprintf(STDOUT, "> 1wk | %8d | %8d | %8d | %8d |\n",
762 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_5],
763 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5],
764 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5],
765 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]);
767 " |-------------------------------------------|\n");
768 } /*Volume status OK */
769 else if (a_xInfoP->status == VBUSY) {
771 qPut(&busyHead, a_xInfoP->volid);
773 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
774 (unsigned long)a_xInfoP->volid);
778 qPut(¬okHead, a_xInfoP->volid);
780 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
781 (unsigned long)a_xInfoP->volid);
782 } /*Screwed volume */
783 fprintf(STDOUT, "\n");
789 if (a_xInfoP->status == VOK) {
790 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
791 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
792 if (a_xInfoP->type == 0)
793 fprintf(STDOUT, "RW ");
794 if (a_xInfoP->type == 1)
795 fprintf(STDOUT, "RO ");
796 if (a_xInfoP->type == 2)
797 fprintf(STDOUT, "BK ");
798 fprintf(STDOUT, "%10d K ", a_xInfoP->size);
799 if (a_xInfoP->inUse == 1) {
800 fprintf(STDOUT, "On-line");
803 fprintf(STDOUT, "Off-line");
806 fprintf(STDOUT, "\n");
808 else if (a_xInfoP->status == VBUSY) {
810 qPut(&busyHead, a_xInfoP->volid);
812 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
813 (unsigned long)a_xInfoP->volid);
817 qPut(¬okHead, a_xInfoP->volid);
819 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
820 (unsigned long)a_xInfoP->volid);
821 } /*Screwed volume */
822 } /*Default listing */
823 } /*XDisplayFormat */
825 #ifdef FULL_LISTVOL_SWITCH
826 /*------------------------------------------------------------------------
827 * PRIVATE XDisplayFormat2
830 * Display the formated contents of one extended volume info structure.
833 * a_xInfoP : Ptr to extended volume info struct to print.
834 * a_servID : Server ID to print.
835 * a_partID : Partition ID to print.
836 * a_totalOKP : Ptr to total-OK counter.
837 * a_totalNotOKP : Ptr to total-screwed counter.
838 * a_totalBusyP : Ptr to total-busy counter.
839 * a_fast : Fast listing?
840 * a_int32 : Int32 listing?
841 * a_showProblems : Show volume problems?
847 * Nothing interesting.
851 *------------------------------------------------------------------------*/
854 XDisplayFormat2(volintXInfo *a_xInfoP, afs_int32 a_servID, afs_int32 a_partID,
855 int *a_totalOKP, int *a_totalNotOKP, int *a_totalBusyP,
856 int a_fast, int a_int32, int a_showProblems)
857 { /*XDisplayFormat */
863 fprintf(STDOUT, "vold_id\t%-10lu\n", (unsigned long)a_xInfoP->volid);
864 } else if (a_int32) {
866 * Fully-detailed listing.
868 if (a_xInfoP->status == VOK) {
870 * Volume's status is OK - all the fields are valid.
873 static long server_cache = -1, partition_cache = -1;
874 static char hostname[256], address[32], pname[16];
875 int i,ai[] = {VOLINT_STATS_TIME_IDX_0,VOLINT_STATS_TIME_IDX_1,VOLINT_STATS_TIME_IDX_2,
876 VOLINT_STATS_TIME_IDX_3,VOLINT_STATS_TIME_IDX_4,VOLINT_STATS_TIME_IDX_5};
878 if (a_servID != server_cache) {
882 strcpy(hostname, hostutil_GetNameByINet(a_servID));
883 strcpy(address, inet_ntoa(s));
884 server_cache = a_servID;
886 if (a_partID != partition_cache) {
887 MapPartIdIntoName(a_partID, pname);
888 partition_cache = a_partID;
891 fprintf(STDOUT, "name\t\t%s\n", a_xInfoP->name);
892 fprintf(STDOUT, "id\t\t%lu\n", afs_printable_uint32_lu(a_xInfoP->volid));
893 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
894 fprintf(STDOUT, "part\t\t%s\n", pname);
895 fprintf(STDOUT, "status\t\tOK\n");
896 fprintf(STDOUT, "backupID\t%lu\n",
897 afs_printable_uint32_lu(a_xInfoP->backupID));
898 fprintf(STDOUT, "parentID\t%lu\n",
899 afs_printable_uint32_lu(a_xInfoP->parentID));
900 fprintf(STDOUT, "cloneID\t\t%lu\n",
901 afs_printable_uint32_lu(a_xInfoP->cloneID));
902 fprintf(STDOUT, "inUse\t\t%s\n", a_xInfoP->inUse ? "Y" : "N");
903 switch (a_xInfoP->type) {
905 fprintf(STDOUT, "type\t\tRW\n");
908 fprintf(STDOUT, "type\t\tRO\n");
911 fprintf(STDOUT, "type\t\tBK\n");
914 fprintf(STDOUT, "type\t\t?\n");
917 t = a_xInfoP->creationDate;
918 fprintf(STDOUT, "creationDate\t%-9lu\t%s",
919 afs_printable_uint32_lu(a_xInfoP->creationDate),
922 t = a_xInfoP->accessDate;
923 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
924 afs_printable_uint32_lu(a_xInfoP->accessDate),
927 t = a_xInfoP->updateDate;
928 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
929 afs_printable_uint32_lu(a_xInfoP->updateDate),
932 t = a_xInfoP->backupDate;
933 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
934 afs_printable_uint32_lu(a_xInfoP->backupDate),
937 t = a_xInfoP->copyDate;
938 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
939 afs_printable_uint32_lu(a_xInfoP->copyDate),
942 fprintf(STDOUT, "diskused\t%u\n", a_xInfoP->size);
943 fprintf(STDOUT, "maxquota\t%u\n", a_xInfoP->maxquota);
945 fprintf(STDOUT, "filecount\t%u\n", a_xInfoP->filecount);
946 fprintf(STDOUT, "dayUse\t\t%u\n", a_xInfoP->dayUse);
950 fprintf(STDOUT,"reads_same_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET]);
951 fprintf(STDOUT,"reads_same_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH]);
952 fprintf(STDOUT,"reads_diff_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET]);
953 fprintf(STDOUT,"reads_diff_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
955 fprintf(STDOUT,"writes_same_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET]);
956 fprintf(STDOUT,"writes_same_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH]);
957 fprintf(STDOUT,"writes_diff_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET]);
958 fprintf(STDOUT,"writes_diff_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
962 fprintf(STDOUT,"file_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileSameAuthor[ai[i]]);
963 fprintf(STDOUT,"file_diff_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileDiffAuthor[ai[i]]);
964 fprintf(STDOUT,"dir_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirSameAuthor[ai[i]]);
965 fprintf(STDOUT,"dir_dif_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirDiffAuthor[ai[i]]);
968 } /*Volume status OK */
969 else if (a_xInfoP->status == VBUSY) {
971 qPut(&busyHead, a_xInfoP->volid);
973 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
974 (unsigned long)a_xInfoP->volid);
978 qPut(¬okHead, a_xInfoP->volid);
980 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
981 (unsigned long)a_xInfoP->volid);
982 } /*Screwed volume */
988 if (a_xInfoP->status == VOK) {
989 fprintf(STDOUT, "name\t%-32s\n", a_xInfoP->name);
990 fprintf(STDOUT, "volID\t%10lu\n", (unsigned long)a_xInfoP->volid);
991 if (a_xInfoP->type == 0)
992 fprintf(STDOUT, "type\tRW\n");
993 if (a_xInfoP->type == 1)
994 fprintf(STDOUT, "type\tRO\n");
995 if (a_xInfoP->type == 2)
996 fprintf(STDOUT, "type\tBK\n");
997 fprintf(STDOUT, "size\t%10dK\n", a_xInfoP->size);
999 fprintf(STDOUT, "inUse\t%d\n",a_xInfoP->inUse);
1000 if (a_xInfoP->inUse == 1)
1006 else if (a_xInfoP->status == VBUSY) {
1008 qPut(&busyHead, a_xInfoP->volid);
1010 fprintf(STDOUT, "VOLUME_BUSY\t%lu\n",
1011 (unsigned long)a_xInfoP->volid);
1015 qPut(¬okHead, a_xInfoP->volid);
1017 fprintf(STDOUT, "COULD_NOT_ATTACH_VOLUME\t%lu\n",
1018 (unsigned long)a_xInfoP->volid);
1019 } /*Screwed volume */
1020 } /*Default listing */
1021 } /*XDisplayFormat */
1022 #endif /*FULL_LISTVOL_SWITCH*/
1024 #ifdef FULL_LISTVOL_SWITCH
1026 DisplayFormat2(long server, long partition, volintInfo *pntr)
1028 static long server_cache = -1, partition_cache = -1;
1029 static char hostname[256], address[32], pname[16];
1032 if (server != server_cache) {
1036 strcpy(hostname, hostutil_GetNameByINet(server));
1037 strcpy(address, inet_ntoa(s));
1038 server_cache = server;
1040 if (partition != partition_cache) {
1041 MapPartIdIntoName(partition, pname);
1042 partition_cache = partition;
1045 if (pntr->status == VOK)
1046 fprintf(STDOUT, "name\t\t%s\n", pntr->name);
1048 fprintf(STDOUT, "id\t\t%lu\n",
1049 afs_printable_uint32_lu(pntr->volid));
1050 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
1051 fprintf(STDOUT, "part\t\t%s\n", pname);
1052 switch (pntr->status) {
1054 fprintf(STDOUT, "status\t\tOK\n");
1057 fprintf(STDOUT, "status\t\tBUSY\n");
1060 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
1063 fprintf(STDOUT, "backupID\t%lu\n",
1064 afs_printable_uint32_lu(pntr->backupID));
1065 fprintf(STDOUT, "parentID\t%lu\n",
1066 afs_printable_uint32_lu(pntr->parentID));
1067 fprintf(STDOUT, "cloneID\t\t%lu\n",
1068 afs_printable_uint32_lu(pntr->cloneID));
1069 fprintf(STDOUT, "inUse\t\t%s\n", pntr->inUse ? "Y" : "N");
1070 fprintf(STDOUT, "needsSalvaged\t%s\n", pntr->needsSalvaged ? "Y" : "N");
1071 /* 0xD3 is from afs/volume.h since I had trouble including the file */
1072 fprintf(STDOUT, "destroyMe\t%s\n", pntr->destroyMe == 0xD3 ? "Y" : "N");
1073 switch (pntr->type) {
1075 fprintf(STDOUT, "type\t\tRW\n");
1078 fprintf(STDOUT, "type\t\tRO\n");
1081 fprintf(STDOUT, "type\t\tBK\n");
1084 fprintf(STDOUT, "type\t\t?\n");
1087 t = pntr->creationDate;
1088 fprintf(STDOUT, "creationDate\t%-9lu\t%s",
1089 afs_printable_uint32_lu(pntr->creationDate),
1092 t = pntr->accessDate;
1093 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
1094 afs_printable_uint32_lu(pntr->accessDate),
1097 t = pntr->updateDate;
1098 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
1099 afs_printable_uint32_lu(pntr->updateDate),
1102 t = pntr->backupDate;
1103 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
1104 afs_printable_uint32_lu(pntr->backupDate),
1108 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
1109 afs_printable_uint32_lu(pntr->copyDate),
1112 fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n",
1113 afs_printable_uint32_lu(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_printable_uint32_lu(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_printable_uint32_lu(pntr->spare1));
1122 fprintf(STDOUT, "spare2\t\t%lu\t(Optional)\n",
1123 afs_printable_uint32_lu(pntr->spare2));
1124 fprintf(STDOUT, "spare3\t\t%lu\t(Optional)\n",
1125 afs_printable_uint32_lu(pntr->spare3));
1130 DisplayVolumes2(long server, long partition, volintInfo *pntr, long count)
1134 for (i = 0; i < count; i++) {
1135 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1136 DisplayFormat2(server, partition, pntr);
1137 fprintf(STDOUT, "END_OF_ENTRY\n\n");
1142 #endif /* FULL_LISTVOL_SWITCH */
1145 DisplayVolumes(afs_int32 server, afs_int32 part, volintInfo *pntr,
1146 afs_int32 count, afs_int32 longlist, afs_int32 fast,
1149 int totalOK, totalNotOK, totalBusy, i;
1150 afs_uint32 volid = 0;
1157 for (i = 0; i < count; i++) {
1158 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy,
1163 while (busyHead.count) {
1164 qGet(&busyHead, &volid);
1165 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1166 (unsigned long)volid);
1170 while (notokHead.count) {
1171 qGet(¬okHead, &volid);
1172 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1173 (unsigned long)volid);
1177 fprintf(STDOUT, "\n");
1180 "Total volumes onLine %d ; Total volumes offLine %d ; Total busy %d\n\n",
1181 totalOK, totalNotOK, totalBusy);
1185 /*------------------------------------------------------------------------
1186 * PRIVATE XDisplayVolumes
1189 * Display extended volume information.
1192 * a_servID : Pointer to the Rx call we're performing.
1193 * a_partID : Partition for which we want the extended list.
1194 * a_xInfoP : Ptr to extended volume info.
1195 * a_count : Number of volume records contained above.
1196 * a_int32 : Int32 listing generated?
1197 * a_fast : Fast listing generated?
1198 * a_quiet : Quiet listing generated?
1204 * Nothing interesting.
1208 *------------------------------------------------------------------------*/
1211 XDisplayVolumes(afs_int32 a_servID, afs_int32 a_partID, volintXInfo *a_xInfoP,
1212 afs_int32 a_count, afs_int32 a_int32, afs_int32 a_fast,
1214 { /*XDisplayVolumes */
1216 int totalOK; /*Total OK volumes */
1217 int totalNotOK; /*Total screwed volumes */
1218 int totalBusy; /*Total busy volumes */
1219 int i; /*Loop variable */
1220 afs_uint32 volid = 0; /*Current volume ID */
1223 * Initialize counters and (global!!) queues.
1232 * Display each volume in the list.
1234 for (i = 0; i < a_count; i++) {
1235 XDisplayFormat(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1236 &totalBusy, a_fast, a_int32, 0);
1241 * If any volumes were found to be busy or screwed, display them.
1244 while (busyHead.count) {
1245 qGet(&busyHead, &volid);
1246 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1247 (unsigned long)volid);
1251 while (notokHead.count) {
1252 qGet(¬okHead, &volid);
1253 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1254 (unsigned long)volid);
1259 fprintf(STDOUT, "\n");
1262 "Total volumes: %d on-line, %d off-line, %d busyd\n\n",
1263 totalOK, totalNotOK, totalBusy);
1267 } /*XDisplayVolumes */
1268 #ifdef FULL_LISTVOL_SWITCH
1269 /*------------------------------------------------------------------------
1270 * PRIVATE XDisplayVolumes2
1273 * Display extended formated volume information.
1276 * a_servID : Pointer to the Rx call we're performing.
1277 * a_partID : Partition for which we want the extended list.
1278 * a_xInfoP : Ptr to extended volume info.
1279 * a_count : Number of volume records contained above.
1280 * a_int32 : Int32 listing generated?
1281 * a_fast : Fast listing generated?
1282 * a_quiet : Quiet listing generated?
1288 * Nothing interesting.
1292 *------------------------------------------------------------------------*/
1295 XDisplayVolumes2(afs_int32 a_servID, afs_int32 a_partID, volintXInfo *a_xInfoP,
1296 afs_int32 a_count, afs_int32 a_int32, afs_int32 a_fast,
1298 { /*XDisplayVolumes */
1300 int totalOK; /*Total OK volumes */
1301 int totalNotOK; /*Total screwed volumes */
1302 int totalBusy; /*Total busy volumes */
1303 int i; /*Loop variable */
1304 afs_uint32 volid = 0; /*Current volume ID */
1307 * Initialize counters and (global!!) queues.
1316 * Display each volume in the list.
1318 for (i = 0; i < a_count; i++) {
1319 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1320 XDisplayFormat2(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1321 &totalBusy, a_fast, a_int32, 0);
1322 fprintf(STDOUT, "END_OF_ENTRY\n");
1327 * If any volumes were found to be busy or screwed, display them.
1330 while (busyHead.count) {
1331 qGet(&busyHead, &volid);
1332 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
1333 (unsigned long)volid);
1337 while (notokHead.count) {
1338 qGet(¬okHead, &volid);
1339 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
1340 (unsigned long)volid);
1345 fprintf(STDOUT, "\n");
1348 "VOLUMES_ONLINE\t%d\nVOLUMES_OFFLINE\t%d\nVOLUMES_BUSY\t%d\n",
1349 totalOK, totalNotOK, totalBusy);
1353 } /*XDisplayVolumes2 */
1354 #endif /* FULL_LISTVOL_SWITCH */
1357 /* set <server> and <part> to the correct values depending on
1358 * <voltype> and <entry> */
1360 GetServerAndPart(struct nvldbentry *entry, int voltype, afs_int32 *server,
1361 afs_int32 *part, int *previdx)
1363 int i, istart, vtype;
1368 /* Doesn't check for non-existance of backup volume */
1369 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
1371 istart = 0; /* seach the entire entry */
1374 /* Seach from beginning of entry or pick up where we left off */
1375 istart = ((*previdx < 0) ? 0 : *previdx + 1);
1378 for (i = istart; i < entry->nServers; i++) {
1379 if (entry->serverFlags[i] & vtype) {
1380 *server = entry->serverNumber[i];
1381 *part = entry->serverPartition[i];
1387 /* Didn't find any, return -1 */
1393 PostVolumeStats(struct nvldbentry *entry)
1395 SubEnumerateEntry(entry);
1396 /* Check for VLOP_ALLOPERS */
1397 if (entry->flags & VLOP_ALLOPERS)
1398 fprintf(STDOUT, " Volume is currently LOCKED \n");
1402 /*------------------------------------------------------------------------
1403 * PRIVATE XVolumeStats
1406 * Display extended volume information.
1409 * a_xInfoP : Ptr to extended volume info.
1410 * a_entryP : Ptr to the volume's VLDB entry.
1411 * a_srvID : Server ID.
1412 * a_partID : Partition ID.
1413 * a_volType : Type of volume to print.
1419 * Nothing interesting.
1423 *------------------------------------------------------------------------*/
1426 XVolumeStats(volintXInfo *a_xInfoP, struct nvldbentry *a_entryP,
1427 afs_int32 a_srvID, afs_int32 a_partID, int a_volType)
1430 int totalOK, totalNotOK, totalBusy; /*Dummies - we don't really count here */
1432 XDisplayFormat(a_xInfoP, /*Ptr to extended volume info */
1433 a_srvID, /*Server ID to print */
1434 a_partID, /*Partition ID to print */
1435 &totalOK, /*Ptr to total-OK counter */
1436 &totalNotOK, /*Ptr to total-screwed counter */
1437 &totalBusy, /*Ptr to total-busy counter */
1438 0, /*Don't do a fast listing */
1439 1, /*Do a long listing */
1440 1); /*Show volume problems */
1446 VolumeStats_int(volintInfo *pntr, struct nvldbentry *entry, afs_int32 server,
1447 afs_int32 part, int voltype)
1449 int totalOK, totalNotOK, totalBusy;
1451 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy, 0, 1,
1456 /* command to forcibly remove a volume */
1458 NukeVolume(register struct cmd_syndesc *as)
1460 register afs_int32 code;
1467 server = GetServer(tp = as->parms[0].items->data);
1469 fprintf(STDERR, "vos: server '%s' not found in host table\n", tp);
1473 partID = volutil_GetPartitionID(tp = as->parms[1].items->data);
1475 fprintf(STDERR, "vos: could not parse '%s' as a partition name", tp);
1479 volID = vsu_GetVolumeID(tp = as->parms[2].items->data, cstruct, &err);
1482 PrintError("", err);
1485 "vos: could not parse '%s' as a numeric volume ID", tp);
1490 "vos: forcibly removing all traces of volume %d, please wait...",
1493 code = UV_NukeVolume(server, partID, volID);
1495 fprintf(STDOUT, "done.\n");
1497 fprintf(STDOUT, "failed with code %d.\n", code);
1502 /*------------------------------------------------------------------------
1503 * PRIVATE ExamineVolume
1506 * Routine used to examine a single volume, contacting the VLDB as
1507 * well as the Volume Server.
1510 * as : Ptr to parsed command line arguments.
1513 * 0 for a successful operation,
1514 * Otherwise, one of the ubik or VolServer error values.
1517 * Nothing interesting.
1521 *------------------------------------------------------------------------
1524 ExamineVolume(register struct cmd_syndesc *as, void *arock)
1526 struct nvldbentry entry;
1527 afs_int32 vcode = 0;
1528 volintInfo *pntr = (volintInfo *) 0;
1529 volintXInfo *xInfoP = (volintXInfo *) 0;
1531 afs_int32 code, err, error = 0;
1532 int voltype, foundserv = 0, foundentry = 0;
1533 afs_int32 aserver, apart;
1535 int wantExtendedInfo; /*Do we want extended vol info? */
1537 wantExtendedInfo = (as->parms[1].items ? 1 : 0); /* -extended */
1539 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1542 PrintError("", err);
1544 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1545 as->parms[0].items->data);
1550 fprintf(STDOUT, "Fetching VLDB entry for %lu .. ",
1551 (unsigned long)volid);
1554 vcode = VLDB_GetEntryByID(volid, -1, &entry);
1557 "Could not fetch the entry for volume number %lu from VLDB \n",
1558 (unsigned long)volid);
1562 fprintf(STDOUT, "done\n");
1563 MapHostToNetwork(&entry);
1565 if (entry.volumeId[RWVOL] == volid)
1567 else if (entry.volumeId[BACKVOL] == volid)
1569 else /* (entry.volumeId[ROVOL] == volid) */
1572 do { /* do {...} while (voltype == ROVOL) */
1573 /* Get the entry for the volume. If its a RW vol, get the RW entry.
1574 * It its a BK vol, get the RW entry (even if VLDB may say the BK doen't exist).
1575 * If its a RO vol, get the next RO entry.
1577 GetServerAndPart(&entry, ((voltype == ROVOL) ? ROVOL : RWVOL),
1578 &aserver, &apart, &previdx);
1579 if (previdx == -1) { /* searched all entries */
1581 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1582 as->parms[0].items->data);
1589 /* Get information about the volume from the server */
1591 fprintf(STDOUT, "Getting volume listing from the server %s .. ",
1592 hostutil_GetNameByINet(aserver));
1595 if (wantExtendedInfo)
1596 code = UV_XListOneVolume(aserver, apart, volid, &xInfoP);
1598 code = UV_ListOneVolume(aserver, apart, volid, &pntr);
1600 fprintf(STDOUT, "done\n");
1604 if (code == ENODEV) {
1605 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1606 /* The VLDB says there is no backup volume and its not on disk */
1607 fprintf(STDERR, "Volume %s does not exist\n",
1608 as->parms[0].items->data);
1612 "Volume does not exist on server %s as indicated by the VLDB\n",
1613 hostutil_GetNameByINet(aserver));
1616 PrintDiagnostics("examine", code);
1618 fprintf(STDOUT, "\n");
1621 if (wantExtendedInfo)
1622 XVolumeStats(xInfoP, &entry, aserver, apart, voltype);
1624 #ifdef FULL_LISTVOL_SWITCH
1625 if (as->parms[2].items) {
1626 DisplayFormat2(aserver, apart, pntr);
1627 EnumerateEntry(&entry);
1629 #endif /* FULL_LISTVOL_SWITCH */
1630 VolumeStats_int(pntr, &entry, aserver, apart, voltype);
1632 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1633 /* The VLDB says there is no backup volume yet we found one on disk */
1634 fprintf(STDERR, "Volume %s does not exist in VLDB\n",
1635 as->parms[0].items->data);
1644 } while (voltype == ROVOL);
1647 fprintf(STDERR, "Dump only information from VLDB\n\n");
1648 fprintf(STDOUT, "%s \n", entry.name); /* PostVolumeStats doesn't print name */
1650 PostVolumeStats(&entry);
1655 /*------------------------------------------------------------------------
1659 * Routine used to change the status of a single volume.
1662 * as : Ptr to parsed command line arguments.
1665 * 0 for a successful operation,
1666 * Otherwise, one of the ubik or VolServer error values.
1669 * Nothing interesting.
1673 *------------------------------------------------------------------------
1676 SetFields(register struct cmd_syndesc *as, void *arock)
1678 struct nvldbentry entry;
1681 afs_int32 code, err;
1682 afs_int32 aserver, apart;
1685 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1688 PrintError("", err);
1690 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1691 as->parms[0].items->data);
1695 code = VLDB_GetEntryByID(volid, RWVOL, &entry);
1698 "Could not fetch the entry for volume number %lu from VLDB \n",
1699 (unsigned long)volid);
1702 MapHostToNetwork(&entry);
1704 GetServerAndPart(&entry, RWVOL, &aserver, &apart, &previdx);
1705 if (previdx == -1) {
1706 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1707 as->parms[0].items->data);
1711 init_volintInfo(&info);
1715 if (as->parms[1].items) {
1717 code = util_GetHumanInt32(as->parms[1].items->data, &info.maxquota);
1719 fprintf(STDERR, "invalid quota value\n");
1723 if (as->parms[2].items) {
1727 if (as->parms[3].items) {
1728 /* -clearVolUpCounter */
1731 code = UV_SetVolumeInfo(aserver, apart, volid, &info);
1734 "Could not update volume info fields for volume number %lu\n",
1735 (unsigned long)volid);
1739 /*------------------------------------------------------------------------
1743 * Brings a volume online.
1746 * as : Ptr to parsed command line arguments.
1749 * 0 for a successful operation,
1752 * Nothing interesting.
1756 *------------------------------------------------------------------------
1759 volOnline(register struct cmd_syndesc *as, void *arock)
1761 afs_int32 server, partition;
1763 afs_int32 code, err = 0;
1765 server = GetServer(as->parms[0].items->data);
1767 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1768 as->parms[0].items->data);
1772 partition = volutil_GetPartitionID(as->parms[1].items->data);
1773 if (partition < 0) {
1774 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1775 as->parms[1].items->data);
1779 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1782 PrintError("", err);
1784 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1785 as->parms[0].items->data);
1789 code = UV_SetVolume(server, partition, volid, ITOffline, 0 /*online */ ,
1792 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1799 /*------------------------------------------------------------------------
1800 * PRIVATE volOffline
1803 * Brings a volume offline.
1806 * as : Ptr to parsed command line arguments.
1809 * 0 for a successful operation,
1812 * Nothing interesting.
1816 *------------------------------------------------------------------------
1819 volOffline(register struct cmd_syndesc *as, void *arock)
1821 afs_int32 server, partition;
1823 afs_int32 code, err = 0;
1824 afs_int32 transflag, sleeptime, transdone;
1826 server = GetServer(as->parms[0].items->data);
1828 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1829 as->parms[0].items->data);
1833 partition = volutil_GetPartitionID(as->parms[1].items->data);
1834 if (partition < 0) {
1835 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1836 as->parms[1].items->data);
1840 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1843 PrintError("", err);
1845 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1846 as->parms[0].items->data);
1850 transflag = (as->parms[4].items ? ITBusy : ITOffline);
1851 sleeptime = (as->parms[3].items ? atol(as->parms[3].items->data) : 0);
1852 transdone = (sleeptime ? 0 /*online */ : VTOutOfService);
1853 if (as->parms[4].items && !as->parms[3].items) {
1854 fprintf(STDERR, "-sleep option must be used with -busy flag\n");
1859 UV_SetVolume(server, partition, volid, transflag, transdone,
1862 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1870 CreateVolume(register struct cmd_syndesc *as, void *arock)
1874 afs_uint32 volid = 0, rovolid = 0, bkvolid = 0;
1875 afs_uint32 *arovolid;
1877 struct nvldbentry entry;
1881 arovolid = &rovolid;
1884 tserver = GetServer(as->parms[0].items->data);
1886 fprintf(STDERR, "vos: host '%s' not found in host table\n",
1887 as->parms[0].items->data);
1890 pnum = volutil_GetPartitionID(as->parms[1].items->data);
1892 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1893 as->parms[1].items->data);
1896 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
1898 PrintError("", code);
1901 "vos : partition %s does not exist on the server\n",
1902 as->parms[1].items->data);
1905 if (!ISNAMEVALID(as->parms[2].items->data)) {
1907 "vos: the name of the root volume %s exceeds the size limit of %d\n",
1908 as->parms[2].items->data, VOLSER_OLDMAXVOLNAME - 10);
1911 if (!VolNameOK(as->parms[2].items->data)) {
1913 "Illegal volume name %s, should not end in .readonly or .backup\n",
1914 as->parms[2].items->data);
1917 if (IsNumeric(as->parms[2].items->data)) {
1918 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
1919 as->parms[2].items->data);
1922 vcode = VLDB_GetEntryByName(as->parms[2].items->data, &entry);
1924 fprintf(STDERR, "Volume %s already exists\n",
1925 as->parms[2].items->data);
1926 PrintDiagnostics("create", code);
1930 if (as->parms[3].items) {
1931 code = util_GetHumanInt32(as->parms[3].items->data, "a);
1933 fprintf(STDERR, "vos: bad integer specified for quota.\n");
1938 if (as->parms[4].items) {
1939 if (!IsNumeric(as->parms[4].items->data)) {
1940 fprintf(STDERR, "vos: Given volume ID %s should be numeric.\n",
1941 as->parms[4].items->data);
1945 code = util_GetInt32(as->parms[4].items->data, &volid);
1947 fprintf(STDERR, "vos: bad integer specified for volume ID.\n");
1952 if (as->parms[5].items) {
1953 if (!IsNumeric(as->parms[5].items->data)) {
1954 fprintf(STDERR, "vos: Given RO volume ID %s should be numeric.\n",
1955 as->parms[5].items->data);
1959 code = util_GetInt32(as->parms[5].items->data, &rovolid);
1961 fprintf(STDERR, "vos: bad integer specified for volume ID.\n");
1971 UV_CreateVolume3(tserver, pnum, as->parms[2].items->data, quota, 0,
1972 0, 0, 0, &volid, arovolid, &bkvolid);
1974 PrintDiagnostics("create", code);
1977 MapPartIdIntoName(pnum, part);
1978 fprintf(STDOUT, "Volume %lu created on partition %s of %s\n",
1979 (unsigned long)volid, part, as->parms[0].items->data);
1986 DeleteAll(struct nvldbentry *entry)
1989 afs_int32 error, code, curserver, curpart;
1992 MapHostToNetwork(entry);
1994 for (i = 0; i < entry->nServers; i++) {
1995 curserver = entry->serverNumber[i];
1996 curpart = entry->serverPartition[i];
1997 if (entry->serverFlags[i] & ITSROVOL) {
1998 volid = entry->volumeId[ROVOL];
2000 volid = entry->volumeId[RWVOL];
2002 code = UV_DeleteVolume(curserver, curpart, volid);
2011 DeleteVolume(struct cmd_syndesc *as, void *arock)
2013 afs_int32 err, code = 0;
2014 afs_int32 server = 0, partition = -1;
2019 if (as->parms[0].items) {
2020 server = GetServer(as->parms[0].items->data);
2022 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2023 as->parms[0].items->data);
2028 if (as->parms[1].items) {
2029 partition = volutil_GetPartitionID(as->parms[1].items->data);
2030 if (partition < 0) {
2031 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2032 as->parms[1].items->data);
2036 /* Check for validity of the partition */
2037 if (!IsPartValid(partition, server, &code)) {
2039 PrintError("", code);
2042 "vos : partition %s does not exist on the server\n",
2043 as->parms[1].items->data);
2049 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
2051 fprintf(STDERR, "Can't find volume name '%s' in VLDB\n",
2052 as->parms[2].items->data);
2054 PrintError("", err);
2058 /* If the server or partition option are not complete, try to fill
2059 * them in from the VLDB entry.
2061 if ((partition == -1) || !server) {
2062 struct nvldbentry entry;
2064 code = VLDB_GetEntryByID(volid, -1, &entry);
2067 "Could not fetch the entry for volume %lu from VLDB\n",
2068 (unsigned long)volid);
2069 PrintError("", code);
2073 if (((volid == entry.volumeId[RWVOL]) && (entry.flags & RW_EXISTS))
2074 || ((volid == entry.volumeId[BACKVOL])
2075 && (entry.flags & BACK_EXISTS))) {
2076 idx = Lp_GetRwIndex(&entry);
2077 if ((idx == -1) || (server && (server != entry.serverNumber[idx]))
2078 || ((partition != -1)
2079 && (partition != entry.serverPartition[idx]))) {
2080 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2081 as->parms[2].items->data);
2084 } else if ((volid == entry.volumeId[ROVOL])
2085 && (entry.flags & RO_EXISTS)) {
2086 for (idx = -1, j = 0; j < entry.nServers; j++) {
2087 if (entry.serverFlags[j] != ITSROVOL)
2090 if (((server == 0) || (server == entry.serverNumber[j]))
2091 && ((partition == -1)
2092 || (partition == entry.serverPartition[j]))) {
2095 "VLDB: Volume '%s' matches more than one RO\n",
2096 as->parms[2].items->data);
2103 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2104 as->parms[2].items->data);
2108 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2109 as->parms[2].items->data);
2113 server = htonl(entry.serverNumber[idx]);
2114 partition = entry.serverPartition[idx];
2118 code = UV_DeleteVolume(server, partition, volid);
2120 PrintDiagnostics("remove", code);
2124 MapPartIdIntoName(partition, pname);
2125 fprintf(STDOUT, "Volume %lu on partition %s server %s deleted\n",
2126 (unsigned long)volid, pname, hostutil_GetNameByINet(server));
2130 #define TESTM 0 /* set for move space tests, clear for production */
2132 MoveVolume(register struct cmd_syndesc *as, void *arock)
2136 afs_int32 fromserver, toserver, frompart, topart;
2137 afs_int32 flags, code, err;
2138 char fromPartName[10], toPartName[10];
2140 struct diskPartition64 partition; /* for space check */
2143 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2146 PrintError("", err);
2148 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2149 as->parms[0].items->data);
2152 fromserver = GetServer(as->parms[1].items->data);
2153 if (fromserver == 0) {
2154 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2155 as->parms[1].items->data);
2158 toserver = GetServer(as->parms[3].items->data);
2159 if (toserver == 0) {
2160 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2161 as->parms[3].items->data);
2164 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2166 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2167 as->parms[2].items->data);
2170 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2172 PrintError("", code);
2175 "vos : partition %s does not exist on the server\n",
2176 as->parms[2].items->data);
2179 topart = volutil_GetPartitionID(as->parms[4].items->data);
2181 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2182 as->parms[4].items->data);
2185 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2187 PrintError("", code);
2190 "vos : partition %s does not exist on the server\n",
2191 as->parms[4].items->data);
2196 if (as->parms[5].items) flags |= RV_NOCLONE;
2199 * check source partition for space to clone volume
2202 MapPartIdIntoName(topart, toPartName);
2203 MapPartIdIntoName(frompart, fromPartName);
2206 * check target partition for space to move volume
2209 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2211 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2215 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2218 p = (volintInfo *) 0;
2219 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2221 fprintf(STDERR, "vos:cannot access volume %lu\n",
2222 (unsigned long)volid);
2226 fprintf(STDOUT, "volume %lu size %d\n", (unsigned long)volid,
2228 if (partition.free <= p->size) {
2230 "vos: no space on target partition %s to move volume %lu\n",
2231 toPartName, (unsigned long)volid);
2238 fprintf(STDOUT, "size test - don't do move\n");
2242 /* successful move still not guaranteed but shoot for it */
2245 UV_MoveVolume2(volid, fromserver, frompart, toserver, topart, flags);
2247 PrintDiagnostics("move", code);
2250 MapPartIdIntoName(topart, toPartName);
2251 MapPartIdIntoName(frompart, fromPartName);
2252 fprintf(STDOUT, "Volume %lu moved from %s %s to %s %s \n",
2253 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2254 as->parms[3].items->data, toPartName);
2260 CopyVolume(register struct cmd_syndesc *as, void *arock)
2263 afs_int32 fromserver, toserver, frompart, topart, code, err, flags;
2264 char fromPartName[10], toPartName[10], *tovolume;
2265 struct nvldbentry entry;
2266 struct diskPartition64 partition; /* for space check */
2269 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2272 PrintError("", err);
2274 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2275 as->parms[0].items->data);
2278 fromserver = GetServer(as->parms[1].items->data);
2279 if (fromserver == 0) {
2280 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2281 as->parms[1].items->data);
2285 toserver = GetServer(as->parms[4].items->data);
2286 if (toserver == 0) {
2287 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2288 as->parms[4].items->data);
2292 tovolume = as->parms[3].items->data;
2293 if (!ISNAMEVALID(tovolume)) {
2295 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2296 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2299 if (!VolNameOK(tovolume)) {
2301 "Illegal volume name %s, should not end in .readonly or .backup\n",
2305 if (IsNumeric(tovolume)) {
2306 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
2310 code = VLDB_GetEntryByName(tovolume, &entry);
2312 fprintf(STDERR, "Volume %s already exists\n", tovolume);
2313 PrintDiagnostics("copy", code);
2317 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2319 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2320 as->parms[2].items->data);
2323 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2325 PrintError("", code);
2328 "vos : partition %s does not exist on the server\n",
2329 as->parms[2].items->data);
2333 topart = volutil_GetPartitionID(as->parms[5].items->data);
2335 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2336 as->parms[5].items->data);
2339 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2341 PrintError("", code);
2344 "vos : partition %s does not exist on the server\n",
2345 as->parms[5].items->data);
2350 if (as->parms[6].items) flags |= RV_OFFLINE;
2351 if (as->parms[7].items) flags |= RV_RDONLY;
2352 if (as->parms[8].items) flags |= RV_NOCLONE;
2354 MapPartIdIntoName(topart, toPartName);
2355 MapPartIdIntoName(frompart, fromPartName);
2358 * check target partition for space to move volume
2361 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2363 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2367 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2370 p = (volintInfo *) 0;
2371 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2373 fprintf(STDERR, "vos:cannot access volume %lu\n",
2374 (unsigned long)volid);
2378 if (partition.free <= p->size) {
2380 "vos: no space on target partition %s to copy volume %lu\n",
2381 toPartName, (unsigned long)volid);
2387 /* successful copy still not guaranteed but shoot for it */
2390 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2393 PrintDiagnostics("copy", code);
2396 MapPartIdIntoName(topart, toPartName);
2397 MapPartIdIntoName(frompart, fromPartName);
2398 fprintf(STDOUT, "Volume %lu copied from %s %s to %s on %s %s \n",
2399 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2400 tovolume, as->parms[4].items->data, toPartName);
2407 ShadowVolume(register struct cmd_syndesc *as, void *arock)
2409 afs_uint32 volid, tovolid;
2410 afs_int32 fromserver, toserver, frompart, topart;
2411 afs_int32 code, err, flags;
2412 char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
2413 struct diskPartition64 partition; /* for space check */
2416 p = (volintInfo *) 0;
2417 q = (volintInfo *) 0;
2419 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2422 PrintError("", err);
2424 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2425 as->parms[0].items->data);
2428 fromserver = GetServer(as->parms[1].items->data);
2429 if (fromserver == 0) {
2430 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2431 as->parms[1].items->data);
2435 toserver = GetServer(as->parms[3].items->data);
2436 if (toserver == 0) {
2437 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2438 as->parms[3].items->data);
2442 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2444 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2445 as->parms[2].items->data);
2448 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2450 PrintError("", code);
2453 "vos : partition %s does not exist on the server\n",
2454 as->parms[2].items->data);
2458 topart = volutil_GetPartitionID(as->parms[4].items->data);
2460 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2461 as->parms[4].items->data);
2464 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2466 PrintError("", code);
2469 "vos : partition %s does not exist on the server\n",
2470 as->parms[4].items->data);
2474 if (as->parms[5].items) {
2475 tovolume = as->parms[5].items->data;
2476 if (!ISNAMEVALID(tovolume)) {
2478 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2479 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2482 if (!VolNameOK(tovolume)) {
2484 "Illegal volume name %s, should not end in .readonly or .backup\n",
2488 if (IsNumeric(tovolume)) {
2490 "Illegal volume name %s, should not be a number\n",
2495 /* use actual name of source volume */
2496 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2498 fprintf(STDERR, "vos:cannot access volume %lu\n",
2499 (unsigned long)volid);
2502 strcpy(toVolName, p->name);
2503 tovolume = toVolName;
2504 /* save p for size checks later */
2507 if (as->parms[6].items) {
2508 tovolid = vsu_GetVolumeID(as->parms[6].items->data, cstruct, &err);
2511 PrintError("", err);
2513 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2514 as->parms[6].items->data);
2520 tovolid = vsu_GetVolumeID(tovolume, cstruct, &err);
2523 PrintError("", err);
2525 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2534 if (as->parms[7].items) flags |= RV_OFFLINE;
2535 if (as->parms[8].items) flags |= RV_RDONLY;
2536 if (as->parms[9].items) flags |= RV_NOCLONE;
2537 if (as->parms[10].items) flags |= RV_CPINCR;
2539 MapPartIdIntoName(topart, toPartName);
2540 MapPartIdIntoName(frompart, fromPartName);
2543 * check target partition for space to move volume
2546 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2548 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2552 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2555 /* Don't do this again if we did it above */
2557 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2559 fprintf(STDERR, "vos:cannot access volume %lu\n",
2560 (unsigned long)volid);
2565 /* OK if this fails */
2566 code = UV_ListOneVolume(toserver, topart, tovolid, &q);
2568 /* Treat existing volume size as "free" */
2570 p->size = (q->size < p->size) ? p->size - q->size : 0;
2572 if (partition.free <= p->size) {
2574 "vos: no space on target partition %s to copy volume %lu\n",
2575 toPartName, (unsigned long)volid);
2583 /* successful copy still not guaranteed but shoot for it */
2586 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2587 topart, tovolid, flags);
2589 PrintDiagnostics("shadow", code);
2592 MapPartIdIntoName(topart, toPartName);
2593 MapPartIdIntoName(frompart, fromPartName);
2594 fprintf(STDOUT, "Volume %lu shadowed from %s %s to %s %s \n",
2595 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2596 as->parms[3].items->data, toPartName);
2603 CloneVolume(register struct cmd_syndesc *as, void *arock)
2605 afs_uint32 volid, cloneid;
2606 afs_int32 server, part, voltype;
2607 char partName[10], *volname;
2608 afs_int32 code, err, flags;
2609 struct nvldbentry entry;
2611 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2614 PrintError("", err);
2616 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2617 as->parms[0].items->data);
2621 if (as->parms[1].items || as->parms[2].items) {
2622 if (!as->parms[1].items || !as->parms[2].items) {
2624 "Must specify both -server and -partition options\n");
2627 server = GetServer(as->parms[1].items->data);
2629 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2630 as->parms[1].items->data);
2633 part = volutil_GetPartitionID(as->parms[2].items->data);
2635 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2636 as->parms[2].items->data);
2639 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
2641 PrintError("", code);
2644 "vos : partition %s does not exist on the server\n",
2645 as->parms[2].items->data);
2649 code = GetVolumeInfo(volid, &server, &part, &voltype, &entry);
2655 if (as->parms[3].items) {
2656 volname = as->parms[3].items->data;
2657 if (strlen(volname) > VOLSER_OLDMAXVOLNAME - 1) {
2659 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2660 volname, VOLSER_OLDMAXVOLNAME - 1);
2665 * In order that you be able to make clones of RO or BK, this
2666 * check must be omitted.
2668 if (!VolNameOK(volname)) {
2670 "Illegal volume name %s, should not end in .readonly or .backup\n",
2675 if (IsNumeric(volname)) {
2677 "Illegal volume name %s, should not be a number\n",
2684 if (as->parms[4].items) {
2685 cloneid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2688 PrintError("", err);
2690 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2691 as->parms[4].items->data);
2697 if (as->parms[5].items) flags |= RV_OFFLINE;
2698 if (as->parms[6].items) flags |= RV_RDONLY;
2702 UV_CloneVolume(server, part, volid, cloneid, volname, flags);
2705 PrintDiagnostics("clone", code);
2708 MapPartIdIntoName(part, partName);
2709 fprintf(STDOUT, "Created clone for volume %s\n",
2710 as->parms[0].items->data);
2717 BackupVolume(register struct cmd_syndesc *as, void *arock)
2720 afs_int32 aserver, apart, vtype, code, err;
2721 struct nvldbentry entry;
2724 afs_int32 buserver, bupart, butype;
2725 struct nvldbentry buentry;
2727 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2730 PrintError("", err);
2732 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2733 as->parms[0].items->data);
2736 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2740 /* verify this is a readwrite volume */
2742 if (vtype != RWVOL) {
2743 fprintf(STDERR, "%s not RW volume\n", as->parms[0].items->data);
2747 /* is there a backup volume already? */
2749 if (entry.flags & BACK_EXISTS) {
2750 /* yep, where is it? */
2752 buvolid = entry.volumeId[BACKVOL];
2753 code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
2758 code = VLDB_IsSameAddrs(buserver, aserver, &err);
2761 "Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
2767 "FATAL ERROR: backup volume %lu exists on server %lu\n",
2768 (unsigned long)buvolid, (unsigned long)buserver);
2773 /* nope, carry on */
2775 code = UV_BackupVolume(aserver, apart, avolid);
2778 PrintDiagnostics("backup", code);
2781 fprintf(STDOUT, "Created backup volume for %s \n",
2782 as->parms[0].items->data);
2787 ReleaseVolume(register struct cmd_syndesc *as, void *arock)
2790 struct nvldbentry entry;
2792 afs_int32 aserver, apart, vtype, code, err;
2795 if (as->parms[1].items)
2797 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2800 PrintError("", err);
2802 fprintf(STDERR, "vos: can't find volume '%s'\n",
2803 as->parms[0].items->data);
2806 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2810 if (vtype != RWVOL) {
2811 fprintf(STDERR, "%s not a RW volume\n", as->parms[0].items->data);
2815 if (!ISNAMEVALID(entry.name)) {
2817 "Volume name %s is too long, rename before releasing\n",
2822 code = UV_ReleaseVolume(avolid, aserver, apart, force);
2824 PrintDiagnostics("release", code);
2827 fprintf(STDOUT, "Released volume %s successfully\n",
2828 as->parms[0].items->data);
2833 DumpVolumeCmd(register struct cmd_syndesc *as, void *arock)
2836 afs_int32 aserver, apart, voltype, fromdate = 0, code, err, i, flags;
2837 char filename[MAXPATHLEN];
2838 struct nvldbentry entry;
2840 rx_SetRxDeadTime(60 * 10);
2841 for (i = 0; i < MAXSERVERS; i++) {
2842 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
2845 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
2846 if (rxConn->service)
2847 rxConn->service->connDeadTime = rx_connDeadTime;
2850 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2853 PrintError("", err);
2855 fprintf(STDERR, "vos: can't find volume '%s'\n",
2856 as->parms[0].items->data);
2860 if (as->parms[3].items || as->parms[4].items) {
2861 if (!as->parms[3].items || !as->parms[4].items) {
2863 "Must specify both -server and -partition options\n");
2866 aserver = GetServer(as->parms[3].items->data);
2868 fprintf(STDERR, "Invalid server name\n");
2871 apart = volutil_GetPartitionID(as->parms[4].items->data);
2873 fprintf(STDERR, "Invalid partition name\n");
2877 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
2882 if (as->parms[1].items && strcmp(as->parms[1].items->data, "0")) {
2883 code = ktime_DateToInt32(as->parms[1].items->data, &fromdate);
2885 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
2886 as->parms[1].items->data, code);
2890 if (as->parms[2].items) {
2891 strcpy(filename, as->parms[2].items->data);
2893 strcpy(filename, "");
2896 flags = as->parms[6].items ? VOLDUMPV2_OMITDIRS : 0;
2898 if (as->parms[5].items) {
2900 UV_DumpClonedVolume(avolid, aserver, apart, fromdate,
2901 DumpFunction, filename, flags);
2904 UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction,
2907 if ((code == RXGEN_OPCODE) && (as->parms[6].items)) {
2908 flags &= ~VOLDUMPV2_OMITDIRS;
2912 PrintDiagnostics("dump", code);
2915 if (strcmp(filename, ""))
2916 fprintf(STDERR, "Dumped volume %s in file %s\n",
2917 as->parms[0].items->data, filename);
2919 fprintf(STDERR, "Dumped volume %s in stdout \n",
2920 as->parms[0].items->data);
2934 RestoreVolumeCmd(register struct cmd_syndesc *as, void *arock)
2936 afs_uint32 avolid, aparentid;
2937 afs_int32 aserver, apart, code, vcode, err;
2938 afs_int32 aoverwrite = ASK;
2939 afs_int32 acreation = 0, alastupdate = 0;
2940 int restoreflags = 0;
2941 int readonly = 0, offline = 0, voltype = RWVOL;
2943 char afilename[MAXPATHLEN], avolname[VOLSER_MAXVOLNAME + 1], apartName[10];
2944 char volname[VOLSER_MAXVOLNAME + 1];
2945 struct nvldbentry entry;
2950 if (as->parms[4].items) {
2951 avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2954 PrintError("", err);
2956 fprintf(STDERR, "vos: can't find volume '%s'\n",
2957 as->parms[4].items->data);
2963 if (as->parms[5].items) {
2964 if ((strcmp(as->parms[5].items->data, "a") == 0)
2965 || (strcmp(as->parms[5].items->data, "abort") == 0)) {
2967 } else if ((strcmp(as->parms[5].items->data, "f") == 0)
2968 || (strcmp(as->parms[5].items->data, "full") == 0)) {
2970 } else if ((strcmp(as->parms[5].items->data, "i") == 0)
2971 || (strcmp(as->parms[5].items->data, "inc") == 0)
2972 || (strcmp(as->parms[5].items->data, "increment") == 0)
2973 || (strcmp(as->parms[5].items->data, "incremental") == 0)) {
2976 fprintf(STDERR, "vos: %s is not a valid argument to -overwrite\n",
2977 as->parms[5].items->data);
2981 if (as->parms[6].items)
2983 if (as->parms[7].items) {
2988 if (as->parms[8].items) {
2989 if ((strcmp(as->parms[8].items->data, "d") == 0)
2990 || (strcmp(as->parms[8].items->data, "dump") == 0)) {
2991 acreation = TS_DUMP;
2992 } else if ((strcmp(as->parms[8].items->data, "k") == 0)
2993 || (strcmp(as->parms[8].items->data, "keep") == 0)) {
2994 acreation = TS_KEEP;
2995 } else if ((strcmp(as->parms[8].items->data, "n") == 0)
2996 || (strcmp(as->parms[8].items->data, "new") == 0)) {
2999 fprintf(STDERR, "vos: %s is not a valid argument to -creation\n",
3000 as->parms[8].items->data);
3005 if (as->parms[9].items) {
3006 if ((strcmp(as->parms[9].items->data, "d") == 0)
3007 || (strcmp(as->parms[9].items->data, "dump") == 0)) {
3008 alastupdate = TS_DUMP;
3009 } else if ((strcmp(as->parms[9].items->data, "k") == 0)
3010 || (strcmp(as->parms[9].items->data, "keep") == 0)) {
3011 alastupdate = TS_KEEP;
3012 } else if ((strcmp(as->parms[9].items->data, "n") == 0)
3013 || (strcmp(as->parms[9].items->data, "new") == 0)) {
3014 alastupdate = TS_NEW;
3016 fprintf(STDERR, "vos: %s is not a valid argument to -lastupdate\n",
3017 as->parms[9].items->data);
3022 aserver = GetServer(as->parms[0].items->data);
3024 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3025 as->parms[0].items->data);
3028 apart = volutil_GetPartitionID(as->parms[1].items->data);
3030 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3031 as->parms[1].items->data);
3034 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3036 PrintError("", code);
3039 "vos : partition %s does not exist on the server\n",
3040 as->parms[1].items->data);
3043 strcpy(avolname, as->parms[2].items->data);
3044 if (!ISNAMEVALID(avolname)) {
3046 "vos: the name of the volume %s exceeds the size limit\n",
3050 if (!VolNameOK(avolname)) {
3052 "Illegal volume name %s, should not end in .readonly or .backup\n",
3056 if (as->parms[3].items) {
3057 strcpy(afilename, as->parms[3].items->data);
3058 if (!FileExists(afilename)) {
3059 fprintf(STDERR, "Can't access file %s\n", afilename);
3063 strcpy(afilename, "");
3066 /* Check if volume exists or not */
3068 vsu_ExtractName(volname, avolname);
3069 vcode = VLDB_GetEntryByName(volname, &entry);
3070 if (vcode) { /* no volume - do a full restore */
3071 restoreflags = RV_FULLRST;
3072 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3074 "Volume does not exist; Will perform a full restore\n");
3077 else if ((!readonly && Lp_GetRwIndex(&entry) == -1) /* RW volume does not exist - do a full */
3078 ||(readonly && !Lp_ROMatch(0, 0, &entry))) { /* RO volume does not exist - do a full */
3079 restoreflags = RV_FULLRST;
3080 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3082 "%s Volume does not exist; Will perform a full restore\n",
3083 readonly ? "RO" : "RW");
3086 avolid = entry.volumeId[voltype];
3087 } else if (entry.volumeId[voltype] != 0
3088 && entry.volumeId[voltype] != avolid) {
3089 avolid = entry.volumeId[voltype];
3091 aparentid = entry.volumeId[RWVOL];
3094 else { /* volume exists - do we do a full incremental or abort */
3095 int Oserver, Opart, Otype, vol_elsewhere = 0;
3096 struct nvldbentry Oentry;
3100 avolid = entry.volumeId[voltype];
3101 } else if (entry.volumeId[voltype] != 0
3102 && entry.volumeId[voltype] != avolid) {
3103 avolid = entry.volumeId[voltype];
3105 aparentid = entry.volumeId[RWVOL];
3107 /* A file name was specified - check if volume is on another partition */
3108 vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
3112 vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
3115 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
3119 if (!vcode || (Opart != apart))
3122 if (aoverwrite == ASK) {
3123 if (strcmp(afilename, "") == 0) { /* The file is from standard in */
3125 "Volume exists and no -overwrite option specified; Aborting restore command\n");
3129 /* Ask what to do */
3130 if (vol_elsewhere) {
3132 "The volume %s %u already exists on a different server/part\n",
3133 volname, entry.volumeId[voltype]);
3135 "Do you want to do a full restore or abort? [fa](a): ");
3138 "The volume %s %u already exists in the VLDB\n",
3139 volname, entry.volumeId[voltype]);
3141 "Do you want to do a full/incremental restore or abort? [fia](a): ");
3144 while (!(dc == EOF || dc == '\n'))
3145 dc = getchar(); /* goto end of line */
3146 if ((c == 'f') || (c == 'F'))
3148 else if ((c == 'i') || (c == 'I'))
3154 if (aoverwrite == ABORT) {
3155 fprintf(STDERR, "Volume exists; Aborting restore command\n");
3157 } else if (aoverwrite == FULL) {
3158 restoreflags = RV_FULLRST;
3160 "Volume exists; Will delete and perform full restore\n");
3161 } else if (aoverwrite == INC) {
3163 if (vol_elsewhere) {
3165 "%s volume %lu already exists on a different server/part; not allowed\n",
3166 readonly ? "RO" : "RW", (unsigned long)avolid);
3172 restoreflags |= RV_OFFLINE;
3174 restoreflags |= RV_RDONLY;
3176 switch (acreation) {
3178 restoreflags |= RV_CRDUMP;
3181 restoreflags |= RV_CRKEEP;
3184 restoreflags |= RV_CRNEW;
3187 if (aoverwrite == FULL)
3188 restoreflags |= RV_CRNEW;
3190 restoreflags |= RV_CRKEEP;
3193 switch (alastupdate) {
3195 restoreflags |= RV_LUDUMP;
3198 restoreflags |= RV_LUKEEP;
3201 restoreflags |= RV_LUNEW;
3204 restoreflags |= RV_LUDUMP;
3206 if (as->parms[10].items) {
3207 restoreflags |= RV_NODEL;
3212 UV_RestoreVolume2(aserver, apart, avolid, aparentid,
3213 avolname, restoreflags, WriteData, afilename);
3215 PrintDiagnostics("restore", code);
3218 MapPartIdIntoName(apart, apartName);
3221 * patch typo here - originally "parms[1]", should be "parms[0]"
3224 fprintf(STDOUT, "Restored volume %s on %s %s\n", avolname,
3225 as->parms[0].items->data, apartName);
3230 LockReleaseCmd(register struct cmd_syndesc *as, void *arock)
3233 afs_int32 code, err;
3235 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
3238 PrintError("", err);
3240 fprintf(STDERR, "vos: can't find volume '%s'\n",
3241 as->parms[0].items->data);
3245 code = UV_LockRelease(avolid);
3247 PrintDiagnostics("unlock", code);
3250 fprintf(STDOUT, "Released lock on vldb entry for volume %s\n",
3251 as->parms[0].items->data);
3256 AddSite(register struct cmd_syndesc *as, void *arock)
3259 afs_int32 aserver, apart, code, err, arovolid, valid = 0;
3260 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3262 vsu_ExtractName(avolname, as->parms[2].items->data);;
3263 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3266 PrintError("", err);
3268 fprintf(STDERR, "vos: can't find volume '%s'\n",
3269 as->parms[2].items->data);
3273 if (as->parms[3].items) {
3274 vsu_ExtractName(avolname, as->parms[3].items->data);
3275 arovolid = vsu_GetVolumeID(avolname, cstruct, &err);
3277 fprintf(STDERR, "vos: invalid ro volume id '%s'\n",
3278 as->parms[3].items->data);
3282 aserver = GetServer(as->parms[0].items->data);
3284 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3285 as->parms[0].items->data);
3288 apart = volutil_GetPartitionID(as->parms[1].items->data);
3290 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3291 as->parms[1].items->data);
3294 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3296 PrintError("", code);
3299 "vos : partition %s does not exist on the server\n",
3300 as->parms[1].items->data);
3303 if (as->parms[4].items) {
3306 code = UV_AddSite2(aserver, apart, avolid, arovolid, valid);
3308 PrintDiagnostics("addsite", code);
3311 MapPartIdIntoName(apart, apartName);
3312 fprintf(STDOUT, "Added replication site %s %s for volume %s\n",
3313 as->parms[0].items->data, apartName, as->parms[2].items->data);
3318 RemoveSite(register struct cmd_syndesc *as, void *arock)
3322 afs_int32 aserver, apart, code, err;
3323 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3325 vsu_ExtractName(avolname, as->parms[2].items->data);
3326 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3329 PrintError("", err);
3331 fprintf(STDERR, "vos: can't find volume '%s'\n",
3332 as->parms[2].items->data);
3335 aserver = GetServer(as->parms[0].items->data);
3337 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3338 as->parms[0].items->data);
3341 apart = volutil_GetPartitionID(as->parms[1].items->data);
3343 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3344 as->parms[1].items->data);
3348 *skip the partition validity check, since it is possible that the partition
3349 *has since been decomissioned.
3352 if (!IsPartValid(apart,aserver,&code)){
3353 if(code) PrintError("",code);
3354 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
3358 code = UV_RemoveSite(aserver, apart, avolid);
3360 PrintDiagnostics("remsite", code);
3363 MapPartIdIntoName(apart, apartName);
3364 fprintf(STDOUT, "Removed replication site %s %s for volume %s\n",
3365 as->parms[0].items->data, apartName, as->parms[2].items->data);
3370 ChangeLocation(register struct cmd_syndesc *as, void *arock)
3373 afs_int32 aserver, apart, code, err;
3376 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3379 PrintError("", err);
3381 fprintf(STDERR, "vos: can't find volume '%s'\n",
3382 as->parms[2].items->data);
3385 aserver = GetServer(as->parms[0].items->data);
3387 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3388 as->parms[0].items->data);
3391 apart = volutil_GetPartitionID(as->parms[1].items->data);
3393 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3394 as->parms[1].items->data);
3397 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3399 PrintError("", code);
3402 "vos : partition %s does not exist on the server\n",
3403 as->parms[1].items->data);
3406 code = UV_ChangeLocation(aserver, apart, avolid);
3408 PrintDiagnostics("addsite", code);
3411 MapPartIdIntoName(apart, apartName);
3412 fprintf(STDOUT, "Changed location to %s %s for volume %s\n",
3413 as->parms[0].items->data, apartName, as->parms[2].items->data);
3418 ListPartitions(register struct cmd_syndesc *as, void *arock)
3420 afs_int32 aserver, code;
3421 struct partList dummyPartList;
3426 aserver = GetServer(as->parms[0].items->data);
3428 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3429 as->parms[0].items->data);
3434 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3436 PrintDiagnostics("listpart", code);
3440 fprintf(STDOUT, "The partitions on the server are:\n");
3441 for (i = 0; i < cnt; i++) {
3442 if (dummyPartList.partFlags[i] & PARTVALID) {
3443 memset(pname, 0, sizeof(pname));
3444 MapPartIdIntoName(dummyPartList.partId[i], pname);
3445 fprintf(STDOUT, " %10s ", pname);
3447 if ((i % 5) == 0 && (i != 0))
3448 fprintf(STDOUT, "\n");
3451 fprintf(STDOUT, "\n");
3452 fprintf(STDOUT, "Total: %d\n", total);
3458 CompareVolName(const void *p1, const void *p2)
3460 volintInfo *arg1, *arg2;
3462 arg1 = (volintInfo *) p1;
3463 arg2 = (volintInfo *) p2;
3464 return (strcmp(arg1->name, arg2->name));
3468 /*------------------------------------------------------------------------
3469 * PRIVATE XCompareVolName
3472 * Comparison routine for volume names coming from an extended
3476 * a_obj1P : Char ptr to first extended vol info object
3477 * a_obj1P : Char ptr to second extended vol info object
3480 * The value of strcmp() on the volume names within the passed
3481 * objects (i,e., -1, 0, or 1).
3484 * Passed to qsort() as the designated comparison routine.
3488 *------------------------------------------------------------------------*/
3491 XCompareVolName(const void *a_obj1P, const void *a_obj2P)
3492 { /*XCompareVolName */
3495 (((struct volintXInfo *)(a_obj1P))->name,
3496 ((struct volintXInfo *)(a_obj2P))->name));
3498 } /*XCompareVolName */
3501 CompareVolID(const void *p1, const void *p2)
3503 volintInfo *arg1, *arg2;
3505 arg1 = (volintInfo *) p1;
3506 arg2 = (volintInfo *) p2;
3507 if (arg1->volid == arg2->volid)
3509 if (arg1->volid > arg2->volid)
3516 /*------------------------------------------------------------------------
3517 * PRIVATE XCompareVolID
3520 * Comparison routine for volume IDs coming from an extended
3524 * a_obj1P : Char ptr to first extended vol info object
3525 * a_obj1P : Char ptr to second extended vol info object
3528 * The value of strcmp() on the volume names within the passed
3529 * objects (i,e., -1, 0, or 1).
3532 * Passed to qsort() as the designated comparison routine.
3536 *------------------------------------------------------------------------*/
3539 XCompareVolID(const void *a_obj1P, const void *a_obj2P)
3540 { /*XCompareVolID */
3542 afs_int32 id1, id2; /*Volume IDs we're comparing */
3544 id1 = ((struct volintXInfo *)(a_obj1P))->volid;
3545 id2 = ((struct volintXInfo *)(a_obj2P))->volid;
3553 } /*XCompareVolID */
3555 /*------------------------------------------------------------------------
3556 * PRIVATE ListVolumes
3559 * Routine used to list volumes, contacting the Volume Server
3560 * directly, bypassing the VLDB.
3563 * as : Ptr to parsed command line arguments.
3566 * 0 Successful operation
3569 * Nothing interesting.
3573 *------------------------------------------------------------------------*/
3576 ListVolumes(register struct cmd_syndesc *as, void *arock)
3578 afs_int32 apart, int32list, fast;
3579 afs_int32 aserver, code;
3581 volintInfo *oldpntr = NULL;
3585 volintXInfo *xInfoP;
3586 volintXInfo *origxInfoP = NULL; /*Ptr to current/orig extended vol info */
3587 int wantExtendedInfo; /*Do we want extended vol info? */
3590 struct partList dummyPartList;
3598 if (as->parms[3].items)
3600 if (as->parms[4].items)
3604 if (as->parms[2].items)
3610 if (as->parms[5].items) {
3612 * We can't coexist with the fast flag.
3616 "vos: Can't use the -fast and -extended flags together\n");
3621 * We need to turn on ``long'' listings to get the full effect.
3623 wantExtendedInfo = 1;
3626 wantExtendedInfo = 0;
3627 if (as->parms[1].items) {
3628 apart = volutil_GetPartitionID(as->parms[1].items->data);
3630 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3631 as->parms[1].items->data);
3634 dummyPartList.partId[0] = apart;
3635 dummyPartList.partFlags[0] = PARTVALID;
3638 aserver = GetServer(as->parms[0].items->data);
3640 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3641 as->parms[0].items->data);
3646 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3648 PrintError("", code);
3651 "vos : partition %s does not exist on the server\n",
3652 as->parms[1].items->data);
3656 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3658 PrintDiagnostics("listvol", code);
3662 for (i = 0; i < cnt; i++) {
3663 if (dummyPartList.partFlags[i] & PARTVALID) {
3664 if (wantExtendedInfo)
3666 UV_XListVolumes(aserver, dummyPartList.partId[i], all,
3670 UV_ListVolumes(aserver, dummyPartList.partId[i], all,
3673 PrintDiagnostics("listvol", code);
3678 if (wantExtendedInfo) {
3679 origxInfoP = xInfoP;
3680 base = (char *)xInfoP;
3683 base = (char *)pntr;
3687 if (wantExtendedInfo)
3688 qsort(base, count, sizeof(volintXInfo), XCompareVolName);
3690 qsort(base, count, sizeof(volintInfo), CompareVolName);
3692 if (wantExtendedInfo)
3693 qsort(base, count, sizeof(volintXInfo), XCompareVolID);
3695 qsort(base, count, sizeof(volintInfo), CompareVolID);
3697 MapPartIdIntoName(dummyPartList.partId[i], pname);
3700 "Total number of volumes on server %s partition %s: %lu \n",
3701 as->parms[0].items->data, pname,
3702 (unsigned long)count);
3703 if (wantExtendedInfo) {
3704 #ifdef FULL_LISTVOL_SWITCH
3705 if (as->parms[6].items)
3706 XDisplayVolumes2(aserver, dummyPartList.partId[i], origxInfoP,
3707 count, int32list, fast, quiet);
3709 #endif /* FULL_LISTVOL_SWITCH */
3710 XDisplayVolumes(aserver, dummyPartList.partId[i], origxInfoP,
3711 count, int32list, fast, quiet);
3714 xInfoP = (volintXInfo *) 0;
3716 #ifdef FULL_LISTVOL_SWITCH
3717 if (as->parms[6].items)
3718 DisplayVolumes2(aserver, dummyPartList.partId[i], oldpntr,
3721 #endif /* FULL_LISTVOL_SWITCH */
3722 DisplayVolumes(aserver, dummyPartList.partId[i], oldpntr,
3723 count, int32list, fast, quiet);
3726 pntr = (volintInfo *) 0;
3734 SyncVldb(register struct cmd_syndesc *as, void *arock)
3736 afs_int32 pnum = 0, code; /* part name */
3742 if (as->parms[0].items) {
3743 tserver = GetServer(as->parms[0].items->data);
3745 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3746 as->parms[0].items->data);
3751 if (as->parms[1].items) {
3752 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3754 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3755 as->parms[1].items->data);
3758 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3760 PrintError("", code);
3763 "vos: partition %s does not exist on the server\n",
3764 as->parms[1].items->data);
3771 "The -partition option requires a -server option\n");
3776 if (as->parms[3].items) {
3777 flags |= 2; /* don't update */
3780 if (as->parms[2].items) {
3781 /* Synchronize an individual volume */
3782 volname = as->parms[2].items->data;
3783 code = UV_SyncVolume(tserver, pnum, volname, flags);
3787 "Without a -volume option, the -server option is required\n");
3790 code = UV_SyncVldb(tserver, pnum, flags, 0 /*unused */ );
3794 PrintDiagnostics("syncvldb", code);
3798 /* Print a summary of what we did */
3800 fprintf(STDOUT, "VLDB volume %s synchronized", volname);
3802 fprintf(STDOUT, "VLDB synchronized");
3804 fprintf(STDOUT, " with state of server %s", as->parms[0].items->data);
3807 MapPartIdIntoName(pnum, part);
3808 fprintf(STDOUT, " partition %s\n", part);
3810 fprintf(STDOUT, "\n");
3816 SyncServer(register struct cmd_syndesc *as, void *arock)
3818 afs_int32 pnum, code; /* part name */
3823 tserver = GetServer(as->parms[0].items->data);
3825 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3826 as->parms[0].items->data);
3829 if (as->parms[1].items) {
3830 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3832 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3833 as->parms[1].items->data);
3836 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3838 PrintError("", code);
3841 "vos : partition %s does not exist on the server\n",
3842 as->parms[1].items->data);
3850 if (as->parms[2].items) {
3851 flags |= 2; /* don't update */
3853 code = UV_SyncServer(tserver, pnum, flags, 0 /*unused */ );
3855 PrintDiagnostics("syncserv", code);
3859 MapPartIdIntoName(pnum, part);
3860 fprintf(STDOUT, "Server %s partition %s synchronized with VLDB\n",
3861 as->parms[0].items->data, part);
3863 fprintf(STDOUT, "Server %s synchronized with VLDB\n",
3864 as->parms[0].items->data);
3870 VolumeInfoCmd(char *name)
3872 struct nvldbentry entry;
3875 /* The vlserver will handle names with the .readonly
3876 * and .backup extension as well as volume ids.
3878 vcode = VLDB_GetEntryByName(name, &entry);
3880 PrintError("", vcode);
3883 MapHostToNetwork(&entry);
3884 EnumerateEntry(&entry);
3886 /* Defect #3027: grubby check to handle locked volume.
3887 * If VLOP_ALLOPERS is set, the entry is locked.
3888 * Leave this routine as is, but put in correct check.
3890 if (entry.flags & VLOP_ALLOPERS)
3891 fprintf(STDOUT, " Volume is currently LOCKED \n");
3897 VolumeZap(register struct cmd_syndesc *as, void *arock)
3899 struct nvldbentry entry;
3900 afs_uint32 volid, zapbackupid = 0, backupid = 0;
3901 afs_int32 code, server, part, err;
3903 if (as->parms[3].items) {
3904 /* force flag is on, use the other version */
3905 return NukeVolume(as);
3908 if (as->parms[4].items) {
3912 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3915 PrintError("", err);
3917 fprintf(STDERR, "vos: can't find volume '%s'\n",
3918 as->parms[2].items->data);
3921 part = volutil_GetPartitionID(as->parms[1].items->data);
3923 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3924 as->parms[1].items->data);
3927 server = GetServer(as->parms[0].items->data);
3929 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3930 as->parms[0].items->data);
3933 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
3935 PrintError("", code);
3938 "vos : partition %s does not exist on the server\n",
3939 as->parms[1].items->data);
3942 code = VLDB_GetEntryByID(volid, -1, &entry);
3944 if (volid == entry.volumeId[RWVOL])
3945 backupid = entry.volumeId[BACKVOL];
3947 "Warning: Entry for volume number %lu exists in VLDB (but we're zapping it anyway!)\n",
3948 (unsigned long)volid);
3951 volintInfo *pntr = (volintInfo *) 0;
3954 code = UV_ListOneVolume(server, part, volid, &pntr);
3956 if (volid == pntr->parentID)
3957 backupid = pntr->backupID;
3963 code = UV_VolumeZap(server, part, backupid);
3965 PrintDiagnostics("zap", code);
3968 fprintf(STDOUT, "Backup Volume %lu deleted\n",
3969 (unsigned long)backupid);
3972 code = UV_VolumeZap(server, part, volid);
3974 PrintDiagnostics("zap", code);
3977 fprintf(STDOUT, "Volume %lu deleted\n", (unsigned long)volid);
3983 VolserStatus(register struct cmd_syndesc *as, void *arock)
3985 afs_int32 server, code;
3986 transDebugInfo *pntr, *oldpntr;
3992 server = GetServer(as->parms[0].items->data);
3994 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3995 as->parms[0].items->data);
3998 code = UV_VolserStatus(server, &pntr, &count);
4000 PrintDiagnostics("status", code);
4005 fprintf(STDOUT, "No active transactions on %s\n",
4006 as->parms[0].items->data);
4008 fprintf(STDOUT, "Total transactions: %d\n", count);
4010 for (i = 0; i < count; i++) {
4011 /*print out the relevant info */
4012 fprintf(STDOUT, "--------------------------------------\n");
4014 fprintf(STDOUT, "transaction: %lu created: %s",
4015 (unsigned long)pntr->tid, ctime(&t));
4016 if (pntr->returnCode) {
4017 fprintf(STDOUT, "returnCode: %lu\n",
4018 (unsigned long)pntr->returnCode);
4021 fprintf(STDOUT, "attachFlags: ");
4022 switch (pntr->iflags) {
4024 fprintf(STDOUT, "offline ");
4027 fprintf(STDOUT, "busy ");
4030 fprintf(STDOUT, "readonly ");
4033 fprintf(STDOUT, "create ");
4036 fprintf(STDOUT, "create volid ");
4039 fprintf(STDOUT, "\n");
4042 fprintf(STDOUT, "volumeStatus: ");
4043 switch (pntr->vflags) {
4044 case VTDeleteOnSalvage:
4045 fprintf(STDOUT, "deleteOnSalvage ");
4046 case VTOutOfService:
4047 fprintf(STDOUT, "outOfService ");
4049 fprintf(STDOUT, "deleted ");
4051 fprintf(STDOUT, "\n");
4054 fprintf(STDOUT, "transactionFlags: ");
4055 fprintf(STDOUT, "delete\n");
4057 MapPartIdIntoName(pntr->partition, pname);
4058 fprintf(STDOUT, "volume: %lu partition: %s procedure: %s\n",
4059 (unsigned long)pntr->volid, pname, pntr->lastProcName);
4060 if (pntr->callValid) {
4062 "packetRead: %lu lastReceiveTime: %d packetSend: %lu lastSendTime: %d\n",
4063 (unsigned long)pntr->readNext, pntr->lastReceiveTime,
4064 (unsigned long)pntr->transmitNext, pntr->lastSendTime);
4067 fprintf(STDOUT, "--------------------------------------\n");
4068 fprintf(STDOUT, "\n");
4076 RenameVolume(register struct cmd_syndesc *as, void *arock)
4078 afs_int32 code1, code2, code;
4079 struct nvldbentry entry;
4081 code1 = VLDB_GetEntryByName(as->parms[0].items->data, &entry);
4083 fprintf(STDERR, "vos: Could not find entry for volume %s\n",
4084 as->parms[0].items->data);
4087 code2 = VLDB_GetEntryByName(as->parms[1].items->data, &entry);
4088 if ((!code1) && (!code2)) { /*the newname already exists */
4089 fprintf(STDERR, "vos: volume %s already exists\n",
4090 as->parms[1].items->data);
4094 if (code1 && code2) {
4095 fprintf(STDERR, "vos: Could not find entry for volume %s or %s\n",
4096 as->parms[0].items->data, as->parms[1].items->data);
4099 if (!VolNameOK(as->parms[0].items->data)) {
4101 "Illegal volume name %s, should not end in .readonly or .backup\n",
4102 as->parms[0].items->data);
4105 if (!ISNAMEVALID(as->parms[1].items->data)) {
4107 "vos: the new volume name %s exceeds the size limit of %d\n",
4108 as->parms[1].items->data, VOLSER_OLDMAXVOLNAME - 10);
4111 if (!VolNameOK(as->parms[1].items->data)) {
4113 "Illegal volume name %s, should not end in .readonly or .backup\n",
4114 as->parms[1].items->data);
4117 if (IsNumeric(as->parms[1].items->data)) {
4118 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
4119 as->parms[1].items->data);
4122 MapHostToNetwork(&entry);
4124 UV_RenameVolume(&entry, as->parms[0].items->data,
4125 as->parms[1].items->data);
4127 PrintDiagnostics("rename", code);
4130 fprintf(STDOUT, "Renamed volume %s to %s\n", as->parms[0].items->data,
4131 as->parms[1].items->data);
4136 GetVolumeInfo(afs_uint32 volid, afs_int32 *server, afs_int32 *part, afs_int32 *voltype,
4137 struct nvldbentry *rentry)
4142 vcode = VLDB_GetEntryByID(volid, -1, rentry);
4145 "Could not fetch the entry for volume %lu from VLDB \n",
4146 (unsigned long)volid);
4147 PrintError("", vcode);
4150 MapHostToNetwork(rentry);
4151 if (volid == rentry->volumeId[ROVOL]) {
4153 for (i = 0; i < rentry->nServers; i++) {
4154 if ((index == -1) && (rentry->serverFlags[i] & ITSROVOL)
4155 && !(rentry->serverFlags[i] & RO_DONTUSE))
4160 "RO volume is not found in VLDB entry for volume %lu\n",
4161 (unsigned long)volid);
4165 *server = rentry->serverNumber[index];
4166 *part = rentry->serverPartition[index];
4170 index = Lp_GetRwIndex(rentry);
4173 "RW Volume is not found in VLDB entry for volume %lu\n",
4174 (unsigned long)volid);
4177 if (volid == rentry->volumeId[RWVOL]) {
4179 *server = rentry->serverNumber[index];
4180 *part = rentry->serverPartition[index];
4183 if (volid == rentry->volumeId[BACKVOL]) {
4185 *server = rentry->serverNumber[index];
4186 *part = rentry->serverPartition[index];
4190 "unexpected volume type for volume %lu\n",
4191 (unsigned long)volid);
4196 DeleteEntry(register struct cmd_syndesc *as, void *arock)
4198 afs_int32 apart = 0;
4201 struct VldbListByAttributes attributes;
4202 nbulkentries arrayEntries;
4203 register struct nvldbentry *vllist;
4204 struct cmd_item *itp;
4207 char prefix[VOLSER_MAXVOLNAME + 1];
4209 afs_int32 totalBack = 0, totalFail = 0, err;
4211 if (as->parms[0].items) { /* -id */
4212 if (as->parms[1].items || as->parms[2].items || as->parms[3].items) {
4214 "You cannot use -server, -partition, or -prefix with the -id argument\n");
4217 for (itp = as->parms[0].items; itp; itp = itp->next) {
4218 avolid = vsu_GetVolumeID(itp->data, cstruct, &err);
4221 PrintError("", err);
4223 fprintf(STDERR, "vos: can't find volume '%s'\n",
4227 if (as->parms[4].items) { /* -noexecute */
4228 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4233 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4235 fprintf(STDERR, "Could not delete entry for volume %s\n",
4238 "You must specify a RW volume name or ID "
4239 "(the entire VLDB entry will be deleted)\n");
4240 PrintError("", vcode);
4246 fprintf(STDOUT, "Deleted %d VLDB entries\n", totalBack);
4250 if (!as->parms[1].items && !as->parms[2].items && !as->parms[3].items) {
4251 fprintf(STDERR, "You must specify an option\n");
4255 /* Zero out search attributes */
4256 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4258 if (as->parms[1].items) { /* -prefix */
4259 strncpy(prefix, as->parms[1].items->data, VOLSER_MAXVOLNAME);
4261 if (!as->parms[2].items && !as->parms[3].items) { /* a single entry only */
4263 "You must provide -server with the -prefix argument\n");
4268 if (as->parms[2].items) { /* -server */
4270 aserver = GetServer(as->parms[2].items->data);
4272 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4273 as->parms[2].items->data);
4276 attributes.server = ntohl(aserver);
4277 attributes.Mask |= VLLIST_SERVER;
4280 if (as->parms[3].items) { /* -partition */
4281 if (!as->parms[2].items) {
4283 "You must provide -server with the -partition argument\n");
4286 apart = volutil_GetPartitionID(as->parms[3].items->data);
4288 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4289 as->parms[3].items->data);
4292 attributes.partition = apart;
4293 attributes.Mask |= VLLIST_PARTITION;
4296 /* Print status line of what we are doing */
4297 fprintf(STDOUT, "Deleting VLDB entries for ");
4298 if (as->parms[2].items) {
4299 fprintf(STDOUT, "server %s ", as->parms[2].items->data);
4301 if (as->parms[3].items) {
4303 MapPartIdIntoName(apart, pname);
4304 fprintf(STDOUT, "partition %s ", pname);
4307 fprintf(STDOUT, "which are prefixed with %s ", prefix);
4309 fprintf(STDOUT, "\n");
4312 /* Get all the VLDB entries on a server and/or partition */
4313 memset(&arrayEntries, 0, sizeof(arrayEntries));
4314 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4316 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4317 PrintError("", vcode);
4321 /* Process each entry */
4322 for (j = 0; j < nentries; j++) {
4323 vllist = &arrayEntries.nbulkentries_val[j];
4325 /* It only deletes the RW volumes */
4326 if (strncmp(vllist->name, prefix, strlen(prefix))) {
4329 "Omitting to delete %s due to prefix %s mismatch\n",
4330 vllist->name, prefix);
4337 if (as->parms[4].items) { /* -noexecute */
4338 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4344 /* Only matches the RW volume name */
4345 avolid = vllist->volumeId[RWVOL];
4346 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4348 fprintf(STDOUT, "Could not delete VDLB entry for %s\n",
4351 PrintError("", vcode);
4356 fprintf(STDOUT, "Deleted VLDB entry for %s \n", vllist->name);
4361 fprintf(STDOUT, "----------------------\n");
4363 "Total VLDB entries deleted: %lu; failed to delete: %lu\n",
4364 (unsigned long)totalBack, (unsigned long)totalFail);
4365 if (arrayEntries.nbulkentries_val)
4366 free(arrayEntries.nbulkentries_val);
4372 CompareVldbEntryByName(const void *p1, const void *p2)
4374 struct nvldbentry *arg1, *arg2;
4376 arg1 = (struct nvldbentry *)p1;
4377 arg2 = (struct nvldbentry *)p2;
4378 return (strcmp(arg1->name, arg2->name));
4382 static int CompareVldbEntry(char *p1, char *p2)
4384 struct nvldbentry *arg1,*arg2;
4387 char comp1[100],comp2[100];
4388 char temp1[20],temp2[20];
4390 arg1 = (struct nvldbentry *)p1;
4391 arg2 = (struct nvldbentry *)p2;
4395 for(i = 0; i < arg1->nServers; i++)
4396 if(arg1->serverFlags[i] & ITSRWVOL) pos1 = i;
4397 for(i = 0; i < arg2->nServers; i++)
4398 if(arg2->serverFlags[i] & ITSRWVOL) pos2 = i;
4399 if(pos1 == -1 || pos2 == -1){
4403 sprintf(comp1,"%10u",arg1->serverNumber[pos1]);
4404 sprintf(comp2,"%10u",arg2->serverNumber[pos2]);
4405 sprintf(temp1,"%10u",arg1->serverPartition[pos1]);
4406 sprintf(temp2,"%10u",arg2->serverPartition[pos2]);
4407 strcat(comp1,temp1);
4408 strcat(comp2,temp2);
4409 strcat(comp1,arg1->name);
4410 strcat(comp1,arg2->name);
4411 return(strcmp(comp1,comp2));
4417 ListVLDB(struct cmd_syndesc *as, void *arock)
4420 afs_int32 aserver, code;
4422 struct VldbListByAttributes attributes;
4423 nbulkentries arrayEntries;
4424 struct nvldbentry *vllist, *tarray = 0, *ttarray;
4425 afs_int32 centries, nentries = 0;
4426 afs_int32 tarraysize = 0;
4427 afs_int32 parraysize;
4430 int quiet, sort, lock;
4431 afs_int32 thisindex, nextindex;
4436 attributes.Mask = 0;
4437 lock = (as->parms[3].items ? 1 : 0); /* -lock flag */
4438 quiet = (as->parms[4].items ? 1 : 0); /* -quit flag */
4439 sort = (as->parms[5].items ? 0 : 1); /* -nosort flag */
4441 /* If the volume name is given, Use VolumeInfoCmd to look it up
4442 * and not ListAttributes.
4444 if (as->parms[0].items) {
4447 "vos: illegal use of '-locked' switch, need to specify server and/or partition\n");
4450 code = VolumeInfoCmd(as->parms[0].items->data);
4452 PrintError("", code);
4458 /* Server specified */
4459 if (as->parms[1].items) {
4460 aserver = GetServer(as->parms[1].items->data);
4462 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4463 as->parms[1].items->data);
4466 attributes.server = ntohl(aserver);
4467 attributes.Mask |= VLLIST_SERVER;
4470 /* Partition specified */
4471 if (as->parms[2].items) {
4472 apart = volutil_GetPartitionID(as->parms[2].items->data);
4474 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4475 as->parms[2].items->data);
4478 attributes.partition = apart;
4479 attributes.Mask |= VLLIST_PARTITION;
4483 attributes.Mask |= VLLIST_FLAG;
4484 attributes.flag = VLOP_ALLOPERS;
4487 /* Print header information */
4489 MapPartIdIntoName(apart, pname);
4490 fprintf(STDOUT, "VLDB entries for %s %s%s%s %s\n",
4491 (as->parms[1].items ? "server" : "all"),
4492 (as->parms[1].items ? as->parms[1].items->data : "servers"),
4493 (as->parms[2].items ? " partition " : ""),
4494 (as->parms[2].items ? pname : ""),
4495 (lock ? "which are locked:" : ""));
4498 for (thisindex = 0; (thisindex != -1); thisindex = nextindex) {
4499 memset(&arrayEntries, 0, sizeof(arrayEntries));
4504 VLDB_ListAttributesN2(&attributes, 0, thisindex, ¢ries,
4505 &arrayEntries, &nextindex);
4506 if (vcode == RXGEN_OPCODE) {
4507 /* Vlserver not running with ListAttributesN2. Fall back */
4509 VLDB_ListAttributes(&attributes, ¢ries, &arrayEntries);
4513 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4514 PrintError("", vcode);
4517 nentries += centries;
4519 /* We don't sort, so just print the entries now */
4521 for (j = 0; j < centries; j++) { /* process each entry */
4522 vllist = &arrayEntries.nbulkentries_val[j];
4523 MapHostToNetwork(vllist);
4524 EnumerateEntry(vllist);
4526 if (vllist->flags & VLOP_ALLOPERS)
4527 fprintf(STDOUT, " Volume is currently LOCKED \n");
4531 /* So we sort. First we must collect all the entries and keep
4534 else if (centries > 0) {
4536 /* steal away the first bulk entries array */
4537 tarray = (struct nvldbentry *)arrayEntries.nbulkentries_val;
4538 tarraysize = centries * sizeof(struct nvldbentry);
4539 arrayEntries.nbulkentries_val = 0;
4541 /* Grow the tarray to keep the extra entries */
4542 parraysize = (centries * sizeof(struct nvldbentry));
4544 (struct nvldbentry *)realloc(tarray,
4545 tarraysize + parraysize);
4548 "Could not allocate enough space for the VLDB entries\n");
4554 memcpy(((char *)tarray) + tarraysize,
4555 (char *)arrayEntries.nbulkentries_val, parraysize);
4556 tarraysize += parraysize;
4560 /* Free the bulk array */
4561 if (arrayEntries.nbulkentries_val) {
4562 free(arrayEntries.nbulkentries_val);
4563 arrayEntries.nbulkentries_val = 0;
4567 /* Here is where we now sort all the entries and print them */
4568 if (sort && (nentries > 0)) {
4569 qsort((char *)tarray, nentries, sizeof(struct nvldbentry),
4570 CompareVldbEntryByName);
4571 for (vllist = tarray, j = 0; j < nentries; j++, vllist++) {
4572 MapHostToNetwork(vllist);
4573 EnumerateEntry(vllist);
4575 if (vllist->flags & VLOP_ALLOPERS)
4576 fprintf(STDOUT, " Volume is currently LOCKED \n");
4582 fprintf(STDOUT, "\nTotal entries: %lu\n", (unsigned long)nentries);
4589 BackSys(register struct cmd_syndesc *as, void *arock)
4592 afs_int32 apart = 0;
4593 afs_int32 aserver = 0, code, aserver1, apart1;
4595 struct VldbListByAttributes attributes;
4596 nbulkentries arrayEntries;
4597 register struct nvldbentry *vllist;
4601 int seenprefix, seenxprefix, exclude, ex, exp, noaction;
4602 afs_int32 totalBack = 0;
4603 afs_int32 totalFail = 0;
4607 struct cmd_item *ti;
4609 #ifndef HAVE_POSIX_REGEX
4613 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4614 attributes.Mask = 0;
4616 seenprefix = (as->parms[0].items ? 1 : 0);
4617 exclude = (as->parms[3].items ? 1 : 0);
4618 seenxprefix = (as->parms[4].items ? 1 : 0);
4619 noaction = (as->parms[5].items ? 1 : 0);
4621 if (as->parms[1].items) { /* -server */
4622 aserver = GetServer(as->parms[1].items->data);
4624 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4625 as->parms[1].items->data);
4628 attributes.server = ntohl(aserver);
4629 attributes.Mask |= VLLIST_SERVER;
4632 if (as->parms[2].items) { /* -partition */
4633 apart = volutil_GetPartitionID(as->parms[2].items->data);
4635 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4636 as->parms[2].items->data);
4639 attributes.partition = apart;
4640 attributes.Mask |= VLLIST_PARTITION;
4643 /* Check to make sure the prefix and xprefix expressions compile ok */
4645 for (ti = as->parms[0].items; ti; ti = ti->next) {
4646 if (strncmp(ti->data, "^", 1) == 0) {
4647 #ifdef HAVE_POSIX_REGEX
4651 code = regcomp(&re, ti->data, REG_NOSUB);
4653 regerror(code, &re, errbuf, sizeof errbuf);
4655 "Unrecognizable -prefix regular expression: '%s': %s\n",
4661 ccode = (char *)re_comp(ti->data);
4664 "Unrecognizable -prefix regular expression: '%s': %s\n",
4673 for (ti = as->parms[4].items; ti; ti = ti->next) {
4674 if (strncmp(ti->data, "^", 1) == 0) {
4675 #ifdef HAVE_POSIX_REGEX
4679 code = regcomp(&re, ti->data, REG_NOSUB);
4681 regerror(code, &re, errbuf, sizeof errbuf);
4683 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4689 ccode = (char *)re_comp(ti->data);
4692 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4701 memset(&arrayEntries, 0, sizeof(arrayEntries)); /* initialize to hint the stub to alloc space */
4702 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4704 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4705 PrintError("", vcode);
4709 if (as->parms[1].items || as->parms[2].items || verbose) {
4710 fprintf(STDOUT, "%s up volumes",
4711 (noaction ? "Would have backed" : "Backing"));
4713 if (as->parms[1].items) {
4714 fprintf(STDOUT, " on server %s", as->parms[1].items->data);
4715 } else if (as->parms[2].items) {
4716 fprintf(STDOUT, " for all servers");
4719 if (as->parms[2].items) {
4720 MapPartIdIntoName(apart, pname);
4721 fprintf(STDOUT, " partition %s", pname);
4724 if (seenprefix || (!seenprefix && seenxprefix)) {
4725 ti = (seenprefix ? as->parms[0].items : as->parms[4].items);
4726 ex = (seenprefix ? exclude : !exclude);
4727 exp = (strncmp(ti->data, "^", 1) == 0);
4728 fprintf(STDOUT, " which %smatch %s '%s'", (ex ? "do not " : ""),
4729 (exp ? "expression" : "prefix"), ti->data);
4730 for (ti = ti->next; ti; ti = ti->next) {
4731 exp = (strncmp(ti->data, "^", 1) == 0);
4732 printf(" %sor %s '%s'", (ex ? "n" : ""),
4733 (exp ? "expression" : "prefix"), ti->data);
4737 if (seenprefix && seenxprefix) {
4738 ti = as->parms[4].items;
4739 exp = (strncmp(ti->data, "^", 1) == 0);
4740 fprintf(STDOUT, " %swhich match %s '%s'",
4741 (exclude ? "adding those " : "removing those "),
4742 (exp ? "expression" : "prefix"), ti->data);
4743 for (ti = ti->next; ti; ti = ti->next) {
4744 exp = (strncmp(ti->data, "^", 1) == 0);
4745 printf(" or %s '%s'", (exp ? "expression" : "prefix"),
4749 fprintf(STDOUT, " .. ");
4751 fprintf(STDOUT, "\n");
4755 for (j = 0; j < nentries; j++) { /* process each vldb entry */
4756 vllist = &arrayEntries.nbulkentries_val[j];
4759 for (ti = as->parms[0].items; ti; ti = ti->next) {
4760 if (strncmp(ti->data, "^", 1) == 0) {
4761 #ifdef HAVE_POSIX_REGEX
4765 /* XXX -- should just do the compile once! */
4766 code = regcomp(&re, ti->data, REG_NOSUB);
4768 regerror(code, &re, errbuf, sizeof errbuf);
4770 "Error in -prefix regular expression: '%s': %s\n",
4774 match = (regexec(&re, vllist->name, 0, NULL, 0) == 0);
4777 ccode = (char *)re_comp(ti->data);
4780 "Error in -prefix regular expression: '%s': %s\n",
4784 match = (re_exec(vllist->name) == 1);
4788 (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4798 /* Without the -exclude flag: If it matches the prefix, then
4799 * check if we want to exclude any from xprefix.
4800 * With the -exclude flag: If it matches the prefix, then
4801 * check if we want to add any from xprefix.
4803 if (match && seenxprefix) {
4804 for (ti = as->parms[4].items; ti; ti = ti->next) {
4805 if (strncmp(ti->data, "^", 1) == 0) {
4806 #ifdef HAVE_POSIX_REGEX
4810 /* XXX -- should just do the compile once! */
4811 code = regcomp(&re, ti->data, REG_NOSUB);
4813 regerror(code, &re, errbuf, sizeof errbuf);
4815 "Error in -xprefix regular expression: '%s': %s\n",
4819 if (regexec(&re, vllist->name, 0, NULL, 0) == 0)
4823 ccode = (char *)re_comp(ti->data);
4826 "Error in -xprefix regular expression: '%s': %s\n",
4830 if (re_exec(vllist->name) == 1) {
4836 if (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4846 match = !match; /* -exclude will reverse the match */
4848 continue; /* Skip if no match */
4850 /* Print list of volumes to backup */
4852 fprintf(STDOUT, " %s\n", vllist->name);
4856 if (!(vllist->flags & RW_EXISTS)) {
4859 "Omitting to backup %s since RW volume does not exist \n",
4861 fprintf(STDOUT, "\n");
4867 avolid = vllist->volumeId[RWVOL];
4868 MapHostToNetwork(vllist);
4869 GetServerAndPart(vllist, RWVOL, &aserver1, &apart1, &previdx);
4870 if (aserver1 == -1 || apart1 == -1) {
4871 fprintf(STDOUT, "could not backup %s, invalid VLDB entry\n",
4877 same = VLDB_IsSameAddrs(aserver, aserver1, &error);
4880 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
4886 if ((aserver && !same) || (apart && (apart != apart1))) {
4889 "Omitting to backup %s since the RW is in a different location\n",
4895 time_t now = time(0);
4896 fprintf(STDOUT, "Creating backup volume for %s on %s",
4897 vllist->name, ctime(&now));
4901 code = UV_BackupVolume(aserver1, apart1, avolid);
4903 fprintf(STDOUT, "Could not backup %s\n", vllist->name);
4909 fprintf(STDOUT, "\n");
4911 } /* process each vldb entry */
4912 fprintf(STDOUT, "done\n");
4913 fprintf(STDOUT, "Total volumes backed up: %lu; failed to backup: %lu\n",
4914 (unsigned long)totalBack, (unsigned long)totalFail);
4916 if (arrayEntries.nbulkentries_val)
4917 free(arrayEntries.nbulkentries_val);
4922 UnlockVLDB(register struct cmd_syndesc *as, void *arock)
4925 afs_int32 aserver = 0;
4928 struct VldbListByAttributes attributes;
4929 nbulkentries arrayEntries;
4930 register struct nvldbentry *vllist;
4939 attributes.Mask = 0;
4941 if (as->parms[0].items) { /* server specified */
4942 aserver = GetServer(as->parms[0].items->data);
4944 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4945 as->parms[0].items->data);
4948 attributes.server = ntohl(aserver);
4949 attributes.Mask |= VLLIST_SERVER;
4951 if (as->parms[1].items) { /* partition specified */
4952 apart = volutil_GetPartitionID(as->parms[1].items->data);
4954 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4955 as->parms[1].items->data);
4958 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
4960 PrintError("", code);
4963 "vos : partition %s does not exist on the server\n",
4964 as->parms[1].items->data);
4967 attributes.partition = apart;
4968 attributes.Mask |= VLLIST_PARTITION;
4970 attributes.flag = VLOP_ALLOPERS;
4971 attributes.Mask |= VLLIST_FLAG;
4972 memset(&arrayEntries, 0, sizeof(arrayEntries)); /*initialize to hint the stub to alloc space */
4973 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4975 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4976 PrintError("", vcode);
4979 for (j = 0; j < nentries; j++) { /* process each entry */
4980 vllist = &arrayEntries.nbulkentries_val[j];
4981 volid = vllist->volumeId[RWVOL];
4983 ubik_VL_ReleaseLock(cstruct, 0, volid, -1,
4984 LOCKREL_OPCODE | LOCKREL_AFSID |
4987 fprintf(STDERR, "Could not unlock entry for volume %s\n",
4989 PrintError("", vcode);
4994 MapPartIdIntoName(apart, pname);
4997 "Could not lock %lu VLDB entries of %lu locked entries\n",
4998 (unsigned long)totalE, (unsigned long)nentries);
5000 if (as->parms[0].items) {
5002 "Unlocked all the VLDB entries for volumes on server %s ",
5003 as->parms[0].items->data);
5004 if (as->parms[1].items) {
5005 MapPartIdIntoName(apart, pname);
5006 fprintf(STDOUT, "partition %s\n", pname);
5008 fprintf(STDOUT, "\n");
5010 } else if (as->parms[1].items) {
5011 MapPartIdIntoName(apart, pname);
5013 "Unlocked all the VLDB entries for volumes on partition %s on all servers\n",
5018 if (arrayEntries.nbulkentries_val)
5019 free(arrayEntries.nbulkentries_val);
5024 PrintInt64Size(afs_uint64 in)
5026 register afs_uint32 hi, lo;
5027 register char * units;
5028 static char output[16];
5030 SplitInt64(in,hi,lo);
5034 } else if (!(hi & 0xFFFFFC00)) {
5036 lo = (hi << 22) | (lo >> 10);
5037 } else if (!(hi & 0xFFF00000)) {
5039 lo = (hi << 12) | (lo >> 20);
5040 } else if (!(hi & 0xC0000000)) {
5042 lo = (hi << 2) | (lo >> 30);
5047 sprintf(output,"%u %s", lo, units);
5052 PartitionInfo(register struct cmd_syndesc *as, void *arock)
5055 afs_int32 aserver, code;
5057 struct diskPartition64 partition;
5058 struct partList dummyPartList;
5060 int printSummary=0, sumPartitions=0;
5061 afs_uint64 sumFree, sumStorage;
5064 ZeroInt64(sumStorage);
5066 aserver = GetServer(as->parms[0].items->data);
5068 fprintf(STDERR, "vos: server '%s' not found in host table\n",
5069 as->parms[0].items->data);
5072 if (as->parms[1].items) {
5073 apart = volutil_GetPartitionID(as->parms[1].items->data);
5075 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5076 as->parms[1].items->data);
5079 dummyPartList.partId[0] = apart;
5080 dummyPartList.partFlags[0] = PARTVALID;
5083 if (as->parms[2].items) {
5087 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
5089 PrintError("", code);
5092 "vos : partition %s does not exist on the server\n",
5093 as->parms[1].items->data);
5097 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
5099 PrintDiagnostics("listpart", code);
5103 for (i = 0; i < cnt; i++) {
5104 if (dummyPartList.partFlags[i] & PARTVALID) {
5105 MapPartIdIntoName(dummyPartList.partId[i], pname);
5106 code = UV_PartitionInfo64(aserver, pname, &partition);
5108 fprintf(STDERR, "Could not get information on partition %s\n",
5110 PrintError("", code);
5114 "Free space on partition %s: %" AFS_INT64_FMT " K blocks out of total %" AFS_INT64_FMT "\n",
5115 pname, partition.free, partition.minFree);
5117 AddUInt64(sumFree,partition.free,&sumFree);
5118 AddUInt64(sumStorage,partition.minFree,&sumStorage);
5123 "Summary: %s free out of ",
5124 PrintInt64Size(sumFree));
5126 "%s on %d partitions\n",
5127 PrintInt64Size(sumStorage),
5134 ChangeAddr(register struct cmd_syndesc *as, void *arock)
5136 afs_int32 ip1, ip2, vcode;
5139 ip1 = GetServer(as->parms[0].items->data);
5141 fprintf(STDERR, "vos: invalid host address\n");
5145 if ((as->parms[1].items && as->parms[2].items)
5146 || (!as->parms[1].items && !as->parms[2].items)) {
5148 "vos: Must specify either '-newaddr <addr>' or '-remove' flag\n");
5152 if (as->parms[1].items) {
5153 ip2 = GetServer(as->parms[1].items->data);
5155 fprintf(STDERR, "vos: invalid host address\n");
5159 /* Play a trick here. If we are removing an address, ip1 will be -1
5160 * and ip2 will be the original address. This switch prevents an
5161 * older revision vlserver from removing the IP address.
5168 vcode = ubik_Call_New(VL_ChangeAddr, cstruct, 0, ntohl(ip1), ntohl(ip2));
5171 fprintf(STDERR, "Could not remove server %s from the VLDB\n",
5172 as->parms[0].items->data);
5173 if (vcode == VL_NOENT) {
5175 "vlserver does not support the remove flag or ");
5178 fprintf(STDERR, "Could not change server %s to server %s\n",
5179 as->parms[0].items->data, as->parms[1].items->data);
5181 PrintError("", vcode);
5186 fprintf(STDOUT, "Removed server %s from the VLDB\n",
5187 as->parms[0].items->data);
5189 fprintf(STDOUT, "Changed server %s to server %s\n",
5190 as->parms[0].items->data, as->parms[1].items->data);
5196 print_addrs(const bulkaddrs * addrs, const afsUUID * m_uuid, int nentries,
5201 struct VLCallBack vlcb;
5204 ListAddrByAttributes m_attrs;
5205 afs_int32 m_nentries, *m_addrp;
5206 afs_int32 base, index;
5210 afsUUID_to_string(m_uuid, buf, sizeof(buf));
5211 printf("UUID: %s\n", buf);
5214 /* print out the list of all the server */
5215 addrp = (afs_int32 *) addrs->bulkaddrs_val;
5216 for (i = 0; i < nentries; i++, addrp++) {
5217 /* If it is a multihomed address, then we will need to
5218 * get the addresses for this multihomed server from
5219 * the vlserver and print them.
5221 if (((*addrp & 0xff000000) == 0xff000000) && ((*addrp) & 0xffff)) {
5222 /* Get the list of multihomed fileservers */
5223 base = (*addrp >> 16) & 0xff;
5224 index = (*addrp) & 0xffff;
5226 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
5227 && (index <= VL_MHSRV_PERBLK)) {
5228 m_attrs.Mask = VLADDR_INDEX;
5229 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
5231 m_addrs.bulkaddrs_val = 0;
5232 m_addrs.bulkaddrs_len = 0;
5234 ubik_VL_GetAddrsU(cstruct, 0, &m_attrs, m_uuid,
5235 (afs_int32 *)&vlcb, &m_nentries, &m_addrs);
5238 "vos: could not list the multi-homed server addresses\n");
5239 PrintError("", vcode);
5242 /* Print the list */
5243 m_addrp = (afs_int32 *) m_addrs.bulkaddrs_val;
5244 for (j = 0; j < m_nentries; j++, m_addrp++) {
5245 *m_addrp = htonl(*m_addrp);
5248 printf("%s ", afs_inet_ntoa_r(*m_addrp, hoststr));
5250 printf("%s ", hostutil_GetNameByINet(*m_addrp));
5254 printf("<unknown>\n");
5263 /* Otherwise, it is a non-multihomed entry and contains
5264 * the IP address of the server - print it.
5266 *addrp = htonl(*addrp);
5269 printf("%s\n", afs_inet_ntoa_r(*addrp, hoststr));
5271 printf("%s\n", hostutil_GetNameByINet(*addrp));
5282 ListAddrs(register struct cmd_syndesc *as, void *arock)
5285 afs_int32 i, printuuid = 0;
5286 struct VLCallBack vlcb;
5289 ListAddrByAttributes m_attrs;
5290 afsUUID m_uuid, askuuid;
5291 afs_int32 m_nentries;
5293 memset(&m_attrs, 0, sizeof(struct ListAddrByAttributes));
5294 m_attrs.Mask = VLADDR_INDEX;
5296 memset(&m_addrs, 0, sizeof(bulkaddrs));
5297 memset(&askuuid, 0, sizeof(afsUUID));
5298 if (as->parms[0].items) {
5300 if (afsUUID_from_string(as->parms[0].items->data, &askuuid) < 0) {
5301 fprintf(STDERR, "vos: invalid UUID '%s'\n",
5302 as->parms[0].items->data);
5305 m_attrs.Mask = VLADDR_UUID;
5306 m_attrs.uuid = askuuid;
5308 if (as->parms[1].items) {
5312 he = hostutil_GetHostByName((char *)as->parms[1].items->data);
5314 fprintf(STDERR, "vos: Can't get host info for '%s'\n",
5315 as->parms[1].items->data);
5318 memcpy(&saddr, he->h_addr, 4);
5319 m_attrs.Mask = VLADDR_IPADDR;
5320 m_attrs.ipaddr = ntohl(saddr);
5322 if (as->parms[2].items) {
5326 m_addrs.bulkaddrs_val = 0;
5327 m_addrs.bulkaddrs_len = 0;
5330 ubik_Call_New(VL_GetAddrs, cstruct, 0, 0, 0, &vlcb, &nentries,
5333 fprintf(STDERR, "vos: could not list the server addresses\n");
5334 PrintError("", vcode);
5339 m_addrs.bulkaddrs_val = 0;
5340 m_addrs.bulkaddrs_len = 0;
5346 ubik_Call_New(VL_GetAddrsU, cstruct, 0, &m_attrs, &m_uuid,
5347 &vlcb, &m_nentries, &m_addrs);
5349 if (vcode == VL_NOENT) {
5350 if (m_attrs.Mask == VLADDR_UUID) {
5351 fprintf(STDERR, "vos: no entry for UUID '%s' found in VLDB\n",
5352 as->parms[0].items->data);
5354 } else if (m_attrs.Mask == VLADDR_IPADDR) {
5355 fprintf(STDERR, "vos: no entry for host '%s' [0x%08x] found in VLDB\n",
5356 as->parms[1].items->data, m_attrs.ipaddr);
5365 if (vcode == VL_INDEXERANGE) {
5370 fprintf(STDERR, "vos: could not list the server addresses\n");
5371 PrintError("", vcode);
5375 print_addrs(&m_addrs, &m_uuid, m_nentries, printuuid);
5378 if ((as->parms[1].items) || (as->parms[0].items) || (i > nentries))
5386 LockEntry(register struct cmd_syndesc *as, void *arock)
5389 afs_int32 vcode, err;
5391 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5394 PrintError("", err);
5396 fprintf(STDERR, "vos: can't find volume '%s'\n",
5397 as->parms[0].items->data);
5400 vcode = ubik_VL_SetLock(cstruct, 0, avolid, -1, VLOP_DELETE);
5402 fprintf(STDERR, "Could not lock VLDB entry for volume %s\n",
5403 as->parms[0].items->data);
5404 PrintError("", vcode);
5407 fprintf(STDOUT, "Locked VLDB entry for volume %s\n",
5408 as->parms[0].items->data);
5413 ConvertRO(register struct cmd_syndesc *as, void *arock)
5415 afs_int32 partition = -1;
5417 afs_int32 server, code, i, same;
5418 struct nvldbentry entry, storeEntry;
5420 afs_int32 rwindex = 0;
5421 afs_int32 rwserver = 0;
5422 afs_int32 rwpartition = 0;
5423 afs_int32 roindex = 0;
5424 afs_int32 roserver = 0;
5425 afs_int32 ropartition = 0;
5427 struct rx_connection *aconn;
5430 server = GetServer(as->parms[0].items->data);
5432 fprintf(STDERR, "vos: host '%s' not found in host table\n",
5433 as->parms[0].items->data);
5436 partition = volutil_GetPartitionID(as->parms[1].items->data);
5437 if (partition < 0) {
5438 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5439 as->parms[1].items->data);
5442 if (!IsPartValid(partition, server, &code)) {
5444 PrintError("", code);
5447 "vos : partition %s does not exist on the server\n",
5448 as->parms[1].items->data);
5451 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &code);
5454 PrintError("", code);
5456 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
5457 as->parms[0].items->data);
5460 if (as->parms[3].items)
5463 vcode = VLDB_GetEntryByID(volid, -1, &entry);
5466 "Could not fetch the entry for volume %lu from VLDB\n",
5467 (unsigned long)volid);
5468 PrintError("convertROtoRW", code);
5472 /* use RO volid even if user specified RW or BK volid */
5474 if (volid != entry.volumeId[ROVOL])
5475 volid = entry.volumeId[ROVOL];
5477 MapHostToNetwork(&entry);
5478 for (i = 0; i < entry.nServers; i++) {
5479 if (entry.serverFlags[i] & ITSRWVOL) {
5481 rwserver = entry.serverNumber[i];
5482 rwpartition = entry.serverPartition[i];
5484 if (entry.serverFlags[i] & ITSROVOL) {
5485 same = VLDB_IsSameAddrs(server, entry.serverNumber[i], &code);
5488 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
5494 roserver = entry.serverNumber[i];
5495 ropartition = entry.serverPartition[i];
5501 fprintf(STDERR, "Warning: RO volume didn't exist in vldb!\n");
5503 if (ropartition != partition) {
5505 "Warning: RO volume should be in partition %d instead of %d (vldb)\n",
5506 ropartition, partition);
5511 "VLDB indicates that a RW volume exists already on %s in partition %s.\n",
5512 hostutil_GetNameByINet(rwserver),
5513 volutil_PartitionName(rwpartition));
5515 fprintf(STDERR, "Overwrite this VLDB entry? [y|n] (n)\n");
5517 while (!(dc == EOF || dc == '\n'))
5518 dc = getchar(); /* goto end of line */
5519 if ((c != 'y') && (c != 'Y')) {
5520 fprintf(STDERR, "aborted.\n");
5527 ubik_VL_SetLock(cstruct, 0, entry.volumeId[RWVOL], RWVOL,
5529 aconn = UV_Bind(server, AFSCONF_VOLUMEPORT);
5530 code = AFSVolConvertROtoRWvolume(aconn, partition, volid);
5533 "Converting RO volume %lu to RW volume failed with code %d\n",
5534 (unsigned long)volid, code);
5535 PrintError("convertROtoRW ", code);
5538 entry.serverFlags[roindex] = ITSRWVOL;
5539 entry.flags |= RW_EXISTS;
5540 entry.flags &= ~BACK_EXISTS;
5543 if (rwindex != entry.nServers) {
5544 entry.serverNumber[rwindex] = entry.serverNumber[entry.nServers];
5545 entry.serverPartition[rwindex] =
5546 entry.serverPartition[entry.nServers];
5547 entry.serverFlags[rwindex] = entry.serverFlags[entry.nServers];
5548 entry.serverNumber[entry.nServers] = 0;
5549 entry.serverPartition[entry.nServers] = 0;
5550 entry.serverFlags[entry.nServers] = 0;
5553 entry.flags &= ~RO_EXISTS;
5554 for (i = 0; i < entry.nServers; i++) {
5555 if (entry.serverFlags[i] & ITSROVOL) {
5556 if (!(entry.serverFlags[i] & (RO_DONTUSE | NEW_REPSITE)))
5557 entry.flags |= RO_EXISTS;
5560 MapNetworkToHost(&entry, &storeEntry);
5562 VLDB_ReplaceEntry(entry.volumeId[RWVOL], RWVOL, &storeEntry,
5563 (LOCKREL_OPCODE | LOCKREL_AFSID |
5564 LOCKREL_TIMESTAMP));
5567 "Warning: volume converted, but vldb update failed with code %d!\n",
5570 vcode = UV_LockRelease(entry.volumeId[RWVOL]);
5572 PrintDiagnostics("unlock", vcode);
5578 Sizes(register struct cmd_syndesc *as, void *arock)
5581 afs_int32 aserver, apart, voltype, fromdate = 0, code, err, i;
5582 struct nvldbentry entry;
5583 volintSize vol_size;
5585 rx_SetRxDeadTime(60 * 10);
5586 for (i = 0; i < MAXSERVERS; i++) {
5587 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
5590 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
5591 if (rxConn->service)
5592 rxConn->service->connDeadTime = rx_connDeadTime;
5595 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5598 PrintError("", err);
5600 fprintf(STDERR, "vos: can't find volume '%s'\n",
5601 as->parms[0].items->data);
5605 if (as->parms[1].items || as->parms[2].items) {
5606 if (!as->parms[1].items || !as->parms[2].items) {
5608 "Must specify both -server and -partition options\n");
5611 aserver = GetServer(as->parms[2].items->data);
5613 fprintf(STDERR, "Invalid server name\n");
5616 apart = volutil_GetPartitionID(as->parms[1].items->data);
5618 fprintf(STDERR, "Invalid partition name\n");
5622 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
5629 if (as->parms[4].items && strcmp(as->parms[4].items->data, "0")) {
5630 code = ktime_DateToInt32(as->parms[4].items->data, &fromdate);
5632 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
5633 as->parms[4].items->data, code);
5638 fprintf(STDOUT, "Volume: %s\n", as->parms[0].items->data);
5640 if (as->parms[3].items) { /* do the dump estimate */
5641 #ifdef AFS_64BIT_ENV
5642 vol_size.dump_size = 0;
5644 FillInt64(vol_size.dump_size,0, 1);
5646 code = UV_GetSize(avolid, aserver, apart, fromdate, &vol_size);
5648 PrintDiagnostics("size", code);
5651 /* presumably the size info is now gathered in pntr */
5652 /* now we display it */
5654 fprintf(STDOUT, "dump_size: %llu\n", vol_size.dump_size);
5663 PrintDiagnostics(char *astring, afs_int32 acode)
5665 if (acode == EACCES) {
5667 "You are not authorized to perform the 'vos %s' command (%d)\n",
5670 fprintf(STDERR, "Error in vos %s command.\n", astring);
5671 PrintError("", acode);
5678 MyBeforeProc(struct cmd_syndesc *as, void *arock)
5680 register char *tcell;
5681 register afs_int32 code;
5682 register afs_int32 sauth;
5684 /* Initialize the ubik_client connection */
5685 rx_SetRxDeadTime(90);
5686 cstruct = (struct ubik_client *)0;
5690 if (as->parms[12].items) /* if -cell specified */
5691 tcell = as->parms[12].items->data;
5692 if (as->parms[14].items) /* -serverauth specified */
5694 if (as->parms[16].items) /* -crypt specified */
5697 vsu_ClientInit((as->parms[13].items != 0), confdir, tcell, sauth,
5698 &cstruct, UV_SetSecurity))) {
5699 fprintf(STDERR, "could not initialize VLDB library (code=%lu) \n",
5700 (unsigned long)code);
5704 if (as->parms[15].items) /* -verbose flag set */
5708 if (as->parms[17].items) /* -noresolve flag set */
5718 /* this sucks but it works for now.
5723 #include "AFS_component_version_number.c"
5726 main(int argc, char **argv)
5728 register afs_int32 code;
5730 register struct cmd_syndesc *ts;
5732 #ifdef AFS_AIX32_ENV
5734 * The following signal action for AIX is necessary so that in case of a
5735 * crash (i.e. core is generated) we can include the user's data section
5736 * in the core dump. Unfortunately, by default, only a partial core is
5737 * generated which, in many cases, isn't too useful.
5739 struct sigaction nsa;
5741 sigemptyset(&nsa.sa_mask);
5742 nsa.sa_handler = SIG_DFL;
5743 nsa.sa_flags = SA_FULLDUMP;
5744 sigaction(SIGSEGV, &nsa, NULL);
5747 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
5749 cmd_SetBeforeProc(MyBeforeProc, NULL);
5751 ts = cmd_CreateSyntax("create", CreateVolume, NULL, "create a new volume");
5752 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5753 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5754 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "volume name");
5755 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL,
5756 "initial quota (KB)");
5757 cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_OPTIONAL, "volume ID");
5758 cmd_AddParm(ts, "-roid", CMD_SINGLE, CMD_OPTIONAL, "readonly volume ID");
5760 cmd_AddParm(ts, "-minquota", CMD_SINGLE, CMD_OPTIONAL, "");
5764 ts = cmd_CreateSyntax("remove", DeleteVolume, NULL, "delete a volume");
5765 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5766 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5767 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5771 ts = cmd_CreateSyntax("move", MoveVolume, NULL, "move a volume");
5772 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5773 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5774 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5775 "partition name on source");
5776 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5777 "machine name on destination");
5778 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5779 "partition name on destination");
5780 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5781 "copy live volume without cloning");
5784 ts = cmd_CreateSyntax("copy", CopyVolume, NULL, "copy a volume");
5785 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5786 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5787 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5788 "partition name on source");
5789 cmd_AddParm(ts, "-toname", CMD_SINGLE, 0, "volume name on destination");
5790 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5791 "machine name on destination");
5792 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5793 "partition name on destination");
5794 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5795 "leave new volume offline");
5796 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5797 "make new volume read-only");
5798 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5799 "copy live volume without cloning");
5802 ts = cmd_CreateSyntax("shadow", ShadowVolume, NULL,
5803 "make or update a shadow volume");
5804 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5805 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5806 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5807 "partition name on source");
5808 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5809 "machine name on destination");
5810 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5811 "partition name on destination");
5812 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5813 "volume name on destination");
5814 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5815 "volume ID on destination");
5816 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5817 "leave shadow volume offline");
5818 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5819 "make shadow volume read-only");
5820 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5821 "copy live volume without cloning");
5822 cmd_AddParm(ts, "-incremental", CMD_FLAG, CMD_OPTIONAL,
5823 "do incremental update if target exists");
5826 ts = cmd_CreateSyntax("backup", BackupVolume, NULL,
5827 "make backup of a volume");
5828 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5831 ts = cmd_CreateSyntax("clone", CloneVolume, NULL,
5832 "make clone of a volume");
5833 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5834 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5835 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5836 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5837 "volume name on destination");
5838 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5839 "volume ID on destination");
5840 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5841 "leave clone volume offline");
5842 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5843 "make clone volume read-only, not readwrite");
5846 ts = cmd_CreateSyntax("release", ReleaseVolume, NULL, "release a volume");
5847 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5848 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5849 "force a complete release");
5852 ts = cmd_CreateSyntax("dump", DumpVolumeCmd, NULL, "dump a volume");
5853 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5854 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
5855 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5856 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5857 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5858 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL,
5859 "dump a clone of the volume");
5860 cmd_AddParm(ts, "-omitdirs", CMD_FLAG, CMD_OPTIONAL,
5861 "omit unchanged directories from an incremental dump");
5864 ts = cmd_CreateSyntax("restore", RestoreVolumeCmd, NULL,
5865 "restore a volume");
5866 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5867 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5868 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of volume to be restored");
5869 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5870 cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_OPTIONAL, "volume ID");
5871 cmd_AddParm(ts, "-overwrite", CMD_SINGLE, CMD_OPTIONAL,
5872 "abort | full | incremental");
5873 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5874 "leave restored volume offline");
5875 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5876 "make restored volume read-only");
5877 cmd_AddParm(ts, "-creation", CMD_SINGLE, CMD_OPTIONAL,
5878 "dump | keep | new");
5879 cmd_AddParm(ts, "-lastupdate", CMD_SINGLE, CMD_OPTIONAL,
5880 "dump | keep | new");
5881 cmd_AddParm(ts, "-nodelete", CMD_FLAG, CMD_OPTIONAL,
5882 "do not delete old site when restoring to a new site");
5885 ts = cmd_CreateSyntax("unlock", LockReleaseCmd, NULL,
5886 "release lock on VLDB entry for a volume");
5887 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5890 ts = cmd_CreateSyntax("changeloc", ChangeLocation, NULL,
5891 "change an RW volume's location in the VLDB");
5892 cmd_AddParm(ts, "-server", CMD_SINGLE, 0,
5893 "machine name for new location");
5894 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5895 "partition name for new location");
5896 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5899 ts = cmd_CreateSyntax("addsite", AddSite, NULL, "add a replication site");
5900 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name for new site");
5901 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5902 "partition name for new site");
5903 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5904 cmd_AddParm(ts, "-roid", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID for RO");
5905 cmd_AddParm(ts, "-valid", CMD_FLAG, CMD_OPTIONAL, "publish as an up-to-date site in VLDB");
5908 ts = cmd_CreateSyntax("remsite", RemoveSite, NULL,
5909 "remove a replication site");
5910 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5911 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5912 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5915 ts = cmd_CreateSyntax("listpart", ListPartitions, NULL, "list partitions");
5916 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5919 ts = cmd_CreateSyntax("listvol", ListVolumes, NULL,
5920 "list volumes on server (bypass VLDB)");
5921 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5922 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5923 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "minimal listing");
5924 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL,
5925 "list all normal volume fields");
5926 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5927 "generate minimal information");
5928 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5929 "list extended volume fields");
5930 #ifdef FULL_LISTVOL_SWITCH
5931 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5932 "machine readable format");
5933 #endif /* FULL_LISTVOL_SWITCH */
5936 ts = cmd_CreateSyntax("syncvldb", SyncVldb, NULL,
5937 "synchronize VLDB with server");
5938 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5939 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5940 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5941 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
5944 ts = cmd_CreateSyntax("syncserv", SyncServer, NULL,
5945 "synchronize server with VLDB");
5946 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5947 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5948 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
5951 ts = cmd_CreateSyntax("examine", ExamineVolume, NULL,
5952 "everything about the volume");
5953 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5954 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5955 "list extended volume fields");
5956 #ifdef FULL_LISTVOL_SWITCH
5957 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5958 "machine readable format");
5959 #endif /* FULL_LISTVOL_SWITCH */
5961 cmd_CreateAlias(ts, "volinfo");
5963 ts = cmd_CreateSyntax("setfields", SetFields, NULL,
5964 "change volume info fields");
5965 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5966 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL, "quota (KB)");
5967 cmd_AddParm(ts, "-clearuse", CMD_FLAG, CMD_OPTIONAL, "clear dayUse");
5968 cmd_AddParm(ts, "-clearVolUpCounter", CMD_FLAG, CMD_OPTIONAL, "clear volUpdateCounter");
5971 ts = cmd_CreateSyntax("offline", volOffline, NULL, "force the volume status to offline");
5972 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5973 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5974 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5975 cmd_AddParm(ts, "-sleep", CMD_SINGLE, CMD_OPTIONAL, "seconds to sleep");
5976 cmd_AddParm(ts, "-busy", CMD_FLAG, CMD_OPTIONAL, "busy volume");
5979 ts = cmd_CreateSyntax("online", volOnline, NULL, "force the volume status to online");
5980 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5981 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5982 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5985 ts = cmd_CreateSyntax("zap", VolumeZap, NULL,
5986 "delete the volume, don't bother with VLDB");
5987 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5988 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5989 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume ID");
5990 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5991 "force deletion of bad volumes");
5992 cmd_AddParm(ts, "-backup", CMD_FLAG, CMD_OPTIONAL,
5993 "also delete backup volume if one is found");
5996 ts = cmd_CreateSyntax("status", VolserStatus, NULL,
5997 "report on volser status");
5998 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
6001 ts = cmd_CreateSyntax("rename", RenameVolume, NULL, "rename a volume");
6002 cmd_AddParm(ts, "-oldname", CMD_SINGLE, 0, "old volume name ");
6003 cmd_AddParm(ts, "-newname", CMD_SINGLE, 0, "new volume name ");
6006 ts = cmd_CreateSyntax("listvldb", ListVLDB, NULL,
6007 "list volumes in the VLDB");
6008 cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
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, "-locked", CMD_FLAG, CMD_OPTIONAL, "locked volumes only");
6012 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
6013 "generate minimal information");
6014 cmd_AddParm(ts, "-nosort", CMD_FLAG, CMD_OPTIONAL,
6015 "do not alphabetically sort the volume names");
6018 ts = cmd_CreateSyntax("backupsys", BackSys, NULL, "en masse backups");
6019 cmd_AddParm(ts, "-prefix", CMD_LIST, CMD_OPTIONAL,
6020 "common prefix on volume(s)");
6021 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6022 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6023 cmd_AddParm(ts, "-exclude", CMD_FLAG, CMD_OPTIONAL,
6024 "exclude common prefix volumes");
6025 cmd_AddParm(ts, "-xprefix", CMD_LIST, CMD_OPTIONAL,
6026 "negative prefix on volume(s)");
6027 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "no action");
6030 ts = cmd_CreateSyntax("delentry", DeleteEntry, NULL,
6031 "delete VLDB entry for a volume");
6032 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL, "volume name or ID");
6033 cmd_AddParm(ts, "-prefix", CMD_SINGLE, CMD_OPTIONAL,
6034 "prefix of the volume whose VLDB entry is to be deleted");
6035 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6036 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6037 cmd_AddParm(ts, "-noexecute", CMD_FLAG, CMD_OPTIONAL,
6041 ts = cmd_CreateSyntax("partinfo", PartitionInfo, NULL,
6042 "list partition information");
6043 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
6044 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6045 cmd_AddParm(ts, "-summary", CMD_FLAG, CMD_OPTIONAL,
6046 "print storage summary");
6049 ts = cmd_CreateSyntax("unlockvldb", UnlockVLDB, NULL,
6050 "unlock all the locked entries in the VLDB");
6051 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6052 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6055 ts = cmd_CreateSyntax("lock", LockEntry, NULL,
6056 "lock VLDB entry for a volume");
6057 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6060 ts = cmd_CreateSyntax("changeaddr", ChangeAddr, NULL,
6061 "change the IP address of a file server");
6062 cmd_AddParm(ts, "-oldaddr", CMD_SINGLE, 0, "original IP address");
6063 cmd_AddParm(ts, "-newaddr", CMD_SINGLE, CMD_OPTIONAL, "new IP address");
6064 cmd_AddParm(ts, "-remove", CMD_FLAG, CMD_OPTIONAL,
6065 "remove the IP address from the VLDB");
6068 ts = cmd_CreateSyntax("listaddrs", ListAddrs, NULL,
6069 "list the IP address of all file servers registered in the VLDB");
6070 cmd_AddParm(ts, "-uuid", CMD_SINGLE, CMD_OPTIONAL, "uuid of server");
6071 cmd_AddParm(ts, "-host", CMD_SINGLE, CMD_OPTIONAL, "address of host");
6072 cmd_AddParm(ts, "-printuuid", CMD_FLAG, CMD_OPTIONAL,
6073 "print uuid of hosts");
6076 ts = cmd_CreateSyntax("convertROtoRW", ConvertRO, NULL,
6077 "convert a RO volume into a RW volume (after loss of old RW volume)");
6078 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
6079 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
6080 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6081 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, "don't ask");
6084 ts = cmd_CreateSyntax("size", Sizes, NULL,
6085 "obtain various sizes of the volume.");
6086 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6087 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6088 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6089 cmd_AddParm(ts, "-dump", CMD_FLAG, CMD_OPTIONAL,
6090 "Obtain the size of the dump");
6091 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
6094 code = cmd_Dispatch(argc, argv);
6096 /* Shut down the ubik_client and rx connections */
6098 (void)ubik_ClientDestroy(cstruct);
6104 exit((code ? -1 : 0));