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>
15 #include <sys/types.h>
24 #include <netinet/in.h>
28 #include <sys/statfs.h>
35 #include <rx/rx_globals.h>
37 #include <afs/vlserver.h>
39 #include <afs/cellconfig.h>
41 #include <afs/afsutil.h>
43 #include <afs/afsint.h>
65 #define COMMONPARMS cmd_Seek(ts, 12);\
66 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");\
67 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "don't authenticate");\
68 cmd_AddParm(ts, "-localauth",CMD_FLAG,CMD_OPTIONAL,"use server tickets");\
69 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose");\
70 cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL, "encrypt commands");\
72 #define ERROR_EXIT(code) {error=(code); goto error_exit;}
76 struct rx_connection *tconn;
78 extern struct ubik_client *cstruct;
80 extern struct rx_connection *UV_Bind();
81 extern struct rx_securityClass *rxnull_NewClientSecurityObject();
82 extern int UV_SetSecurity();
83 extern int UV_SetVolumeInfo();
84 extern int vsu_SetCrypt();
86 extern VL_ReleaseLock();
87 extern VL_DeleteEntry();
88 extern VL_ListEntry();
90 extern VL_GetAddrsU();
91 extern VL_ChangeAddr();
93 extern int vsu_ExtractName();
95 extern int MapPartIdIntoName();
96 extern int MapHostToNetwork();
97 extern int MapNetworkToHost();
98 extern void EnumerateEntry();
99 extern void SubEnumerateEntry();
102 static struct tqHead busyHead, notokHead;
104 static void qInit(ahead)
105 struct tqHead *ahead;
107 memset((char *)ahead, 0, sizeof(struct tqHead));
112 static void qPut(ahead,volid)
113 struct tqHead *ahead;
118 elem = (struct tqElem *)malloc(sizeof(struct tqElem));
119 elem->next = ahead->next;
126 static void qGet(ahead,volid)
127 struct tqHead *ahead;
132 if(ahead->count <= 0) return;
133 *volid = ahead->next->volid;
135 ahead->next = tmp->next;
141 /* returns 1 if <filename> exists else 0 */
142 static FileExists(filename)
149 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
153 code = USD_IOCTL(ufd, USD_IOCTL_GETSIZE, &size);
161 /* returns 1 if <name> doesnot end in .readonly or .backup, else 0 */
162 static VolNameOK(name)
168 total = strlen(name);
169 if(!strcmp(&name[total - 9],".readonly")) {
172 else if(!strcmp(&name[total - 7 ],".backup")) {
180 /* return 1 if name is a number else 0 */
181 static IsNumeric(name)
190 for(i = 0; i < len ; i++){
191 if(*ptr < '0' || *ptr > '9'){
205 * Parse a server name/address and return the address in HOST BYTE order
207 afs_int32 GetServer(aname)
209 register struct hostent *th;
212 register afs_int32 code;
213 char hostname[MAXHOSTCHARS];
215 code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
217 addr = (b1<<24) | (b2<<16) | (b3<<8) | b4;
218 addr = ntohl(addr); /* convert to host order */
220 th = gethostbyname(aname);
222 memcpy(&addr, th->h_addr, sizeof(addr));
225 if (addr == htonl(0x7f000001)) { /* local host */
226 code = gethostname(hostname, MAXHOSTCHARS);
228 th = gethostbyname(hostname); /* returns host byte order */
230 memcpy(&addr, th->h_addr, sizeof(addr));
236 afs_int32 GetVolumeType(aname)
240 if(!strcmp(aname,"ro"))
242 else if(!strcmp(aname, "rw"))
244 else if(!strcmp(aname,"bk"))
249 int IsPartValid(partId, server, code)
250 afs_int32 server, partId,*code;
253 struct partList dummyPartList;
261 *code = UV_ListPartitions(server,&dummyPartList, &cnt);
262 if(*code) return success;
263 for(i = 0 ; i < cnt ; i++) {
264 if(dummyPartList.partFlags[i] & PARTVALID)
265 if(dummyPartList.partId[i] == partId)
273 /*sends the contents of file associated with <fd> and <blksize> to Rx Stream
274 * associated with <call> */
275 SendFile(ufd, call, blksize)
277 register struct rx_call *call;
280 char *buffer = (char*) 0;
285 buffer = (char *)malloc(blksize);
287 fprintf(STDERR,"malloc failed\n");
291 while (!error && !done) {
292 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
295 FD_SET((int)(ufd->handle), &in);
296 /* don't timeout if read blocks */
297 IOMGR_Select(((int)(ufd->handle))+1, &in, 0, 0, 0);
299 error = USD_READ(ufd, buffer, blksize, &nbytes);
301 fprintf(STDERR, "File system read failed\n");
308 if (rx_Write(call, buffer, nbytes) != nbytes){
313 if (buffer) free(buffer);
317 /* function invoked by UV_RestoreVolume, reads the data from rx_trx_stream and
318 * writes it out to the volume. */
319 afs_int32 WriteData(call,rock)
320 struct rx_call *call;
326 afs_int32 error,code;
332 if(!filename || !*filename) {
333 usd_StandardInput(&ufd);
337 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
340 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
343 fprintf(STDERR,"Could not access file '%s'\n", filename);
348 code = SendFile(ufd,call,blksize);
355 code = USD_CLOSE(ufd);
357 fprintf(STDERR,"Could not close dump file %s\n",
358 (filename && *filename)?filename:"STDOUT");
359 if(!error) error = code;
365 /* Receive data from <call> stream into file associated
366 * with <fd> <blksize>
368 int ReceiveFile(ufd, call, blksize)
370 struct rx_call *call;
373 char *buffer = (char *) 0;
375 afs_uint32 bytesleft, w;
378 buffer = (char *)malloc(blksize);
380 fprintf(STDERR,"memory allocation failed\n");
384 while ((bytesread=rx_Read(call,buffer,blksize)) > 0) {
385 for (bytesleft=bytesread; bytesleft; bytesleft-=w) {
386 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
389 FD_SET((int)(ufd->handle), &out);
390 /* don't timeout if write blocks */
391 IOMGR_Select(((int)(ufd->handle))+1, 0, &out, 0, 0);
393 error = USD_WRITE(ufd, &buffer[bytesread-bytesleft], bytesleft, &w);
395 fprintf(STDERR,"File system write failed\n");
402 if (buffer) free(buffer);
406 afs_int32 DumpFunction(call, filename)
407 struct rx_call *call;
410 usd_handle_t ufd; /* default is to stdout */
411 afs_int32 error=0, code;
416 /* Open the output file */
417 if (!filename || !*filename) {
418 usd_StandardOutput(&ufd);
422 code = usd_Open(filename, USD_OPEN_CREATE|USD_OPEN_RDWR, 0666, &ufd);
426 code = USD_IOCTL(ufd, USD_IOCTL_SETSIZE, &size);
429 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
432 fprintf(STDERR, "Could not create file '%s'\n", filename);
433 ERROR_EXIT(VOLSERBADOP);
437 code = ReceiveFile(ufd, call, blksize);
438 if (code) ERROR_EXIT(code);
441 /* Close the output file */
443 code = USD_CLOSE(ufd);
445 fprintf(STDERR,"Could not close dump file %s\n",
446 (filename && *filename)?filename:"STDIN");
447 if (!error) error = code;
454 static void DisplayFormat(pntr,server,part,totalOK,totalNotOK,totalBusy,fast,longlist,disp)
456 afs_int32 server,part;
457 int *totalOK,*totalNotOK,*totalBusy;
458 int fast,longlist, disp;
463 fprintf(STDOUT,"%-10u\n",pntr->volid);
466 if(pntr->status == VOK){
467 fprintf(STDOUT,"%-32s ",pntr->name);
468 fprintf(STDOUT,"%10u ",pntr->volid);
469 if(pntr->type == 0) fprintf(STDOUT,"RW ");
470 if(pntr->type == 1) fprintf(STDOUT,"RO ");
471 if(pntr->type == 2) fprintf(STDOUT,"BK ");
472 fprintf(STDOUT,"%10d K ",pntr->size);
473 if(pntr->inUse == 1) {
474 fprintf(STDOUT,"On-line");
477 fprintf(STDOUT,"Off-line");
480 if(pntr->needsSalvaged == 1) fprintf(STDOUT,"**needs salvage**");
481 fprintf(STDOUT,"\n");
482 MapPartIdIntoName(part,pname);
483 fprintf(STDOUT," %s %s \n",hostutil_GetNameByINet(server),pname);
484 fprintf(STDOUT," RWrite %10u ROnly %10u Backup %10u \n", pntr->parentID,pntr->cloneID, pntr->backupID);
485 fprintf(STDOUT," MaxQuota %10d K \n",pntr->maxquota);
486 fprintf(STDOUT," Creation %s",
487 ctime((time_t *)&pntr->creationDate));
488 if(pntr->updateDate < pntr->creationDate)
489 fprintf(STDOUT," Last Update %s",
490 ctime((time_t *)&pntr->creationDate));
492 fprintf(STDOUT," Last Update %s",
493 ctime((time_t *)&pntr->updateDate));
494 fprintf(STDOUT, " %d accesses in the past day (i.e., vnode references)\n",
497 else if (pntr->status == VBUSY) {
499 qPut(&busyHead,pntr->volid);
500 if (disp) fprintf(STDOUT,"**** Volume %u is busy ****\n",pntr->volid);
504 qPut(¬okHead,pntr->volid);
505 if (disp) fprintf(STDOUT,"**** Could not attach volume %u ****\n",pntr->volid);
507 fprintf(STDOUT,"\n");
509 else {/* default listing */
510 if(pntr->status == VOK){
511 fprintf(STDOUT,"%-32s ",pntr->name);
512 fprintf(STDOUT,"%10u ",pntr->volid);
513 if(pntr->type == 0) fprintf(STDOUT,"RW ");
514 if(pntr->type == 1) fprintf(STDOUT,"RO ");
515 if(pntr->type == 2) fprintf(STDOUT,"BK ");
516 fprintf(STDOUT,"%10d K ",pntr->size);
517 if(pntr->inUse == 1) {
518 fprintf(STDOUT,"On-line");
521 fprintf(STDOUT,"Off-line");
524 if(pntr->needsSalvaged == 1) fprintf(STDOUT,"**needs salvage**");
525 fprintf(STDOUT,"\n");
527 else if (pntr->status == VBUSY) {
529 qPut(&busyHead,pntr->volid);
530 if (disp) fprintf(STDOUT,"**** Volume %u is busy ****\n",pntr->volid);
534 qPut(¬okHead,pntr->volid);
535 if (disp) fprintf(STDOUT,"**** Could not attach volume %u ****\n",pntr->volid);
540 /*------------------------------------------------------------------------
541 * PRIVATE XDisplayFormat
544 * Display the contents of one extended volume info structure.
547 * a_xInfoP : Ptr to extended volume info struct to print.
548 * a_servID : Server ID to print.
549 * a_partID : Partition ID to print.
550 * a_totalOKP : Ptr to total-OK counter.
551 * a_totalNotOKP : Ptr to total-screwed counter.
552 * a_totalBusyP : Ptr to total-busy counter.
553 * a_fast : Fast listing?
554 * a_int32 : Int32 listing?
555 * a_showProblems : Show volume problems?
561 * Nothing interesting.
565 *------------------------------------------------------------------------*/
567 static void XDisplayFormat(a_xInfoP, a_servID, a_partID, a_totalOKP,
568 a_totalNotOKP, a_totalBusyP, a_fast, a_int32,
570 volintXInfo *a_xInfoP;
588 fprintf(STDOUT, "%-10u\n", a_xInfoP->volid);
593 * Fully-detailed listing.
595 if (a_xInfoP->status == VOK) {
597 * Volume's status is OK - all the fields are valid.
599 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
600 fprintf(STDOUT, "%10u ", a_xInfoP->volid);
601 if (a_xInfoP->type == 0) fprintf(STDOUT,"RW ");
602 if (a_xInfoP->type == 1) fprintf(STDOUT,"RO ");
603 if (a_xInfoP->type == 2) fprintf(STDOUT,"BK ");
604 fprintf(STDOUT, "%10d K used ", a_xInfoP->size);
605 fprintf(STDOUT, "%d files ", a_xInfoP->filecount);
606 if(a_xInfoP->inUse == 1) {
607 fprintf(STDOUT, "On-line");
611 fprintf(STDOUT, "Off-line");
614 fprintf(STDOUT, "\n");
615 MapPartIdIntoName(a_partID, pname);
616 fprintf(STDOUT, " %s %s \n",
617 hostutil_GetNameByINet(a_servID),
619 fprintf(STDOUT, " RWrite %10u ROnly %10u Backup %10u \n",
620 a_xInfoP->parentID, a_xInfoP->cloneID, a_xInfoP->backupID);
621 fprintf(STDOUT, " MaxQuota %10d K \n",
623 fprintf(STDOUT, " Creation %s",
624 ctime((time_t *)&a_xInfoP->creationDate));
625 if (a_xInfoP->updateDate < a_xInfoP->creationDate)
626 fprintf(STDOUT, " Last Update %s",
627 ctime((time_t *)&a_xInfoP->creationDate));
629 fprintf(STDOUT, " Last Update %s",
630 ctime((time_t *)&a_xInfoP->updateDate));
631 fprintf(STDOUT, " %d accesses in the past day (i.e., vnode references)\n",
635 * Print all the read/write and authorship stats.
638 "\n Raw Read/Write Stats\n");
640 " |-------------------------------------------|\n");
642 " | Same Network | Diff Network |\n");
644 " |----------|----------|----------|----------|\n");
646 " | Total | Auth | Total | Auth |\n");
648 " |----------|----------|----------|----------|\n");
650 "Reads | %8d | %8d | %8d | %8d |\n",
651 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET],
652 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH],
653 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET],
654 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
656 "Writes | %8d | %8d | %8d | %8d |\n",
657 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET],
658 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH],
659 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET],
660 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
662 " |-------------------------------------------|\n\n");
665 " Writes Affecting Authorship\n");
667 " |-------------------------------------------|\n");
669 " | File Authorship | Directory Authorship|\n");
671 " |----------|----------|----------|----------|\n");
673 " | Same | Diff | Same | Diff |\n");
675 " |----------|----------|----------|----------|\n");
677 "0-60 sec | %8d | %8d | %8d | %8d |\n",
678 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_0],
679 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0],
680 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0],
681 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]);
683 "1-10 min | %8d | %8d | %8d | %8d |\n",
684 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1],
685 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1],
686 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1],
687 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]);
689 "10min-1hr | %8d | %8d | %8d | %8d |\n",
690 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_2],
691 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_2],
692 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_2],
693 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_2]);
695 "1hr-1day | %8d | %8d | %8d | %8d |\n",
696 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_3],
697 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_3],
698 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_3],
699 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_3]);
701 "1day-1wk | %8d | %8d | %8d | %8d |\n",
702 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_4],
703 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_4],
704 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_4],
705 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_4]);
707 "> 1wk | %8d | %8d | %8d | %8d |\n",
708 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_5],
709 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5],
710 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5],
711 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]);
713 " |-------------------------------------------|\n");
714 } /*Volume status OK*/
716 if (a_xInfoP->status == VBUSY) {
718 qPut(&busyHead, a_xInfoP->volid);
720 fprintf(STDOUT, "**** Volume %u is busy ****\n",
725 qPut(¬okHead, a_xInfoP->volid);
727 fprintf(STDOUT, "**** Could not attach volume %u ****\n",
730 fprintf(STDOUT,"\n");
736 if (a_xInfoP->status == VOK) {
737 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
738 fprintf(STDOUT, "%10u ", a_xInfoP->volid);
739 if (a_xInfoP->type == 0) fprintf(STDOUT, "RW ");
740 if (a_xInfoP->type == 1) fprintf(STDOUT, "RO ");
741 if (a_xInfoP->type == 2) fprintf(STDOUT, "BK ");
742 fprintf(STDOUT, "%10d K ", a_xInfoP->size);
743 if(a_xInfoP->inUse == 1) {
744 fprintf(STDOUT, "On-line");
747 fprintf(STDOUT, "Off-line");
750 fprintf(STDOUT, "\n");
753 if (a_xInfoP->status == VBUSY) {
755 qPut(&busyHead, a_xInfoP->volid);
757 fprintf(STDOUT,"**** Volume %u is busy ****\n",
762 qPut(¬okHead, a_xInfoP->volid);
764 fprintf(STDOUT,"**** Could not attach volume %u ****\n",
767 } /*Default listing*/
770 #ifdef FULL_LISTVOL_SWITCH
771 static void DisplayFormat2(server, partition, pntr)
772 long server, partition;
775 static long server_cache = -1, partition_cache = -1;
776 static char hostname[256],
780 if (server != server_cache) {
784 strcpy(hostname, hostutil_GetNameByINet(server));
785 strcpy(address, inet_ntoa(s));
786 server_cache = server;
788 if (partition != partition_cache) {
789 MapPartIdIntoName(partition, pname);
790 partition_cache = partition;
792 fprintf(STDOUT, "name\t\t%s\n", pntr->name);
793 fprintf(STDOUT, "id\t\t%lu\n", pntr->volid);
794 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
795 fprintf(STDOUT, "part\t\t%s\n", pname);
796 switch (pntr->status) {
798 fprintf(STDOUT, "status\t\tOK\n");
801 fprintf(STDOUT, "status\t\tBUSY\n");
804 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
807 fprintf(STDOUT, "backupID\t%lu\n", pntr->backupID);
808 fprintf(STDOUT, "parentID\t%lu\n", pntr->parentID);
809 fprintf(STDOUT, "cloneID\t\t%lu\n", pntr->cloneID);
810 fprintf(STDOUT, "inUse\t\t%s\n", pntr->inUse ? "Y" : "N");
811 fprintf(STDOUT, "needsSalvaged\t%s\n", pntr->needsSalvaged ? "Y" : "N");
812 /* 0xD3 is from afs/volume.h since I had trouble including the file */
813 fprintf(STDOUT, "destroyMe\t%s\n", pntr->destroyMe == 0xD3 ? "Y" : "N");
814 switch (pntr->type) {
816 fprintf(STDOUT, "type\t\tRW\n");
819 fprintf(STDOUT, "type\t\tRO\n");
822 fprintf(STDOUT, "type\t\tBK\n");
825 fprintf(STDOUT, "type\t\t?\n");
828 fprintf(STDOUT, "creationDate\t%-9lu\t%s", pntr->creationDate, ctime(&pntr->creationDate));
829 fprintf(STDOUT, "accessDate\t%-9lu\t%s", pntr->accessDate, ctime(&pntr->accessDate));
830 fprintf(STDOUT, "updateDate\t%-9lu\t%s", pntr->updateDate, ctime(&pntr->updateDate));
831 fprintf(STDOUT, "backupDate\t%-9lu\t%s", pntr->backupDate, ctime(&pntr->backupDate));
832 fprintf(STDOUT, "copyDate\t%-9lu\t%s", pntr->copyDate, ctime(&pntr->copyDate));
833 fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n", pntr->flags);
834 fprintf(STDOUT, "diskused\t%u\n", pntr->size);
835 fprintf(STDOUT, "maxquota\t%u\n", pntr->maxquota);
836 fprintf(STDOUT, "minquota\t%lu\t(Optional)\n", pntr->spare0);
837 fprintf(STDOUT, "filecount\t%u\n", pntr->filecount);
838 fprintf(STDOUT, "dayUse\t\t%u\n", pntr->dayUse);
839 fprintf(STDOUT, "weekUse\t\t%lu\t(Optional)\n", pntr->spare1);
840 fprintf(STDOUT, "spare2\t\t%lu\t(Optional)\n", pntr->spare2);
841 fprintf(STDOUT, "spare3\t\t%lu\t(Optional)\n", pntr->spare3);
845 static void DisplayVolumes2(server, partition, pntr, count)
847 long server, partition, count;
851 for (i = 0; i < count; i++) {
852 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
853 DisplayFormat2(server, partition, pntr);
854 fprintf(STDOUT, "END_OF_ENTRY\n\n");
859 #endif /* FULL_LISTVOL_SWITCH */
861 static void DisplayVolumes(server,part,pntr,count,longlist,fast,quiet)
862 afs_int32 server,part;
864 afs_int32 count,longlist,fast;
867 int totalOK,totalNotOK,totalBusy, i;
875 for(i = 0; i < count; i++){
876 DisplayFormat(pntr,server,part,&totalOK,&totalNotOK,&totalBusy,fast,longlist,0);
880 while(busyHead.count){
881 qGet(&busyHead,&volid);
882 fprintf(STDOUT,"**** Volume %u is busy ****\n",volid);
886 while(notokHead.count){
887 qGet(¬okHead,&volid);
888 fprintf(STDOUT,"**** Could not attach volume %u ****\n",volid);
892 fprintf(STDOUT,"\n");
894 fprintf(STDOUT,"Total volumes onLine %d ; Total volumes offLine %d ; Total busy %d\n\n",totalOK,totalNotOK,totalBusy);
899 /*------------------------------------------------------------------------
900 * PRIVATE XDisplayVolumes
903 * Display extended volume information.
906 * a_servID : Pointer to the Rx call we're performing.
907 * a_partID : Partition for which we want the extended list.
908 * a_xInfoP : Ptr to extended volume info.
909 * a_count : Number of volume records contained above.
910 * a_int32 : Int32 listing generated?
911 * a_fast : Fast listing generated?
912 * a_quiet : Quiet listing generated?
918 * Nothing interesting.
922 *------------------------------------------------------------------------*/
924 static void XDisplayVolumes(a_servID, a_partID, a_xInfoP,
925 a_count, a_int32, a_fast, a_quiet)
928 volintXInfo *a_xInfoP;
934 { /*XDisplayVolumes*/
936 int totalOK; /*Total OK volumes*/
937 int totalNotOK; /*Total screwed volumes*/
938 int totalBusy; /*Total busy volumes*/
939 int i; /*Loop variable*/
940 afs_int32 volid; /*Current volume ID*/
943 * Initialize counters and (global!!) queues.
952 * Display each volume in the list.
954 for(i = 0; i < a_count; i++) {
955 XDisplayFormat(a_xInfoP,
968 * If any volumes were found to be busy or screwed, display them.
971 while (busyHead.count) {
972 qGet(&busyHead, &volid);
973 fprintf(STDOUT, "**** Volume %u is busy ****\n", volid);
977 while (notokHead.count) {
978 qGet(¬okHead, &volid);
979 fprintf(STDOUT, "**** Could not attach volume %u ****\n", volid);
984 fprintf(STDOUT, "\n");
987 "Total volumes: %d on-line, %d off-line, %d busyd\n\n",
988 totalOK, totalNotOK, totalBusy);
992 } /*XDisplayVolumes*/
994 /* set <server> and <part> to the correct values depending on
995 * <voltype> and <entry> */
996 static void GetServerAndPart (entry, voltype, server, part, previdx)
997 struct nvldbentry *entry;
998 afs_int32 *server,*part;
1002 int i, istart, vtype;
1007 /* Doesn't check for non-existance of backup volume */
1008 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
1010 istart = 0; /* seach the entire entry */
1013 /* Seach from beginning of entry or pick up where we left off */
1014 istart = ((*previdx < 0) ? 0 : *previdx+1);
1017 for (i = istart; i < entry->nServers; i++) {
1018 if (entry->serverFlags[i] & vtype) {
1019 *server = entry->serverNumber[i];
1020 *part = entry->serverPartition[i];
1026 /* Didn't find any, return -1 */
1031 static void PostVolumeStats(entry)
1032 struct nvldbentry *entry;
1034 SubEnumerateEntry(entry);
1035 /* Check for VLOP_ALLOPERS */
1036 if (entry->flags & VLOP_ALLOPERS)
1037 fprintf(STDOUT," Volume is currently LOCKED \n");
1041 /*------------------------------------------------------------------------
1042 * PRIVATE XVolumeStats
1045 * Display extended volume information.
1048 * a_xInfoP : Ptr to extended volume info.
1049 * a_entryP : Ptr to the volume's VLDB entry.
1050 * a_srvID : Server ID.
1051 * a_partID : Partition ID.
1052 * a_volType : Type of volume to print.
1058 * Nothing interesting.
1062 *------------------------------------------------------------------------*/
1064 static void XVolumeStats(a_xInfoP, a_entryP, a_srvID, a_partID, a_volType)
1065 volintXInfo *a_xInfoP;
1066 struct nvldbentry *a_entryP;
1073 int totalOK, totalNotOK, totalBusy; /*Dummies - we don't really count here*/
1075 XDisplayFormat(a_xInfoP, /*Ptr to extended volume info*/
1076 a_srvID, /*Server ID to print*/
1077 a_partID, /*Partition ID to print*/
1078 &totalOK, /*Ptr to total-OK counter*/
1079 &totalNotOK, /*Ptr to total-screwed counter*/
1080 &totalBusy, /*Ptr to total-busy counter*/
1081 0, /*Don't do a fast listing*/
1082 1, /*Do a long listing*/
1083 1); /*Show volume problems*/
1088 static void VolumeStats(pntr,entry,server,part,voltype)
1090 struct nvldbentry *entry;
1092 afs_int32 server,part;
1094 int totalOK,totalNotOK,totalBusy;
1095 afs_int32 vcode,vcode2;
1097 DisplayFormat(pntr,server,part,&totalOK,&totalNotOK,&totalBusy,0,1,1);
1101 /* command to forcibly remove a volume */
1102 static NukeVolume(as)
1103 register struct cmd_syndesc *as; {
1104 register afs_int32 code;
1105 afs_int32 volID, err;
1110 server = GetServer(tp = as->parms[0].items->data);
1112 fprintf(STDERR,"vos: server '%s' not found in host table\n", tp);
1116 partID = volutil_GetPartitionID(tp = as->parms[1].items->data);
1118 fprintf(STDERR, "vos: could not parse '%s' as a partition name", tp);
1122 volID = vsu_GetVolumeID(tp = as->parms[2].items->data, cstruct, &err);
1124 if (err) PrintError("", err);
1125 else fprintf(STDERR, "vos: could not parse '%s' as a numeric volume ID", tp);
1129 fprintf(STDOUT, "vos: forcibly removing all traces of volume %d, please wait...", volID);
1131 code = UV_NukeVolume(server, partID, volID);
1133 fprintf(STDOUT, "done.\n");
1135 fprintf(STDOUT, "failed with code %d.\n", code);
1140 /*------------------------------------------------------------------------
1141 * PRIVATE ExamineVolume
1144 * Routine used to examine a single volume, contacting the VLDB as
1145 * well as the Volume Server.
1148 * as : Ptr to parsed command line arguments.
1151 * 0 for a successful operation,
1152 * Otherwise, one of the ubik or VolServer error values.
1155 * Nothing interesting.
1159 *------------------------------------------------------------------------
1161 static ExamineVolume(as)
1162 register struct cmd_syndesc *as;
1164 struct nvldbentry entry;
1165 afs_int32 vcode = 0;
1166 volintInfo *pntr = (volintInfo *)0;
1167 volintXInfo *xInfoP = (volintXInfo *)0;
1169 afs_int32 code, err, error = 0;
1170 int voltype, foundserv = 0, foundentry = 0;
1171 afs_int32 aserver, apart;
1173 int wantExtendedInfo; /*Do we want extended vol info?*/
1175 wantExtendedInfo = (as->parms[1].items ? 1 : 0); /* -extended */
1177 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1179 if (err) PrintError("", err);
1180 else fprintf(STDERR, "Unknown volume ID or name '%s'\n", as->parms[0].items->data);
1185 fprintf(STDOUT, "Fetching VLDB entry for %u .. ", volid);
1188 vcode = VLDB_GetEntryByID (volid, -1, &entry);
1190 fprintf(STDERR, "Could not fetch the entry for volume number %u from VLDB \n",volid);
1194 fprintf(STDOUT, "done\n");
1195 MapHostToNetwork(&entry);
1197 if (entry.volumeId[RWVOL] == volid)
1199 else if (entry.volumeId[BACKVOL] == volid)
1201 else /* (entry.volumeId[ROVOL] == volid) */
1204 do { /* do {...} while (voltype == ROVOL) */
1205 /* Get the entry for the volume. If its a RW vol, get the RW entry.
1206 * It its a BK vol, get the RW entry (even if VLDB may say the BK doen't exist).
1207 * If its a RO vol, get the next RO entry.
1209 GetServerAndPart(&entry, ((voltype == ROVOL) ? ROVOL : RWVOL), &aserver, &apart, &previdx);
1210 if (previdx == -1) { /* searched all entries */
1212 fprintf(STDERR,"Volume %s does not exist in VLDB\n\n", as->parms[0].items->data);
1219 /* Get information about the volume from the server */
1221 fprintf(STDOUT,"Getting volume listing from the server %s .. ",
1222 hostutil_GetNameByINet(aserver));
1225 if (wantExtendedInfo)
1226 code = UV_XListOneVolume(aserver, apart, volid, &xInfoP);
1228 code = UV_ListOneVolume(aserver, apart, volid, &pntr);
1230 fprintf(STDOUT,"done\n");
1234 if (code == ENODEV) {
1235 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1236 /* The VLDB says there is no backup volume and its not on disk */
1237 fprintf(STDERR, "Volume %s does not exist\n", as->parms[0].items->data);
1240 fprintf(STDERR, "Volume does not exist on server %s as indicated by the VLDB\n",
1241 hostutil_GetNameByINet(aserver));
1244 PrintDiagnostics("examine", code);
1246 fprintf(STDOUT, "\n");
1249 if (wantExtendedInfo)
1250 XVolumeStats(xInfoP, &entry, aserver, apart, voltype);
1252 #ifdef FULL_LISTVOL_SWITCH
1253 if (as->parms[2].items) {
1254 DisplayFormat2(aserver, apart, pntr);
1255 EnumerateEntry(&entry);
1257 #endif /* FULL_LISTVOL_SWITCH */
1258 VolumeStats(pntr, &entry, aserver, apart, voltype);
1260 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1261 /* The VLDB says there is no backup volume yet we found one on disk */
1262 fprintf(STDERR, "Volume %s does not exist in VLDB\n", as->parms[0].items->data);
1267 if (pntr) free(pntr);
1268 if (xInfoP) free(xInfoP);
1269 } while (voltype == ROVOL);
1272 fprintf(STDERR,"Dump only information from VLDB\n\n");
1273 fprintf(STDOUT,"%s \n", entry.name); /* PostVolumeStats doesn't print name */
1275 PostVolumeStats(&entry);
1280 /*------------------------------------------------------------------------
1284 * Routine used to change the status of a single volume.
1287 * as : Ptr to parsed command line arguments.
1290 * 0 for a successful operation,
1291 * Otherwise, one of the ubik or VolServer error values.
1294 * Nothing interesting.
1298 *------------------------------------------------------------------------
1300 static SetFields(as)
1301 register struct cmd_syndesc *as;
1303 struct nvldbentry entry;
1304 afs_int32 vcode = 0;
1307 afs_int32 code, err;
1308 afs_int32 aserver, apart;
1311 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1313 if (err) PrintError("", err);
1314 else fprintf(STDERR, "Unknown volume ID or name '%s'\n", as->parms[0].items->data);
1318 code = VLDB_GetEntryByID (volid, RWVOL, &entry);
1320 fprintf(STDERR, "Could not fetch the entry for volume number %u from VLDB \n",volid);
1323 MapHostToNetwork(&entry);
1325 GetServerAndPart(&entry, RWVOL, &aserver, &apart, &previdx);
1326 if (previdx == -1) {
1327 fprintf(STDERR,"Volume %s does not exist in VLDB\n\n", as->parms[0].items->data);
1331 memset(&info, 0, sizeof(info));
1342 if (as->parms[1].items) {
1344 code = util_GetInt32(as->parms[1].items->data, &info.maxquota);
1346 fprintf(STDERR,"invalid quota value\n");
1350 if (as->parms[2].items) {
1354 code = UV_SetVolumeInfo(aserver, apart, volid, &info);
1356 fprintf(STDERR,"Could not update volume info fields for volume number %u\n",volid);
1360 /*------------------------------------------------------------------------
1364 * Brings a volume online.
1367 * as : Ptr to parsed command line arguments.
1370 * 0 for a successful operation,
1373 * Nothing interesting.
1377 *------------------------------------------------------------------------
1379 static volOnline(as)
1380 register struct cmd_syndesc *as;
1382 afs_int32 server, partition, volid;
1383 afs_int32 code, err=0;
1385 server = GetServer(as->parms[0].items->data);
1387 fprintf(STDERR,"vos: server '%s' not found in host table\n", as->parms[0].items->data);
1391 partition = volutil_GetPartitionID(as->parms[1].items->data);
1392 if (partition < 0) {
1393 fprintf(STDERR,"vos: could not interpret partition name '%s'\n", as->parms[1].items->data);
1397 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1399 if (err) PrintError("", err);
1400 else fprintf(STDERR, "Unknown volume ID or name '%s'\n", as->parms[0].items->data);
1404 code = UV_SetVolume(server, partition, volid, ITOffline, 0/*online*/, 0/*sleep*/);
1406 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1413 /*------------------------------------------------------------------------
1414 * PRIVATE volOffline
1417 * Brings a volume offline.
1420 * as : Ptr to parsed command line arguments.
1423 * 0 for a successful operation,
1426 * Nothing interesting.
1430 *------------------------------------------------------------------------
1432 static volOffline(as)
1433 register struct cmd_syndesc *as;
1435 afs_int32 server, partition, volid;
1436 afs_int32 code, err=0;
1437 afs_int32 transflag, sleeptime, transdone;
1439 server = GetServer(as->parms[0].items->data);
1441 fprintf(STDERR,"vos: server '%s' not found in host table\n", as->parms[0].items->data);
1445 partition = volutil_GetPartitionID(as->parms[1].items->data);
1446 if (partition < 0) {
1447 fprintf(STDERR,"vos: could not interpret partition name '%s'\n", as->parms[1].items->data);
1451 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1453 if (err) PrintError("", err);
1454 else fprintf(STDERR, "Unknown volume ID or name '%s'\n", as->parms[0].items->data);
1458 transflag = (as->parms[4].items ? ITBusy : ITOffline);
1459 sleeptime = (as->parms[3].items ? atol(as->parms[3].items->data) : 0);
1460 transdone = (sleeptime ? 0/*online*/ : VTOutOfService);
1461 if (as->parms[4].items && !as->parms[3].items) {
1462 fprintf(STDERR,"-sleep option must be used with -busy flag\n");
1466 code = UV_SetVolume(server, partition, volid, transflag, transdone, sleeptime);
1468 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1475 static CreateVolume(as)
1476 register struct cmd_syndesc *as;
1480 afs_int32 volid,code;
1481 struct nvldbentry entry;
1486 tserver = GetServer(as->parms[0].items->data);
1488 fprintf(STDERR,"vos: host '%s' not found in host table\n",as->parms[0].items->data );
1491 pname = volutil_GetPartitionID(as->parms[1].items->data);
1493 fprintf(STDERR,"vos: could not interpret partition name '%s'\n",as->parms[1].items->data );
1496 if (!IsPartValid(pname,tserver,&code)){/*check for validity of the partition */
1497 if(code) PrintError("",code);
1498 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
1501 if(!ISNAMEVALID(as->parms[2].items->data)) {
1502 fprintf(STDERR,"vos: the name of the root volume %s exceeds the size limit of %d\n",as->parms[2].items->data,VOLSER_OLDMAXVOLNAME - 10);
1505 if(!VolNameOK(as->parms[2].items->data)){
1506 fprintf(STDERR,"Illegal volume name %s, should not end in .readonly or .backup\n",as->parms[2].items->data);
1509 if(IsNumeric(as->parms[2].items->data)){
1510 fprintf(STDERR,"Illegal volume name %s, should not be a number\n",as->parms[2].items->data);
1513 vcode = VLDB_GetEntryByName(as->parms[2].items->data, &entry);
1515 fprintf(STDERR,"Volume %s already exists\n",as->parms[2].items->data);
1516 PrintDiagnostics("create", code);
1520 if (as->parms[3].items) {
1521 if (!IsNumeric(as->parms[3].items->data)){
1522 fprintf(STDERR,"Initial quota %s should be numeric.\n", as->parms[3].items->data);
1526 code = util_GetInt32(as->parms[3].items->data, "a);
1528 fprintf(STDERR,"vos: bad integer specified for quota.\n");
1533 code = UV_CreateVolume2(tserver, pname,as->parms[2].items->data,
1534 quota, 0, 0, 0, 0, &volid);
1536 PrintDiagnostics("create", code);
1539 MapPartIdIntoName(pname, part);
1540 fprintf(STDOUT,"Volume %u created on partition %s of %s\n", volid, part,as->parms[0].items->data );
1545 static afs_int32 DeleteAll(entry)
1546 struct nvldbentry *entry;
1549 afs_int32 error, code, curserver, curpart, volid;
1551 MapHostToNetwork(entry);
1553 for(i=0; i < entry->nServers; i++){
1554 curserver = entry->serverNumber[i];
1555 curpart = entry->serverPartition[i];
1556 if(entry->serverFlags[i] & ITSROVOL){
1557 volid = entry->volumeId[ROVOL];
1560 volid = entry->volumeId[RWVOL];
1562 code = UV_DeleteVolume(curserver,curpart,volid);
1569 static DeleteVolume(as)
1570 struct cmd_syndesc *as;
1572 afs_int32 err, code = 0;
1573 afs_int32 server = 0, partition = -1, volid;
1577 if (as->parms[0].items) {
1578 server = GetServer(as->parms[0].items->data);
1580 fprintf(STDERR,"vos: server '%s' not found in host table\n",
1581 as->parms[0].items->data);
1586 if (as->parms[1].items) {
1587 partition = volutil_GetPartitionID(as->parms[1].items->data);
1588 if (partition < 0) {
1589 fprintf(STDERR,"vos: could not interpret partition name '%s'\n",
1590 as->parms[1].items->data );
1594 /* Check for validity of the partition */
1595 if (!IsPartValid(partition, server, &code)) {
1597 PrintError("", code);
1599 fprintf(STDERR,"vos : partition %s does not exist on the server\n",
1600 as->parms[1].items->data);
1606 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
1608 fprintf(STDERR, "Can't find volume name '%s' in VLDB\n",
1609 as->parms[2].items->data);
1610 if (err) PrintError("", err);
1614 /* If the server or partition option are not complete, try to fill
1615 * them in from the VLDB entry.
1617 if ((partition == -1) || !server) {
1618 struct nvldbentry entry;
1620 code = VLDB_GetEntryByID(volid, -1, &entry);
1622 fprintf(STDERR,"Could not fetch the entry for volume %u from VLDB\n",
1624 PrintError("",code);
1628 if (((volid == entry.volumeId[RWVOL]) && (entry.flags & RW_EXISTS)) ||
1629 ((volid == entry.volumeId[BACKVOL]) && (entry.flags & BACK_EXISTS)) ) {
1630 idx = Lp_GetRwIndex(&entry);
1632 (server && (server != entry.serverNumber[idx])) ||
1633 ((partition != -1) && (partition != entry.serverPartition[idx])) ) {
1634 fprintf(STDERR,"VLDB: Volume '%s' no match\n", as->parms[2].items->data);
1638 else if ((volid == entry.volumeId[ROVOL]) && (entry.flags & RO_EXISTS)) {
1639 for (idx=-1,j=0; j<entry.nServers; j++) {
1640 if (entry.serverFlags[j] != ITSROVOL) continue;
1642 if ( ((server == 0) || (server == entry.serverNumber[j])) &&
1643 ((partition == -1) || (partition == entry.serverPartition[j])) ) {
1645 fprintf(STDERR,"VLDB: Volume '%s' matches more than one RO\n",
1646 as->parms[2].items->data);
1653 fprintf(STDERR,"VLDB: Volume '%s' no match\n", as->parms[2].items->data);
1658 fprintf(STDERR,"VLDB: Volume '%s' no match\n", as->parms[2].items->data);
1662 server = htonl(entry.serverNumber[idx]);
1663 partition = entry.serverPartition[idx];
1667 code = UV_DeleteVolume(server, partition, volid);
1669 PrintDiagnostics("remove", code);
1673 MapPartIdIntoName(partition, pname);
1674 fprintf(STDOUT,"Volume %u on partition %s server %s deleted\n",
1675 volid, pname, hostutil_GetNameByINet(server));
1679 #define TESTM 0 /* set for move space tests, clear for production */
1680 static MoveVolume(as)
1681 register struct cmd_syndesc *as;
1684 afs_int32 volid, fromserver, toserver, frompart, topart,code, err;
1685 char fromPartName[10], toPartName[10];
1687 struct diskPartition partition; /* for space check */
1690 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
1692 if (err) PrintError("", err);
1693 else fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
1694 as->parms[0].items->data);
1697 fromserver = GetServer(as->parms[1].items->data);
1698 if (fromserver == 0) {
1699 fprintf(STDERR,"vos: server '%s' not found in host table\n", as->parms[1].items->data);
1702 toserver = GetServer(as->parms[3].items->data);
1703 if (toserver == 0) {
1704 fprintf(STDERR,"vos: server '%s' not found in host table\n", as->parms[3].items->data);
1707 frompart = volutil_GetPartitionID(as->parms[2].items->data);
1709 fprintf(STDERR,"vos: could not interpret partition name '%s'\n", as->parms[2].items->data);
1712 if (!IsPartValid(frompart,fromserver,&code)){/*check for validity of the partition */
1713 if(code) PrintError("",code);
1714 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[2].items->data);
1717 topart = volutil_GetPartitionID(as->parms[4].items->data);
1719 fprintf(STDERR,"vos: could not interpret partition name '%s'\n",as->parms[4].items->data);
1722 if (!IsPartValid(topart,toserver,&code)){/*check for validity of the partition */
1723 if(code) PrintError("",code);
1724 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[4].items->data);
1729 check source partition for space to clone volume
1732 MapPartIdIntoName(topart,toPartName);
1733 MapPartIdIntoName(frompart, fromPartName);
1736 check target partition for space to move volume
1739 code=UV_PartitionInfo(toserver,toPartName,&partition);
1742 fprintf(STDERR,"vos: cannot access partition %s\n",toPartName);
1746 fprintf(STDOUT,"target partition %s free space %d\n",
1747 toPartName,partition.free);
1750 code=UV_ListOneVolume(fromserver,frompart,volid,&p);
1753 fprintf(STDERR,"vos:cannot access volume %u\n",volid);
1758 fprintf(STDOUT,"volume %u size %d\n",volid,p->size);
1759 if(partition.free<=p->size)
1761 fprintf(STDERR,"vos: no space on target partition %s to move volume %u\n",
1770 fprintf(STDOUT,"size test - don't do move\n");
1774 /* successful move still not guaranteed but shoot for it */
1776 code = UV_MoveVolume(volid, fromserver, frompart, toserver, topart);
1778 PrintDiagnostics("move", code);
1781 MapPartIdIntoName(topart,toPartName);
1782 MapPartIdIntoName(frompart, fromPartName);
1783 fprintf(STDOUT,"Volume %u moved from %s %s to %s %s \n",volid,as->parms[1].items->data,fromPartName,as->parms[3].items->data,toPartName);
1787 static BackupVolume(as)
1788 register struct cmd_syndesc *as;
1790 afs_int32 avolid, aserver, apart,vtype,code, err;
1791 struct nvldbentry entry;
1793 afs_int32 buvolid,buserver,bupart,butype;
1794 struct nvldbentry buentry;
1795 struct rx_connection *conn;
1797 struct nvldbentry store;
1799 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
1801 if (err) PrintError("", err);
1802 else fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
1803 as->parms[0].items->data);
1806 code = GetVolumeInfo( avolid,&aserver, &apart,&vtype,&entry);
1809 /* verify this is a readwrite volume */
1813 fprintf(STDERR,"%s not RW volume\n",as->parms[0].items->data);
1817 /* is there a backup volume already? */
1819 if(entry.flags & BACK_EXISTS)
1821 /* yep, where is it? */
1823 buvolid=entry.volumeId[BACKVOL];
1824 code=GetVolumeInfo(buvolid,&buserver,&bupart,&butype,&buentry);
1828 code = VLDB_IsSameAddrs(buserver, aserver, &err);
1830 fprintf(STDERR,"Failed to get info about server's %d address(es) from vlserver; aborting call!\n", buserver);
1835 fprintf(STDERR,"FATAL ERROR: backup volume %u exists on server %u\n",
1841 /* nope, carry on */
1843 code = UV_BackupVolume(aserver, apart, avolid);
1846 PrintDiagnostics("backup", code);
1849 fprintf(STDOUT,"Created backup volume for %s \n",as->parms[0].items->data);
1852 static ReleaseVolume(as)
1853 register struct cmd_syndesc *as;
1856 struct nvldbentry entry;
1857 afs_int32 avolid, aserver, apart,vtype,code, err;
1860 if(as->parms[1].items) force = 1;
1861 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
1863 if (err) PrintError("", err);
1864 else fprintf(STDERR, "vos: can't find volume '%s'\n", as->parms[0].items->data);
1867 code = GetVolumeInfo( avolid,&aserver, &apart,&vtype,&entry);
1868 if(code) return code;
1870 if (vtype != RWVOL) {
1871 fprintf(STDERR,"%s not a RW volume\n", as->parms[0].items->data);
1875 if(!ISNAMEVALID(entry.name)){
1876 fprintf(STDERR,"Volume name %s is too long, rename before releasing\n",entry.name);
1880 code = UV_ReleaseVolume(avolid, aserver, apart, force);
1882 PrintDiagnostics("release", code);
1885 fprintf(STDOUT,"Released volume %s successfully\n",as->parms[0].items->data );
1888 static DumpVolume(as)
1889 register struct cmd_syndesc *as;
1892 afs_int32 avolid, aserver, apart,voltype,fromdate=0,code, err, i;
1893 char filename[NameLen];
1894 struct nvldbentry entry;
1896 rx_SetRxDeadTime(60 * 10);
1897 for (i = 0; i<MAXSERVERS; i++) {
1898 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct,i);
1899 if (rxConn == 0) break;
1900 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
1901 if (rxConn->service) rxConn->service->connDeadTime = rx_connDeadTime;
1904 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
1906 if (err) PrintError("", err);
1907 else fprintf(STDERR, "vos: can't find volume '%s'\n", as->parms[0].items->data);
1911 if (as->parms[3].items || as->parms[4].items) {
1912 if (!as->parms[3].items || !as->parms[4].items) {
1913 fprintf(STDERR, "Must specify both -server and -partition options\n");
1916 aserver = GetServer(as->parms[3].items->data);
1918 fprintf(STDERR, "Invalid server name\n");
1921 apart = volutil_GetPartitionID(as->parms[4].items->data);
1923 fprintf(STDERR, "Invalid partition name\n");
1927 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
1928 if (code) return code;
1931 if (as->parms[1].items && strcmp(as->parms[1].items->data,"0")) {
1932 code = ktime_DateToInt32(as->parms[1].items->data, &fromdate);
1934 fprintf(STDERR,"vos: failed to parse date '%s' (error=%d))\n",
1935 as->parms[1].items->data, code);
1939 if(as->parms[2].items){
1940 strcpy(filename,as->parms[2].items->data);
1943 strcpy(filename,"");
1945 code = UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction, filename);
1947 PrintDiagnostics("dump", code);
1950 if(strcmp(filename,""))
1951 fprintf(STDERR,"Dumped volume %s in file %s\n",as->parms[0].items->data, filename);
1953 fprintf(STDERR,"Dumped volume %s in stdout \n",as->parms[0].items->data);
1962 static RestoreVolume(as)
1963 register struct cmd_syndesc *as;
1966 afs_int32 avolid, aserver, apart, code,vcode, err;
1967 afs_int32 aoverwrite = ASK;
1968 int restoreflags, readonly = 0, offline = 0, voltype = RWVOL;
1970 char afilename[NameLen], avolname[VOLSER_MAXVOLNAME +1],apartName[10];
1971 char volname[VOLSER_MAXVOLNAME +1];
1972 struct nvldbentry entry;
1976 if(as->parms[4].items){
1977 avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
1979 if (err) PrintError("", err);
1980 else fprintf(STDERR, "vos: can't find volume '%s'\n", as->parms[4].items->data);
1987 if (as->parms[5].items) {
1988 if ( (strcmp(as->parms[5].items->data, "a") == 0) ||
1989 (strcmp(as->parms[5].items->data, "abort") == 0) ) {
1992 else if ( (strcmp(as->parms[5].items->data, "f") == 0) ||
1993 (strcmp(as->parms[5].items->data, "full") == 0) ) {
1996 else if ( (strcmp(as->parms[5].items->data, "i") == 0) ||
1997 (strcmp(as->parms[5].items->data, "inc") == 0) ||
1998 (strcmp(as->parms[5].items->data, "increment") == 0) ||
1999 (strcmp(as->parms[5].items->data, "incremental") == 0) ) {
2003 fprintf(STDERR, "vos: %s is not a valid argument to -overwrite\n",
2004 as->parms[5].items->data);
2008 if (as->parms[6].items) offline = 1;
2009 if (as->parms[7].items) {
2014 aserver = GetServer(as->parms[0].items->data);
2016 fprintf(STDERR,"vos: server '%s' not found in host table\n", as->parms[0].items->data);
2019 apart = volutil_GetPartitionID(as->parms[1].items->data);
2021 fprintf(STDERR,"vos: could not interpret partition name '%s'\n",as->parms[1].items->data );
2024 if (!IsPartValid(apart,aserver,&code)){/*check for validity of the partition */
2025 if(code) PrintError("",code);
2026 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
2029 strcpy(avolname,as->parms[2].items->data );
2030 if(!ISNAMEVALID(avolname)) {
2031 fprintf(STDERR,"vos: the name of the volume %s exceeds the size limit\n",avolname);
2034 if(!VolNameOK(avolname)){
2035 fprintf(STDERR,"Illegal volume name %s, should not end in .readonly or .backup\n",avolname);
2038 if(as->parms[3].items){
2039 strcpy(afilename,as->parms[3].items->data );
2040 if(!FileExists(afilename)){
2041 fprintf(STDERR,"Can't access file %s\n",afilename);
2046 strcpy(afilename,"");
2049 /* Check if volume exists or not */
2051 vsu_ExtractName(volname,avolname);
2052 vcode = VLDB_GetEntryByName(volname, &entry);
2053 if (vcode) { /* no volume - do a full restore */
2054 restoreflags = RV_FULLRST;
2055 if ( (aoverwrite == INC) || (aoverwrite == ABORT) )
2056 fprintf(STDERR,"Volume does not exist; Will perform a full restore\n");
2059 else if ((!readonly && Lp_GetRwIndex(&entry) == -1) /* RW volume does not exist - do a full */
2060 || (readonly && !Lp_ROMatch(0, 0, &entry))) { /* RO volume does not exist - do a full */
2061 restoreflags = RV_FULLRST;
2062 if ( (aoverwrite == INC) || (aoverwrite == ABORT) )
2063 fprintf(STDERR,"%s Volume does not exist; Will perform a full restore\n",
2064 readonly ? "RO" : "RW");
2067 avolid = entry.volumeId[voltype];
2069 else if (entry.volumeId[voltype] != 0 && entry.volumeId[voltype] != avolid) {
2070 avolid = entry.volumeId[voltype];
2074 else { /* volume exists - do we do a full incremental or abort */
2075 int Oserver, Opart, Otype, vol_elsewhere = 0;
2076 struct nvldbentry Oentry;
2080 avolid = entry.volumeId[voltype];
2082 else if(entry.volumeId[voltype] != 0 && entry.volumeId[voltype] != avolid) {
2083 avolid = entry.volumeId[voltype];
2086 /* A file name was specified - check if volume is on another partition */
2087 vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
2090 vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
2092 fprintf(STDERR,"Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
2096 if (!vcode || (Opart != apart)) vol_elsewhere = 1;
2098 if (aoverwrite == ASK) {
2099 if (strcmp(afilename,"") == 0) { /* The file is from standard in */
2100 fprintf(STDERR,"Volume exists and no -overwrite option specified; Aborting restore command\n");
2104 /* Ask what to do */
2105 if (vol_elsewhere) {
2106 fprintf(STDERR,"The volume %s %u already exists on a different server/part\n",
2107 volname, entry.volumeId[voltype]);
2109 "Do you want to do a full restore or abort? [fa](a): ");
2113 fprintf(STDERR,"The volume %s %u already exists in the VLDB\n",
2114 volname, entry.volumeId[voltype]);
2116 "Do you want to do a full/incremental restore or abort? [fia](a): ");
2119 while (!(dc==EOF || dc=='\n')) dc=getchar(); /* goto end of line */
2120 if ((c == 'f') || (c == 'F')) aoverwrite = FULL;
2121 else if ((c == 'i') || (c == 'I')) aoverwrite = INC;
2122 else aoverwrite = ABORT;
2125 if (aoverwrite == ABORT) {
2126 fprintf(STDERR,"Volume exists; Aborting restore command\n");
2129 else if (aoverwrite == FULL) {
2130 restoreflags = RV_FULLRST;
2131 fprintf(STDERR,"Volume exists; Will delete and perform full restore\n");
2133 else if (aoverwrite == INC) {
2135 if (vol_elsewhere) {
2137 "%s volume %u already exists on a different server/part; not allowed\n",
2138 readonly ? "RO" : "RW", avolid);
2143 if (offline) restoreflags |= RV_OFFLINE;
2144 if (readonly) restoreflags |= RV_RDONLY;
2145 code = UV_RestoreVolume(aserver, apart, avolid, avolname,
2146 restoreflags, WriteData, afilename);
2148 PrintDiagnostics("restore", code);
2151 MapPartIdIntoName(apart,apartName);
2154 patch typo here - originally "parms[1]", should be "parms[0]"
2157 fprintf(STDOUT,"Restored volume %s on %s %s\n",
2158 avolname, as->parms[0].items->data, apartName);
2161 static LockReleaseCmd(as)
2162 register struct cmd_syndesc *as;
2165 afs_int32 avolid,code, err;
2167 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2169 if (err) PrintError("", err);
2170 else fprintf(STDERR, "vos: can't find volume '%s'\n", as->parms[0].items->data);
2174 code = UV_LockRelease(avolid);
2176 PrintDiagnostics("unlock", code);
2179 fprintf(STDOUT,"Released lock on vldb entry for volume %s\n",as->parms[0].items->data);
2183 register struct cmd_syndesc *as;
2185 afs_int32 avolid, aserver, apart,code, err;
2188 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
2190 if (err) PrintError("", err);
2191 else fprintf(STDERR, "vos: can't find volume '%s'\n", as->parms[2].items->data);
2194 aserver = GetServer(as->parms[0].items->data);
2196 fprintf(STDERR,"vos: server '%s' not found in host table\n", as->parms[0].items->data);
2199 apart = volutil_GetPartitionID(as->parms[1].items->data);
2201 fprintf(STDERR,"vos: could not interpret partition name '%s'\n",as->parms[1].items->data );
2204 if (!IsPartValid(apart,aserver,&code)){/*check for validity of the partition */
2205 if(code) PrintError("",code);
2206 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
2209 code = UV_AddSite(aserver, apart, avolid);
2211 PrintDiagnostics("addsite", code);
2214 MapPartIdIntoName(apart,apartName);
2215 fprintf(STDOUT,"Added replication site %s %s for volume %s\n",as->parms[0].items->data, apartName,as->parms[2].items->data);
2219 static RemoveSite(as)
2220 register struct cmd_syndesc *as;
2223 afs_int32 avolid, aserver, apart, code, err;
2226 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
2228 if (err) PrintError("", err);
2229 else fprintf(STDERR, "vos: can't find volume '%s'\n", as->parms[2].items->data);
2232 aserver = GetServer(as->parms[0].items->data);
2234 fprintf(STDERR,"vos: server '%s' not found in host table\n", as->parms[0].items->data);
2237 apart = volutil_GetPartitionID(as->parms[1].items->data);
2239 fprintf(STDERR,"vos: could not interpret partition name '%s'\n",as->parms[1].items->data );
2243 *skip the partition validity check, since it is possible that the partition
2244 *has since been decomissioned.
2247 if (!IsPartValid(apart,aserver,&code)){
2248 if(code) PrintError("",code);
2249 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
2253 code = UV_RemoveSite(aserver, apart, avolid);
2255 PrintDiagnostics("remsite", code);
2258 MapPartIdIntoName(apart,apartName);
2259 fprintf(STDOUT,"Removed replication site %s %s for volume %s\n",as->parms[0].items->data,apartName,as->parms[2].items->data);
2262 static ChangeLocation(as)
2263 register struct cmd_syndesc *as;
2265 afs_int32 avolid, aserver, apart,code, err;
2268 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
2270 if (err) PrintError("", err);
2271 else fprintf(STDERR, "vos: can't find volume '%s'\n", as->parms[2].items->data);
2274 aserver = GetServer(as->parms[0].items->data);
2276 fprintf(STDERR,"vos: server '%s' not found in host table\n", as->parms[0].items->data);
2279 apart = volutil_GetPartitionID(as->parms[1].items->data);
2281 fprintf(STDERR,"vos: could not interpret partition name '%s'\n",as->parms[1].items->data );
2284 if (!IsPartValid(apart,aserver,&code)){/*check for validity of the partition */
2285 if(code) PrintError("",code);
2286 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
2289 code = UV_ChangeLocation(aserver, apart, avolid);
2291 PrintDiagnostics("addsite", code);
2294 MapPartIdIntoName(apart,apartName);
2295 fprintf(STDOUT,"Changed location to %s %s for volume %s\n",as->parms[0].items->data, apartName,as->parms[2].items->data);
2299 static ListPartitions(as)
2300 register struct cmd_syndesc *as;
2302 afs_int32 aserver,code;
2303 struct partList dummyPartList;
2308 aserver = GetServer(as->parms[0].items->data);
2310 fprintf(STDERR,"vos: server '%s' not found in host table\n", as->parms[0].items->data);
2315 code = UV_ListPartitions(aserver,&dummyPartList, &cnt);
2317 PrintDiagnostics("listpart", code);
2321 fprintf(STDOUT,"The partitions on the server are:\n");
2322 for(i = 0 ; i < cnt ; i++){
2323 if(dummyPartList.partFlags[i] & PARTVALID){
2324 memset(pname, 0, sizeof(pname));
2325 MapPartIdIntoName(dummyPartList.partId[i],pname);
2326 fprintf(STDOUT," %10s ",pname);
2328 if( (i % 5) == 0 && (i != 0)) fprintf(STDOUT,"\n");
2331 fprintf(STDOUT,"\n");
2332 fprintf(STDOUT,"Total: %d\n",total);
2337 static int CompareVolName(p1,p2)
2340 volintInfo *arg1,*arg2;
2342 arg1 = (volintInfo *)p1;
2343 arg2 = (volintInfo *)p2;
2344 return(strcmp(arg1->name,arg2->name));
2348 /*------------------------------------------------------------------------
2349 * PRIVATE XCompareVolName
2352 * Comparison routine for volume names coming from an extended
2356 * a_obj1P : Char ptr to first extended vol info object
2357 * a_obj1P : Char ptr to second extended vol info object
2360 * The value of strcmp() on the volume names within the passed
2361 * objects (i,e., -1, 0, or 1).
2364 * Passed to qsort() as the designated comparison routine.
2368 *------------------------------------------------------------------------*/
2370 static int XCompareVolName(a_obj1P, a_obj2P)
2371 char *a_obj1P, *a_obj2P;
2373 { /*XCompareVolName*/
2375 return(strcmp(((struct volintXInfo *)(a_obj1P))->name,
2376 ((struct volintXInfo *)(a_obj2P))->name));
2378 } /*XCompareVolName*/
2380 static int CompareVolID(p1,p2)
2383 volintInfo *arg1,*arg2;
2385 arg1 = (volintInfo *)p1;
2386 arg2 = (volintInfo *)p2;
2387 if(arg1->volid == arg2->volid) return 0;
2388 if(arg1->volid > arg2->volid) return 1;
2393 /*------------------------------------------------------------------------
2394 * PRIVATE XCompareVolID
2397 * Comparison routine for volume IDs coming from an extended
2401 * a_obj1P : Char ptr to first extended vol info object
2402 * a_obj1P : Char ptr to second extended vol info object
2405 * The value of strcmp() on the volume names within the passed
2406 * objects (i,e., -1, 0, or 1).
2409 * Passed to qsort() as the designated comparison routine.
2413 *------------------------------------------------------------------------*/
2415 static int XCompareVolID(a_obj1P, a_obj2P)
2416 char *a_obj1P, *a_obj2P;
2420 afs_int32 id1, id2; /*Volume IDs we're comparing*/
2422 id1 = ((struct volintXInfo *)(a_obj1P))->volid;
2423 id2 = ((struct volintXInfo *)(a_obj2P))->volid;
2434 /*------------------------------------------------------------------------
2435 * PRIVATE ListVolumes
2438 * Routine used to list volumes, contacting the Volume Server
2439 * directly, bypassing the VLDB.
2442 * as : Ptr to parsed command line arguments.
2445 * 0 Successful operation
2448 * Nothing interesting.
2452 *------------------------------------------------------------------------*/
2454 static ListVolumes(as)
2455 register struct cmd_syndesc *as;
2457 afs_int32 apart,int32list,fast;
2458 afs_int32 aserver,code;
2459 volintInfo *pntr,*oldpntr;
2463 volintXInfo *xInfoP, *origxInfoP; /*Ptr to current/orig extended vol info*/
2464 int wantExtendedInfo; /*Do we want extended vol info?*/
2467 struct partList dummyPartList;
2475 if(as->parms[3].items) int32list = 1;
2476 if(as->parms[4].items) quiet = 1;
2478 if(as->parms[2].items) fast = 1;
2481 if (as->parms[5].items) {
2483 * We can't coexist with the fast flag.
2487 "vos: Can't use the -fast and -extended flags together\n");
2492 * We need to turn on ``long'' listings to get the full effect.
2494 wantExtendedInfo = 1;
2498 wantExtendedInfo = 0;
2499 if(as->parms[1].items){
2500 apart = volutil_GetPartitionID(as->parms[1].items->data);
2502 fprintf(STDERR,"vos: could not interpret partition name '%s'\n", as->parms[1].items->data);
2505 dummyPartList.partId[0] = apart;
2506 dummyPartList.partFlags[0] = PARTVALID;
2509 aserver = GetServer(as->parms[0].items->data);
2511 fprintf(STDERR,"vos: server '%s' not found in host table\n",as->parms[0].items->data );
2516 if (!IsPartValid(apart,aserver,&code)){/*check for validity of the partition */
2517 if(code) PrintError("",code);
2518 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
2523 code = UV_ListPartitions(aserver,&dummyPartList, &cnt);
2525 PrintDiagnostics("listvol", code);
2529 for(i = 0 ; i < cnt ; i++){
2530 if(dummyPartList.partFlags[i] & PARTVALID){
2531 if (wantExtendedInfo)
2532 code = UV_XListVolumes(aserver,
2533 dummyPartList.partId[i],
2538 code = UV_ListVolumes(aserver,
2539 dummyPartList.partId[i],
2544 PrintDiagnostics("listvol", code);
2545 if(pntr) free(pntr);
2548 if (wantExtendedInfo) {
2549 origxInfoP = xInfoP;
2550 base = (char *)xInfoP;
2553 base = (char *)pntr;
2557 if (wantExtendedInfo)
2558 qsort(base, count, sizeof(volintXInfo), XCompareVolName);
2560 qsort(base, count, sizeof(volintInfo), CompareVolName);
2562 if (wantExtendedInfo)
2563 qsort(base, count, sizeof(volintXInfo), XCompareVolID);
2565 qsort(base, count, sizeof(volintInfo), CompareVolID);
2567 MapPartIdIntoName(dummyPartList.partId[i],pname);
2569 fprintf(STDOUT,"Total number of volumes on server %s partition %s: %u \n",as->parms[0].items->data,pname,count);
2570 if (wantExtendedInfo) {
2571 XDisplayVolumes(aserver,
2572 dummyPartList.partId[i],
2580 xInfoP = (volintXInfo *)0;
2583 #ifdef FULL_LISTVOL_SWITCH
2584 if (as->parms[6].items)
2585 DisplayVolumes2(aserver, dummyPartList.partId[i], oldpntr,
2588 #endif /* FULL_LISTVOL_SWITCH */
2589 DisplayVolumes(aserver,
2590 dummyPartList.partId[i],
2598 pntr = (volintInfo *)0;
2606 register struct cmd_syndesc *as;
2608 afs_int32 pname, code; /* part name */
2614 if (as->parms[0].items) {
2615 tserver = GetServer(as->parms[0].items->data);
2617 fprintf(STDERR,"vos: host '%s' not found in host table\n",as->parms[0].items->data );
2622 if (as->parms[1].items) {
2623 pname = volutil_GetPartitionID(as->parms[1].items->data);
2625 fprintf(STDERR,"vos: could not interpret partition name '%s'\n",as->parms[1].items->data );
2628 if (!IsPartValid(pname,tserver,&code)) { /*check for validity of the partition */
2629 if(code) PrintError("",code);
2630 else fprintf(STDERR,"vos: partition %s does not exist on the server\n",
2631 as->parms[1].items->data);
2637 fprintf(STDERR,"The -partition option requires a -server option\n");
2642 if (as->parms[2].items) {
2643 /* Synchronize an individual volume */
2644 volname = as->parms[2].items->data;
2645 code = UV_SyncVolume(tserver, pname, volname, flags);
2648 fprintf(STDERR,"Without a -volume option, the -server option is required\n");
2651 code = UV_SyncVldb(tserver, pname, flags, 0/*unused*/);
2655 PrintDiagnostics("syncvldb", code);
2659 /* Print a summary of what we did */
2660 if (volname) fprintf(STDOUT,"VLDB volume %s synchronized", volname);
2661 else fprintf(STDOUT,"VLDB synchronized");
2663 fprintf(STDOUT," with state of server %s", as->parms[0].items->data);
2666 MapPartIdIntoName(pname,part);
2667 fprintf(STDOUT," partition %s\n", part);
2669 fprintf(STDOUT, "\n");
2674 static SyncServer(as)
2675 register struct cmd_syndesc *as;
2678 afs_int32 pname,code; /* part name */
2683 tserver = GetServer(as->parms[0].items->data);
2685 fprintf(STDERR,"vos: host '%s' not found in host table\n",as->parms[0].items->data );
2688 if(as->parms[1].items){
2689 pname = volutil_GetPartitionID(as->parms[1].items->data);
2691 fprintf(STDERR,"vos: could not interpret partition name '%s'\n",as->parms[1].items->data);
2694 if (!IsPartValid(pname,tserver,&code)){/*check for validity of the partition */
2695 if(code) PrintError("",code);
2696 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
2702 code = UV_SyncServer(tserver, pname, flags, 0/*unused*/);
2704 PrintDiagnostics("syncserv", code);
2708 MapPartIdIntoName(pname,part);
2709 fprintf(STDOUT,"Server %s partition %s synchronized with VLDB\n",as->parms[0].items->data,part);
2711 else fprintf(STDOUT,"Server %s synchronized with VLDB\n",as->parms[0].items->data);
2716 static VolumeInfoCmd(name)
2719 struct nvldbentry entry;
2722 /* The vlserver will handle names with the .readonly
2723 * and .backup extension as well as volume ids.
2725 vcode = VLDB_GetEntryByName(name, &entry);
2727 PrintError("", vcode);
2730 MapHostToNetwork(&entry);
2731 EnumerateEntry(&entry);
2733 /* Defect #3027: grubby check to handle locked volume.
2734 * If VLOP_ALLOPERS is set, the entry is locked.
2735 * Leave this routine as is, but put in correct check.
2737 if (entry.flags & VLOP_ALLOPERS)
2738 fprintf(STDOUT," Volume is currently LOCKED \n");
2743 static VolumeZap(as)
2744 register struct cmd_syndesc *as;
2747 struct nvldbentry entry;
2748 afs_int32 volid,code,server,part, zapbackupid=0, backupid=0, err;
2750 if (as->parms[3].items) {
2751 /* force flag is on, use the other version */
2752 return NukeVolume(as);
2755 if (as->parms[4].items) {
2759 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
2761 if (err) PrintError("", err);
2762 else fprintf(STDERR, "vos: can't find volume '%s'\n", as->parms[2].items->data);
2765 part = volutil_GetPartitionID(as->parms[1].items->data);
2767 fprintf(STDERR,"vos: could not interpret partition name '%s'\n",as->parms[1].items->data );
2770 server = GetServer(as->parms[0].items->data);
2772 fprintf(STDERR,"vos: host '%s' not found in host table\n",as->parms[0].items->data );
2775 if (!IsPartValid(part,server,&code)){/*check for validity of the partition */
2776 if(code) PrintError("",code);
2777 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
2780 code = VLDB_GetEntryByID(volid,-1, &entry);
2782 if (volid == entry.volumeId[RWVOL])
2783 backupid = entry.volumeId[BACKVOL];
2784 fprintf(STDERR,"Warning: Entry for volume number %u exists in VLDB (but we're zapping it anyway!)\n",
2788 volintInfo *pntr = (volintInfo *)0;
2791 code = UV_ListOneVolume(server, part, volid, &pntr);
2793 if (volid == pntr->parentID)
2794 backupid = pntr->backupID;
2795 if (pntr) free(pntr);
2799 code = UV_VolumeZap(server,part, backupid);
2801 PrintDiagnostics("zap", code);
2804 fprintf(STDOUT,"Backup Volume %u deleted\n", backupid);
2807 code = UV_VolumeZap(server,part,volid);
2809 PrintDiagnostics("zap", code);
2812 fprintf(STDOUT,"Volume %u deleted\n",volid);
2817 static VolserStatus(as)
2818 register struct cmd_syndesc *as;
2821 afs_int32 server, code;
2822 transDebugInfo *pntr,*oldpntr;
2827 server = GetServer(as->parms[0].items->data);
2829 fprintf(STDERR,"vos: host '%s' not found in host table\n",as->parms[0].items->data );
2832 code = UV_VolserStatus(server,&pntr,&count);
2834 PrintDiagnostics("status",code);
2839 fprintf(STDOUT,"No active transactions on %s\n",as->parms[0].items->data);
2841 fprintf(STDOUT,"Total transactions: %d\n",count);
2843 for(i = 0; i < count ; i++){
2844 /*print out the relevant info */
2845 fprintf(STDOUT,"--------------------------------------\n");
2846 fprintf(STDOUT,"transaction: %u created: %s",pntr->tid,
2847 ctime((time_t *)&pntr->time));
2848 if(pntr->returnCode){
2849 fprintf(STDOUT,"returnCode: %u\n",pntr->returnCode);
2852 fprintf(STDOUT,"attachFlags: ");
2853 switch(pntr->iflags){
2854 case ITOffline: fprintf(STDOUT,"offline ");
2856 case ITBusy: fprintf(STDOUT,"busy ");
2858 case ITReadOnly: fprintf(STDOUT,"readonly ");
2860 case ITCreate: fprintf(STDOUT,"create ");
2862 case ITCreateVolID: fprintf(STDOUT,"create volid ");
2865 fprintf(STDOUT,"\n");
2868 fprintf(STDOUT,"volumeStatus: ");
2869 switch(pntr->vflags){
2870 case VTDeleteOnSalvage: fprintf(STDOUT,"deleteOnSalvage ");
2871 case VTOutOfService: fprintf(STDOUT,"outOfService ");
2872 case VTDeleted: fprintf(STDOUT,"deleted ");
2874 fprintf(STDOUT,"\n");
2877 fprintf(STDOUT,"transactionFlags: ");
2878 fprintf(STDOUT,"delete\n");
2880 MapPartIdIntoName(pntr->partition ,pname);
2881 fprintf(STDOUT,"volume: %u partition: %s procedure: %s\n",pntr->volid,pname, pntr->lastProcName);
2882 if(pntr->callValid){
2883 fprintf(STDOUT,"packetRead: %u lastReceiveTime: %d packetSend: %u lastSendTime: %d\n",pntr->readNext,pntr->lastReceiveTime,pntr->transmitNext, pntr->lastSendTime);
2886 fprintf(STDOUT,"--------------------------------------\n");
2887 fprintf(STDOUT,"\n");
2889 if(oldpntr) free(oldpntr);
2893 static RenameVolume(as)
2894 register struct cmd_syndesc *as;
2896 afs_int32 code1,code2,code;
2897 struct nvldbentry entry;
2899 code1 = VLDB_GetEntryByName(as->parms[0].items->data, &entry);
2901 fprintf(STDERR,"vos: Could not find entry for volume %s\n",as->parms[0].items->data);
2904 code2 = VLDB_GetEntryByName(as->parms[1].items->data, &entry);
2905 if((!code1) && (!code2)) { /*the newname already exists */
2906 fprintf(STDERR,"vos: volume %s already exists\n",as->parms[1].items->data);
2911 fprintf(STDERR,"vos: Could not find entry for volume %s or %s\n",as->parms[0].items->data,as->parms[1].items->data);
2914 if(!VolNameOK(as->parms[0].items->data)){
2915 fprintf(STDERR,"Illegal volume name %s, should not end in .readonly or .backup\n",as->parms[0].items->data);
2918 if(!ISNAMEVALID(as->parms[1].items->data)) {
2919 fprintf(STDERR,"vos: the new volume name %s exceeds the size limit of %d\n",as->parms[1].items->data,VOLSER_OLDMAXVOLNAME - 10);
2922 if(!VolNameOK(as->parms[1].items->data)){
2923 fprintf(STDERR,"Illegal volume name %s, should not end in .readonly or .backup\n",as->parms[1].items->data);
2926 if(IsNumeric(as->parms[1].items->data)){
2927 fprintf(STDERR,"Illegal volume name %s, should not be a number\n",as->parms[1].items->data);
2930 MapHostToNetwork(&entry);
2931 code = UV_RenameVolume(&entry,as->parms[0].items->data,as->parms[1].items->data);
2933 PrintDiagnostics("rename", code);
2936 fprintf(STDOUT,"Renamed volume %s to %s\n",as->parms[0].items->data,as->parms[1].items->data);
2940 GetVolumeInfo(volid, server, part, voltype,rentry)
2941 afs_int32 *server, volid, *part, *voltype;
2942 register struct nvldbentry *rentry;
2947 vcode = VLDB_GetEntryByID(volid, -1, rentry);
2949 fprintf(STDERR,"Could not fetch the entry for volume %u from VLDB \n",volid);
2950 PrintError("",vcode);
2953 MapHostToNetwork(rentry);
2954 if(volid == rentry->volumeId[ROVOL]){
2956 for (i = 0; i < rentry->nServers; i++) {
2957 if ( (index == -1) && (rentry->serverFlags[i] & ITSROVOL) &&
2958 !(rentry->serverFlags[i] & RO_DONTUSE) )
2962 fprintf(STDERR,"RO volume is not found in VLDB entry for volume %u\n", volid);
2966 *server = rentry->serverNumber[index];
2967 *part = rentry->serverPartition[index];
2971 index = Lp_GetRwIndex(rentry);
2973 fprintf(STDERR,"RW Volume is not found in VLDB entry for volume %u\n", volid);
2976 if(volid == rentry->volumeId[RWVOL]){
2978 *server = rentry->serverNumber[index];
2979 *part = rentry->serverPartition[index];
2982 if(volid == rentry->volumeId[BACKVOL]){
2984 *server = rentry->serverNumber[index];
2985 *part = rentry->serverPartition[index];
2990 static DeleteEntry(as)
2991 register struct cmd_syndesc *as;
2997 struct VldbListByAttributes attributes;
2998 nbulkentries arrayEntries;
2999 register struct nvldbentry *vllist;
3000 struct cmd_item *itp;
3003 char prefix[VOLSER_MAXVOLNAME+1];
3005 afs_int32 totalBack=0, totalFail=0, err;
3007 if (as->parms[0].items) { /* -id */
3008 if (as->parms[1].items || as->parms[2].items || as->parms[3].items) {
3009 fprintf(STDERR,"You cannot use -server, -partition, or -prefix with the -id argument\n");
3012 for (itp=as->parms[0].items; itp; itp=itp->next) {
3013 avolid = vsu_GetVolumeID(itp->data, cstruct, &err);
3015 if (err) PrintError("", err);
3016 else fprintf(STDERR, "vos: can't find volume '%s'\n", itp->data);
3019 if (as->parms[4].items) { /* -noexecute */
3020 fprintf(STDOUT,"Would have deleted VLDB entry for %s \n", itp->data);
3024 vcode = ubik_Call(VL_DeleteEntry,cstruct, 0, avolid, RWVOL);
3026 fprintf(STDERR,"Could not delete entry for volume %s\n", itp->data);
3027 fprintf(STDERR,"You must specify a RW volume name or ID "
3028 "(the entire VLDB entry will be deleted)\n", itp->data);
3029 PrintError("",vcode);
3035 fprintf(STDOUT,"Deleted %d VLDB entries\n", totalBack);
3039 if (!as->parms[1].items && !as->parms[2].items && !as->parms[3].items) {
3040 fprintf(STDERR,"You must specify an option\n");
3044 /* Zero out search attributes */
3045 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
3047 if (as->parms[1].items) { /* -prefix */
3048 strncpy(prefix, as->parms[1].items->data, VOLSER_MAXVOLNAME);
3050 if (!as->parms[2].items && !as->parms[3].items) { /* a single entry only */
3051 fprintf(STDERR,"You must provide -server with the -prefix argument\n");
3056 if (as->parms[2].items) { /* -server */
3058 aserver = GetServer(as->parms[2].items->data);
3060 fprintf(STDERR,"vos: server '%s' not found in host table\n",as->parms[2].items->data );
3063 attributes.server = ntohl(aserver);
3064 attributes.Mask |= VLLIST_SERVER;
3067 if (as->parms[3].items) { /* -partition */
3068 if (!as->parms[2].items) {
3069 fprintf(STDERR,"You must provide -server with the -partition argument\n");
3072 apart = volutil_GetPartitionID(as->parms[3].items->data);
3074 fprintf(STDERR,"vos: could not interpret partition name '%s'\n",
3075 as->parms[3].items->data);
3078 attributes.partition = apart;
3079 attributes.Mask |= VLLIST_PARTITION;
3082 /* Print status line of what we are doing */
3083 fprintf(STDOUT,"Deleting VLDB entries for ");
3084 if (as->parms[2].items) {
3085 fprintf(STDOUT,"server %s ", as->parms[2].items->data);
3087 if (as->parms[3].items) {
3089 MapPartIdIntoName(apart, pname);
3090 fprintf(STDOUT,"partition %s ", pname);
3093 fprintf(STDOUT,"which are prefixed with %s ", prefix);
3095 fprintf(STDOUT,"\n");
3098 /* Get all the VLDB entries on a server and/or partition */
3099 memset(&arrayEntries, 0, sizeof(arrayEntries));
3100 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
3102 fprintf(STDERR,"Could not access the VLDB for attributes\n");
3103 PrintError("",vcode);
3107 /* Process each entry */
3108 for (j=0; j<nentries; j++) {
3109 vllist = &arrayEntries.nbulkentries_val[j];
3111 /* It only deletes the RW volumes */
3112 if (strncmp(vllist->name, prefix, strlen(prefix))){
3114 fprintf(STDOUT,"Omitting to delete %s due to prefix %s mismatch\n",
3115 vllist->name, prefix);
3122 if (as->parms[4].items) { /* -noexecute */
3123 fprintf(STDOUT,"Would have deleted VLDB entry for %s \n", vllist->name);
3128 /* Only matches the RW volume name */
3129 avolid = vllist->volumeId[RWVOL];
3130 vcode = ubik_Call(VL_DeleteEntry, cstruct, 0, avolid, RWVOL);
3132 fprintf(STDOUT,"Could not delete VDLB entry for %s\n",vllist->name);
3134 PrintError("",vcode);
3139 fprintf(STDOUT,"Deleted VLDB entry for %s \n",vllist->name);
3144 fprintf(STDOUT,"----------------------\n");
3145 fprintf(STDOUT,"Total VLDB entries deleted: %u; failed to delete: %u\n",totalBack,totalFail);
3146 if (arrayEntries.nbulkentries_val) free(arrayEntries.nbulkentries_val);
3151 static int CompareVldbEntryByName(p1,p2)
3154 struct nvldbentry *arg1,*arg2;
3156 arg1 = (struct nvldbentry *)p1;
3157 arg2 = (struct nvldbentry *)p2;
3158 return(strcmp(arg1->name,arg2->name));
3162 static int CompareVldbEntry(p1,p2)
3165 struct nvldbentry *arg1,*arg2;
3168 char comp1[100],comp2[100];
3169 char temp1[20],temp2[20];
3171 arg1 = (struct nvldbentry *)p1;
3172 arg2 = (struct nvldbentry *)p2;
3176 for(i = 0; i < arg1->nServers; i++)
3177 if(arg1->serverFlags[i] & ITSRWVOL) pos1 = i;
3178 for(i = 0; i < arg2->nServers; i++)
3179 if(arg2->serverFlags[i] & ITSRWVOL) pos2 = i;
3180 if(pos1 == -1 || pos2 == -1){
3184 sprintf(comp1,"%10u",arg1->serverNumber[pos1]);
3185 sprintf(comp2,"%10u",arg2->serverNumber[pos2]);
3186 sprintf(temp1,"%10u",arg1->serverPartition[pos1]);
3187 sprintf(temp2,"%10u",arg2->serverPartition[pos2]);
3188 strcat(comp1,temp1);
3189 strcat(comp2,temp2);
3190 strcat(comp1,arg1->name);
3191 strcat(comp1,arg2->name);
3192 return(strcmp(comp1,comp2));
3198 struct cmd_syndesc *as;
3201 afs_int32 aserver,code;
3203 struct VldbListByAttributes attributes;
3204 nbulkentries arrayEntries;
3205 struct nvldbentry *vllist, *tarray=0, *ttarray;
3206 afs_int32 centries, nentries = 0, tarraysize, parraysize;
3209 int quiet, sort, lock;
3210 afs_int32 thisindex, nextindex;
3215 attributes.Mask = 0;
3216 lock = (as->parms[3].items ? 1 : 0); /* -lock flag */
3217 quiet = (as->parms[4].items ? 1 : 0); /* -quit flag */
3218 sort = (as->parms[5].items ? 0 : 1); /* -nosort flag */
3220 /* If the volume name is given, Use VolumeInfoCmd to look it up
3221 * and not ListAttributes.
3223 if (as->parms[0].items) {
3225 fprintf(STDERR,"vos: illegal use of '-locked' switch, need to specify server and/or partition\n");
3228 code = VolumeInfoCmd(as->parms[0].items->data);
3230 PrintError("",code);
3236 /* Server specified */
3237 if (as->parms[1].items) {
3238 aserver = GetServer(as->parms[1].items->data);
3240 fprintf(STDERR,"vos: server '%s' not found in host table\n",as->parms[1].items->data );
3243 attributes.server = ntohl(aserver);
3244 attributes.Mask |= VLLIST_SERVER;
3247 /* Partition specified */
3248 if (as->parms[2].items) {
3249 apart = volutil_GetPartitionID(as->parms[2].items->data);
3251 fprintf(STDERR,"vos: could not interpret partition name '%s'\n", as->parms[2].items->data);
3254 attributes.partition = apart;
3255 attributes.Mask |= VLLIST_PARTITION;
3259 attributes.Mask |= VLLIST_FLAG;
3260 attributes.flag = VLOP_ALLOPERS;
3263 /* Print header information */
3265 MapPartIdIntoName(apart, pname);
3266 fprintf(STDOUT,"VLDB entries for %s %s%s%s %s\n",
3267 (as->parms[1].items ? "server" : "all" ),
3268 (as->parms[1].items ? as->parms[1].items->data : "servers"),
3269 (as->parms[2].items ? " partition " : ""),
3270 (as->parms[2].items ? pname : ""),
3271 (lock ? "which are locked:" : ""));
3274 for (thisindex = 0; (thisindex != -1); thisindex = nextindex) {
3275 memset(&arrayEntries, 0, sizeof(arrayEntries));
3279 vcode = VLDB_ListAttributesN2(&attributes, 0, thisindex,
3280 ¢ries, &arrayEntries, &nextindex);
3281 if (vcode == RXGEN_OPCODE) {
3282 /* Vlserver not running with ListAttributesN2. Fall back */
3283 vcode = VLDB_ListAttributes(&attributes, ¢ries, &arrayEntries);
3287 fprintf(STDERR,"Could not access the VLDB for attributes\n");
3288 PrintError("",vcode);
3291 nentries += centries;
3293 /* We don't sort, so just print the entries now */
3295 for (j = 0; j < centries; j++) { /* process each entry */
3296 vllist = &arrayEntries.nbulkentries_val[j];
3297 MapHostToNetwork(vllist);
3298 EnumerateEntry(vllist);
3300 if(vllist->flags & VLOP_ALLOPERS)
3301 fprintf(STDOUT," Volume is currently LOCKED \n");
3305 /* So we sort. First we must collect all the entries and keep
3308 else if (centries > 0) {
3310 /* steal away the first bulk entries array */
3311 tarray = (struct nvldbentry *)arrayEntries.nbulkentries_val;
3312 tarraysize = centries * sizeof(struct nvldbentry);
3313 arrayEntries.nbulkentries_val = 0;
3315 /* Grow the tarray to keep the extra entries */
3316 parraysize = (centries * sizeof(struct nvldbentry));
3317 ttarray = (struct nvldbentry *) realloc(tarray, tarraysize + parraysize);
3319 fprintf(STDERR,"Could not allocate enough space for the VLDB entries\n");
3325 memcpy(((char *)tarray)+tarraysize, (char *)arrayEntries.nbulkentries_val, parraysize);
3326 tarraysize += parraysize;
3330 /* Free the bulk array */
3331 if (arrayEntries.nbulkentries_val) {
3332 free(arrayEntries.nbulkentries_val);
3333 arrayEntries.nbulkentries_val = 0;
3337 /* Here is where we now sort all the entries and print them */
3338 if (sort && (nentries > 0)) {
3339 qsort((char *)tarray, nentries, sizeof(struct nvldbentry), CompareVldbEntryByName);
3340 for (vllist=tarray, j=0; j<nentries; j++, vllist++) {
3341 MapHostToNetwork(vllist);
3342 EnumerateEntry(vllist);
3344 if(vllist->flags & VLOP_ALLOPERS)
3345 fprintf(STDOUT," Volume is currently LOCKED \n");
3350 if (!quiet) fprintf(STDOUT,"\nTotal entries: %u\n", nentries);
3351 if (tarray) free(tarray);
3356 register struct cmd_syndesc *as;
3358 afs_int32 apart=0, avolid;
3359 afs_int32 aserver=0, code, aserver1, apart1;
3361 struct VldbListByAttributes attributes;
3362 nbulkentries arrayEntries;
3363 register struct nvldbentry *vllist;
3367 int seenprefix, seenxprefix, exclude, ex, exp, noaction;
3368 afs_int32 totalBack=0;
3369 afs_int32 totalFail=0;
3370 int previdx=-1, error, same;
3373 struct cmd_item *ti;
3377 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
3378 attributes.Mask = 0;
3380 seenprefix = (as->parms[0].items ? 1 : 0);
3381 exclude = (as->parms[3].items ? 1 : 0);
3382 seenxprefix = (as->parms[4].items ? 1 : 0);
3383 noaction = (as->parms[5].items ? 1 : 0);
3385 if (as->parms[1].items) { /* -server */
3386 aserver = GetServer(as->parms[1].items->data);
3388 fprintf(STDERR,"vos: server '%s' not found in host table\n",as->parms[1].items->data );
3391 attributes.server = ntohl(aserver);
3392 attributes.Mask |= VLLIST_SERVER;
3395 if (as->parms[2].items) { /* -partition */
3396 apart = volutil_GetPartitionID(as->parms[2].items->data);
3398 fprintf(STDERR,"vos: could not interpret partition name '%s'\n", as->parms[2].items->data);
3401 attributes.partition = apart;
3402 attributes.Mask |= VLLIST_PARTITION;
3405 /* Check to make sure the prefix and xprefix expressions compile ok */
3407 for (ti=as->parms[0].items; ti; ti=ti->next) {
3408 if (strncmp(ti->data,"^",1) == 0) {
3409 ccode = (char *)re_comp(ti->data);
3411 fprintf(STDERR,"Unrecognizable -prefix regular expression: '%s': %s\n",
3419 for (ti=as->parms[4].items; ti; ti=ti->next) {
3420 if (strncmp(ti->data,"^",1) == 0) {
3421 ccode = (char *)re_comp(ti->data);
3423 fprintf(STDERR,"Unrecognizable -xprefix regular expression: '%s': %s\n",
3431 memset(&arrayEntries, 0, sizeof(arrayEntries)); /* initialize to hint the stub to alloc space */
3432 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
3434 fprintf(STDERR,"Could not access the VLDB for attributes\n");
3435 PrintError("",vcode);
3439 if (as->parms[1].items || as->parms[2].items || verbose) {
3440 fprintf(STDOUT,"%s up volumes", (noaction?"Would have backed":"Backing"));
3442 if (as->parms[1].items) {
3443 fprintf(STDOUT," on server %s", as->parms[1].items->data);
3444 } else if (as->parms[2].items) {
3445 fprintf(STDOUT," for all servers");
3448 if (as->parms[2].items) {
3449 MapPartIdIntoName(apart, pname);
3450 fprintf(STDOUT," partition %s", pname);
3453 if (seenprefix || (!seenprefix && seenxprefix)) {
3454 ti = (seenprefix ? as->parms[0].items : as->parms[4].items);
3455 ex = (seenprefix ? exclude : !exclude);
3456 exp = (strncmp(ti->data,"^",1) == 0);
3457 fprintf(STDOUT," which %smatch %s '%s'", (ex ? "do not " : ""),
3458 (exp?"expression":"prefix"), ti->data);
3459 for (ti=ti->next; ti; ti=ti->next) {
3460 exp = (strncmp(ti->data,"^",1) == 0);
3461 printf(" %sor %s '%s'", (ex ? "n" : ""),
3462 (exp?"expression":"prefix"), ti->data);
3466 if (seenprefix && seenxprefix) {
3467 ti = as->parms[4].items;
3468 exp = (strncmp(ti->data,"^",1) == 0);
3469 fprintf(STDOUT," %swhich match %s '%s'",
3470 (exclude?"adding those ":"removing those "),
3471 (exp?"expression":"prefix"), ti->data);
3472 for (ti=ti->next; ti; ti=ti->next) {
3473 exp = (strncmp(ti->data,"^",1) == 0);
3474 printf(" or %s '%s'", (exp?"expression":"prefix"), ti->data);
3477 fprintf(STDOUT," .. ");
3478 if (verbose) fprintf(STDOUT,"\n");
3482 for (j=0; j<nentries; j++) { /* process each vldb entry */
3483 vllist = &arrayEntries.nbulkentries_val[j];
3486 for (ti=as->parms[0].items; ti; ti=ti->next) {
3487 if (strncmp(ti->data,"^",1) == 0) {
3488 ccode = (char *)re_comp(ti->data);
3490 fprintf(STDERR,"Error in -prefix regular expression: '%s': %s\n",
3494 match = (re_exec(vllist->name) == 1);
3496 match = (strncmp(vllist->name,ti->data,strlen(ti->data)) == 0);
3504 /* Without the -exclude flag: If it matches the prefix, then
3505 * check if we want to exclude any from xprefix.
3506 * With the -exclude flag: If it matches the prefix, then
3507 * check if we want to add any from xprefix.
3509 if (match && seenxprefix) {
3510 for (ti=as->parms[4].items; ti; ti=ti->next) {
3511 if (strncmp(ti->data,"^",1) == 0) {
3512 ccode = (char *)re_comp(ti->data);
3514 fprintf(STDERR,"Error in -xprefix regular expression: '%s': %s\n",
3518 if (re_exec(vllist->name) == 1) {
3523 if (strncmp(vllist->name,ti->data,strlen(ti->data)) == 0) {
3531 if (exclude) match = !match; /* -exclude will reverse the match */
3532 if (!match) continue; /* Skip if no match */
3534 /* Print list of volumes to backup */
3536 fprintf(STDOUT," %s\n", vllist->name);
3540 if(!(vllist->flags & RW_EXISTS)){
3542 fprintf(STDOUT,"Omitting to backup %s since RW volume does not exist \n", vllist->name);
3543 fprintf(STDOUT,"\n");
3549 avolid = vllist->volumeId[RWVOL];
3550 MapHostToNetwork(vllist);
3551 GetServerAndPart(vllist,RWVOL,&aserver1,&apart1,&previdx);
3552 if(aserver1 == -1 || apart1 == -1){
3553 fprintf(STDOUT,"could not backup %s, invalid VLDB entry\n",vllist->name);
3558 same = VLDB_IsSameAddrs(aserver, aserver1, &error);
3560 fprintf(STDERR,"Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
3566 if ((aserver && !same) || (apart && (apart != apart1))) {
3568 fprintf(STDOUT, "Omitting to backup %s since the RW is in a different location\n", vllist->name);
3573 time_t now = time(0);
3574 fprintf(STDOUT,"Creating backup volume for %s on %s",vllist->name, ctime(&now));
3578 code = UV_BackupVolume(aserver1, apart1, avolid);
3580 fprintf(STDOUT,"Could not backup %s\n",vllist->name);
3586 if (verbose) fprintf(STDOUT,"\n");
3588 } /* process each vldb entry */
3589 fprintf(STDOUT,"done\n");
3590 fprintf(STDOUT,"Total volumes backed up: %u; failed to backup: %u\n",totalBack,totalFail);
3592 if(arrayEntries.nbulkentries_val) free(arrayEntries.nbulkentries_val);
3596 static UnlockVLDB(as)
3597 register struct cmd_syndesc *as;
3600 afs_int32 aserver,code;
3602 struct VldbListByAttributes attributes;
3603 nbulkentries arrayEntries;
3604 register struct nvldbentry *vllist;
3613 attributes.Mask = 0;
3615 if(as->parms[0].items) {/* server specified */
3616 aserver = GetServer(as->parms[0].items->data);
3618 fprintf(STDERR,"vos: server '%s' not found in host table\n",as->parms[0].items->data );
3621 attributes.server = ntohl(aserver);
3622 attributes.Mask |= VLLIST_SERVER;
3624 if(as->parms[1].items) {/* partition specified */
3625 apart = volutil_GetPartitionID(as->parms[1].items->data);
3627 fprintf(STDERR,"vos: could not interpret partition name '%s'\n", as->parms[1].items->data);
3630 if (!IsPartValid(apart,aserver,&code)){/*check for validity of the partition */
3631 if(code) PrintError("",code);
3632 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
3635 attributes.partition = apart;
3636 attributes.Mask |= VLLIST_PARTITION;
3638 attributes.flag = VLOP_ALLOPERS;
3639 attributes.Mask |= VLLIST_FLAG;
3640 memset(&arrayEntries, 0, sizeof(arrayEntries)); /*initialize to hint the stub to alloc space */
3641 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
3643 fprintf(STDERR,"Could not access the VLDB for attributes\n");
3644 PrintError("",vcode);
3647 for(j=0;j<nentries;j++) { /* process each entry */
3648 vllist = &arrayEntries.nbulkentries_val[j];
3649 volid = vllist->volumeId[RWVOL];
3650 vcode = ubik_Call(VL_ReleaseLock,cstruct, 0, volid,-1, LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
3652 fprintf(STDERR,"Could not unlock entry for volume %s\n",vllist->name);
3653 PrintError("",vcode);
3658 MapPartIdIntoName(apart,pname);
3659 if(totalE) fprintf(STDOUT,"Could not lock %u VLDB entries of %u locked entries\n",totalE,nentries);
3661 if(as->parms[0].items) {
3662 fprintf(STDOUT,"Unlocked all the VLDB entries for volumes on server %s ",as->parms[0].items->data);
3663 if(as->parms[1].items){
3664 MapPartIdIntoName(apart,pname);
3665 fprintf(STDOUT,"partition %s\n",pname);
3667 else fprintf(STDOUT,"\n");
3670 else if(as->parms[1].items){
3671 MapPartIdIntoName(apart,pname);
3672 fprintf(STDOUT,"Unlocked all the VLDB entries for volumes on partition %s on all servers\n",pname);
3676 if(arrayEntries.nbulkentries_val) free(arrayEntries.nbulkentries_val);
3680 static PartitionInfo(as)
3681 register struct cmd_syndesc *as;
3684 afs_int32 aserver,code;
3686 struct diskPartition partition;
3687 struct partList dummyPartList;
3691 aserver = GetServer(as->parms[0].items->data);
3693 fprintf(STDERR,"vos: server '%s' not found in host table\n",as->parms[0].items->data );
3696 if(as->parms[1].items){
3697 apart = volutil_GetPartitionID(as->parms[1].items->data);
3699 fprintf(STDERR,"vos: could not interpret partition name '%s'\n", as->parms[1].items->data);
3702 dummyPartList.partId[0] = apart;
3703 dummyPartList.partFlags[0] = PARTVALID;
3707 if (!IsPartValid(apart,aserver,&code)){/*check for validity of the partition */
3708 if(code) PrintError("",code);
3709 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
3714 code = UV_ListPartitions(aserver,&dummyPartList, &cnt);
3716 PrintDiagnostics("listpart", code);
3720 for(i = 0 ; i < cnt ; i++){
3721 if(dummyPartList.partFlags[i] & PARTVALID){
3722 MapPartIdIntoName(dummyPartList.partId[i],pname);
3723 code = UV_PartitionInfo(aserver,pname,&partition);
3725 fprintf(STDERR,"Could not get information on partition %s\n",pname);
3726 PrintError("",code);
3729 fprintf(STDOUT,"Free space on partition %s: %d K blocks out of total %d\n",pname,partition.free,partition.minFree);
3735 static ChangeAddr(as)
3736 register struct cmd_syndesc *as;
3739 afs_int32 ip1, ip2, vcode;
3742 ip1 = GetServer(as->parms[0].items->data);
3744 fprintf(STDERR, "vos: invalid host address\n");
3748 if ( ( as->parms[1].items && as->parms[2].items) ||
3749 (!as->parms[1].items && !as->parms[2].items) ) {
3750 fprintf(STDERR, "vos: Must specify either '-newaddr <addr>' or '-remove' flag\n");
3754 if (as->parms[1].items) {
3755 ip2 = GetServer(as->parms[1].items->data);
3757 fprintf(STDERR, "vos: invalid host address\n");
3761 /* Play a trick here. If we are removing an address, ip1 will be -1
3762 * and ip2 will be the original address. This switch prevents an
3763 * older revision vlserver from removing the IP address.
3770 vcode = ubik_Call_New(VL_ChangeAddr, cstruct, 0, ntohl(ip1), ntohl(ip2) );
3773 fprintf(STDERR,"Could not remove server %s from the VLDB\n",
3774 as->parms[0].items->data);
3775 if (vcode == VL_NOENT) {
3776 fprintf(STDERR, "vlserver does not support the remove flag or ");
3779 fprintf(STDERR,"Could not change server %s to server %s\n",
3780 as->parms[0].items->data, as->parms[1].items->data);
3782 PrintError("",vcode);
3787 fprintf(STDOUT,"Removed server %s from the VLDB\n",
3788 as->parms[0].items->data);
3790 fprintf(STDOUT,"Changed server %s to server %s\n",
3791 as->parms[0].items->data, as->parms[1].items->data);
3796 static ListAddrs(as)
3797 register struct cmd_syndesc *as;
3802 struct VLCallBack unused;
3803 afs_int32 nentries, *addrp;
3804 bulkaddrs addrs, m_addrs;
3805 ListAddrByAttributes m_attrs;
3807 afs_int32 m_unique, m_nentries, *m_addrp;
3808 afs_int32 base, index;
3810 /* Get the list of non multihomed fileservers */
3811 addrs.bulkaddrs_val = 0;
3812 addrs.bulkaddrs_len = 0;
3813 vcode = ubik_Call_New(VL_GetAddrs, cstruct, 0,
3814 0, 0, &unused, &nentries, &addrs);
3816 fprintf(STDERR,"vos: could not list the server addresses\n");
3817 PrintError("",vcode);
3821 /* print out the list of all the server */
3822 addrp = (afs_int32 *)addrs.bulkaddrs_val;
3823 for (i=0; i<nentries; i++, addrp++) {
3824 /* If it is a multihomed address, then we will need to
3825 * get the addresses for this multihomed server from
3826 * the vlserver and print them.
3828 if ( ((*addrp & 0xff000000) == 0xff000000) && ((*addrp)&0xffff) ) {
3829 /* Get the list of multihomed fileservers */
3830 base = (*addrp>>16) & 0xff;
3831 index = (*addrp) & 0xffff;
3833 if ( (base >= 0) && (base <= VL_MAX_ADDREXTBLKS) &&
3834 (index >= 1) && (index <= VL_MHSRV_PERBLK) ) {
3835 m_attrs.Mask = VLADDR_INDEX;
3836 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
3838 m_addrs.bulkaddrs_val = 0;
3839 m_addrs.bulkaddrs_len = 0;
3840 vcode = ubik_Call(VL_GetAddrsU, cstruct, 0,
3841 &m_attrs, &m_uuid, &m_unique, &m_nentries, &m_addrs);
3843 fprintf(STDERR,"vos: could not list the multi-homed server addresses\n");
3844 PrintError("",vcode);
3847 /* Print the list */
3848 m_addrp = (afs_int32 *)m_addrs.bulkaddrs_val;
3849 for (j=0; j<m_nentries; j++, m_addrp++) {
3850 *m_addrp = htonl(*m_addrp);
3851 printf("%s ", hostutil_GetNameByINet(*m_addrp));
3854 printf("<unknown>\n");
3863 /* Otherwise, it is a non-multihomed entry and contains
3864 * the IP address of the server - print it.
3866 printf ("%s\n", hostutil_GetNameByINet(htonl(*addrp)));
3869 if (addrs.bulkaddrs_val) {
3870 free (addrs.bulkaddrs_val);
3875 static LockEntry(as)
3876 register struct cmd_syndesc *as;
3879 afs_int32 avolid,vcode, err;
3881 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
3883 if (err) PrintError("", err);
3884 else fprintf(STDERR, "vos: can't find volume '%s'\n", as->parms[0].items->data);
3887 vcode = ubik_Call(VL_SetLock,cstruct, 0, avolid, -1, VLOP_DELETE);
3889 fprintf(STDERR,"Could not lock VLDB entry for volume %s\n",as->parms[0].items->data);
3890 PrintError("",vcode);
3893 fprintf(STDOUT,"Locked VLDB entry for volume %s\n",as->parms[0].items->data);
3897 PrintDiagnostics(astring, acode)
3901 if (acode == EACCES) {
3902 fprintf(STDERR,"You are not authorized to perform the 'vos %s' command (%d)\n",
3906 fprintf(STDERR,"Error in vos %s command.\n", astring);
3907 PrintError("", acode);
3913 static MyBeforeProc(as, arock)
3914 struct cmd_syndesc *as;
3916 register char *tcell;
3917 register afs_int32 code;
3918 register afs_int32 sauth;
3920 /* Initialize the ubik_client connection */
3921 rx_SetRxDeadTime(90);
3922 cstruct = (struct ubik_client *)0;
3926 if (as->parms[12].items) /* if -cell specified */
3927 tcell = as->parms[12].items->data;
3928 if(as->parms[14].items) /* -serverauth specified */
3930 if(as->parms[16].items) /* -crypt specified */
3932 if (code = vsu_ClientInit((as->parms[13].items != 0), confdir, tcell, sauth,
3933 &cstruct, UV_SetSecurity)) {
3934 fprintf(STDERR,"could not initialize VLDB library (code=%u) \n",code);
3938 if(as->parms[15].items) /* -verbose flag set */
3947 /* this sucks but it works for now.
3952 #include "AFS_component_version_number.c"
3957 register afs_int32 code;
3959 register struct cmd_syndesc *ts;
3961 #ifdef AFS_AIX32_ENV
3963 * The following signal action for AIX is necessary so that in case of a
3964 * crash (i.e. core is generated) we can include the user's data section
3965 * in the core dump. Unfortunately, by default, only a partial core is
3966 * generated which, in many cases, isn't too useful.
3968 struct sigaction nsa;
3970 sigemptyset(&nsa.sa_mask);
3971 nsa.sa_handler = SIG_DFL;
3972 nsa.sa_flags = SA_FULLDUMP;
3973 sigaction(SIGSEGV, &nsa, NULL);
3976 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
3978 cmd_SetBeforeProc(MyBeforeProc, (char *) 0);
3980 ts = cmd_CreateSyntax("create", CreateVolume, 0, "create a new volume");
3981 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
3982 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
3983 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "volume name");
3984 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL, "initial quota (KB)");
3986 cmd_AddParm(ts, "-minquota", CMD_SINGLE, CMD_OPTIONAL, "");
3990 ts = cmd_CreateSyntax("remove", DeleteVolume, 0, "delete a volume");
3991 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
3992 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
3993 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
3997 ts = cmd_CreateSyntax("move", MoveVolume, 0, "move a volume");
3998 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
3999 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
4000 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0, "partition name on source");
4001 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0, "machine name on destination");
4002 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0, "partition name on destination");
4005 ts = cmd_CreateSyntax("backup", BackupVolume, 0, "make backup of a volume");
4006 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
4009 ts = cmd_CreateSyntax("release", ReleaseVolume, 0, "release a volume");
4010 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
4011 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, "force a complete release");
4014 ts = cmd_CreateSyntax("dump", DumpVolume, 0, "dump a volume");
4015 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
4016 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
4017 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
4018 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
4019 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
4022 ts = cmd_CreateSyntax("restore", RestoreVolume, 0, "restore a volume");
4023 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
4024 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
4025 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of volume to be restored");
4026 cmd_AddParm(ts, "-file", CMD_SINGLE,CMD_OPTIONAL, "dump file");
4027 cmd_AddParm(ts, "-id", CMD_SINGLE,CMD_OPTIONAL, "volume ID");
4028 cmd_AddParm(ts, "-overwrite", CMD_SINGLE,CMD_OPTIONAL, "abort | full | incremental");
4029 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
4030 "leave restored volume offline");
4031 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
4032 "make restored volume read-only");
4035 ts = cmd_CreateSyntax("unlock", LockReleaseCmd, 0, "release lock on VLDB entry for a volume");
4036 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
4039 ts = cmd_CreateSyntax("changeloc", ChangeLocation, 0, "change an RW volume's location in the VLDB");
4040 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name for new location");
4041 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name for new location");
4042 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
4045 ts = cmd_CreateSyntax("addsite", AddSite, 0, "add a replication site");
4046 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name for new site");
4047 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name for new site");
4048 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
4051 ts = cmd_CreateSyntax("remsite", RemoveSite, 0, "remove a replication site");
4052 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
4053 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
4054 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
4057 ts = cmd_CreateSyntax("listpart", ListPartitions, 0, "list partitions");
4058 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
4061 ts = cmd_CreateSyntax("listvol", ListVolumes, 0, "list volumes on server (bypass VLDB)");
4062 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
4063 cmd_AddParm(ts, "-partition", CMD_SINGLE,CMD_OPTIONAL, "partition name");
4064 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "minimal listing");
4065 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL,
4066 "list all normal volume fields");
4067 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL, "generate minimal information");
4068 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
4069 "list extended volume fields");
4070 #ifdef FULL_LISTVOL_SWITCH
4071 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
4072 "machine readable format");
4073 #endif /* FULL_LISTVOL_SWITCH */
4076 ts = cmd_CreateSyntax("syncvldb", SyncVldb, 0, "synchronize VLDB with server");
4077 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
4078 cmd_AddParm(ts, "-partition", CMD_SINGLE,CMD_OPTIONAL , "partition name");
4079 cmd_AddParm(ts, "-volume", CMD_SINGLE,CMD_OPTIONAL , "volume name or ID");
4082 ts = cmd_CreateSyntax("syncserv", SyncServer, 0, "synchronize server with VLDB");
4083 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
4084 cmd_AddParm(ts, "-partition", CMD_SINGLE,CMD_OPTIONAL , "partition name");
4087 ts = cmd_CreateSyntax("examine", ExamineVolume, 0, "everything about the volume");
4088 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
4089 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
4090 "list extended volume fields");
4091 #ifdef FULL_LISTVOL_SWITCH
4092 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
4093 "machine readable format");
4094 #endif /* FULL_LISTVOL_SWITCH */
4096 cmd_CreateAlias (ts, "volinfo");
4098 ts = cmd_CreateSyntax("setfields", SetFields, 0, "change volume info fields");
4099 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
4100 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL, "quota (KB)");
4101 cmd_AddParm(ts, "-clearuse", CMD_FLAG, CMD_OPTIONAL, "clear dayUse");
4104 ts = cmd_CreateSyntax("offline", volOffline, 0, (char *) CMD_HIDDEN);
4105 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
4106 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
4107 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
4108 cmd_AddParm(ts, "-sleep", CMD_SINGLE, CMD_OPTIONAL, "seconds to sleep");
4109 cmd_AddParm(ts, "-busy", CMD_FLAG, CMD_OPTIONAL, "busy volume");
4112 ts = cmd_CreateSyntax("online", volOnline, 0, (char *) CMD_HIDDEN);
4113 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
4114 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
4115 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
4118 ts = cmd_CreateSyntax("zap", VolumeZap, 0, "delete the volume, don't bother with VLDB");
4119 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
4120 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
4121 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume ID");
4122 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, "force deletion of bad volumes");
4123 cmd_AddParm(ts, "-backup", CMD_FLAG, CMD_OPTIONAL, "also delete backup volume if one is found");
4126 ts = cmd_CreateSyntax("status", VolserStatus, 0, "report on volser status");
4127 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
4130 ts = cmd_CreateSyntax("rename", RenameVolume, 0, "rename a volume");
4131 cmd_AddParm(ts, "-oldname", CMD_SINGLE, 0, "old volume name ");
4132 cmd_AddParm(ts, "-newname", CMD_SINGLE, 0, "new volume name ");
4135 ts = cmd_CreateSyntax("listvldb", ListVLDB, 0, "list volumes in the VLDB");
4136 cmd_AddParm(ts, "-name", CMD_SINGLE,CMD_OPTIONAL, "volume name or ID");
4137 cmd_AddParm(ts, "-server", CMD_SINGLE,CMD_OPTIONAL, "machine name");
4138 cmd_AddParm(ts, "-partition", CMD_SINGLE,CMD_OPTIONAL, "partition name");
4139 cmd_AddParm(ts, "-locked", CMD_FLAG, CMD_OPTIONAL, "locked volumes only");
4140 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL, "generate minimal information");
4141 cmd_AddParm(ts, "-nosort", CMD_FLAG, CMD_OPTIONAL, "do not alphabetically sort the volume names");
4144 ts = cmd_CreateSyntax("backupsys", BackSys, 0, "en masse backups");
4145 cmd_AddParm(ts, "-prefix", CMD_LIST,CMD_OPTIONAL, "common prefix on volume(s)");
4146 cmd_AddParm(ts, "-server", CMD_SINGLE,CMD_OPTIONAL, "machine name");
4147 cmd_AddParm(ts, "-partition", CMD_SINGLE,CMD_OPTIONAL, "partition name");
4148 cmd_AddParm(ts, "-exclude", CMD_FLAG, CMD_OPTIONAL, "exclude common prefix volumes");
4149 cmd_AddParm(ts, "-xprefix", CMD_LIST, CMD_OPTIONAL, "negative prefix on volume(s)");
4150 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "no action");
4153 ts = cmd_CreateSyntax("delentry", DeleteEntry, 0, "delete VLDB entry for a volume");
4154 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL, "volume name or ID");
4155 cmd_AddParm(ts, "-prefix", CMD_SINGLE,CMD_OPTIONAL, "prefix of the volume whose VLDB entry is to be deleted");
4156 cmd_AddParm(ts, "-server", CMD_SINGLE,CMD_OPTIONAL, "machine name");
4157 cmd_AddParm(ts, "-partition", CMD_SINGLE,CMD_OPTIONAL, "partition name");
4158 cmd_AddParm(ts, "-noexecute", CMD_FLAG,CMD_OPTIONAL|CMD_HIDE, "no execute");
4161 ts = cmd_CreateSyntax("partinfo", PartitionInfo, 0, "list partition information");
4162 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
4163 cmd_AddParm(ts, "-partition", CMD_SINGLE,CMD_OPTIONAL, "partition name");
4166 ts = cmd_CreateSyntax("unlockvldb", UnlockVLDB, 0, "unlock all the locked entries in the VLDB");
4167 cmd_AddParm(ts, "-server", CMD_SINGLE,CMD_OPTIONAL, "machine name");
4168 cmd_AddParm(ts, "-partition", CMD_SINGLE,CMD_OPTIONAL, "partition name");
4171 ts = cmd_CreateSyntax("lock", LockEntry, 0, "lock VLDB entry for a volume");
4172 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
4175 ts = cmd_CreateSyntax("changeaddr", ChangeAddr, 0, "change the IP address of a file server");
4176 cmd_AddParm(ts, "-oldaddr", CMD_SINGLE, 0, "original IP address");
4177 cmd_AddParm(ts, "-newaddr", CMD_SINGLE, CMD_OPTIONAL, "new IP address");
4178 cmd_AddParm(ts, "-remove", CMD_FLAG, CMD_OPTIONAL, "remove the IP address from the VLDB");
4181 ts = cmd_CreateSyntax("listaddrs", ListAddrs, 0, "list the IP address of all file servers registered in the VLDB");
4184 code = cmd_Dispatch(argc, argv);
4186 /* Shut down the ubik_client and rx connections */
4188 ubik_ClientDestroy (cstruct);