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>
13 #ifdef IGNORE_SOME_GCC_WARNINGS
14 # pragma GCC diagnostic warning "-Wimplicit-function-declaration"
17 #include <sys/types.h>
26 #include <WINNT/afsreg.h>
31 #include <netinet/in.h>
32 #include <arpa/inet.h>
36 #include <sys/statfs.h>
44 #include <rx/rx_globals.h>
46 #include <afs/vlserver.h>
47 #include <afs/cellconfig.h>
49 #include <afs/afsutil.h>
51 #include <afs/afsint.h>
56 #include <afs/ihandle.h>
57 #include <afs/vnode.h>
58 #include <afs/volume.h>
59 #include <afs/com_err.h>
66 #include "volser_internal.h"
67 #include "volser_prototypes.h"
68 #include "vsutils_prototypes.h"
69 #include "lockprocs_prototypes.h"
71 #ifdef HAVE_POSIX_REGEX
75 /* Local Prototypes */
76 int PrintDiagnostics(char *astring
, afs_int32 acode
);
77 int GetVolumeInfo(afs_uint32 volid
, afs_uint32
*server
, afs_int32
*part
,
78 afs_int32
*voltype
, struct nvldbentry
*rentry
);
90 #define COMMONPARMS cmd_Seek(ts, 12);\
91 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");\
92 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "don't authenticate");\
93 cmd_AddParm(ts, "-localauth",CMD_FLAG,CMD_OPTIONAL,"use server tickets");\
94 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose");\
95 cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL, "encrypt commands");\
96 cmd_AddParm(ts, "-noresolve", CMD_FLAG, CMD_OPTIONAL, "don't resolve addresses"); \
98 #define ERROR_EXIT(code) do { \
104 struct rx_connection
*tconn
;
106 extern struct ubik_client
*cstruct
;
109 static struct tqHead busyHead
, notokHead
;
112 qInit(struct tqHead
*ahead
)
114 memset(ahead
, 0, sizeof(struct tqHead
));
120 qPut(struct tqHead
*ahead
, afs_uint32 volid
)
124 elem
= (struct tqElem
*)malloc(sizeof(struct tqElem
));
125 elem
->next
= ahead
->next
;
133 qGet(struct tqHead
*ahead
, afs_uint32
*volid
)
137 if (ahead
->count
<= 0)
139 *volid
= ahead
->next
->volid
;
141 ahead
->next
= tmp
->next
;
147 /* returns 1 if <filename> exists else 0 */
149 FileExists(char *filename
)
155 code
= usd_Open(filename
, USD_OPEN_RDONLY
, 0, &ufd
);
159 code
= USD_IOCTL(ufd
, USD_IOCTL_GETSIZE
, &size
);
167 /* returns 1 if <name> doesnot end in .readonly or .backup, else 0 */
169 VolNameOK(char *name
)
174 total
= strlen(name
);
175 if (!strcmp(&name
[total
- 9], ".readonly")) {
177 } else if (!strcmp(&name
[total
- 7], ".backup")) {
184 /* return 1 if name is a number else 0 */
186 IsNumeric(char *name
)
194 for (i
= 0; i
< len
; i
++) {
195 if (*ptr
< '0' || *ptr
> '9') {
207 * Parse a server dotted address and return the address in network byte order
210 GetServerNoresolve(char *aname
)
216 code
= sscanf(aname
, "%d.%d.%d.%d", &b1
, &b2
, &b3
, &b4
);
218 addr
= (b1
<< 24) | (b2
<< 16) | (b3
<< 8) | b4
;
219 addr
= htonl(addr
); /* convert to network byte order */
225 * Parse a server name/address and return the address in network byte order
228 GetServer(char *aname
)
231 afs_uint32 addr
; /* in network byte order */
233 char hostname
[MAXHOSTCHARS
];
235 if ((addr
= GetServerNoresolve(aname
)) == 0) {
236 th
= gethostbyname(aname
);
239 memcpy(&addr
, th
->h_addr
, sizeof(addr
));
242 if (rx_IsLoopbackAddr(ntohl(addr
))) { /* local host */
243 code
= gethostname(hostname
, MAXHOSTCHARS
);
246 th
= gethostbyname(hostname
);
249 memcpy(&addr
, th
->h_addr
, sizeof(addr
));
256 GetVolumeType(char *aname
)
259 if (!strcmp(aname
, "ro"))
261 else if (!strcmp(aname
, "rw"))
263 else if (!strcmp(aname
, "bk"))
270 IsPartValid(afs_int32 partId
, afs_uint32 server
, afs_int32
*code
)
272 struct partList dummyPartList
;
278 *code
= UV_ListPartitions(server
, &dummyPartList
, &cnt
);
281 for (i
= 0; i
< cnt
; i
++) {
282 if (dummyPartList
.partFlags
[i
] & PARTVALID
)
283 if (dummyPartList
.partId
[i
] == partId
)
291 /*sends the contents of file associated with <fd> and <blksize> to Rx Stream
292 * associated with <call> */
294 SendFile(usd_handle_t ufd
, struct rx_call
*call
, long blksize
)
296 char *buffer
= (char *)0;
301 buffer
= (char *)malloc(blksize
);
303 fprintf(STDERR
, "malloc failed\n");
307 while (!error
&& !done
) {
308 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
311 FD_SET((intptr_t)(ufd
->handle
), &in
);
312 /* don't timeout if read blocks */
313 #if defined(AFS_PTHREAD_ENV)
314 select(((intptr_t)(ufd
->handle
)) + 1, &in
, 0, 0, 0);
316 IOMGR_Select(((intptr_t)(ufd
->handle
)) + 1, &in
, 0, 0, 0);
319 error
= USD_READ(ufd
, buffer
, blksize
, &nbytes
);
321 fprintf(STDERR
, "File system read failed: %s\n",
322 afs_error_message(error
));
329 if (rx_Write(call
, buffer
, nbytes
) != nbytes
) {
339 /* function invoked by UV_RestoreVolume, reads the data from rx_trx_stream and
340 * writes it out to the volume. */
342 WriteData(struct rx_call
*call
, void *rock
)
344 char *filename
= (char *) rock
;
347 afs_int32 error
, code
;
349 afs_hyper_t filesize
, currOffset
;
355 if (!filename
|| !*filename
) {
356 usd_StandardInput(&ufd
);
360 code
= usd_Open(filename
, USD_OPEN_RDONLY
, 0, &ufd
);
363 code
= USD_IOCTL(ufd
, USD_IOCTL_GETBLKSIZE
, &blksize
);
366 fprintf(STDERR
, "Could not access file '%s': %s\n", filename
,
367 afs_error_message(code
));
371 /* test if we have a valid dump */
372 hset64(filesize
, 0, 0);
373 USD_SEEK(ufd
, filesize
, SEEK_END
, &currOffset
);
374 hset64(filesize
, hgethi(currOffset
), hgetlo(currOffset
)-sizeof(afs_uint32
));
375 USD_SEEK(ufd
, filesize
, SEEK_SET
, &currOffset
);
376 USD_READ(ufd
, (char *)&buffer
, sizeof(afs_uint32
), &got
);
377 if ((got
!= sizeof(afs_uint32
)) || (ntohl(buffer
) != DUMPENDMAGIC
)) {
378 fprintf(STDERR
, "Signature missing from end of file '%s'\n", filename
);
382 /* rewind, we are done */
383 hset64(filesize
, 0, 0);
384 USD_SEEK(ufd
, filesize
, SEEK_SET
, &currOffset
);
386 code
= SendFile(ufd
, call
, blksize
);
393 code
= USD_CLOSE(ufd
);
395 fprintf(STDERR
, "Could not close dump file %s\n",
396 (filename
&& *filename
) ? filename
: "STDOUT");
404 /* Receive data from <call> stream into file associated
405 * with <fd> <blksize>
408 ReceiveFile(usd_handle_t ufd
, struct rx_call
*call
, long blksize
)
412 afs_uint32 bytesleft
, w
;
415 buffer
= (char *)malloc(blksize
);
417 fprintf(STDERR
, "memory allocation failed\n");
421 while ((bytesread
= rx_Read(call
, buffer
, blksize
)) > 0) {
422 for (bytesleft
= bytesread
; bytesleft
; bytesleft
-= w
) {
423 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
426 FD_SET((intptr_t)(ufd
->handle
), &out
);
427 /* don't timeout if write blocks */
428 #if defined(AFS_PTHREAD_ENV)
429 select(((intptr_t)(ufd
->handle
)) + 1, &out
, 0, 0, 0);
431 IOMGR_Select(((intptr_t)(ufd
->handle
)) + 1, 0, &out
, 0, 0);
435 USD_WRITE(ufd
, &buffer
[bytesread
- bytesleft
], bytesleft
, &w
);
437 fprintf(STDERR
, "File system write failed: %s\n",
438 afs_error_message(error
));
451 DumpFunction(struct rx_call
*call
, void *rock
)
453 char *filename
= (char *)rock
;
454 usd_handle_t ufd
; /* default is to stdout */
455 afs_int32 error
= 0, code
;
460 /* Open the output file */
461 if (!filename
|| !*filename
) {
462 usd_StandardOutput(&ufd
);
467 usd_Open(filename
, USD_OPEN_CREATE
| USD_OPEN_RDWR
, 0666, &ufd
);
471 code
= USD_IOCTL(ufd
, USD_IOCTL_SETSIZE
, &size
);
474 code
= USD_IOCTL(ufd
, USD_IOCTL_GETBLKSIZE
, &blksize
);
477 fprintf(STDERR
, "Could not create file '%s': %s\n", filename
,
478 afs_error_message(code
));
479 ERROR_EXIT(VOLSERBADOP
);
483 code
= ReceiveFile(ufd
, call
, blksize
);
488 /* Close the output file */
490 code
= USD_CLOSE(ufd
);
492 fprintf(STDERR
, "Could not close dump file %s\n",
493 (filename
&& *filename
) ? filename
: "STDIN");
503 DisplayFormat(volintInfo
*pntr
, afs_uint32 server
, afs_int32 part
,
504 int *totalOK
, int *totalNotOK
, int *totalBusy
, int fast
,
505 int longlist
, int disp
)
511 fprintf(STDOUT
, "%-10lu\n", (unsigned long)pntr
->volid
);
512 } else if (longlist
) {
513 if (pntr
->status
== VOK
) {
514 fprintf(STDOUT
, "%-32s ", pntr
->name
);
515 fprintf(STDOUT
, "%10lu ", (unsigned long)pntr
->volid
);
517 fprintf(STDOUT
, "RW ");
519 fprintf(STDOUT
, "RO ");
521 fprintf(STDOUT
, "BK ");
522 fprintf(STDOUT
, "%10d K ", pntr
->size
);
523 if (pntr
->inUse
== 1) {
524 fprintf(STDOUT
, "On-line");
527 fprintf(STDOUT
, "Off-line");
530 if (pntr
->needsSalvaged
== 1)
531 fprintf(STDOUT
, "**needs salvage**");
532 fprintf(STDOUT
, "\n");
533 MapPartIdIntoName(part
, pname
);
534 fprintf(STDOUT
, " %s %s \n", hostutil_GetNameByINet(server
),
536 fprintf(STDOUT
, " RWrite %10lu ROnly %10lu Backup %10lu \n",
537 (unsigned long)pntr
->parentID
,
538 (unsigned long)pntr
->cloneID
,
539 (unsigned long)pntr
->backupID
);
540 fprintf(STDOUT
, " MaxQuota %10d K \n", pntr
->maxquota
);
541 t
= pntr
->creationDate
;
542 fprintf(STDOUT
, " Creation %s",
545 fprintf(STDOUT
, " Copy %s",
548 t
= pntr
->backupDate
;
550 fprintf(STDOUT
, " Backup Never\n");
552 fprintf(STDOUT
, " Backup %s",
555 t
= pntr
->accessDate
;
557 fprintf(STDOUT
, " Last Access %s",
560 t
= pntr
->updateDate
;
562 fprintf(STDOUT
, " Last Update Never\n");
564 fprintf(STDOUT
, " Last Update %s",
567 " %d accesses in the past day (i.e., vnode references)\n",
569 } else if (pntr
->status
== VBUSY
) {
571 qPut(&busyHead
, pntr
->volid
);
573 fprintf(STDOUT
, "**** Volume %lu is busy ****\n",
574 (unsigned long)pntr
->volid
);
577 qPut(¬okHead
, pntr
->volid
);
579 fprintf(STDOUT
, "**** Could not attach volume %lu ****\n",
580 (unsigned long)pntr
->volid
);
582 fprintf(STDOUT
, "\n");
583 } else { /* default listing */
584 if (pntr
->status
== VOK
) {
585 fprintf(STDOUT
, "%-32s ", pntr
->name
);
586 fprintf(STDOUT
, "%10lu ", (unsigned long)pntr
->volid
);
588 fprintf(STDOUT
, "RW ");
590 fprintf(STDOUT
, "RO ");
592 fprintf(STDOUT
, "BK ");
593 fprintf(STDOUT
, "%10d K ", pntr
->size
);
594 if (pntr
->inUse
== 1) {
595 fprintf(STDOUT
, "On-line");
598 fprintf(STDOUT
, "Off-line");
601 if (pntr
->needsSalvaged
== 1)
602 fprintf(STDOUT
, "**needs salvage**");
603 fprintf(STDOUT
, "\n");
604 } else if (pntr
->status
== VBUSY
) {
606 qPut(&busyHead
, pntr
->volid
);
608 fprintf(STDOUT
, "**** Volume %lu is busy ****\n",
609 (unsigned long)pntr
->volid
);
612 qPut(¬okHead
, pntr
->volid
);
614 fprintf(STDOUT
, "**** Could not attach volume %lu ****\n",
615 (unsigned long)pntr
->volid
);
620 /*------------------------------------------------------------------------
621 * PRIVATE XDisplayFormat
624 * Display the contents of one extended volume info structure.
627 * a_xInfoP : Ptr to extended volume info struct to print.
628 * a_servID : Server ID to print.
629 * a_partID : Partition ID to print.
630 * a_totalOKP : Ptr to total-OK counter.
631 * a_totalNotOKP : Ptr to total-screwed counter.
632 * a_totalBusyP : Ptr to total-busy counter.
633 * a_fast : Fast listing?
634 * a_int32 : Int32 listing?
635 * a_showProblems : Show volume problems?
641 * Nothing interesting.
645 *------------------------------------------------------------------------*/
648 XDisplayFormat(volintXInfo
*a_xInfoP
, afs_uint32 a_servID
, afs_int32 a_partID
,
649 int *a_totalOKP
, int *a_totalNotOKP
, int *a_totalBusyP
,
650 int a_fast
, int a_int32
, int a_showProblems
)
651 { /*XDisplayFormat */
659 fprintf(STDOUT
, "%-10lu\n", (unsigned long)a_xInfoP
->volid
);
660 } else if (a_int32
) {
662 * Fully-detailed listing.
664 if (a_xInfoP
->status
== VOK
) {
666 * Volume's status is OK - all the fields are valid.
668 fprintf(STDOUT
, "%-32s ", a_xInfoP
->name
);
669 fprintf(STDOUT
, "%10lu ", (unsigned long)a_xInfoP
->volid
);
670 if (a_xInfoP
->type
== 0)
671 fprintf(STDOUT
, "RW ");
672 if (a_xInfoP
->type
== 1)
673 fprintf(STDOUT
, "RO ");
674 if (a_xInfoP
->type
== 2)
675 fprintf(STDOUT
, "BK ");
676 fprintf(STDOUT
, "%10d K used ", a_xInfoP
->size
);
677 fprintf(STDOUT
, "%d files ", a_xInfoP
->filecount
);
678 if (a_xInfoP
->inUse
== 1) {
679 fprintf(STDOUT
, "On-line");
682 fprintf(STDOUT
, "Off-line");
685 fprintf(STDOUT
, "\n");
686 MapPartIdIntoName(a_partID
, pname
);
687 fprintf(STDOUT
, " %s %s \n", hostutil_GetNameByINet(a_servID
),
689 fprintf(STDOUT
, " RWrite %10lu ROnly %10lu Backup %10lu \n",
690 (unsigned long)a_xInfoP
->parentID
,
691 (unsigned long)a_xInfoP
->cloneID
,
692 (unsigned long)a_xInfoP
->backupID
);
693 fprintf(STDOUT
, " MaxQuota %10d K \n", a_xInfoP
->maxquota
);
695 t
= a_xInfoP
->creationDate
;
696 fprintf(STDOUT
, " Creation %s",
699 t
= a_xInfoP
->copyDate
;
700 fprintf(STDOUT
, " Copy %s",
703 t
= a_xInfoP
->backupDate
;
705 fprintf(STDOUT
, " Backup Never\n");
707 fprintf(STDOUT
, " Backup %s",
710 t
= a_xInfoP
->accessDate
;
712 fprintf(STDOUT
, " Last Access %s",
715 t
= a_xInfoP
->updateDate
;
717 fprintf(STDOUT
, " Last Update Never\n");
719 fprintf(STDOUT
, " Last Update %s",
722 " %d accesses in the past day (i.e., vnode references)\n",
726 * Print all the read/write and authorship stats.
728 fprintf(STDOUT
, "\n Raw Read/Write Stats\n");
730 " |-------------------------------------------|\n");
732 " | Same Network | Diff Network |\n");
734 " |----------|----------|----------|----------|\n");
736 " | Total | Auth | Total | Auth |\n");
738 " |----------|----------|----------|----------|\n");
739 fprintf(STDOUT
, "Reads | %8d | %8d | %8d | %8d |\n",
740 a_xInfoP
->stat_reads
[VOLINT_STATS_SAME_NET
],
741 a_xInfoP
->stat_reads
[VOLINT_STATS_SAME_NET_AUTH
],
742 a_xInfoP
->stat_reads
[VOLINT_STATS_DIFF_NET
],
743 a_xInfoP
->stat_reads
[VOLINT_STATS_DIFF_NET_AUTH
]);
744 fprintf(STDOUT
, "Writes | %8d | %8d | %8d | %8d |\n",
745 a_xInfoP
->stat_writes
[VOLINT_STATS_SAME_NET
],
746 a_xInfoP
->stat_writes
[VOLINT_STATS_SAME_NET_AUTH
],
747 a_xInfoP
->stat_writes
[VOLINT_STATS_DIFF_NET
],
748 a_xInfoP
->stat_writes
[VOLINT_STATS_DIFF_NET_AUTH
]);
750 " |-------------------------------------------|\n\n");
753 " Writes Affecting Authorship\n");
755 " |-------------------------------------------|\n");
757 " | File Authorship | Directory Authorship|\n");
759 " |----------|----------|----------|----------|\n");
761 " | Same | Diff | Same | Diff |\n");
763 " |----------|----------|----------|----------|\n");
764 fprintf(STDOUT
, "0-60 sec | %8d | %8d | %8d | %8d |\n",
765 a_xInfoP
->stat_fileSameAuthor
[VOLINT_STATS_TIME_IDX_0
],
766 a_xInfoP
->stat_fileDiffAuthor
[VOLINT_STATS_TIME_IDX_0
],
767 a_xInfoP
->stat_dirSameAuthor
[VOLINT_STATS_TIME_IDX_0
],
768 a_xInfoP
->stat_dirDiffAuthor
[VOLINT_STATS_TIME_IDX_0
]);
769 fprintf(STDOUT
, "1-10 min | %8d | %8d | %8d | %8d |\n",
770 a_xInfoP
->stat_fileSameAuthor
[VOLINT_STATS_TIME_IDX_1
],
771 a_xInfoP
->stat_fileDiffAuthor
[VOLINT_STATS_TIME_IDX_1
],
772 a_xInfoP
->stat_dirSameAuthor
[VOLINT_STATS_TIME_IDX_1
],
773 a_xInfoP
->stat_dirDiffAuthor
[VOLINT_STATS_TIME_IDX_1
]);
774 fprintf(STDOUT
, "10min-1hr | %8d | %8d | %8d | %8d |\n",
775 a_xInfoP
->stat_fileSameAuthor
[VOLINT_STATS_TIME_IDX_2
],
776 a_xInfoP
->stat_fileDiffAuthor
[VOLINT_STATS_TIME_IDX_2
],
777 a_xInfoP
->stat_dirSameAuthor
[VOLINT_STATS_TIME_IDX_2
],
778 a_xInfoP
->stat_dirDiffAuthor
[VOLINT_STATS_TIME_IDX_2
]);
779 fprintf(STDOUT
, "1hr-1day | %8d | %8d | %8d | %8d |\n",
780 a_xInfoP
->stat_fileSameAuthor
[VOLINT_STATS_TIME_IDX_3
],
781 a_xInfoP
->stat_fileDiffAuthor
[VOLINT_STATS_TIME_IDX_3
],
782 a_xInfoP
->stat_dirSameAuthor
[VOLINT_STATS_TIME_IDX_3
],
783 a_xInfoP
->stat_dirDiffAuthor
[VOLINT_STATS_TIME_IDX_3
]);
784 fprintf(STDOUT
, "1day-1wk | %8d | %8d | %8d | %8d |\n",
785 a_xInfoP
->stat_fileSameAuthor
[VOLINT_STATS_TIME_IDX_4
],
786 a_xInfoP
->stat_fileDiffAuthor
[VOLINT_STATS_TIME_IDX_4
],
787 a_xInfoP
->stat_dirSameAuthor
[VOLINT_STATS_TIME_IDX_4
],
788 a_xInfoP
->stat_dirDiffAuthor
[VOLINT_STATS_TIME_IDX_4
]);
789 fprintf(STDOUT
, "> 1wk | %8d | %8d | %8d | %8d |\n",
790 a_xInfoP
->stat_fileSameAuthor
[VOLINT_STATS_TIME_IDX_5
],
791 a_xInfoP
->stat_fileDiffAuthor
[VOLINT_STATS_TIME_IDX_5
],
792 a_xInfoP
->stat_dirSameAuthor
[VOLINT_STATS_TIME_IDX_5
],
793 a_xInfoP
->stat_dirDiffAuthor
[VOLINT_STATS_TIME_IDX_5
]);
795 " |-------------------------------------------|\n");
796 } /*Volume status OK */
797 else if (a_xInfoP
->status
== VBUSY
) {
799 qPut(&busyHead
, a_xInfoP
->volid
);
801 fprintf(STDOUT
, "**** Volume %lu is busy ****\n",
802 (unsigned long)a_xInfoP
->volid
);
806 qPut(¬okHead
, a_xInfoP
->volid
);
808 fprintf(STDOUT
, "**** Could not attach volume %lu ****\n",
809 (unsigned long)a_xInfoP
->volid
);
810 } /*Screwed volume */
811 fprintf(STDOUT
, "\n");
817 if (a_xInfoP
->status
== VOK
) {
818 fprintf(STDOUT
, "%-32s ", a_xInfoP
->name
);
819 fprintf(STDOUT
, "%10lu ", (unsigned long)a_xInfoP
->volid
);
820 if (a_xInfoP
->type
== 0)
821 fprintf(STDOUT
, "RW ");
822 if (a_xInfoP
->type
== 1)
823 fprintf(STDOUT
, "RO ");
824 if (a_xInfoP
->type
== 2)
825 fprintf(STDOUT
, "BK ");
826 fprintf(STDOUT
, "%10d K ", a_xInfoP
->size
);
827 if (a_xInfoP
->inUse
== 1) {
828 fprintf(STDOUT
, "On-line");
831 fprintf(STDOUT
, "Off-line");
834 fprintf(STDOUT
, "\n");
836 else if (a_xInfoP
->status
== VBUSY
) {
838 qPut(&busyHead
, a_xInfoP
->volid
);
840 fprintf(STDOUT
, "**** Volume %lu is busy ****\n",
841 (unsigned long)a_xInfoP
->volid
);
845 qPut(¬okHead
, a_xInfoP
->volid
);
847 fprintf(STDOUT
, "**** Could not attach volume %lu ****\n",
848 (unsigned long)a_xInfoP
->volid
);
849 } /*Screwed volume */
850 } /*Default listing */
851 } /*XDisplayFormat */
853 /*------------------------------------------------------------------------
854 * PRIVATE XDisplayFormat2
857 * Display the formated contents of one extended volume info structure.
860 * a_xInfoP : Ptr to extended volume info struct to print.
861 * a_servID : Server ID to print.
862 * a_partID : Partition ID to print.
863 * a_totalOKP : Ptr to total-OK counter.
864 * a_totalNotOKP : Ptr to total-screwed counter.
865 * a_totalBusyP : Ptr to total-busy counter.
866 * a_fast : Fast listing?
867 * a_int32 : Int32 listing?
868 * a_showProblems : Show volume problems?
874 * Nothing interesting.
878 *------------------------------------------------------------------------*/
881 XDisplayFormat2(volintXInfo
*a_xInfoP
, afs_uint32 a_servID
, afs_int32 a_partID
,
882 int *a_totalOKP
, int *a_totalNotOKP
, int *a_totalBusyP
,
883 int a_fast
, int a_int32
, int a_showProblems
)
884 { /*XDisplayFormat */
890 fprintf(STDOUT
, "vold_id\t%-10lu\n", (unsigned long)a_xInfoP
->volid
);
891 } else if (a_int32
) {
893 * Fully-detailed listing.
895 if (a_xInfoP
->status
== VOK
) {
897 * Volume's status is OK - all the fields are valid.
900 static long server_cache
= -1, partition_cache
= -1;
901 static char hostname
[256], address
[32], pname
[16];
902 int i
,ai
[] = {VOLINT_STATS_TIME_IDX_0
,VOLINT_STATS_TIME_IDX_1
,VOLINT_STATS_TIME_IDX_2
,
903 VOLINT_STATS_TIME_IDX_3
,VOLINT_STATS_TIME_IDX_4
,VOLINT_STATS_TIME_IDX_5
};
905 if (a_servID
!= server_cache
) {
909 strcpy(hostname
, hostutil_GetNameByINet(a_servID
));
910 strcpy(address
, inet_ntoa(s
));
911 server_cache
= a_servID
;
913 if (a_partID
!= partition_cache
) {
914 MapPartIdIntoName(a_partID
, pname
);
915 partition_cache
= a_partID
;
918 fprintf(STDOUT
, "name\t\t%s\n", a_xInfoP
->name
);
919 fprintf(STDOUT
, "id\t\t%lu\n", afs_printable_uint32_lu(a_xInfoP
->volid
));
920 fprintf(STDOUT
, "serv\t\t%s\t%s\n", address
, hostname
);
921 fprintf(STDOUT
, "part\t\t%s\n", pname
);
922 fprintf(STDOUT
, "status\t\tOK\n");
923 fprintf(STDOUT
, "backupID\t%lu\n",
924 afs_printable_uint32_lu(a_xInfoP
->backupID
));
925 fprintf(STDOUT
, "parentID\t%lu\n",
926 afs_printable_uint32_lu(a_xInfoP
->parentID
));
927 fprintf(STDOUT
, "cloneID\t\t%lu\n",
928 afs_printable_uint32_lu(a_xInfoP
->cloneID
));
929 fprintf(STDOUT
, "inUse\t\t%s\n", a_xInfoP
->inUse
? "Y" : "N");
930 switch (a_xInfoP
->type
) {
932 fprintf(STDOUT
, "type\t\tRW\n");
935 fprintf(STDOUT
, "type\t\tRO\n");
938 fprintf(STDOUT
, "type\t\tBK\n");
941 fprintf(STDOUT
, "type\t\t?\n");
944 t
= a_xInfoP
->creationDate
;
945 fprintf(STDOUT
, "creationDate\t%-9lu\t%s",
946 afs_printable_uint32_lu(a_xInfoP
->creationDate
),
949 t
= a_xInfoP
->accessDate
;
950 fprintf(STDOUT
, "accessDate\t%-9lu\t%s",
951 afs_printable_uint32_lu(a_xInfoP
->accessDate
),
954 t
= a_xInfoP
->updateDate
;
955 fprintf(STDOUT
, "updateDate\t%-9lu\t%s",
956 afs_printable_uint32_lu(a_xInfoP
->updateDate
),
959 t
= a_xInfoP
->backupDate
;
960 fprintf(STDOUT
, "backupDate\t%-9lu\t%s",
961 afs_printable_uint32_lu(a_xInfoP
->backupDate
),
964 t
= a_xInfoP
->copyDate
;
965 fprintf(STDOUT
, "copyDate\t%-9lu\t%s",
966 afs_printable_uint32_lu(a_xInfoP
->copyDate
),
969 fprintf(STDOUT
, "diskused\t%u\n", a_xInfoP
->size
);
970 fprintf(STDOUT
, "maxquota\t%u\n", a_xInfoP
->maxquota
);
972 fprintf(STDOUT
, "filecount\t%u\n", a_xInfoP
->filecount
);
973 fprintf(STDOUT
, "dayUse\t\t%u\n", a_xInfoP
->dayUse
);
977 fprintf(STDOUT
,"reads_same_net\t%8d\n",a_xInfoP
->stat_reads
[VOLINT_STATS_SAME_NET
]);
978 fprintf(STDOUT
,"reads_same_net_auth\t%8d\n",a_xInfoP
->stat_reads
[VOLINT_STATS_SAME_NET_AUTH
]);
979 fprintf(STDOUT
,"reads_diff_net\t%8d\n",a_xInfoP
->stat_reads
[VOLINT_STATS_DIFF_NET
]);
980 fprintf(STDOUT
,"reads_diff_net_auth\t%8d\n",a_xInfoP
->stat_reads
[VOLINT_STATS_DIFF_NET_AUTH
]);
982 fprintf(STDOUT
,"writes_same_net\t%8d\n",a_xInfoP
->stat_writes
[VOLINT_STATS_SAME_NET
]);
983 fprintf(STDOUT
,"writes_same_net_auth\t%8d\n",a_xInfoP
->stat_writes
[VOLINT_STATS_SAME_NET_AUTH
]);
984 fprintf(STDOUT
,"writes_diff_net\t%8d\n",a_xInfoP
->stat_writes
[VOLINT_STATS_DIFF_NET
]);
985 fprintf(STDOUT
,"writes_diff_net_auth\t%8d\n",a_xInfoP
->stat_writes
[VOLINT_STATS_DIFF_NET_AUTH
]);
989 fprintf(STDOUT
,"file_same_author_idx_%d\t%8d\n",i
+1,a_xInfoP
->stat_fileSameAuthor
[ai
[i
]]);
990 fprintf(STDOUT
,"file_diff_author_idx_%d\t%8d\n",i
+1,a_xInfoP
->stat_fileDiffAuthor
[ai
[i
]]);
991 fprintf(STDOUT
,"dir_same_author_idx_%d\t%8d\n",i
+1,a_xInfoP
->stat_dirSameAuthor
[ai
[i
]]);
992 fprintf(STDOUT
,"dir_dif_author_idx_%d\t%8d\n",i
+1,a_xInfoP
->stat_dirDiffAuthor
[ai
[i
]]);
995 } /*Volume status OK */
996 else if (a_xInfoP
->status
== VBUSY
) {
998 qPut(&busyHead
, a_xInfoP
->volid
);
1000 fprintf(STDOUT
, "BUSY_VOL\t%lu\n",
1001 (unsigned long)a_xInfoP
->volid
);
1005 qPut(¬okHead
, a_xInfoP
->volid
);
1007 fprintf(STDOUT
, "COULD_NOT_ATTACH\t%lu\n",
1008 (unsigned long)a_xInfoP
->volid
);
1009 } /*Screwed volume */
1015 if (a_xInfoP
->status
== VOK
) {
1016 fprintf(STDOUT
, "name\t%-32s\n", a_xInfoP
->name
);
1017 fprintf(STDOUT
, "volID\t%10lu\n", (unsigned long)a_xInfoP
->volid
);
1018 if (a_xInfoP
->type
== 0)
1019 fprintf(STDOUT
, "type\tRW\n");
1020 if (a_xInfoP
->type
== 1)
1021 fprintf(STDOUT
, "type\tRO\n");
1022 if (a_xInfoP
->type
== 2)
1023 fprintf(STDOUT
, "type\tBK\n");
1024 fprintf(STDOUT
, "size\t%10dK\n", a_xInfoP
->size
);
1026 fprintf(STDOUT
, "inUse\t%d\n",a_xInfoP
->inUse
);
1027 if (a_xInfoP
->inUse
== 1)
1033 else if (a_xInfoP
->status
== VBUSY
) {
1035 qPut(&busyHead
, a_xInfoP
->volid
);
1037 fprintf(STDOUT
, "VOLUME_BUSY\t%lu\n",
1038 (unsigned long)a_xInfoP
->volid
);
1042 qPut(¬okHead
, a_xInfoP
->volid
);
1044 fprintf(STDOUT
, "COULD_NOT_ATTACH_VOLUME\t%lu\n",
1045 (unsigned long)a_xInfoP
->volid
);
1046 } /*Screwed volume */
1047 } /*Default listing */
1048 } /*XDisplayFormat */
1051 DisplayFormat2(long server
, long partition
, volintInfo
*pntr
)
1053 static long server_cache
= -1, partition_cache
= -1;
1054 static char hostname
[256], address
[32], pname
[16];
1057 if (server
!= server_cache
) {
1061 strcpy(hostname
, hostutil_GetNameByINet(server
));
1062 strcpy(address
, inet_ntoa(s
));
1063 server_cache
= server
;
1065 if (partition
!= partition_cache
) {
1066 MapPartIdIntoName(partition
, pname
);
1067 partition_cache
= partition
;
1070 if (pntr
->status
== VOK
)
1071 fprintf(STDOUT
, "name\t\t%s\n", pntr
->name
);
1073 fprintf(STDOUT
, "id\t\t%lu\n",
1074 afs_printable_uint32_lu(pntr
->volid
));
1075 fprintf(STDOUT
, "serv\t\t%s\t%s\n", address
, hostname
);
1076 fprintf(STDOUT
, "part\t\t%s\n", pname
);
1077 switch (pntr
->status
) {
1079 fprintf(STDOUT
, "status\t\tOK\n");
1082 fprintf(STDOUT
, "status\t\tBUSY\n");
1085 fprintf(STDOUT
, "status\t\tUNATTACHABLE\n");
1088 fprintf(STDOUT
, "backupID\t%lu\n",
1089 afs_printable_uint32_lu(pntr
->backupID
));
1090 fprintf(STDOUT
, "parentID\t%lu\n",
1091 afs_printable_uint32_lu(pntr
->parentID
));
1092 fprintf(STDOUT
, "cloneID\t\t%lu\n",
1093 afs_printable_uint32_lu(pntr
->cloneID
));
1094 fprintf(STDOUT
, "inUse\t\t%s\n", pntr
->inUse
? "Y" : "N");
1095 fprintf(STDOUT
, "needsSalvaged\t%s\n", pntr
->needsSalvaged
? "Y" : "N");
1096 /* 0xD3 is from afs/volume.h since I had trouble including the file */
1097 fprintf(STDOUT
, "destroyMe\t%s\n", pntr
->destroyMe
== 0xD3 ? "Y" : "N");
1098 switch (pntr
->type
) {
1100 fprintf(STDOUT
, "type\t\tRW\n");
1103 fprintf(STDOUT
, "type\t\tRO\n");
1106 fprintf(STDOUT
, "type\t\tBK\n");
1109 fprintf(STDOUT
, "type\t\t?\n");
1112 t
= pntr
->creationDate
;
1113 fprintf(STDOUT
, "creationDate\t%-9lu\t%s",
1114 afs_printable_uint32_lu(pntr
->creationDate
),
1117 t
= pntr
->accessDate
;
1118 fprintf(STDOUT
, "accessDate\t%-9lu\t%s",
1119 afs_printable_uint32_lu(pntr
->accessDate
),
1122 t
= pntr
->updateDate
;
1123 fprintf(STDOUT
, "updateDate\t%-9lu\t%s",
1124 afs_printable_uint32_lu(pntr
->updateDate
),
1127 t
= pntr
->backupDate
;
1128 fprintf(STDOUT
, "backupDate\t%-9lu\t%s",
1129 afs_printable_uint32_lu(pntr
->backupDate
),
1133 fprintf(STDOUT
, "copyDate\t%-9lu\t%s",
1134 afs_printable_uint32_lu(pntr
->copyDate
),
1137 fprintf(STDOUT
, "flags\t\t%#lx\t(Optional)\n",
1138 afs_printable_uint32_lu(pntr
->flags
));
1139 fprintf(STDOUT
, "diskused\t%u\n", pntr
->size
);
1140 fprintf(STDOUT
, "maxquota\t%u\n", pntr
->maxquota
);
1141 fprintf(STDOUT
, "minquota\t%lu\t(Optional)\n",
1142 afs_printable_uint32_lu(pntr
->spare0
));
1143 fprintf(STDOUT
, "filecount\t%u\n", pntr
->filecount
);
1144 fprintf(STDOUT
, "dayUse\t\t%u\n", pntr
->dayUse
);
1145 fprintf(STDOUT
, "weekUse\t\t%lu\t(Optional)\n",
1146 afs_printable_uint32_lu(pntr
->spare1
));
1147 fprintf(STDOUT
, "spare2\t\t%lu\t(Optional)\n",
1148 afs_printable_uint32_lu(pntr
->spare2
));
1149 fprintf(STDOUT
, "spare3\t\t%lu\t(Optional)\n",
1150 afs_printable_uint32_lu(pntr
->spare3
));
1155 DisplayVolumes2(long server
, long partition
, volintInfo
*pntr
, long count
)
1159 for (i
= 0; i
< count
; i
++) {
1160 fprintf(STDOUT
, "BEGIN_OF_ENTRY\n");
1161 DisplayFormat2(server
, partition
, pntr
);
1162 fprintf(STDOUT
, "END_OF_ENTRY\n\n");
1169 DisplayVolumes(afs_uint32 server
, afs_int32 part
, volintInfo
*pntr
,
1170 afs_int32 count
, afs_int32 longlist
, afs_int32 fast
,
1173 int totalOK
, totalNotOK
, totalBusy
, i
;
1174 afs_uint32 volid
= 0;
1181 for (i
= 0; i
< count
; i
++) {
1182 DisplayFormat(pntr
, server
, part
, &totalOK
, &totalNotOK
, &totalBusy
,
1187 while (busyHead
.count
) {
1188 qGet(&busyHead
, &volid
);
1189 fprintf(STDOUT
, "**** Volume %lu is busy ****\n",
1190 (unsigned long)volid
);
1194 while (notokHead
.count
) {
1195 qGet(¬okHead
, &volid
);
1196 fprintf(STDOUT
, "**** Could not attach volume %lu ****\n",
1197 (unsigned long)volid
);
1201 fprintf(STDOUT
, "\n");
1204 "Total volumes onLine %d ; Total volumes offLine %d ; Total busy %d\n\n",
1205 totalOK
, totalNotOK
, totalBusy
);
1209 /*------------------------------------------------------------------------
1210 * PRIVATE XDisplayVolumes
1213 * Display extended volume information.
1216 * a_servID : Pointer to the Rx call we're performing.
1217 * a_partID : Partition for which we want the extended list.
1218 * a_xInfoP : Ptr to extended volume info.
1219 * a_count : Number of volume records contained above.
1220 * a_int32 : Int32 listing generated?
1221 * a_fast : Fast listing generated?
1222 * a_quiet : Quiet listing generated?
1228 * Nothing interesting.
1232 *------------------------------------------------------------------------*/
1235 XDisplayVolumes(afs_uint32 a_servID
, afs_int32 a_partID
, volintXInfo
*a_xInfoP
,
1236 afs_int32 a_count
, afs_int32 a_int32
, afs_int32 a_fast
,
1238 { /*XDisplayVolumes */
1240 int totalOK
; /*Total OK volumes */
1241 int totalNotOK
; /*Total screwed volumes */
1242 int totalBusy
; /*Total busy volumes */
1243 int i
; /*Loop variable */
1244 afs_uint32 volid
= 0; /*Current volume ID */
1247 * Initialize counters and (global!!) queues.
1256 * Display each volume in the list.
1258 for (i
= 0; i
< a_count
; i
++) {
1259 XDisplayFormat(a_xInfoP
, a_servID
, a_partID
, &totalOK
, &totalNotOK
,
1260 &totalBusy
, a_fast
, a_int32
, 0);
1265 * If any volumes were found to be busy or screwed, display them.
1268 while (busyHead
.count
) {
1269 qGet(&busyHead
, &volid
);
1270 fprintf(STDOUT
, "**** Volume %lu is busy ****\n",
1271 (unsigned long)volid
);
1275 while (notokHead
.count
) {
1276 qGet(¬okHead
, &volid
);
1277 fprintf(STDOUT
, "**** Could not attach volume %lu ****\n",
1278 (unsigned long)volid
);
1283 fprintf(STDOUT
, "\n");
1286 "Total volumes: %d on-line, %d off-line, %d busyd\n\n",
1287 totalOK
, totalNotOK
, totalBusy
);
1291 } /*XDisplayVolumes */
1293 /*------------------------------------------------------------------------
1294 * PRIVATE XDisplayVolumes2
1297 * Display extended formated volume information.
1300 * a_servID : Pointer to the Rx call we're performing.
1301 * a_partID : Partition for which we want the extended list.
1302 * a_xInfoP : Ptr to extended volume info.
1303 * a_count : Number of volume records contained above.
1304 * a_int32 : Int32 listing generated?
1305 * a_fast : Fast listing generated?
1306 * a_quiet : Quiet listing generated?
1312 * Nothing interesting.
1316 *------------------------------------------------------------------------*/
1319 XDisplayVolumes2(afs_uint32 a_servID
, afs_int32 a_partID
, volintXInfo
*a_xInfoP
,
1320 afs_int32 a_count
, afs_int32 a_int32
, afs_int32 a_fast
,
1322 { /*XDisplayVolumes */
1324 int totalOK
; /*Total OK volumes */
1325 int totalNotOK
; /*Total screwed volumes */
1326 int totalBusy
; /*Total busy volumes */
1327 int i
; /*Loop variable */
1328 afs_uint32 volid
= 0; /*Current volume ID */
1331 * Initialize counters and (global!!) queues.
1340 * Display each volume in the list.
1342 for (i
= 0; i
< a_count
; i
++) {
1343 fprintf(STDOUT
, "BEGIN_OF_ENTRY\n");
1344 XDisplayFormat2(a_xInfoP
, a_servID
, a_partID
, &totalOK
, &totalNotOK
,
1345 &totalBusy
, a_fast
, a_int32
, 0);
1346 fprintf(STDOUT
, "END_OF_ENTRY\n");
1351 * If any volumes were found to be busy or screwed, display them.
1354 while (busyHead
.count
) {
1355 qGet(&busyHead
, &volid
);
1356 fprintf(STDOUT
, "BUSY_VOL\t%lu\n",
1357 (unsigned long)volid
);
1361 while (notokHead
.count
) {
1362 qGet(¬okHead
, &volid
);
1363 fprintf(STDOUT
, "COULD_NOT_ATTACH\t%lu\n",
1364 (unsigned long)volid
);
1369 fprintf(STDOUT
, "\n");
1372 "VOLUMES_ONLINE\t%d\nVOLUMES_OFFLINE\t%d\nVOLUMES_BUSY\t%d\n",
1373 totalOK
, totalNotOK
, totalBusy
);
1377 } /*XDisplayVolumes2 */
1380 /* set <server> and <part> to the correct values depending on
1381 * <voltype> and <entry> */
1383 GetServerAndPart(struct nvldbentry
*entry
, int voltype
, afs_uint32
*server
,
1384 afs_int32
*part
, int *previdx
)
1386 int i
, istart
, vtype
;
1391 /* Doesn't check for non-existance of backup volume */
1392 if ((voltype
== RWVOL
) || (voltype
== BACKVOL
)) {
1394 istart
= 0; /* seach the entire entry */
1397 /* Seach from beginning of entry or pick up where we left off */
1398 istart
= ((*previdx
< 0) ? 0 : *previdx
+ 1);
1401 for (i
= istart
; i
< entry
->nServers
; i
++) {
1402 if (entry
->serverFlags
[i
] & vtype
) {
1403 *server
= entry
->serverNumber
[i
];
1404 *part
= entry
->serverPartition
[i
];
1410 /* Didn't find any, return -1 */
1416 PrintLocked(afs_int32 aflags
)
1418 afs_int32 flags
= aflags
& VLOP_ALLOPERS
;
1421 fprintf(STDOUT
, " Volume is currently LOCKED \n");
1423 if (flags
& VLOP_MOVE
) {
1424 fprintf(STDOUT
, " Volume is locked for a move operation\n");
1426 if (flags
& VLOP_RELEASE
) {
1427 fprintf(STDOUT
, " Volume is locked for a release operation\n");
1429 if (flags
& VLOP_BACKUP
) {
1430 fprintf(STDOUT
, " Volume is locked for a backup operation\n");
1432 if (flags
& VLOP_DELETE
) {
1433 fprintf(STDOUT
, " Volume is locked for a delete/misc operation\n");
1435 if (flags
& VLOP_DUMP
) {
1436 fprintf(STDOUT
, " Volume is locked for a dump/restore operation\n");
1442 PostVolumeStats(struct nvldbentry
*entry
)
1444 SubEnumerateEntry(entry
);
1445 /* Check for VLOP_ALLOPERS */
1446 PrintLocked(entry
->flags
);
1450 /*------------------------------------------------------------------------
1451 * PRIVATE XVolumeStats
1454 * Display extended volume information.
1457 * a_xInfoP : Ptr to extended volume info.
1458 * a_entryP : Ptr to the volume's VLDB entry.
1459 * a_srvID : Server ID.
1460 * a_partID : Partition ID.
1461 * a_volType : Type of volume to print.
1467 * Nothing interesting.
1471 *------------------------------------------------------------------------*/
1474 XVolumeStats(volintXInfo
*a_xInfoP
, struct nvldbentry
*a_entryP
,
1475 afs_int32 a_srvID
, afs_int32 a_partID
, int a_volType
)
1478 int totalOK
, totalNotOK
, totalBusy
; /*Dummies - we don't really count here */
1480 XDisplayFormat(a_xInfoP
, /*Ptr to extended volume info */
1481 a_srvID
, /*Server ID to print */
1482 a_partID
, /*Partition ID to print */
1483 &totalOK
, /*Ptr to total-OK counter */
1484 &totalNotOK
, /*Ptr to total-screwed counter */
1485 &totalBusy
, /*Ptr to total-busy counter */
1486 0, /*Don't do a fast listing */
1487 1, /*Do a long listing */
1488 1); /*Show volume problems */
1494 VolumeStats_int(volintInfo
*pntr
, struct nvldbentry
*entry
, afs_uint32 server
,
1495 afs_int32 part
, int voltype
)
1497 int totalOK
, totalNotOK
, totalBusy
;
1499 DisplayFormat(pntr
, server
, part
, &totalOK
, &totalNotOK
, &totalBusy
, 0, 1,
1504 /* command to forcibly remove a volume */
1506 NukeVolume(struct cmd_syndesc
*as
)
1515 server
= GetServer(tp
= as
->parms
[0].items
->data
);
1517 fprintf(STDERR
, "vos: server '%s' not found in host table\n", tp
);
1521 partID
= volutil_GetPartitionID(tp
= as
->parms
[1].items
->data
);
1523 fprintf(STDERR
, "vos: could not parse '%s' as a partition name", tp
);
1527 volID
= vsu_GetVolumeID(tp
= as
->parms
[2].items
->data
, cstruct
, &err
);
1530 PrintError("", err
);
1533 "vos: could not parse '%s' as a numeric volume ID", tp
);
1538 "vos: forcibly removing all traces of volume %d, please wait...",
1541 code
= UV_NukeVolume(server
, partID
, volID
);
1543 fprintf(STDOUT
, "done.\n");
1545 fprintf(STDOUT
, "failed with code %d.\n", code
);
1550 /*------------------------------------------------------------------------
1551 * PRIVATE ExamineVolume
1554 * Routine used to examine a single volume, contacting the VLDB as
1555 * well as the Volume Server.
1558 * as : Ptr to parsed command line arguments.
1561 * 0 for a successful operation,
1562 * Otherwise, one of the ubik or VolServer error values.
1565 * Nothing interesting.
1569 *------------------------------------------------------------------------
1572 ExamineVolume(struct cmd_syndesc
*as
, void *arock
)
1574 struct nvldbentry entry
;
1575 afs_int32 vcode
= 0;
1576 volintInfo
*pntr
= (volintInfo
*) 0;
1577 volintXInfo
*xInfoP
= (volintXInfo
*) 0;
1579 afs_int32 code
, err
, error
= 0;
1580 int voltype
, foundserv
= 0, foundentry
= 0;
1584 int wantExtendedInfo
; /*Do we want extended vol info? */
1585 int isSubEnum
=0; /* Keep track whether sub enumerate called. */
1586 wantExtendedInfo
= (as
->parms
[1].items
? 1 : 0); /* -extended */
1588 volid
= vsu_GetVolumeID(as
->parms
[0].items
->data
, cstruct
, &err
); /* -id */
1591 PrintError("", err
);
1593 fprintf(STDERR
, "Unknown volume ID or name '%s'\n",
1594 as
->parms
[0].items
->data
);
1599 fprintf(STDOUT
, "Fetching VLDB entry for %lu .. ",
1600 (unsigned long)volid
);
1603 vcode
= VLDB_GetEntryByID(volid
, -1, &entry
);
1606 "Could not fetch the entry for volume number %lu from VLDB \n",
1607 (unsigned long)volid
);
1611 fprintf(STDOUT
, "done\n");
1612 MapHostToNetwork(&entry
);
1614 if (entry
.volumeId
[RWVOL
] == volid
)
1616 else if (entry
.volumeId
[BACKVOL
] == volid
)
1618 else /* (entry.volumeId[ROVOL] == volid) */
1621 do { /* do {...} while (voltype == ROVOL) */
1622 /* Get the entry for the volume. If its a RW vol, get the RW entry.
1623 * It its a BK vol, get the RW entry (even if VLDB may say the BK doen't exist).
1624 * If its a RO vol, get the next RO entry.
1626 GetServerAndPart(&entry
, ((voltype
== ROVOL
) ? ROVOL
: RWVOL
),
1627 &aserver
, &apart
, &previdx
);
1628 if (previdx
== -1) { /* searched all entries */
1630 fprintf(STDERR
, "Volume %s does not exist in VLDB\n\n",
1631 as
->parms
[0].items
->data
);
1638 /* Get information about the volume from the server */
1640 fprintf(STDOUT
, "Getting volume listing from the server %s .. ",
1641 hostutil_GetNameByINet(aserver
));
1644 if (wantExtendedInfo
)
1645 code
= UV_XListOneVolume(aserver
, apart
, volid
, &xInfoP
);
1647 code
= UV_ListOneVolume(aserver
, apart
, volid
, &pntr
);
1649 fprintf(STDOUT
, "done\n");
1653 if (code
== ENODEV
) {
1654 if ((voltype
== BACKVOL
) && !(entry
.flags
& BACK_EXISTS
)) {
1655 /* The VLDB says there is no backup volume and its not on disk */
1656 fprintf(STDERR
, "Volume %s does not exist\n",
1657 as
->parms
[0].items
->data
);
1661 "Volume does not exist on server %s as indicated by the VLDB\n",
1662 hostutil_GetNameByINet(aserver
));
1665 PrintDiagnostics("examine", code
);
1667 fprintf(STDOUT
, "\n");
1670 if (wantExtendedInfo
)
1671 XVolumeStats(xInfoP
, &entry
, aserver
, apart
, voltype
);
1672 else if (as
->parms
[2].items
) {
1673 DisplayFormat2(aserver
, apart
, pntr
);
1674 EnumerateEntry(&entry
);
1677 VolumeStats_int(pntr
, &entry
, aserver
, apart
, voltype
);
1679 if ((voltype
== BACKVOL
) && !(entry
.flags
& BACK_EXISTS
)) {
1680 /* The VLDB says there is no backup volume yet we found one on disk */
1681 fprintf(STDERR
, "Volume %s does not exist in VLDB\n",
1682 as
->parms
[0].items
->data
);
1691 } while (voltype
== ROVOL
);
1694 fprintf(STDERR
, "Dump only information from VLDB\n\n");
1695 fprintf(STDOUT
, "%s \n", entry
.name
); /* PostVolumeStats doesn't print name */
1699 PostVolumeStats(&entry
);
1704 /*------------------------------------------------------------------------
1708 * Routine used to change the status of a single volume.
1711 * as : Ptr to parsed command line arguments.
1714 * 0 for a successful operation,
1715 * Otherwise, one of the ubik or VolServer error values.
1718 * Nothing interesting.
1722 *------------------------------------------------------------------------
1725 SetFields(struct cmd_syndesc
*as
, void *arock
)
1727 struct nvldbentry entry
;
1730 afs_int32 code
, err
;
1735 volid
= vsu_GetVolumeID(as
->parms
[0].items
->data
, cstruct
, &err
); /* -id */
1738 PrintError("", err
);
1740 fprintf(STDERR
, "Unknown volume ID or name '%s'\n",
1741 as
->parms
[0].items
->data
);
1745 code
= VLDB_GetEntryByID(volid
, RWVOL
, &entry
);
1748 "Could not fetch the entry for volume number %lu from VLDB \n",
1749 (unsigned long)volid
);
1752 MapHostToNetwork(&entry
);
1754 GetServerAndPart(&entry
, RWVOL
, &aserver
, &apart
, &previdx
);
1755 if (previdx
== -1) {
1756 fprintf(STDERR
, "Volume %s does not exist in VLDB\n\n",
1757 as
->parms
[0].items
->data
);
1761 init_volintInfo(&info
);
1765 if (as
->parms
[1].items
) {
1767 code
= util_GetHumanInt32(as
->parms
[1].items
->data
, &info
.maxquota
);
1769 fprintf(STDERR
, "invalid quota value\n");
1773 if (as
->parms
[2].items
) {
1777 if (as
->parms
[3].items
) {
1778 /* -clearVolUpCounter */
1781 code
= UV_SetVolumeInfo(aserver
, apart
, volid
, &info
);
1784 "Could not update volume info fields for volume number %lu\n",
1785 (unsigned long)volid
);
1789 /*------------------------------------------------------------------------
1793 * Brings a volume online.
1796 * as : Ptr to parsed command line arguments.
1799 * 0 for a successful operation,
1802 * Nothing interesting.
1806 *------------------------------------------------------------------------
1809 volOnline(struct cmd_syndesc
*as
, void *arock
)
1812 afs_int32 partition
;
1814 afs_int32 code
, err
= 0;
1816 server
= GetServer(as
->parms
[0].items
->data
);
1818 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
1819 as
->parms
[0].items
->data
);
1823 partition
= volutil_GetPartitionID(as
->parms
[1].items
->data
);
1824 if (partition
< 0) {
1825 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
1826 as
->parms
[1].items
->data
);
1830 volid
= vsu_GetVolumeID(as
->parms
[2].items
->data
, cstruct
, &err
); /* -id */
1833 PrintError("", err
);
1835 fprintf(STDERR
, "Unknown volume ID or name '%s'\n",
1836 as
->parms
[0].items
->data
);
1840 code
= UV_SetVolume(server
, partition
, volid
, ITOffline
, 0 /*online */ ,
1843 fprintf(STDERR
, "Failed to set volume. Code = %d\n", code
);
1850 /*------------------------------------------------------------------------
1851 * PRIVATE volOffline
1854 * Brings a volume offline.
1857 * as : Ptr to parsed command line arguments.
1860 * 0 for a successful operation,
1863 * Nothing interesting.
1867 *------------------------------------------------------------------------
1870 volOffline(struct cmd_syndesc
*as
, void *arock
)
1873 afs_int32 partition
;
1875 afs_int32 code
, err
= 0;
1876 afs_int32 transflag
, sleeptime
, transdone
;
1878 server
= GetServer(as
->parms
[0].items
->data
);
1880 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
1881 as
->parms
[0].items
->data
);
1885 partition
= volutil_GetPartitionID(as
->parms
[1].items
->data
);
1886 if (partition
< 0) {
1887 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
1888 as
->parms
[1].items
->data
);
1892 volid
= vsu_GetVolumeID(as
->parms
[2].items
->data
, cstruct
, &err
); /* -id */
1895 PrintError("", err
);
1897 fprintf(STDERR
, "Unknown volume ID or name '%s'\n",
1898 as
->parms
[0].items
->data
);
1902 transflag
= (as
->parms
[4].items
? ITBusy
: ITOffline
);
1903 sleeptime
= (as
->parms
[3].items
? atol(as
->parms
[3].items
->data
) : 0);
1904 transdone
= ((sleeptime
|| as
->parms
[4].items
) ? 0 /*online */ : VTOutOfService
);
1905 if (as
->parms
[4].items
&& !as
->parms
[3].items
) {
1906 fprintf(STDERR
, "-sleep option must be used with -busy flag\n");
1911 UV_SetVolume(server
, partition
, volid
, transflag
, transdone
,
1914 fprintf(STDERR
, "Failed to set volume. Code = %d\n", code
);
1922 CreateVolume(struct cmd_syndesc
*as
, void *arock
)
1926 afs_uint32 volid
= 0, rovolid
= 0, bkvolid
= 0;
1927 afs_uint32
*arovolid
;
1929 struct nvldbentry entry
;
1933 arovolid
= &rovolid
;
1936 tserver
= GetServer(as
->parms
[0].items
->data
);
1938 fprintf(STDERR
, "vos: host '%s' not found in host table\n",
1939 as
->parms
[0].items
->data
);
1942 pnum
= volutil_GetPartitionID(as
->parms
[1].items
->data
);
1944 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
1945 as
->parms
[1].items
->data
);
1948 if (!IsPartValid(pnum
, tserver
, &code
)) { /*check for validity of the partition */
1950 PrintError("", code
);
1953 "vos : partition %s does not exist on the server\n",
1954 as
->parms
[1].items
->data
);
1957 if (!ISNAMEVALID(as
->parms
[2].items
->data
)) {
1959 "vos: the name of the root volume %s exceeds the size limit of %d\n",
1960 as
->parms
[2].items
->data
, VOLSER_OLDMAXVOLNAME
- 10);
1963 if (!VolNameOK(as
->parms
[2].items
->data
)) {
1965 "Illegal volume name %s, should not end in .readonly or .backup\n",
1966 as
->parms
[2].items
->data
);
1969 if (IsNumeric(as
->parms
[2].items
->data
)) {
1970 fprintf(STDERR
, "Illegal volume name %s, should not be a number\n",
1971 as
->parms
[2].items
->data
);
1974 vcode
= VLDB_GetEntryByName(as
->parms
[2].items
->data
, &entry
);
1976 fprintf(STDERR
, "Volume %s already exists\n",
1977 as
->parms
[2].items
->data
);
1978 PrintDiagnostics("create", code
);
1982 if (as
->parms
[3].items
) {
1983 code
= util_GetHumanInt32(as
->parms
[3].items
->data
, "a
);
1985 fprintf(STDERR
, "vos: bad integer specified for quota.\n");
1990 if (as
->parms
[4].items
) {
1991 if (!IsNumeric(as
->parms
[4].items
->data
)) {
1992 fprintf(STDERR
, "vos: Given volume ID %s should be numeric.\n",
1993 as
->parms
[4].items
->data
);
1997 code
= util_GetUInt32(as
->parms
[4].items
->data
, &volid
);
1999 fprintf(STDERR
, "vos: bad integer specified for volume ID.\n");
2004 if (as
->parms
[5].items
) {
2005 if (!IsNumeric(as
->parms
[5].items
->data
)) {
2006 fprintf(STDERR
, "vos: Given RO volume ID %s should be numeric.\n",
2007 as
->parms
[5].items
->data
);
2011 code
= util_GetUInt32(as
->parms
[5].items
->data
, &rovolid
);
2013 fprintf(STDERR
, "vos: bad integer specified for volume ID.\n");
2023 UV_CreateVolume3(tserver
, pnum
, as
->parms
[2].items
->data
, quota
, 0,
2024 0, 0, 0, &volid
, arovolid
, &bkvolid
);
2026 PrintDiagnostics("create", code
);
2029 MapPartIdIntoName(pnum
, part
);
2030 fprintf(STDOUT
, "Volume %lu created on partition %s of %s\n",
2031 (unsigned long)volid
, part
, as
->parms
[0].items
->data
);
2038 DeleteAll(struct nvldbentry
*entry
)
2041 afs_int32 error
, code
, curserver
, curpart
;
2044 MapHostToNetwork(entry
);
2046 for (i
= 0; i
< entry
->nServers
; i
++) {
2047 curserver
= entry
->serverNumber
[i
];
2048 curpart
= entry
->serverPartition
[i
];
2049 if (entry
->serverFlags
[i
] & ITSROVOL
) {
2050 volid
= entry
->volumeId
[ROVOL
];
2052 volid
= entry
->volumeId
[RWVOL
];
2054 code
= UV_DeleteVolume(curserver
, curpart
, volid
);
2063 DeleteVolume(struct cmd_syndesc
*as
, void *arock
)
2065 afs_int32 err
, code
= 0;
2066 afs_uint32 server
= 0;
2067 afs_int32 partition
= -1;
2072 if (as
->parms
[0].items
) {
2073 server
= GetServer(as
->parms
[0].items
->data
);
2075 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
2076 as
->parms
[0].items
->data
);
2081 if (as
->parms
[1].items
) {
2082 partition
= volutil_GetPartitionID(as
->parms
[1].items
->data
);
2083 if (partition
< 0) {
2084 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
2085 as
->parms
[1].items
->data
);
2089 /* Check for validity of the partition */
2090 if (!IsPartValid(partition
, server
, &code
)) {
2092 PrintError("", code
);
2095 "vos : partition %s does not exist on the server\n",
2096 as
->parms
[1].items
->data
);
2102 volid
= vsu_GetVolumeID(as
->parms
[2].items
->data
, cstruct
, &err
);
2104 fprintf(STDERR
, "Can't find volume name '%s' in VLDB\n",
2105 as
->parms
[2].items
->data
);
2107 PrintError("", err
);
2111 /* If the server or partition option are not complete, try to fill
2112 * them in from the VLDB entry.
2114 if ((partition
== -1) || !server
) {
2115 struct nvldbentry entry
;
2117 code
= VLDB_GetEntryByID(volid
, -1, &entry
);
2120 "Could not fetch the entry for volume %lu from VLDB\n",
2121 (unsigned long)volid
);
2122 PrintError("", code
);
2126 if (((volid
== entry
.volumeId
[RWVOL
]) && (entry
.flags
& RW_EXISTS
))
2127 || ((volid
== entry
.volumeId
[BACKVOL
])
2128 && (entry
.flags
& BACK_EXISTS
))) {
2129 idx
= Lp_GetRwIndex(&entry
);
2130 if ((idx
== -1) || (server
&& (server
!= entry
.serverNumber
[idx
]))
2131 || ((partition
!= -1)
2132 && (partition
!= entry
.serverPartition
[idx
]))) {
2133 fprintf(STDERR
, "VLDB: Volume '%s' no match\n",
2134 as
->parms
[2].items
->data
);
2137 } else if ((volid
== entry
.volumeId
[ROVOL
])
2138 && (entry
.flags
& RO_EXISTS
)) {
2139 for (idx
= -1, j
= 0; j
< entry
.nServers
; j
++) {
2140 if (entry
.serverFlags
[j
] != ITSROVOL
)
2143 if (((server
== 0) || (server
== entry
.serverNumber
[j
]))
2144 && ((partition
== -1)
2145 || (partition
== entry
.serverPartition
[j
]))) {
2148 "VLDB: Volume '%s' matches more than one RO\n",
2149 as
->parms
[2].items
->data
);
2156 fprintf(STDERR
, "VLDB: Volume '%s' no match\n",
2157 as
->parms
[2].items
->data
);
2161 fprintf(STDERR
, "VLDB: Volume '%s' no match\n",
2162 as
->parms
[2].items
->data
);
2166 server
= htonl(entry
.serverNumber
[idx
]);
2167 partition
= entry
.serverPartition
[idx
];
2171 code
= UV_DeleteVolume(server
, partition
, volid
);
2173 PrintDiagnostics("remove", code
);
2177 MapPartIdIntoName(partition
, pname
);
2178 fprintf(STDOUT
, "Volume %lu on partition %s server %s deleted\n",
2179 (unsigned long)volid
, pname
, hostutil_GetNameByINet(server
));
2183 #define TESTM 0 /* set for move space tests, clear for production */
2185 MoveVolume(struct cmd_syndesc
*as
, void *arock
)
2189 afs_uint32 fromserver
, toserver
;
2190 afs_int32 frompart
, topart
;
2191 afs_int32 flags
, code
, err
;
2192 char fromPartName
[10], toPartName
[10];
2194 struct diskPartition64 partition
; /* for space check */
2197 volid
= vsu_GetVolumeID(as
->parms
[0].items
->data
, cstruct
, &err
);
2200 PrintError("", err
);
2202 fprintf(STDERR
, "vos: can't find volume ID or name '%s'\n",
2203 as
->parms
[0].items
->data
);
2206 fromserver
= GetServer(as
->parms
[1].items
->data
);
2207 if (fromserver
== 0) {
2208 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
2209 as
->parms
[1].items
->data
);
2212 toserver
= GetServer(as
->parms
[3].items
->data
);
2213 if (toserver
== 0) {
2214 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
2215 as
->parms
[3].items
->data
);
2218 frompart
= volutil_GetPartitionID(as
->parms
[2].items
->data
);
2220 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
2221 as
->parms
[2].items
->data
);
2224 if (!IsPartValid(frompart
, fromserver
, &code
)) { /*check for validity of the partition */
2226 PrintError("", code
);
2229 "vos : partition %s does not exist on the server\n",
2230 as
->parms
[2].items
->data
);
2233 topart
= volutil_GetPartitionID(as
->parms
[4].items
->data
);
2235 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
2236 as
->parms
[4].items
->data
);
2239 if (!IsPartValid(topart
, toserver
, &code
)) { /*check for validity of the partition */
2241 PrintError("", code
);
2244 "vos : partition %s does not exist on the server\n",
2245 as
->parms
[4].items
->data
);
2250 if (as
->parms
[5].items
) flags
|= RV_NOCLONE
;
2253 * check source partition for space to clone volume
2256 MapPartIdIntoName(topart
, toPartName
);
2257 MapPartIdIntoName(frompart
, fromPartName
);
2260 * check target partition for space to move volume
2263 code
= UV_PartitionInfo64(toserver
, toPartName
, &partition
);
2265 fprintf(STDERR
, "vos: cannot access partition %s\n", toPartName
);
2269 fprintf(STDOUT
, "target partition %s free space %" AFS_INT64_FMT
"\n", toPartName
,
2272 p
= (volintInfo
*) 0;
2273 code
= UV_ListOneVolume(fromserver
, frompart
, volid
, &p
);
2275 fprintf(STDERR
, "vos:cannot access volume %lu\n",
2276 (unsigned long)volid
);
2280 fprintf(STDOUT
, "volume %lu size %d\n", (unsigned long)volid
,
2282 if (partition
.free
<= p
->size
) {
2284 "vos: no space on target partition %s to move volume %lu\n",
2285 toPartName
, (unsigned long)volid
);
2292 fprintf(STDOUT
, "size test - don't do move\n");
2296 /* successful move still not guaranteed but shoot for it */
2299 UV_MoveVolume2(volid
, fromserver
, frompart
, toserver
, topart
, flags
);
2301 PrintDiagnostics("move", code
);
2304 MapPartIdIntoName(topart
, toPartName
);
2305 MapPartIdIntoName(frompart
, fromPartName
);
2306 fprintf(STDOUT
, "Volume %lu moved from %s %s to %s %s \n",
2307 (unsigned long)volid
, as
->parms
[1].items
->data
, fromPartName
,
2308 as
->parms
[3].items
->data
, toPartName
);
2314 CopyVolume(struct cmd_syndesc
*as
, void *arock
)
2317 afs_uint32 fromserver
, toserver
;
2318 afs_int32 frompart
, topart
, code
, err
, flags
;
2319 char fromPartName
[10], toPartName
[10], *tovolume
;
2320 struct nvldbentry entry
;
2321 struct diskPartition64 partition
; /* for space check */
2324 volid
= vsu_GetVolumeID(as
->parms
[0].items
->data
, cstruct
, &err
);
2327 PrintError("", err
);
2329 fprintf(STDERR
, "vos: can't find volume ID or name '%s'\n",
2330 as
->parms
[0].items
->data
);
2333 fromserver
= GetServer(as
->parms
[1].items
->data
);
2334 if (fromserver
== 0) {
2335 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
2336 as
->parms
[1].items
->data
);
2340 toserver
= GetServer(as
->parms
[4].items
->data
);
2341 if (toserver
== 0) {
2342 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
2343 as
->parms
[4].items
->data
);
2347 tovolume
= as
->parms
[3].items
->data
;
2348 if (!ISNAMEVALID(tovolume
)) {
2350 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2351 tovolume
, VOLSER_OLDMAXVOLNAME
- 10);
2354 if (!VolNameOK(tovolume
)) {
2356 "Illegal volume name %s, should not end in .readonly or .backup\n",
2360 if (IsNumeric(tovolume
)) {
2361 fprintf(STDERR
, "Illegal volume name %s, should not be a number\n",
2365 code
= VLDB_GetEntryByName(tovolume
, &entry
);
2367 fprintf(STDERR
, "Volume %s already exists\n", tovolume
);
2368 PrintDiagnostics("copy", code
);
2372 frompart
= volutil_GetPartitionID(as
->parms
[2].items
->data
);
2374 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
2375 as
->parms
[2].items
->data
);
2378 if (!IsPartValid(frompart
, fromserver
, &code
)) { /*check for validity of the partition */
2380 PrintError("", code
);
2383 "vos : partition %s does not exist on the server\n",
2384 as
->parms
[2].items
->data
);
2388 topart
= volutil_GetPartitionID(as
->parms
[5].items
->data
);
2390 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
2391 as
->parms
[5].items
->data
);
2394 if (!IsPartValid(topart
, toserver
, &code
)) { /*check for validity of the partition */
2396 PrintError("", code
);
2399 "vos : partition %s does not exist on the server\n",
2400 as
->parms
[5].items
->data
);
2405 if (as
->parms
[6].items
) flags
|= RV_OFFLINE
;
2406 if (as
->parms
[7].items
) flags
|= RV_RDONLY
;
2407 if (as
->parms
[8].items
) flags
|= RV_NOCLONE
;
2409 MapPartIdIntoName(topart
, toPartName
);
2410 MapPartIdIntoName(frompart
, fromPartName
);
2413 * check target partition for space to move volume
2416 code
= UV_PartitionInfo64(toserver
, toPartName
, &partition
);
2418 fprintf(STDERR
, "vos: cannot access partition %s\n", toPartName
);
2422 fprintf(STDOUT
, "target partition %s free space %" AFS_INT64_FMT
"\n", toPartName
,
2425 p
= (volintInfo
*) 0;
2426 code
= UV_ListOneVolume(fromserver
, frompart
, volid
, &p
);
2428 fprintf(STDERR
, "vos:cannot access volume %lu\n",
2429 (unsigned long)volid
);
2433 if (partition
.free
<= p
->size
) {
2435 "vos: no space on target partition %s to copy volume %lu\n",
2436 toPartName
, (unsigned long)volid
);
2442 /* successful copy still not guaranteed but shoot for it */
2445 UV_CopyVolume2(volid
, fromserver
, frompart
, tovolume
, toserver
,
2448 PrintDiagnostics("copy", code
);
2451 MapPartIdIntoName(topart
, toPartName
);
2452 MapPartIdIntoName(frompart
, fromPartName
);
2453 fprintf(STDOUT
, "Volume %lu copied from %s %s to %s on %s %s \n",
2454 (unsigned long)volid
, as
->parms
[1].items
->data
, fromPartName
,
2455 tovolume
, as
->parms
[4].items
->data
, toPartName
);
2462 ShadowVolume(struct cmd_syndesc
*as
, void *arock
)
2464 afs_uint32 volid
, tovolid
;
2465 afs_uint32 fromserver
, toserver
;
2466 afs_int32 frompart
, topart
;
2467 afs_int32 code
, err
, flags
;
2468 char fromPartName
[10], toPartName
[10], toVolName
[32], *tovolume
;
2469 struct diskPartition64 partition
; /* for space check */
2472 p
= (volintInfo
*) 0;
2473 q
= (volintInfo
*) 0;
2475 volid
= vsu_GetVolumeID(as
->parms
[0].items
->data
, cstruct
, &err
);
2478 PrintError("", err
);
2480 fprintf(STDERR
, "vos: can't find volume ID or name '%s'\n",
2481 as
->parms
[0].items
->data
);
2484 fromserver
= GetServer(as
->parms
[1].items
->data
);
2485 if (fromserver
== 0) {
2486 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
2487 as
->parms
[1].items
->data
);
2491 toserver
= GetServer(as
->parms
[3].items
->data
);
2492 if (toserver
== 0) {
2493 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
2494 as
->parms
[3].items
->data
);
2498 frompart
= volutil_GetPartitionID(as
->parms
[2].items
->data
);
2500 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
2501 as
->parms
[2].items
->data
);
2504 if (!IsPartValid(frompart
, fromserver
, &code
)) { /*check for validity of the partition */
2506 PrintError("", code
);
2509 "vos : partition %s does not exist on the server\n",
2510 as
->parms
[2].items
->data
);
2514 topart
= volutil_GetPartitionID(as
->parms
[4].items
->data
);
2516 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
2517 as
->parms
[4].items
->data
);
2520 if (!IsPartValid(topart
, toserver
, &code
)) { /*check for validity of the partition */
2522 PrintError("", code
);
2525 "vos : partition %s does not exist on the server\n",
2526 as
->parms
[4].items
->data
);
2530 if (as
->parms
[5].items
) {
2531 tovolume
= as
->parms
[5].items
->data
;
2532 if (!ISNAMEVALID(tovolume
)) {
2534 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2535 tovolume
, VOLSER_OLDMAXVOLNAME
- 10);
2538 if (!VolNameOK(tovolume
)) {
2540 "Illegal volume name %s, should not end in .readonly or .backup\n",
2544 if (IsNumeric(tovolume
)) {
2546 "Illegal volume name %s, should not be a number\n",
2551 /* use actual name of source volume */
2552 code
= UV_ListOneVolume(fromserver
, frompart
, volid
, &p
);
2554 fprintf(STDERR
, "vos:cannot access volume %lu\n",
2555 (unsigned long)volid
);
2558 strcpy(toVolName
, p
->name
);
2559 tovolume
= toVolName
;
2560 /* save p for size checks later */
2563 if (as
->parms
[6].items
) {
2564 tovolid
= vsu_GetVolumeID(as
->parms
[6].items
->data
, cstruct
, &err
);
2567 PrintError("", err
);
2569 fprintf(STDERR
, "vos: can't find volume ID or name '%s'\n",
2570 as
->parms
[6].items
->data
);
2576 tovolid
= vsu_GetVolumeID(tovolume
, cstruct
, &err
);
2579 PrintError("", err
);
2581 fprintf(STDERR
, "vos: can't find volume ID or name '%s'\n",
2590 if (as
->parms
[7].items
) flags
|= RV_OFFLINE
;
2591 if (as
->parms
[8].items
) flags
|= RV_RDONLY
;
2592 if (as
->parms
[9].items
) flags
|= RV_NOCLONE
;
2593 if (as
->parms
[10].items
) flags
|= RV_CPINCR
;
2595 MapPartIdIntoName(topart
, toPartName
);
2596 MapPartIdIntoName(frompart
, fromPartName
);
2599 * check target partition for space to move volume
2602 code
= UV_PartitionInfo64(toserver
, toPartName
, &partition
);
2604 fprintf(STDERR
, "vos: cannot access partition %s\n", toPartName
);
2608 fprintf(STDOUT
, "target partition %s free space %" AFS_INT64_FMT
"\n", toPartName
,
2611 /* Don't do this again if we did it above */
2613 code
= UV_ListOneVolume(fromserver
, frompart
, volid
, &p
);
2615 fprintf(STDERR
, "vos:cannot access volume %lu\n",
2616 (unsigned long)volid
);
2621 /* OK if this fails */
2622 code
= UV_ListOneVolume(toserver
, topart
, tovolid
, &q
);
2624 /* Treat existing volume size as "free" */
2626 p
->size
= (q
->size
< p
->size
) ? p
->size
- q
->size
: 0;
2628 if (partition
.free
<= p
->size
) {
2630 "vos: no space on target partition %s to copy volume %lu\n",
2631 toPartName
, (unsigned long)volid
);
2639 /* successful copy still not guaranteed but shoot for it */
2642 UV_CopyVolume2(volid
, fromserver
, frompart
, tovolume
, toserver
,
2643 topart
, tovolid
, flags
);
2645 PrintDiagnostics("shadow", code
);
2648 MapPartIdIntoName(topart
, toPartName
);
2649 MapPartIdIntoName(frompart
, fromPartName
);
2650 fprintf(STDOUT
, "Volume %lu shadowed from %s %s to %s %s \n",
2651 (unsigned long)volid
, as
->parms
[1].items
->data
, fromPartName
,
2652 as
->parms
[3].items
->data
, toPartName
);
2659 CloneVolume(struct cmd_syndesc
*as
, void *arock
)
2661 afs_uint32 volid
, cloneid
;
2663 afs_int32 part
, voltype
;
2664 char partName
[10], *volname
;
2665 afs_int32 code
, err
, flags
;
2666 struct nvldbentry entry
;
2668 volid
= vsu_GetVolumeID(as
->parms
[0].items
->data
, cstruct
, &err
);
2671 PrintError("", err
);
2673 fprintf(STDERR
, "vos: can't find volume ID or name '%s'\n",
2674 as
->parms
[0].items
->data
);
2678 if (as
->parms
[1].items
|| as
->parms
[2].items
) {
2679 if (!as
->parms
[1].items
|| !as
->parms
[2].items
) {
2681 "Must specify both -server and -partition options\n");
2684 server
= GetServer(as
->parms
[1].items
->data
);
2686 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
2687 as
->parms
[1].items
->data
);
2690 part
= volutil_GetPartitionID(as
->parms
[2].items
->data
);
2692 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
2693 as
->parms
[2].items
->data
);
2696 if (!IsPartValid(part
, server
, &code
)) { /*check for validity of the partition */
2698 PrintError("", code
);
2701 "vos : partition %s does not exist on the server\n",
2702 as
->parms
[2].items
->data
);
2706 code
= GetVolumeInfo(volid
, &server
, &part
, &voltype
, &entry
);
2712 if (as
->parms
[3].items
) {
2713 volname
= as
->parms
[3].items
->data
;
2714 if (strlen(volname
) > VOLSER_OLDMAXVOLNAME
- 1) {
2716 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2717 volname
, VOLSER_OLDMAXVOLNAME
- 1);
2722 * In order that you be able to make clones of RO or BK, this
2723 * check must be omitted.
2725 if (!VolNameOK(volname
)) {
2727 "Illegal volume name %s, should not end in .readonly or .backup\n",
2732 if (IsNumeric(volname
)) {
2734 "Illegal volume name %s, should not be a number\n",
2741 if (as
->parms
[4].items
) {
2742 cloneid
= vsu_GetVolumeID(as
->parms
[4].items
->data
, cstruct
, &err
);
2745 PrintError("", err
);
2747 fprintf(STDERR
, "vos: can't find volume ID or name '%s'\n",
2748 as
->parms
[4].items
->data
);
2754 if (as
->parms
[5].items
) flags
|= RV_OFFLINE
;
2755 if (as
->parms
[6].items
&& as
->parms
[7].items
) {
2756 fprintf(STDERR
, "vos: cannot specify that a volume be -readwrite and -readonly\n");
2759 if (as
->parms
[6].items
) flags
|= RV_RDONLY
;
2760 if (as
->parms
[7].items
) flags
|= RV_RWONLY
;
2764 UV_CloneVolume(server
, part
, volid
, cloneid
, volname
, flags
);
2767 PrintDiagnostics("clone", code
);
2770 MapPartIdIntoName(part
, partName
);
2771 fprintf(STDOUT
, "Created clone for volume %s\n",
2772 as
->parms
[0].items
->data
);
2779 BackupVolume(struct cmd_syndesc
*as
, void *arock
)
2783 afs_int32 apart
, vtype
, code
, err
;
2784 struct nvldbentry entry
;
2787 afs_uint32 buserver
;
2788 afs_int32 bupart
, butype
;
2789 struct nvldbentry buentry
;
2791 avolid
= vsu_GetVolumeID(as
->parms
[0].items
->data
, cstruct
, &err
);
2794 PrintError("", err
);
2796 fprintf(STDERR
, "vos: can't find volume ID or name '%s'\n",
2797 as
->parms
[0].items
->data
);
2800 code
= GetVolumeInfo(avolid
, &aserver
, &apart
, &vtype
, &entry
);
2804 /* verify this is a readwrite volume */
2806 if (vtype
!= RWVOL
) {
2807 fprintf(STDERR
, "%s not RW volume\n", as
->parms
[0].items
->data
);
2811 /* is there a backup volume already? */
2813 if (entry
.flags
& BACK_EXISTS
) {
2814 /* yep, where is it? */
2816 buvolid
= entry
.volumeId
[BACKVOL
];
2817 code
= GetVolumeInfo(buvolid
, &buserver
, &bupart
, &butype
, &buentry
);
2822 code
= VLDB_IsSameAddrs(buserver
, aserver
, &err
);
2825 "Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
2831 "FATAL ERROR: backup volume %lu exists on server %lu\n",
2832 (unsigned long)buvolid
, (unsigned long)buserver
);
2837 /* nope, carry on */
2839 code
= UV_BackupVolume(aserver
, apart
, avolid
);
2842 PrintDiagnostics("backup", code
);
2845 fprintf(STDOUT
, "Created backup volume for %s \n",
2846 as
->parms
[0].items
->data
);
2851 ReleaseVolume(struct cmd_syndesc
*as
, void *arock
)
2854 struct nvldbentry entry
;
2857 afs_int32 apart
, vtype
, code
, err
;
2861 if (as
->parms
[1].items
)
2863 if (as
->parms
[2].items
)
2865 avolid
= vsu_GetVolumeID(as
->parms
[0].items
->data
, cstruct
, &err
);
2868 PrintError("", err
);
2870 fprintf(STDERR
, "vos: can't find volume '%s'\n",
2871 as
->parms
[0].items
->data
);
2874 code
= GetVolumeInfo(avolid
, &aserver
, &apart
, &vtype
, &entry
);
2878 if (vtype
!= RWVOL
) {
2879 fprintf(STDERR
, "%s not a RW volume\n", as
->parms
[0].items
->data
);
2883 if (!ISNAMEVALID(entry
.name
)) {
2885 "Volume name %s is too long, rename before releasing\n",
2890 code
= UV_ReleaseVolume(avolid
, aserver
, apart
, force
, stayUp
);
2893 PrintDiagnostics("release", code
);
2896 fprintf(STDOUT
, "Released volume %s successfully\n",
2897 as
->parms
[0].items
->data
);
2902 DumpVolumeCmd(struct cmd_syndesc
*as
, void *arock
)
2906 afs_int32 apart
, voltype
, fromdate
= 0, code
, err
, i
, flags
;
2907 char filename
[MAXPATHLEN
];
2908 struct nvldbentry entry
;
2910 rx_SetRxDeadTime(60 * 10);
2911 for (i
= 0; i
< MAXSERVERS
; i
++) {
2912 struct rx_connection
*rxConn
= ubik_GetRPCConn(cstruct
, i
);
2915 rx_SetConnDeadTime(rxConn
, rx_connDeadTime
);
2916 if (rxConn
->service
)
2917 rxConn
->service
->connDeadTime
= rx_connDeadTime
;
2920 avolid
= vsu_GetVolumeID(as
->parms
[0].items
->data
, cstruct
, &err
);
2923 PrintError("", err
);
2925 fprintf(STDERR
, "vos: can't find volume '%s'\n",
2926 as
->parms
[0].items
->data
);
2930 if (as
->parms
[3].items
|| as
->parms
[4].items
) {
2931 if (!as
->parms
[3].items
|| !as
->parms
[4].items
) {
2933 "Must specify both -server and -partition options\n");
2936 aserver
= GetServer(as
->parms
[3].items
->data
);
2938 fprintf(STDERR
, "Invalid server name\n");
2941 apart
= volutil_GetPartitionID(as
->parms
[4].items
->data
);
2943 fprintf(STDERR
, "Invalid partition name\n");
2947 code
= GetVolumeInfo(avolid
, &aserver
, &apart
, &voltype
, &entry
);
2952 if (as
->parms
[1].items
&& strcmp(as
->parms
[1].items
->data
, "0")) {
2953 code
= ktime_DateToInt32(as
->parms
[1].items
->data
, &fromdate
);
2955 fprintf(STDERR
, "vos: failed to parse date '%s' (error=%d))\n",
2956 as
->parms
[1].items
->data
, code
);
2960 if (as
->parms
[2].items
) {
2961 strcpy(filename
, as
->parms
[2].items
->data
);
2963 strcpy(filename
, "");
2966 flags
= as
->parms
[6].items
? VOLDUMPV2_OMITDIRS
: 0;
2968 if (as
->parms
[5].items
) {
2970 UV_DumpClonedVolume(avolid
, aserver
, apart
, fromdate
,
2971 DumpFunction
, filename
, flags
);
2974 UV_DumpVolume(avolid
, aserver
, apart
, fromdate
, DumpFunction
,
2977 if ((code
== RXGEN_OPCODE
) && (as
->parms
[6].items
)) {
2978 flags
&= ~VOLDUMPV2_OMITDIRS
;
2982 PrintDiagnostics("dump", code
);
2985 if (strcmp(filename
, ""))
2986 fprintf(STDERR
, "Dumped volume %s in file %s\n",
2987 as
->parms
[0].items
->data
, filename
);
2989 fprintf(STDERR
, "Dumped volume %s in stdout \n",
2990 as
->parms
[0].items
->data
);
3004 RestoreVolumeCmd(struct cmd_syndesc
*as
, void *arock
)
3006 afs_uint32 avolid
, aparentid
;
3008 afs_int32 apart
, code
, vcode
, err
;
3009 afs_int32 aoverwrite
= ASK
;
3010 afs_int32 acreation
= 0, alastupdate
= 0;
3011 int restoreflags
= 0;
3012 int readonly
= 0, offline
= 0, voltype
= RWVOL
;
3013 char afilename
[MAXPATHLEN
], avolname
[VOLSER_MAXVOLNAME
+ 1], apartName
[10];
3014 char volname
[VOLSER_MAXVOLNAME
+ 1];
3015 struct nvldbentry entry
;
3018 if (as
->parms
[4].items
) {
3019 avolid
= vsu_GetVolumeID(as
->parms
[4].items
->data
, cstruct
, &err
);
3022 PrintError("", err
);
3024 fprintf(STDERR
, "vos: can't find volume '%s'\n",
3025 as
->parms
[4].items
->data
);
3031 if (as
->parms
[5].items
) {
3032 if ((strcmp(as
->parms
[5].items
->data
, "a") == 0)
3033 || (strcmp(as
->parms
[5].items
->data
, "abort") == 0)) {
3035 } else if ((strcmp(as
->parms
[5].items
->data
, "f") == 0)
3036 || (strcmp(as
->parms
[5].items
->data
, "full") == 0)) {
3038 } else if ((strcmp(as
->parms
[5].items
->data
, "i") == 0)
3039 || (strcmp(as
->parms
[5].items
->data
, "inc") == 0)
3040 || (strcmp(as
->parms
[5].items
->data
, "increment") == 0)
3041 || (strcmp(as
->parms
[5].items
->data
, "incremental") == 0)) {
3044 fprintf(STDERR
, "vos: %s is not a valid argument to -overwrite\n",
3045 as
->parms
[5].items
->data
);
3049 if (as
->parms
[6].items
)
3051 if (as
->parms
[7].items
) {
3056 if (as
->parms
[8].items
) {
3057 if ((strcmp(as
->parms
[8].items
->data
, "d") == 0)
3058 || (strcmp(as
->parms
[8].items
->data
, "dump") == 0)) {
3059 acreation
= TS_DUMP
;
3060 } else if ((strcmp(as
->parms
[8].items
->data
, "k") == 0)
3061 || (strcmp(as
->parms
[8].items
->data
, "keep") == 0)) {
3062 acreation
= TS_KEEP
;
3063 } else if ((strcmp(as
->parms
[8].items
->data
, "n") == 0)
3064 || (strcmp(as
->parms
[8].items
->data
, "new") == 0)) {
3067 fprintf(STDERR
, "vos: %s is not a valid argument to -creation\n",
3068 as
->parms
[8].items
->data
);
3073 if (as
->parms
[9].items
) {
3074 if ((strcmp(as
->parms
[9].items
->data
, "d") == 0)
3075 || (strcmp(as
->parms
[9].items
->data
, "dump") == 0)) {
3076 alastupdate
= TS_DUMP
;
3077 } else if ((strcmp(as
->parms
[9].items
->data
, "k") == 0)
3078 || (strcmp(as
->parms
[9].items
->data
, "keep") == 0)) {
3079 alastupdate
= TS_KEEP
;
3080 } else if ((strcmp(as
->parms
[9].items
->data
, "n") == 0)
3081 || (strcmp(as
->parms
[9].items
->data
, "new") == 0)) {
3082 alastupdate
= TS_NEW
;
3084 fprintf(STDERR
, "vos: %s is not a valid argument to -lastupdate\n",
3085 as
->parms
[9].items
->data
);
3090 aserver
= GetServer(as
->parms
[0].items
->data
);
3092 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
3093 as
->parms
[0].items
->data
);
3096 apart
= volutil_GetPartitionID(as
->parms
[1].items
->data
);
3098 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
3099 as
->parms
[1].items
->data
);
3102 if (!IsPartValid(apart
, aserver
, &code
)) { /*check for validity of the partition */
3104 PrintError("", code
);
3107 "vos : partition %s does not exist on the server\n",
3108 as
->parms
[1].items
->data
);
3111 strcpy(avolname
, as
->parms
[2].items
->data
);
3112 if (!ISNAMEVALID(avolname
)) {
3114 "vos: the name of the volume %s exceeds the size limit\n",
3118 if (!VolNameOK(avolname
)) {
3120 "Illegal volume name %s, should not end in .readonly or .backup\n",
3124 if (as
->parms
[3].items
) {
3125 strcpy(afilename
, as
->parms
[3].items
->data
);
3126 if (!FileExists(afilename
)) {
3127 fprintf(STDERR
, "Can't access file %s\n", afilename
);
3131 strcpy(afilename
, "");
3134 /* Check if volume exists or not */
3136 vsu_ExtractName(volname
, avolname
);
3137 vcode
= VLDB_GetEntryByName(volname
, &entry
);
3138 if (vcode
) { /* no volume - do a full restore */
3139 restoreflags
= RV_FULLRST
;
3140 if ((aoverwrite
== INC
) || (aoverwrite
== ABORT
))
3142 "Volume does not exist; Will perform a full restore\n");
3145 else if ((!readonly
&& Lp_GetRwIndex(&entry
) == -1) /* RW volume does not exist - do a full */
3146 ||(readonly
&& !Lp_ROMatch(0, 0, &entry
))) { /* RO volume does not exist - do a full */
3147 restoreflags
= RV_FULLRST
;
3148 if ((aoverwrite
== INC
) || (aoverwrite
== ABORT
))
3150 "%s Volume does not exist; Will perform a full restore\n",
3151 readonly
? "RO" : "RW");
3154 avolid
= entry
.volumeId
[voltype
];
3155 } else if (entry
.volumeId
[voltype
] != 0
3156 && entry
.volumeId
[voltype
] != avolid
) {
3157 avolid
= entry
.volumeId
[voltype
];
3159 aparentid
= entry
.volumeId
[RWVOL
];
3162 else { /* volume exists - do we do a full incremental or abort */
3164 afs_int32 Opart
, Otype
, vol_elsewhere
= 0;
3165 struct nvldbentry Oentry
;
3169 avolid
= entry
.volumeId
[voltype
];
3170 } else if (entry
.volumeId
[voltype
] != 0
3171 && entry
.volumeId
[voltype
] != avolid
) {
3172 avolid
= entry
.volumeId
[voltype
];
3174 aparentid
= entry
.volumeId
[RWVOL
];
3176 /* A file name was specified - check if volume is on another partition */
3177 vcode
= GetVolumeInfo(avolid
, &Oserver
, &Opart
, &Otype
, &Oentry
);
3181 vcode
= VLDB_IsSameAddrs(Oserver
, aserver
, &err
);
3184 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
3188 if (!vcode
|| (Opart
!= apart
))
3191 if (aoverwrite
== ASK
) {
3192 if (strcmp(afilename
, "") == 0) { /* The file is from standard in */
3194 "Volume exists and no -overwrite option specified; Aborting restore command\n");
3198 /* Ask what to do */
3199 if (vol_elsewhere
) {
3201 "The volume %s %u already exists on a different server/part\n",
3202 volname
, entry
.volumeId
[voltype
]);
3204 "Do you want to do a full restore or abort? [fa](a): ");
3207 "The volume %s %u already exists in the VLDB\n",
3208 volname
, entry
.volumeId
[voltype
]);
3210 "Do you want to do a full/incremental restore or abort? [fia](a): ");
3213 while (!(dc
== EOF
|| dc
== '\n'))
3214 dc
= getchar(); /* goto end of line */
3215 if ((c
== 'f') || (c
== 'F'))
3217 else if ((c
== 'i') || (c
== 'I'))
3223 if (aoverwrite
== ABORT
) {
3224 fprintf(STDERR
, "Volume exists; Aborting restore command\n");
3226 } else if (aoverwrite
== FULL
) {
3227 restoreflags
= RV_FULLRST
;
3229 "Volume exists; Will delete and perform full restore\n");
3230 } else if (aoverwrite
== INC
) {
3232 if (vol_elsewhere
) {
3234 "%s volume %lu already exists on a different server/part; not allowed\n",
3235 readonly
? "RO" : "RW", (unsigned long)avolid
);
3241 restoreflags
|= RV_OFFLINE
;
3243 restoreflags
|= RV_RDONLY
;
3245 switch (acreation
) {
3247 restoreflags
|= RV_CRDUMP
;
3250 restoreflags
|= RV_CRKEEP
;
3253 restoreflags
|= RV_CRNEW
;
3256 if (aoverwrite
== FULL
)
3257 restoreflags
|= RV_CRNEW
;
3259 restoreflags
|= RV_CRKEEP
;
3262 switch (alastupdate
) {
3264 restoreflags
|= RV_LUDUMP
;
3267 restoreflags
|= RV_LUKEEP
;
3270 restoreflags
|= RV_LUNEW
;
3273 restoreflags
|= RV_LUDUMP
;
3275 if (as
->parms
[10].items
) {
3276 restoreflags
|= RV_NODEL
;
3281 UV_RestoreVolume2(aserver
, apart
, avolid
, aparentid
,
3282 avolname
, restoreflags
, WriteData
, afilename
);
3284 PrintDiagnostics("restore", code
);
3287 MapPartIdIntoName(apart
, apartName
);
3290 * patch typo here - originally "parms[1]", should be "parms[0]"
3293 fprintf(STDOUT
, "Restored volume %s on %s %s\n", avolname
,
3294 as
->parms
[0].items
->data
, apartName
);
3299 LockReleaseCmd(struct cmd_syndesc
*as
, void *arock
)
3302 afs_int32 code
, err
;
3304 avolid
= vsu_GetVolumeID(as
->parms
[0].items
->data
, cstruct
, &err
);
3307 PrintError("", err
);
3309 fprintf(STDERR
, "vos: can't find volume '%s'\n",
3310 as
->parms
[0].items
->data
);
3314 code
= UV_LockRelease(avolid
);
3316 PrintDiagnostics("unlock", code
);
3319 fprintf(STDOUT
, "Released lock on vldb entry for volume %s\n",
3320 as
->parms
[0].items
->data
);
3325 AddSite(struct cmd_syndesc
*as
, void *arock
)
3329 afs_int32 apart
, code
, err
, arovolid
, valid
= 0;
3330 char apartName
[10], avolname
[VOLSER_MAXVOLNAME
+ 1];
3332 vsu_ExtractName(avolname
, as
->parms
[2].items
->data
);;
3333 avolid
= vsu_GetVolumeID(avolname
, cstruct
, &err
);
3336 PrintError("", err
);
3338 fprintf(STDERR
, "vos: can't find volume '%s'\n",
3339 as
->parms
[2].items
->data
);
3343 if (as
->parms
[3].items
) {
3344 vsu_ExtractName(avolname
, as
->parms
[3].items
->data
);
3345 arovolid
= vsu_GetVolumeID(avolname
, cstruct
, &err
);
3347 fprintf(STDERR
, "vos: invalid ro volume id '%s'\n",
3348 as
->parms
[3].items
->data
);
3352 aserver
= GetServer(as
->parms
[0].items
->data
);
3354 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
3355 as
->parms
[0].items
->data
);
3358 apart
= volutil_GetPartitionID(as
->parms
[1].items
->data
);
3360 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
3361 as
->parms
[1].items
->data
);
3364 if (!IsPartValid(apart
, aserver
, &code
)) { /*check for validity of the partition */
3366 PrintError("", code
);
3369 "vos : partition %s does not exist on the server\n",
3370 as
->parms
[1].items
->data
);
3373 if (as
->parms
[4].items
) {
3376 code
= UV_AddSite2(aserver
, apart
, avolid
, arovolid
, valid
);
3378 PrintDiagnostics("addsite", code
);
3381 MapPartIdIntoName(apart
, apartName
);
3382 fprintf(STDOUT
, "Added replication site %s %s for volume %s\n",
3383 as
->parms
[0].items
->data
, apartName
, as
->parms
[2].items
->data
);
3388 RemoveSite(struct cmd_syndesc
*as
, void *arock
)
3393 afs_int32 apart
, code
, err
;
3394 char apartName
[10], avolname
[VOLSER_MAXVOLNAME
+ 1];
3396 vsu_ExtractName(avolname
, as
->parms
[2].items
->data
);
3397 avolid
= vsu_GetVolumeID(avolname
, cstruct
, &err
);
3400 PrintError("", err
);
3402 fprintf(STDERR
, "vos: can't find volume '%s'\n",
3403 as
->parms
[2].items
->data
);
3406 aserver
= GetServer(as
->parms
[0].items
->data
);
3408 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
3409 as
->parms
[0].items
->data
);
3412 apart
= volutil_GetPartitionID(as
->parms
[1].items
->data
);
3414 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
3415 as
->parms
[1].items
->data
);
3419 *skip the partition validity check, since it is possible that the partition
3420 *has since been decomissioned.
3423 if (!IsPartValid(apart,aserver,&code)){
3424 if(code) PrintError("",code);
3425 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
3429 code
= UV_RemoveSite(aserver
, apart
, avolid
);
3431 PrintDiagnostics("remsite", code
);
3434 MapPartIdIntoName(apart
, apartName
);
3435 fprintf(STDOUT
, "Removed replication site %s %s for volume %s\n",
3436 as
->parms
[0].items
->data
, apartName
, as
->parms
[2].items
->data
);
3441 ChangeLocation(struct cmd_syndesc
*as
, void *arock
)
3445 afs_int32 apart
, code
, err
;
3448 avolid
= vsu_GetVolumeID(as
->parms
[2].items
->data
, cstruct
, &err
);
3451 PrintError("", err
);
3453 fprintf(STDERR
, "vos: can't find volume '%s'\n",
3454 as
->parms
[2].items
->data
);
3457 aserver
= GetServer(as
->parms
[0].items
->data
);
3459 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
3460 as
->parms
[0].items
->data
);
3463 apart
= volutil_GetPartitionID(as
->parms
[1].items
->data
);
3465 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
3466 as
->parms
[1].items
->data
);
3469 if (!IsPartValid(apart
, aserver
, &code
)) { /*check for validity of the partition */
3471 PrintError("", code
);
3474 "vos : partition %s does not exist on the server\n",
3475 as
->parms
[1].items
->data
);
3478 code
= UV_ChangeLocation(aserver
, apart
, avolid
);
3480 PrintDiagnostics("changeloc", code
);
3483 MapPartIdIntoName(apart
, apartName
);
3484 fprintf(STDOUT
, "Changed location to %s %s for volume %s\n",
3485 as
->parms
[0].items
->data
, apartName
, as
->parms
[2].items
->data
);
3490 ListPartitions(struct cmd_syndesc
*as
, void *arock
)
3494 struct partList dummyPartList
;
3499 aserver
= GetServer(as
->parms
[0].items
->data
);
3501 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
3502 as
->parms
[0].items
->data
);
3507 code
= UV_ListPartitions(aserver
, &dummyPartList
, &cnt
);
3509 PrintDiagnostics("listpart", code
);
3513 fprintf(STDOUT
, "The partitions on the server are:\n");
3514 for (i
= 0; i
< cnt
; i
++) {
3515 if (dummyPartList
.partFlags
[i
] & PARTVALID
) {
3516 memset(pname
, 0, sizeof(pname
));
3517 MapPartIdIntoName(dummyPartList
.partId
[i
], pname
);
3518 fprintf(STDOUT
, " %10s ", pname
);
3520 if ((i
% 5) == 0 && (i
!= 0))
3521 fprintf(STDOUT
, "\n");
3524 fprintf(STDOUT
, "\n");
3525 fprintf(STDOUT
, "Total: %d\n", total
);
3531 CompareVolName(const void *p1
, const void *p2
)
3533 volintInfo
*arg1
, *arg2
;
3535 arg1
= (volintInfo
*) p1
;
3536 arg2
= (volintInfo
*) p2
;
3537 return (strcmp(arg1
->name
, arg2
->name
));
3541 /*------------------------------------------------------------------------
3542 * PRIVATE XCompareVolName
3545 * Comparison routine for volume names coming from an extended
3549 * a_obj1P : Char ptr to first extended vol info object
3550 * a_obj1P : Char ptr to second extended vol info object
3553 * The value of strcmp() on the volume names within the passed
3554 * objects (i,e., -1, 0, or 1).
3557 * Passed to qsort() as the designated comparison routine.
3561 *------------------------------------------------------------------------*/
3564 XCompareVolName(const void *a_obj1P
, const void *a_obj2P
)
3565 { /*XCompareVolName */
3568 (((struct volintXInfo
*)(a_obj1P
))->name
,
3569 ((struct volintXInfo
*)(a_obj2P
))->name
));
3571 } /*XCompareVolName */
3574 CompareVolID(const void *p1
, const void *p2
)
3576 volintInfo
*arg1
, *arg2
;
3578 arg1
= (volintInfo
*) p1
;
3579 arg2
= (volintInfo
*) p2
;
3580 if (arg1
->volid
== arg2
->volid
)
3582 if (arg1
->volid
> arg2
->volid
)
3589 /*------------------------------------------------------------------------
3590 * PRIVATE XCompareVolID
3593 * Comparison routine for volume IDs coming from an extended
3597 * a_obj1P : Char ptr to first extended vol info object
3598 * a_obj1P : Char ptr to second extended vol info object
3601 * The value of strcmp() on the volume names within the passed
3602 * objects (i,e., -1, 0, or 1).
3605 * Passed to qsort() as the designated comparison routine.
3609 *------------------------------------------------------------------------*/
3612 XCompareVolID(const void *a_obj1P
, const void *a_obj2P
)
3613 { /*XCompareVolID */
3615 afs_int32 id1
, id2
; /*Volume IDs we're comparing */
3617 id1
= ((struct volintXInfo
*)(a_obj1P
))->volid
;
3618 id2
= ((struct volintXInfo
*)(a_obj2P
))->volid
;
3626 } /*XCompareVolID */
3628 /*------------------------------------------------------------------------
3629 * PRIVATE ListVolumes
3632 * Routine used to list volumes, contacting the Volume Server
3633 * directly, bypassing the VLDB.
3636 * as : Ptr to parsed command line arguments.
3639 * 0 Successful operation
3642 * Nothing interesting.
3646 *------------------------------------------------------------------------*/
3649 ListVolumes(struct cmd_syndesc
*as
, void *arock
)
3651 afs_int32 apart
, int32list
, fast
;
3655 volintInfo
*oldpntr
= NULL
;
3659 volintXInfo
*xInfoP
;
3660 volintXInfo
*origxInfoP
= NULL
; /*Ptr to current/orig extended vol info */
3661 int wantExtendedInfo
; /*Do we want extended vol info? */
3664 struct partList dummyPartList
;
3672 if (as
->parms
[3].items
)
3674 if (as
->parms
[4].items
)
3678 if (as
->parms
[2].items
)
3684 if (as
->parms
[5].items
) {
3686 * We can't coexist with the fast flag.
3690 "vos: Can't use the -fast and -extended flags together\n");
3695 * We need to turn on ``long'' listings to get the full effect.
3697 wantExtendedInfo
= 1;
3700 wantExtendedInfo
= 0;
3701 if (as
->parms
[1].items
) {
3702 apart
= volutil_GetPartitionID(as
->parms
[1].items
->data
);
3704 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
3705 as
->parms
[1].items
->data
);
3708 dummyPartList
.partId
[0] = apart
;
3709 dummyPartList
.partFlags
[0] = PARTVALID
;
3712 aserver
= GetServer(as
->parms
[0].items
->data
);
3714 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
3715 as
->parms
[0].items
->data
);
3720 if (!IsPartValid(apart
, aserver
, &code
)) { /*check for validity of the partition */
3722 PrintError("", code
);
3725 "vos : partition %s does not exist on the server\n",
3726 as
->parms
[1].items
->data
);
3730 code
= UV_ListPartitions(aserver
, &dummyPartList
, &cnt
);
3732 PrintDiagnostics("listvol", code
);
3736 for (i
= 0; i
< cnt
; i
++) {
3737 if (dummyPartList
.partFlags
[i
] & PARTVALID
) {
3738 if (wantExtendedInfo
)
3740 UV_XListVolumes(aserver
, dummyPartList
.partId
[i
], all
,
3744 UV_ListVolumes(aserver
, dummyPartList
.partId
[i
], all
,
3747 PrintDiagnostics("listvol", code
);
3750 if (wantExtendedInfo
) {
3751 origxInfoP
= xInfoP
;
3752 base
= (char *)xInfoP
;
3755 base
= (char *)pntr
;
3759 if (wantExtendedInfo
)
3760 qsort(base
, count
, sizeof(volintXInfo
), XCompareVolName
);
3762 qsort(base
, count
, sizeof(volintInfo
), CompareVolName
);
3764 if (wantExtendedInfo
)
3765 qsort(base
, count
, sizeof(volintXInfo
), XCompareVolID
);
3767 qsort(base
, count
, sizeof(volintInfo
), CompareVolID
);
3769 MapPartIdIntoName(dummyPartList
.partId
[i
], pname
);
3772 "Total number of volumes on server %s partition %s: %lu \n",
3773 as
->parms
[0].items
->data
, pname
,
3774 (unsigned long)count
);
3775 if (wantExtendedInfo
) {
3776 if (as
->parms
[6].items
)
3777 XDisplayVolumes2(aserver
, dummyPartList
.partId
[i
], origxInfoP
,
3778 count
, int32list
, fast
, quiet
);
3780 XDisplayVolumes(aserver
, dummyPartList
.partId
[i
], origxInfoP
,
3781 count
, int32list
, fast
, quiet
);
3784 xInfoP
= (volintXInfo
*) 0;
3786 if (as
->parms
[6].items
)
3787 DisplayVolumes2(aserver
, dummyPartList
.partId
[i
], oldpntr
,
3790 DisplayVolumes(aserver
, dummyPartList
.partId
[i
], oldpntr
,
3791 count
, int32list
, fast
, quiet
);
3794 pntr
= (volintInfo
*) 0;
3802 SyncVldb(struct cmd_syndesc
*as
, void *arock
)
3804 afs_int32 pnum
= 0, code
; /* part name */
3810 if (as
->parms
[0].items
) {
3811 tserver
= GetServer(as
->parms
[0].items
->data
);
3813 fprintf(STDERR
, "vos: host '%s' not found in host table\n",
3814 as
->parms
[0].items
->data
);
3819 if (as
->parms
[1].items
) {
3820 pnum
= volutil_GetPartitionID(as
->parms
[1].items
->data
);
3822 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
3823 as
->parms
[1].items
->data
);
3826 if (!IsPartValid(pnum
, tserver
, &code
)) { /*check for validity of the partition */
3828 PrintError("", code
);
3831 "vos: partition %s does not exist on the server\n",
3832 as
->parms
[1].items
->data
);
3839 "The -partition option requires a -server option\n");
3844 if (as
->parms
[3].items
) {
3845 flags
|= 2; /* don't update */
3848 if (as
->parms
[2].items
) {
3849 /* Synchronize an individual volume */
3850 volname
= as
->parms
[2].items
->data
;
3851 code
= UV_SyncVolume(tserver
, pnum
, volname
, flags
);
3855 "Without a -volume option, the -server option is required\n");
3858 code
= UV_SyncVldb(tserver
, pnum
, flags
, 0 /*unused */ );
3862 PrintDiagnostics("syncvldb", code
);
3866 /* Print a summary of what we did */
3868 fprintf(STDOUT
, "VLDB volume %s synchronized", volname
);
3870 fprintf(STDOUT
, "VLDB synchronized");
3872 fprintf(STDOUT
, " with state of server %s", as
->parms
[0].items
->data
);
3875 MapPartIdIntoName(pnum
, part
);
3876 fprintf(STDOUT
, " partition %s\n", part
);
3878 fprintf(STDOUT
, "\n");
3884 SyncServer(struct cmd_syndesc
*as
, void *arock
)
3886 afs_int32 pnum
, code
; /* part name */
3891 tserver
= GetServer(as
->parms
[0].items
->data
);
3893 fprintf(STDERR
, "vos: host '%s' not found in host table\n",
3894 as
->parms
[0].items
->data
);
3897 if (as
->parms
[1].items
) {
3898 pnum
= volutil_GetPartitionID(as
->parms
[1].items
->data
);
3900 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
3901 as
->parms
[1].items
->data
);
3904 if (!IsPartValid(pnum
, tserver
, &code
)) { /*check for validity of the partition */
3906 PrintError("", code
);
3909 "vos : partition %s does not exist on the server\n",
3910 as
->parms
[1].items
->data
);
3918 if (as
->parms
[2].items
) {
3919 flags
|= 2; /* don't update */
3921 code
= UV_SyncServer(tserver
, pnum
, flags
, 0 /*unused */ );
3923 PrintDiagnostics("syncserv", code
);
3927 MapPartIdIntoName(pnum
, part
);
3928 fprintf(STDOUT
, "Server %s partition %s synchronized with VLDB\n",
3929 as
->parms
[0].items
->data
, part
);
3931 fprintf(STDOUT
, "Server %s synchronized with VLDB\n",
3932 as
->parms
[0].items
->data
);
3938 VolumeInfoCmd(char *name
)
3940 struct nvldbentry entry
;
3943 /* The vlserver will handle names with the .readonly
3944 * and .backup extension as well as volume ids.
3946 vcode
= VLDB_GetEntryByName(name
, &entry
);
3948 PrintError("", vcode
);
3951 MapHostToNetwork(&entry
);
3952 EnumerateEntry(&entry
);
3954 /* Defect #3027: grubby check to handle locked volume.
3955 * If VLOP_ALLOPERS is set, the entry is locked.
3956 * Leave this routine as is, but put in correct check.
3958 PrintLocked(entry
.flags
);
3964 VolumeZap(struct cmd_syndesc
*as
, void *arock
)
3966 struct nvldbentry entry
;
3967 afs_uint32 volid
, zapbackupid
= 0, backupid
= 0;
3968 afs_int32 code
, server
, part
, err
;
3970 if (as
->parms
[3].items
) {
3971 /* force flag is on, use the other version */
3972 return NukeVolume(as
);
3975 if (as
->parms
[4].items
) {
3979 volid
= vsu_GetVolumeID(as
->parms
[2].items
->data
, cstruct
, &err
);
3982 PrintError("", err
);
3984 fprintf(STDERR
, "vos: can't find volume '%s'\n",
3985 as
->parms
[2].items
->data
);
3988 part
= volutil_GetPartitionID(as
->parms
[1].items
->data
);
3990 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
3991 as
->parms
[1].items
->data
);
3994 server
= GetServer(as
->parms
[0].items
->data
);
3996 fprintf(STDERR
, "vos: host '%s' not found in host table\n",
3997 as
->parms
[0].items
->data
);
4000 if (!IsPartValid(part
, server
, &code
)) { /*check for validity of the partition */
4002 PrintError("", code
);
4005 "vos : partition %s does not exist on the server\n",
4006 as
->parms
[1].items
->data
);
4009 code
= VLDB_GetEntryByID(volid
, -1, &entry
);
4011 if (volid
== entry
.volumeId
[RWVOL
])
4012 backupid
= entry
.volumeId
[BACKVOL
];
4014 "Warning: Entry for volume number %lu exists in VLDB (but we're zapping it anyway!)\n",
4015 (unsigned long)volid
);
4018 volintInfo
*pntr
= (volintInfo
*) 0;
4021 code
= UV_ListOneVolume(server
, part
, volid
, &pntr
);
4023 if (volid
== pntr
->parentID
)
4024 backupid
= pntr
->backupID
;
4030 code
= UV_VolumeZap(server
, part
, backupid
);
4032 PrintDiagnostics("zap", code
);
4035 fprintf(STDOUT
, "Backup Volume %lu deleted\n",
4036 (unsigned long)backupid
);
4039 code
= UV_VolumeZap(server
, part
, volid
);
4041 PrintDiagnostics("zap", code
);
4044 fprintf(STDOUT
, "Volume %lu deleted\n", (unsigned long)volid
);
4050 VolserStatus(struct cmd_syndesc
*as
, void *arock
)
4054 transDebugInfo
*pntr
, *oldpntr
;
4060 server
= GetServer(as
->parms
[0].items
->data
);
4062 fprintf(STDERR
, "vos: host '%s' not found in host table\n",
4063 as
->parms
[0].items
->data
);
4066 code
= UV_VolserStatus(server
, &pntr
, &count
);
4068 PrintDiagnostics("status", code
);
4073 fprintf(STDOUT
, "No active transactions on %s\n",
4074 as
->parms
[0].items
->data
);
4076 fprintf(STDOUT
, "Total transactions: %d\n", count
);
4078 for (i
= 0; i
< count
; i
++) {
4079 /*print out the relevant info */
4080 fprintf(STDOUT
, "--------------------------------------\n");
4081 t
= pntr
->creationTime
;
4082 fprintf(STDOUT
, "transaction: %lu created: %s",
4083 (unsigned long)pntr
->tid
, ctime(&t
));
4085 fprintf(STDOUT
, "lastActiveTime: %s", ctime(&t
));
4086 if (pntr
->returnCode
) {
4087 fprintf(STDOUT
, "returnCode: %lu\n",
4088 (unsigned long)pntr
->returnCode
);
4091 fprintf(STDOUT
, "attachFlags: ");
4092 switch (pntr
->iflags
) {
4094 fprintf(STDOUT
, "offline ");
4097 fprintf(STDOUT
, "busy ");
4100 fprintf(STDOUT
, "readonly ");
4103 fprintf(STDOUT
, "create ");
4106 fprintf(STDOUT
, "create volid ");
4109 fprintf(STDOUT
, "\n");
4112 fprintf(STDOUT
, "volumeStatus: ");
4113 switch (pntr
->vflags
) {
4114 case VTDeleteOnSalvage
:
4115 fprintf(STDOUT
, "deleteOnSalvage ");
4116 case VTOutOfService
:
4117 fprintf(STDOUT
, "outOfService ");
4119 fprintf(STDOUT
, "deleted ");
4121 fprintf(STDOUT
, "\n");
4124 fprintf(STDOUT
, "transactionFlags: ");
4125 fprintf(STDOUT
, "delete\n");
4127 MapPartIdIntoName(pntr
->partition
, pname
);
4128 fprintf(STDOUT
, "volume: %lu partition: %s procedure: %s\n",
4129 (unsigned long)pntr
->volid
, pname
, pntr
->lastProcName
);
4130 if (pntr
->callValid
) {
4131 t
= pntr
->lastReceiveTime
;
4132 fprintf(STDOUT
, "packetRead: %lu lastReceiveTime: %s",
4133 (unsigned long)pntr
->readNext
, ctime(&t
));
4134 t
= pntr
->lastSendTime
;
4135 fprintf(STDOUT
, "packetSend: %lu lastSendTime: %s",
4136 (unsigned long)pntr
->transmitNext
, ctime(&t
));
4139 fprintf(STDOUT
, "--------------------------------------\n");
4140 fprintf(STDOUT
, "\n");
4148 RenameVolume(struct cmd_syndesc
*as
, void *arock
)
4150 afs_int32 code1
, code2
, code
;
4151 struct nvldbentry entry
;
4153 code1
= VLDB_GetEntryByName(as
->parms
[0].items
->data
, &entry
);
4155 fprintf(STDERR
, "vos: Could not find entry for volume %s\n",
4156 as
->parms
[0].items
->data
);
4159 code2
= VLDB_GetEntryByName(as
->parms
[1].items
->data
, &entry
);
4160 if ((!code1
) && (!code2
)) { /*the newname already exists */
4161 fprintf(STDERR
, "vos: volume %s already exists\n",
4162 as
->parms
[1].items
->data
);
4166 if (code1
&& code2
) {
4167 fprintf(STDERR
, "vos: Could not find entry for volume %s or %s\n",
4168 as
->parms
[0].items
->data
, as
->parms
[1].items
->data
);
4171 if (!VolNameOK(as
->parms
[0].items
->data
)) {
4173 "Illegal volume name %s, should not end in .readonly or .backup\n",
4174 as
->parms
[0].items
->data
);
4177 if (!ISNAMEVALID(as
->parms
[1].items
->data
)) {
4179 "vos: the new volume name %s exceeds the size limit of %d\n",
4180 as
->parms
[1].items
->data
, VOLSER_OLDMAXVOLNAME
- 10);
4183 if (!VolNameOK(as
->parms
[1].items
->data
)) {
4185 "Illegal volume name %s, should not end in .readonly or .backup\n",
4186 as
->parms
[1].items
->data
);
4189 if (IsNumeric(as
->parms
[1].items
->data
)) {
4190 fprintf(STDERR
, "Illegal volume name %s, should not be a number\n",
4191 as
->parms
[1].items
->data
);
4194 MapHostToNetwork(&entry
);
4196 UV_RenameVolume(&entry
, as
->parms
[0].items
->data
,
4197 as
->parms
[1].items
->data
);
4199 PrintDiagnostics("rename", code
);
4202 fprintf(STDOUT
, "Renamed volume %s to %s\n", as
->parms
[0].items
->data
,
4203 as
->parms
[1].items
->data
);
4208 GetVolumeInfo(afs_uint32 volid
, afs_uint32
*server
, afs_int32
*part
, afs_int32
*voltype
,
4209 struct nvldbentry
*rentry
)
4214 vcode
= VLDB_GetEntryByID(volid
, -1, rentry
);
4217 "Could not fetch the entry for volume %lu from VLDB \n",
4218 (unsigned long)volid
);
4219 PrintError("", vcode
);
4222 MapHostToNetwork(rentry
);
4223 if (volid
== rentry
->volumeId
[ROVOL
]) {
4225 for (i
= 0; i
< rentry
->nServers
; i
++) {
4226 if ((index
== -1) && (rentry
->serverFlags
[i
] & ITSROVOL
)
4227 && !(rentry
->serverFlags
[i
] & RO_DONTUSE
))
4232 "RO volume is not found in VLDB entry for volume %lu\n",
4233 (unsigned long)volid
);
4237 *server
= rentry
->serverNumber
[index
];
4238 *part
= rentry
->serverPartition
[index
];
4242 index
= Lp_GetRwIndex(rentry
);
4245 "RW Volume is not found in VLDB entry for volume %lu\n",
4246 (unsigned long)volid
);
4249 if (volid
== rentry
->volumeId
[RWVOL
]) {
4251 *server
= rentry
->serverNumber
[index
];
4252 *part
= rentry
->serverPartition
[index
];
4255 if (volid
== rentry
->volumeId
[BACKVOL
]) {
4257 *server
= rentry
->serverNumber
[index
];
4258 *part
= rentry
->serverPartition
[index
];
4262 "unexpected volume type for volume %lu\n",
4263 (unsigned long)volid
);
4268 DeleteEntry(struct cmd_syndesc
*as
, void *arock
)
4270 afs_int32 apart
= 0;
4273 struct VldbListByAttributes attributes
;
4274 nbulkentries arrayEntries
;
4275 struct nvldbentry
*vllist
;
4276 struct cmd_item
*itp
;
4279 char prefix
[VOLSER_MAXVOLNAME
+ 1];
4281 afs_int32 totalBack
= 0, totalFail
= 0, err
;
4283 if (as
->parms
[0].items
) { /* -id */
4284 if (as
->parms
[1].items
|| as
->parms
[2].items
|| as
->parms
[3].items
) {
4286 "You cannot use -server, -partition, or -prefix with the -id argument\n");
4289 for (itp
= as
->parms
[0].items
; itp
; itp
= itp
->next
) {
4290 avolid
= vsu_GetVolumeID(itp
->data
, cstruct
, &err
);
4293 PrintError("", err
);
4295 fprintf(STDERR
, "vos: can't find volume '%s'\n",
4299 if (as
->parms
[4].items
|| as
->parms
[5].items
) {
4300 /* -noexecute (hidden) or -dryrun */
4301 fprintf(STDOUT
, "Would have deleted VLDB entry for %s \n",
4306 vcode
= ubik_VL_DeleteEntry(cstruct
, 0, avolid
, RWVOL
);
4308 fprintf(STDERR
, "Could not delete entry for volume %s\n",
4311 "You must specify a RW volume name or ID "
4312 "(the entire VLDB entry will be deleted)\n");
4313 PrintError("", vcode
);
4319 fprintf(STDOUT
, "Deleted %d VLDB entries\n", totalBack
);
4323 if (!as
->parms
[1].items
&& !as
->parms
[2].items
&& !as
->parms
[3].items
) {
4324 fprintf(STDERR
, "You must specify an option\n");
4328 /* Zero out search attributes */
4329 memset(&attributes
, 0, sizeof(struct VldbListByAttributes
));
4331 if (as
->parms
[1].items
) { /* -prefix */
4332 strncpy(prefix
, as
->parms
[1].items
->data
, VOLSER_MAXVOLNAME
);
4334 if (!as
->parms
[2].items
&& !as
->parms
[3].items
) { /* a single entry only */
4336 "You must provide -server with the -prefix argument\n");
4341 if (as
->parms
[2].items
) { /* -server */
4343 aserver
= GetServer(as
->parms
[2].items
->data
);
4345 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
4346 as
->parms
[2].items
->data
);
4349 attributes
.server
= ntohl(aserver
);
4350 attributes
.Mask
|= VLLIST_SERVER
;
4353 if (as
->parms
[3].items
) { /* -partition */
4354 if (!as
->parms
[2].items
) {
4356 "You must provide -server with the -partition argument\n");
4359 apart
= volutil_GetPartitionID(as
->parms
[3].items
->data
);
4361 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
4362 as
->parms
[3].items
->data
);
4365 attributes
.partition
= apart
;
4366 attributes
.Mask
|= VLLIST_PARTITION
;
4369 /* Print status line of what we are doing */
4370 fprintf(STDOUT
, "Deleting VLDB entries for ");
4371 if (as
->parms
[2].items
) {
4372 fprintf(STDOUT
, "server %s ", as
->parms
[2].items
->data
);
4374 if (as
->parms
[3].items
) {
4376 MapPartIdIntoName(apart
, pname
);
4377 fprintf(STDOUT
, "partition %s ", pname
);
4380 fprintf(STDOUT
, "which are prefixed with %s ", prefix
);
4382 fprintf(STDOUT
, "\n");
4385 /* Get all the VLDB entries on a server and/or partition */
4386 memset(&arrayEntries
, 0, sizeof(arrayEntries
));
4387 vcode
= VLDB_ListAttributes(&attributes
, &nentries
, &arrayEntries
);
4389 fprintf(STDERR
, "Could not access the VLDB for attributes\n");
4390 PrintError("", vcode
);
4394 /* Process each entry */
4395 for (j
= 0; j
< nentries
; j
++) {
4396 vllist
= &arrayEntries
.nbulkentries_val
[j
];
4398 /* It only deletes the RW volumes */
4399 if (strncmp(vllist
->name
, prefix
, strlen(prefix
))) {
4402 "Omitting to delete %s due to prefix %s mismatch\n",
4403 vllist
->name
, prefix
);
4410 if (as
->parms
[4].items
|| as
->parms
[5].items
) {
4411 /* -noexecute (hidden) or -dryrun */
4412 fprintf(STDOUT
, "Would have deleted VLDB entry for %s \n",
4418 /* Only matches the RW volume name */
4419 avolid
= vllist
->volumeId
[RWVOL
];
4420 vcode
= ubik_VL_DeleteEntry(cstruct
, 0, avolid
, RWVOL
);
4422 fprintf(STDOUT
, "Could not delete VLDB entry for %s\n",
4425 PrintError("", vcode
);
4430 fprintf(STDOUT
, "Deleted VLDB entry for %s \n", vllist
->name
);
4435 fprintf(STDOUT
, "----------------------\n");
4437 "Total VLDB entries deleted: %lu; failed to delete: %lu\n",
4438 (unsigned long)totalBack
, (unsigned long)totalFail
);
4440 xdr_free((xdrproc_t
) xdr_nbulkentries
, &arrayEntries
);
4446 CompareVldbEntryByName(const void *p1
, const void *p2
)
4448 struct nvldbentry
*arg1
, *arg2
;
4450 arg1
= (struct nvldbentry
*)p1
;
4451 arg2
= (struct nvldbentry
*)p2
;
4452 return (strcmp(arg1
->name
, arg2
->name
));
4456 static int CompareVldbEntry(char *p1, char *p2)
4458 struct nvldbentry *arg1,*arg2;
4461 char comp1[100],comp2[100];
4462 char temp1[20],temp2[20];
4464 arg1 = (struct nvldbentry *)p1;
4465 arg2 = (struct nvldbentry *)p2;
4469 for(i = 0; i < arg1->nServers; i++)
4470 if(arg1->serverFlags[i] & ITSRWVOL) pos1 = i;
4471 for(i = 0; i < arg2->nServers; i++)
4472 if(arg2->serverFlags[i] & ITSRWVOL) pos2 = i;
4473 if(pos1 == -1 || pos2 == -1){
4477 sprintf(comp1,"%10u",arg1->serverNumber[pos1]);
4478 sprintf(comp2,"%10u",arg2->serverNumber[pos2]);
4479 sprintf(temp1,"%10u",arg1->serverPartition[pos1]);
4480 sprintf(temp2,"%10u",arg2->serverPartition[pos2]);
4481 strcat(comp1,temp1);
4482 strcat(comp2,temp2);
4483 strcat(comp1,arg1->name);
4484 strcat(comp1,arg2->name);
4485 return(strcmp(comp1,comp2));
4491 ListVLDB(struct cmd_syndesc
*as
, void *arock
)
4497 struct VldbListByAttributes attributes
;
4498 nbulkentries arrayEntries
;
4499 struct nvldbentry
*vllist
, *tarray
= 0, *ttarray
;
4500 afs_int32 centries
, nentries
= 0;
4501 afs_int32 tarraysize
= 0;
4502 afs_int32 parraysize
;
4505 int quiet
, sort
, lock
;
4506 afs_int32 thisindex
, nextindex
;
4511 memset(&attributes
, 0, sizeof(attributes
));
4512 lock
= (as
->parms
[3].items
? 1 : 0); /* -lock flag */
4513 quiet
= (as
->parms
[4].items
? 1 : 0); /* -quit flag */
4514 sort
= (as
->parms
[5].items
? 0 : 1); /* -nosort flag */
4516 /* If the volume name is given, Use VolumeInfoCmd to look it up
4517 * and not ListAttributes.
4519 if (as
->parms
[0].items
) {
4522 "vos: illegal use of '-locked' switch, need to specify server and/or partition\n");
4525 code
= VolumeInfoCmd(as
->parms
[0].items
->data
);
4527 PrintError("", code
);
4533 /* Server specified */
4534 if (as
->parms
[1].items
) {
4535 aserver
= GetServer(as
->parms
[1].items
->data
);
4537 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
4538 as
->parms
[1].items
->data
);
4541 attributes
.server
= ntohl(aserver
);
4542 attributes
.Mask
|= VLLIST_SERVER
;
4545 /* Partition specified */
4546 if (as
->parms
[2].items
) {
4547 apart
= volutil_GetPartitionID(as
->parms
[2].items
->data
);
4549 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
4550 as
->parms
[2].items
->data
);
4553 attributes
.partition
= apart
;
4554 attributes
.Mask
|= VLLIST_PARTITION
;
4558 attributes
.Mask
|= VLLIST_FLAG
;
4559 attributes
.flag
= VLOP_ALLOPERS
;
4562 /* Print header information */
4564 MapPartIdIntoName(apart
, pname
);
4565 fprintf(STDOUT
, "VLDB entries for %s %s%s%s %s\n",
4566 (as
->parms
[1].items
? "server" : "all"),
4567 (as
->parms
[1].items
? as
->parms
[1].items
->data
: "servers"),
4568 (as
->parms
[2].items
? " partition " : ""),
4569 (as
->parms
[2].items
? pname
: ""),
4570 (lock
? "which are locked:" : ""));
4573 for (thisindex
= 0; (thisindex
!= -1); thisindex
= nextindex
) {
4574 memset(&arrayEntries
, 0, sizeof(arrayEntries
));
4579 VLDB_ListAttributesN2(&attributes
, 0, thisindex
, ¢ries
,
4580 &arrayEntries
, &nextindex
);
4581 if (vcode
== RXGEN_OPCODE
) {
4582 /* Vlserver not running with ListAttributesN2. Fall back */
4584 VLDB_ListAttributes(&attributes
, ¢ries
, &arrayEntries
);
4588 fprintf(STDERR
, "Could not access the VLDB for attributes\n");
4589 PrintError("", vcode
);
4592 nentries
+= centries
;
4594 /* We don't sort, so just print the entries now */
4596 for (j
= 0; j
< centries
; j
++) { /* process each entry */
4597 vllist
= &arrayEntries
.nbulkentries_val
[j
];
4598 MapHostToNetwork(vllist
);
4599 EnumerateEntry(vllist
);
4601 PrintLocked(vllist
->flags
);
4605 /* So we sort. First we must collect all the entries and keep
4608 else if (centries
> 0) {
4610 /* malloc the first bulk entries array */
4611 tarraysize
= centries
* sizeof(struct nvldbentry
);
4612 tarray
= malloc(tarraysize
);
4615 "Could not allocate enough space for the VLDB entries\n");
4618 memcpy((char*)tarray
, arrayEntries
.nbulkentries_val
, tarraysize
);
4620 /* Grow the tarray to keep the extra entries */
4621 parraysize
= (centries
* sizeof(struct nvldbentry
));
4623 (struct nvldbentry
*)realloc(tarray
,
4624 tarraysize
+ parraysize
);
4627 "Could not allocate enough space for the VLDB entries\n");
4633 memcpy(((char *)tarray
) + tarraysize
,
4634 (char *)arrayEntries
.nbulkentries_val
, parraysize
);
4635 tarraysize
+= parraysize
;
4639 /* Free the bulk array */
4640 xdr_free((xdrproc_t
) xdr_nbulkentries
, &arrayEntries
);
4643 /* Here is where we now sort all the entries and print them */
4644 if (sort
&& (nentries
> 0)) {
4645 qsort((char *)tarray
, nentries
, sizeof(struct nvldbentry
),
4646 CompareVldbEntryByName
);
4647 for (vllist
= tarray
, j
= 0; j
< nentries
; j
++, vllist
++) {
4648 MapHostToNetwork(vllist
);
4649 EnumerateEntry(vllist
);
4651 PrintLocked(vllist
->flags
);
4657 fprintf(STDOUT
, "\nTotal entries: %lu\n", (unsigned long)nentries
);
4664 BackSys(struct cmd_syndesc
*as
, void *arock
)
4667 afs_int32 apart
= 0;
4668 afs_uint32 aserver
= 0, aserver1
;
4669 afs_int32 code
, apart1
;
4671 struct VldbListByAttributes attributes
;
4672 nbulkentries arrayEntries
;
4673 struct nvldbentry
*vllist
;
4677 int seenprefix
, seenxprefix
, exclude
, ex
, exp
, noaction
;
4678 afs_int32 totalBack
= 0;
4679 afs_int32 totalFail
= 0;
4683 struct cmd_item
*ti
;
4685 #ifndef HAVE_POSIX_REGEX
4689 memset(&attributes
, 0, sizeof(struct VldbListByAttributes
));
4690 attributes
.Mask
= 0;
4692 seenprefix
= (as
->parms
[0].items
? 1 : 0);
4693 exclude
= (as
->parms
[3].items
? 1 : 0);
4694 seenxprefix
= (as
->parms
[4].items
? 1 : 0);
4695 noaction
= (as
->parms
[5].items
? 1 : 0);
4697 if (as
->parms
[1].items
) { /* -server */
4698 aserver
= GetServer(as
->parms
[1].items
->data
);
4700 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
4701 as
->parms
[1].items
->data
);
4704 attributes
.server
= ntohl(aserver
);
4705 attributes
.Mask
|= VLLIST_SERVER
;
4708 if (as
->parms
[2].items
) { /* -partition */
4709 apart
= volutil_GetPartitionID(as
->parms
[2].items
->data
);
4711 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
4712 as
->parms
[2].items
->data
);
4715 attributes
.partition
= apart
;
4716 attributes
.Mask
|= VLLIST_PARTITION
;
4719 /* Check to make sure the prefix and xprefix expressions compile ok */
4721 for (ti
= as
->parms
[0].items
; ti
; ti
= ti
->next
) {
4722 if (strncmp(ti
->data
, "^", 1) == 0) {
4723 #ifdef HAVE_POSIX_REGEX
4727 code
= regcomp(&re
, ti
->data
, REG_NOSUB
);
4729 regerror(code
, &re
, errbuf
, sizeof errbuf
);
4731 "Unrecognizable -prefix regular expression: '%s': %s\n",
4737 ccode
= (char *)re_comp(ti
->data
);
4740 "Unrecognizable -prefix regular expression: '%s': %s\n",
4749 for (ti
= as
->parms
[4].items
; ti
; ti
= ti
->next
) {
4750 if (strncmp(ti
->data
, "^", 1) == 0) {
4751 #ifdef HAVE_POSIX_REGEX
4755 code
= regcomp(&re
, ti
->data
, REG_NOSUB
);
4757 regerror(code
, &re
, errbuf
, sizeof errbuf
);
4759 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4765 ccode
= (char *)re_comp(ti
->data
);
4768 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4777 memset(&arrayEntries
, 0, sizeof(arrayEntries
)); /* initialize to hint the stub to alloc space */
4778 vcode
= VLDB_ListAttributes(&attributes
, &nentries
, &arrayEntries
);
4780 fprintf(STDERR
, "Could not access the VLDB for attributes\n");
4781 PrintError("", vcode
);
4785 if (as
->parms
[1].items
|| as
->parms
[2].items
|| verbose
) {
4786 fprintf(STDOUT
, "%s up volumes",
4787 (noaction
? "Would have backed" : "Backing"));
4789 if (as
->parms
[1].items
) {
4790 fprintf(STDOUT
, " on server %s", as
->parms
[1].items
->data
);
4791 } else if (as
->parms
[2].items
) {
4792 fprintf(STDOUT
, " for all servers");
4795 if (as
->parms
[2].items
) {
4796 MapPartIdIntoName(apart
, pname
);
4797 fprintf(STDOUT
, " partition %s", pname
);
4800 if (seenprefix
|| (!seenprefix
&& seenxprefix
)) {
4801 ti
= (seenprefix
? as
->parms
[0].items
: as
->parms
[4].items
);
4802 ex
= (seenprefix
? exclude
: !exclude
);
4803 exp
= (strncmp(ti
->data
, "^", 1) == 0);
4804 fprintf(STDOUT
, " which %smatch %s '%s'", (ex
? "do not " : ""),
4805 (exp
? "expression" : "prefix"), ti
->data
);
4806 for (ti
= ti
->next
; ti
; ti
= ti
->next
) {
4807 exp
= (strncmp(ti
->data
, "^", 1) == 0);
4808 printf(" %sor %s '%s'", (ex
? "n" : ""),
4809 (exp
? "expression" : "prefix"), ti
->data
);
4813 if (seenprefix
&& seenxprefix
) {
4814 ti
= as
->parms
[4].items
;
4815 exp
= (strncmp(ti
->data
, "^", 1) == 0);
4816 fprintf(STDOUT
, " %swhich match %s '%s'",
4817 (exclude
? "adding those " : "removing those "),
4818 (exp
? "expression" : "prefix"), ti
->data
);
4819 for (ti
= ti
->next
; ti
; ti
= ti
->next
) {
4820 exp
= (strncmp(ti
->data
, "^", 1) == 0);
4821 printf(" or %s '%s'", (exp
? "expression" : "prefix"),
4825 fprintf(STDOUT
, " .. ");
4827 fprintf(STDOUT
, "\n");
4831 for (j
= 0; j
< nentries
; j
++) { /* process each vldb entry */
4832 vllist
= &arrayEntries
.nbulkentries_val
[j
];
4835 for (ti
= as
->parms
[0].items
; ti
; ti
= ti
->next
) {
4836 if (strncmp(ti
->data
, "^", 1) == 0) {
4837 #ifdef HAVE_POSIX_REGEX
4841 /* XXX -- should just do the compile once! */
4842 code
= regcomp(&re
, ti
->data
, REG_NOSUB
);
4844 regerror(code
, &re
, errbuf
, sizeof errbuf
);
4846 "Error in -prefix regular expression: '%s': %s\n",
4850 match
= (regexec(&re
, vllist
->name
, 0, NULL
, 0) == 0);
4853 ccode
= (char *)re_comp(ti
->data
);
4856 "Error in -prefix regular expression: '%s': %s\n",
4860 match
= (re_exec(vllist
->name
) == 1);
4864 (strncmp(vllist
->name
, ti
->data
, strlen(ti
->data
)) ==
4874 /* Without the -exclude flag: If it matches the prefix, then
4875 * check if we want to exclude any from xprefix.
4876 * With the -exclude flag: If it matches the prefix, then
4877 * check if we want to add any from xprefix.
4879 if (match
&& seenxprefix
) {
4880 for (ti
= as
->parms
[4].items
; ti
; ti
= ti
->next
) {
4881 if (strncmp(ti
->data
, "^", 1) == 0) {
4882 #ifdef HAVE_POSIX_REGEX
4886 /* XXX -- should just do the compile once! */
4887 code
= regcomp(&re
, ti
->data
, REG_NOSUB
);
4889 regerror(code
, &re
, errbuf
, sizeof errbuf
);
4891 "Error in -xprefix regular expression: '%s': %s\n",
4895 if (regexec(&re
, vllist
->name
, 0, NULL
, 0) == 0)
4899 ccode
= (char *)re_comp(ti
->data
);
4902 "Error in -xprefix regular expression: '%s': %s\n",
4906 if (re_exec(vllist
->name
) == 1) {
4912 if (strncmp(vllist
->name
, ti
->data
, strlen(ti
->data
)) ==
4922 match
= !match
; /* -exclude will reverse the match */
4924 continue; /* Skip if no match */
4926 /* Print list of volumes to backup */
4928 fprintf(STDOUT
, " %s\n", vllist
->name
);
4932 if (!(vllist
->flags
& RW_EXISTS
)) {
4935 "Omitting to backup %s since RW volume does not exist \n",
4937 fprintf(STDOUT
, "\n");
4943 avolid
= vllist
->volumeId
[RWVOL
];
4944 MapHostToNetwork(vllist
);
4945 GetServerAndPart(vllist
, RWVOL
, &aserver1
, &apart1
, &previdx
);
4946 if (aserver1
== -1 || apart1
== -1) {
4947 fprintf(STDOUT
, "could not backup %s, invalid VLDB entry\n",
4953 same
= VLDB_IsSameAddrs(aserver
, aserver1
, &error
);
4956 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
4962 if ((aserver
&& !same
) || (apart
&& (apart
!= apart1
))) {
4965 "Omitting to backup %s since the RW is in a different location\n",
4971 time_t now
= time(0);
4972 fprintf(STDOUT
, "Creating backup volume for %s on %s",
4973 vllist
->name
, ctime(&now
));
4977 code
= UV_BackupVolume(aserver1
, apart1
, avolid
);
4979 fprintf(STDOUT
, "Could not backup %s\n", vllist
->name
);
4985 fprintf(STDOUT
, "\n");
4987 } /* process each vldb entry */
4988 fprintf(STDOUT
, "done\n");
4989 fprintf(STDOUT
, "Total volumes backed up: %lu; failed to backup: %lu\n",
4990 (unsigned long)totalBack
, (unsigned long)totalFail
);
4992 xdr_free((xdrproc_t
) xdr_nbulkentries
, &arrayEntries
);
4997 UnlockVLDB(struct cmd_syndesc
*as
, void *arock
)
5000 afs_uint32 aserver
= 0;
5003 struct VldbListByAttributes attributes
;
5004 nbulkentries arrayEntries
;
5005 struct nvldbentry
*vllist
;
5014 memset(&attributes
, 0, sizeof(attributes
));
5016 if (as
->parms
[0].items
) { /* server specified */
5017 aserver
= GetServer(as
->parms
[0].items
->data
);
5019 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
5020 as
->parms
[0].items
->data
);
5023 attributes
.server
= ntohl(aserver
);
5024 attributes
.Mask
|= VLLIST_SERVER
;
5026 if (as
->parms
[1].items
) { /* partition specified */
5027 apart
= volutil_GetPartitionID(as
->parms
[1].items
->data
);
5029 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
5030 as
->parms
[1].items
->data
);
5033 if (!IsPartValid(apart
, aserver
, &code
)) { /*check for validity of the partition */
5035 PrintError("", code
);
5038 "vos : partition %s does not exist on the server\n",
5039 as
->parms
[1].items
->data
);
5042 attributes
.partition
= apart
;
5043 attributes
.Mask
|= VLLIST_PARTITION
;
5045 attributes
.flag
= VLOP_ALLOPERS
;
5046 attributes
.Mask
|= VLLIST_FLAG
;
5047 memset(&arrayEntries
, 0, sizeof(arrayEntries
)); /*initialize to hint the stub to alloc space */
5048 vcode
= VLDB_ListAttributes(&attributes
, &nentries
, &arrayEntries
);
5050 fprintf(STDERR
, "Could not access the VLDB for attributes\n");
5051 PrintError("", vcode
);
5054 for (j
= 0; j
< nentries
; j
++) { /* process each entry */
5055 vllist
= &arrayEntries
.nbulkentries_val
[j
];
5056 volid
= vllist
->volumeId
[RWVOL
];
5058 ubik_VL_ReleaseLock(cstruct
, 0, volid
, -1,
5059 LOCKREL_OPCODE
| LOCKREL_AFSID
|
5062 fprintf(STDERR
, "Could not unlock entry for volume %s\n",
5064 PrintError("", vcode
);
5069 MapPartIdIntoName(apart
, pname
);
5072 "Could not lock %lu VLDB entries of %lu locked entries\n",
5073 (unsigned long)totalE
, (unsigned long)nentries
);
5075 if (as
->parms
[0].items
) {
5077 "Unlocked all the VLDB entries for volumes on server %s ",
5078 as
->parms
[0].items
->data
);
5079 if (as
->parms
[1].items
) {
5080 MapPartIdIntoName(apart
, pname
);
5081 fprintf(STDOUT
, "partition %s\n", pname
);
5083 fprintf(STDOUT
, "\n");
5085 } else if (as
->parms
[1].items
) {
5086 MapPartIdIntoName(apart
, pname
);
5088 "Unlocked all the VLDB entries for volumes on partition %s on all servers\n",
5093 xdr_free((xdrproc_t
) xdr_nbulkentries
, &arrayEntries
);
5098 PrintInt64Size(afs_uint64 in
)
5102 static char output
[16];
5104 SplitInt64(in
,hi
,lo
);
5108 } else if (!(hi
& 0xFFFFFC00)) {
5110 lo
= (hi
<< 22) | (lo
>> 10);
5111 } else if (!(hi
& 0xFFF00000)) {
5113 lo
= (hi
<< 12) | (lo
>> 20);
5114 } else if (!(hi
& 0xC0000000)) {
5116 lo
= (hi
<< 2) | (lo
>> 30);
5121 sprintf(output
,"%u %s", lo
, units
);
5126 PartitionInfo(struct cmd_syndesc
*as
, void *arock
)
5132 struct diskPartition64 partition
;
5133 struct partList dummyPartList
;
5135 int printSummary
=0, sumPartitions
=0;
5136 afs_uint64 sumFree
, sumStorage
;
5139 ZeroInt64(sumStorage
);
5141 aserver
= GetServer(as
->parms
[0].items
->data
);
5143 fprintf(STDERR
, "vos: server '%s' not found in host table\n",
5144 as
->parms
[0].items
->data
);
5147 if (as
->parms
[1].items
) {
5148 apart
= volutil_GetPartitionID(as
->parms
[1].items
->data
);
5150 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
5151 as
->parms
[1].items
->data
);
5154 dummyPartList
.partId
[0] = apart
;
5155 dummyPartList
.partFlags
[0] = PARTVALID
;
5158 if (as
->parms
[2].items
) {
5162 if (!IsPartValid(apart
, aserver
, &code
)) { /*check for validity of the partition */
5164 PrintError("", code
);
5167 "vos : partition %s does not exist on the server\n",
5168 as
->parms
[1].items
->data
);
5172 code
= UV_ListPartitions(aserver
, &dummyPartList
, &cnt
);
5174 PrintDiagnostics("listpart", code
);
5178 for (i
= 0; i
< cnt
; i
++) {
5179 if (dummyPartList
.partFlags
[i
] & PARTVALID
) {
5180 MapPartIdIntoName(dummyPartList
.partId
[i
], pname
);
5181 code
= UV_PartitionInfo64(aserver
, pname
, &partition
);
5183 fprintf(STDERR
, "Could not get information on partition %s\n",
5185 PrintError("", code
);
5189 "Free space on partition %s: %" AFS_INT64_FMT
" K blocks out of total %" AFS_INT64_FMT
"\n",
5190 pname
, partition
.free
, partition
.minFree
);
5192 AddUInt64(sumFree
,partition
.free
,&sumFree
);
5193 AddUInt64(sumStorage
,partition
.minFree
,&sumStorage
);
5198 "Summary: %s free out of ",
5199 PrintInt64Size(sumFree
));
5201 "%s on %d partitions\n",
5202 PrintInt64Size(sumStorage
),
5209 ChangeAddr(struct cmd_syndesc
*as
, void *arock
)
5211 afs_int32 ip1
, ip2
, vcode
;
5216 ip1
= GetServerNoresolve(as
->parms
[0].items
->data
);
5218 ip1
= GetServer(as
->parms
[0].items
->data
);
5220 fprintf(STDERR
, "vos: invalid host address\n");
5224 if ((as
->parms
[1].items
&& as
->parms
[2].items
)
5225 || (!as
->parms
[1].items
&& !as
->parms
[2].items
)) {
5227 "vos: Must specify either '-newaddr <addr>' or '-remove' flag\n");
5231 if (as
->parms
[3].items
) {
5235 if (as
->parms
[1].items
) {
5237 ip2
= GetServerNoresolve(as
->parms
[1].items
->data
);
5239 ip2
= GetServer(as
->parms
[1].items
->data
);
5241 fprintf(STDERR
, "vos: invalid host address\n");
5245 /* Play a trick here. If we are removing an address, ip1 will be -1
5246 * and ip2 will be the original address. This switch prevents an
5247 * older revision vlserver from removing the IP address.
5254 if (!remove
&& !force
) {
5255 afs_int32 m_nentries
;
5257 afs_int32 m_uniq
= 0;
5259 ListAddrByAttributes m_attrs
;
5262 memset(&m_attrs
, 0, sizeof(m_attrs
));
5263 memset(&m_uuid
, 0, sizeof(m_uuid
));
5264 memset(&m_addrs
, 0, sizeof(m_addrs
));
5265 memset(buffer
, 0, sizeof(buffer
));
5267 m_attrs
.Mask
= VLADDR_IPADDR
;
5268 m_attrs
.ipaddr
= ntohl(ip1
); /* -oldaddr */
5271 ubik_VL_GetAddrsU(cstruct
, UBIK_CALL_NEW
, &m_attrs
, &m_uuid
,
5272 &m_uniq
, &m_nentries
, &m_addrs
);
5273 xdr_free((xdrproc_t
) xdr_bulkaddrs
, &m_addrs
);
5275 case 0: /* mh entry detected */
5276 afsUUID_to_string(&m_uuid
, buffer
, sizeof(buffer
) - 1);
5277 fprintf(STDERR
, "vos: Refusing to change address in multi-homed server entry.\n");
5278 fprintf(STDERR
, " -oldaddr address is registered to file server UUID %s\n", buffer
);
5279 fprintf(STDERR
, " Please restart the file server or use vos setaddrs.\n");
5284 fprintf(STDERR
, "vos: could not list the server addresses\n");
5285 PrintError("", vcode
);
5290 vcode
= ubik_VL_ChangeAddr(cstruct
, UBIK_CALL_NEW
, ntohl(ip1
), ntohl(ip2
));
5292 char hoststr1
[16], hoststr2
[16];
5294 afs_inet_ntoa_r(ip2
, hoststr2
);
5295 fprintf(STDERR
, "Could not remove server %s from the VLDB\n",
5297 if (vcode
== VL_NOENT
) {
5299 "vlserver does not support the remove flag or ");
5302 afs_inet_ntoa_r(ip1
, hoststr1
);
5303 afs_inet_ntoa_r(ip2
, hoststr2
);
5304 fprintf(STDERR
, "Could not change server %s to server %s\n",
5305 hoststr1
, hoststr2
);
5307 PrintError("", vcode
);
5312 fprintf(STDOUT
, "Removed server %s from the VLDB\n",
5313 as
->parms
[0].items
->data
);
5315 fprintf(STDOUT
, "Changed server %s to server %s\n",
5316 as
->parms
[0].items
->data
, as
->parms
[1].items
->data
);
5322 print_addrs(const bulkaddrs
* addrs
, afsUUID
* m_uuid
, int nentries
,
5330 afsUUID_to_string(m_uuid
, buf
, sizeof(buf
));
5331 printf("UUID: %s\n", buf
);
5334 /* print out the list of all the server */
5335 for (i
= 0; i
< addrs
->bulkaddrs_len
; i
++) {
5336 addr
= htonl(addrs
->bulkaddrs_val
[i
]);
5339 printf("%s\n", afs_inet_ntoa_r(addr
, hoststr
));
5341 printf("%s\n", hostutil_GetNameByINet(addr
));
5352 ListAddrs(struct cmd_syndesc
*as
, void *arock
)
5354 afs_int32 vcode
, m_uniq
=0;
5355 afs_int32 i
, printuuid
= 0;
5356 struct VLCallBack vlcb
;
5359 ListAddrByAttributes m_attrs
;
5360 afsUUID m_uuid
, askuuid
;
5361 afs_int32 m_nentries
;
5363 memset(&m_attrs
, 0, sizeof(struct ListAddrByAttributes
));
5364 m_attrs
.Mask
= VLADDR_INDEX
;
5366 memset(&askuuid
, 0, sizeof(afsUUID
));
5367 if (as
->parms
[0].items
) {
5369 if (afsUUID_from_string(as
->parms
[0].items
->data
, &askuuid
) < 0) {
5370 fprintf(STDERR
, "vos: invalid UUID '%s'\n",
5371 as
->parms
[0].items
->data
);
5374 m_attrs
.Mask
= VLADDR_UUID
;
5375 m_attrs
.uuid
= askuuid
;
5377 if (as
->parms
[1].items
) {
5381 he
= hostutil_GetHostByName((char *)as
->parms
[1].items
->data
);
5383 fprintf(STDERR
, "vos: Can't get host info for '%s'\n",
5384 as
->parms
[1].items
->data
);
5387 memcpy(&saddr
, he
->h_addr
, 4);
5388 m_attrs
.Mask
= VLADDR_IPADDR
;
5389 m_attrs
.ipaddr
= ntohl(saddr
);
5391 if (as
->parms
[2].items
) {
5395 memset(&m_addrs
, 0, sizeof(bulkaddrs
));
5396 memset(&vlcb
, 0, sizeof(struct VLCallBack
));
5399 ubik_VL_GetAddrs(cstruct
, UBIK_CALL_NEW
, 0, 0, &vlcb
, &nentries
,
5402 fprintf(STDERR
, "vos: could not list the server addresses\n");
5403 PrintError("", vcode
);
5412 xdr_free((xdrproc_t
)xdr_bulkaddrs
, &m_addrs
); /* reset addr list */
5414 ubik_VL_GetAddrsU(cstruct
, UBIK_CALL_NEW
, &m_attrs
, &m_uuid
,
5415 &m_uniq
, &m_nentries
, &m_addrs
);
5417 if (vcode
== VL_NOENT
) {
5418 if (m_attrs
.Mask
== VLADDR_UUID
) {
5419 fprintf(STDERR
, "vos: no entry for UUID '%s' found in VLDB\n",
5420 as
->parms
[0].items
->data
);
5422 } else if (m_attrs
.Mask
== VLADDR_IPADDR
) {
5423 fprintf(STDERR
, "vos: no entry for host '%s' [0x%08x] found in VLDB\n",
5424 as
->parms
[1].items
->data
, m_attrs
.ipaddr
);
5433 if (vcode
== VL_INDEXERANGE
) {
5434 vcode
= 0; /* not an error, just means we're done */
5439 fprintf(STDERR
, "vos: could not list the server addresses\n");
5440 PrintError("", vcode
);
5444 print_addrs(&m_addrs
, &m_uuid
, m_nentries
, printuuid
);
5447 if ((as
->parms
[1].items
) || (as
->parms
[0].items
) || (i
> nentries
))
5452 xdr_free((xdrproc_t
)xdr_bulkaddrs
, &m_addrs
);
5458 SetAddrs(struct cmd_syndesc
*as
, void *arock
)
5463 afs_uint32 FS_HostAddrs_HBO
[ADDRSPERSITE
];
5465 memset(&m_addrs
, 0, sizeof(bulkaddrs
));
5466 memset(&askuuid
, 0, sizeof(afsUUID
));
5467 if (as
->parms
[0].items
) {
5469 if (afsUUID_from_string(as
->parms
[0].items
->data
, &askuuid
) < 0) {
5470 fprintf(STDERR
, "vos: invalid UUID '%s'\n",
5471 as
->parms
[0].items
->data
);
5475 if (as
->parms
[1].items
) {
5477 struct cmd_item
*ti
;
5481 for (ti
= as
->parms
[1].items
; ti
&& i
< ADDRSPERSITE
; ti
= ti
->next
) {
5484 saddr
= GetServerNoresolve(ti
->data
);
5486 saddr
= GetServer(ti
->data
);
5489 fprintf(STDERR
, "vos: Can't get host info for '%s'\n",
5493 /* Convert it to host byte order */
5494 FS_HostAddrs_HBO
[i
] = ntohl(saddr
);
5497 m_addrs
.bulkaddrs_len
= i
;
5498 m_addrs
.bulkaddrs_val
= FS_HostAddrs_HBO
;
5501 vcode
= ubik_VL_RegisterAddrs(cstruct
, 0, &askuuid
, 0, &m_addrs
);
5504 if (vcode
== VL_MULTIPADDR
) {
5505 fprintf(STDERR
, "vos: VL_RegisterAddrs rpc failed; The IP address exists on a different server; repair it\n");
5506 } else if (vcode
== RXGEN_OPCODE
) {
5507 fprintf(STDERR
, "vlserver doesn't support VL_RegisterAddrs rpc; ignored\n");
5509 fprintf(STDERR
, "vos: VL_RegisterAddrs rpc failed\n");
5511 PrintError("", vcode
);
5515 fprintf(STDOUT
, "vos: Changed UUID with addresses:\n");
5516 print_addrs(&m_addrs
, &askuuid
, m_addrs
.bulkaddrs_len
, 1);
5522 RemoveAddrs(struct cmd_syndesc
*as
, void *arock
)
5525 ListAddrByAttributes attrs
;
5528 afs_int32 nentries
= 0;
5533 memset(&attrs
, 0, sizeof(ListAddrByAttributes
));
5534 memset(&addrs
, 0, sizeof(bulkaddrs
));
5535 memset(&uuid
, 0, sizeof(afsUUID
));
5536 attrs
.Mask
= VLADDR_UUID
;
5538 if (as
->parms
[0].items
) { /* -uuid */
5539 if (afsUUID_from_string(as
->parms
[0].items
->data
, &attrs
.uuid
) < 0) {
5540 fprintf(STDERR
, "vos: invalid UUID '%s'\n",
5541 as
->parms
[0].items
->data
);
5547 ubik_VL_GetAddrsU(cstruct
, UBIK_CALL_NEW
, &attrs
, &uuid
, &uniq
,
5549 if (code
== VL_NOENT
) {
5550 fprintf(STDERR
, "vos: UUID not found\n");
5554 fprintf(STDERR
, "vos: could not list the server addresses\n");
5555 PrintError("", code
);
5558 if (addrs
.bulkaddrs_len
== 0) {
5559 fprintf(STDERR
, "vos: no addresses found for UUID\n");
5563 ip2
= addrs
.bulkaddrs_val
[0]; /* network byte order */
5564 ip1
= 0xffffffff; /* indicates removal mode */
5567 printf("vos: Removing UUID with hosts:\n");
5568 print_addrs(&addrs
, &uuid
, nentries
, 1);
5571 code
= ubik_VL_ChangeAddr(cstruct
, UBIK_CALL_NEW
, ip1
, ip2
);
5573 fprintf(STDERR
, "Could not remove server entry from the VLDB.\n");
5574 PrintError("", code
);
5578 xdr_free((xdrproc_t
) xdr_bulkaddrs
, &addrs
);
5584 LockEntry(struct cmd_syndesc
*as
, void *arock
)
5587 afs_int32 vcode
, err
;
5589 avolid
= vsu_GetVolumeID(as
->parms
[0].items
->data
, cstruct
, &err
);
5592 PrintError("", err
);
5594 fprintf(STDERR
, "vos: can't find volume '%s'\n",
5595 as
->parms
[0].items
->data
);
5598 vcode
= ubik_VL_SetLock(cstruct
, 0, avolid
, -1, VLOP_DELETE
);
5600 fprintf(STDERR
, "Could not lock VLDB entry for volume %s\n",
5601 as
->parms
[0].items
->data
);
5602 PrintError("", vcode
);
5605 fprintf(STDOUT
, "Locked VLDB entry for volume %s\n",
5606 as
->parms
[0].items
->data
);
5611 ConvertRO(struct cmd_syndesc
*as
, void *arock
)
5613 afs_int32 partition
= -1;
5616 afs_int32 code
, i
, same
;
5617 struct nvldbentry entry
, checkEntry
, storeEntry
;
5619 afs_int32 rwindex
= 0;
5620 afs_uint32 rwserver
= 0;
5621 afs_int32 rwpartition
= 0;
5622 afs_int32 roindex
= 0;
5623 afs_uint32 roserver
= 0;
5624 afs_int32 ropartition
= 0;
5626 struct rx_connection
*aconn
;
5629 memset(&storeEntry
, 0, sizeof(struct nvldbentry
));
5631 server
= GetServer(as
->parms
[0].items
->data
);
5633 fprintf(STDERR
, "vos: host '%s' not found in host table\n",
5634 as
->parms
[0].items
->data
);
5637 partition
= volutil_GetPartitionID(as
->parms
[1].items
->data
);
5638 if (partition
< 0) {
5639 fprintf(STDERR
, "vos: could not interpret partition name '%s'\n",
5640 as
->parms
[1].items
->data
);
5643 if (!IsPartValid(partition
, server
, &code
)) {
5645 PrintError("", code
);
5648 "vos : partition %s does not exist on the server\n",
5649 as
->parms
[1].items
->data
);
5652 volid
= vsu_GetVolumeID(as
->parms
[2].items
->data
, cstruct
, &code
);
5655 PrintError("", code
);
5657 fprintf(STDERR
, "Unknown volume ID or name '%s'\n",
5658 as
->parms
[2].items
->data
);
5661 if (as
->parms
[3].items
)
5664 memset(&entry
, 0, sizeof(entry
));
5665 vcode
= VLDB_GetEntryByID(volid
, -1, &entry
);
5668 "Could not fetch the entry for volume %lu from VLDB\n",
5669 (unsigned long)volid
);
5670 PrintError("convertROtoRW ", vcode
);
5674 /* use RO volid even if user specified RW or BK volid */
5675 if (volid
!= entry
.volumeId
[ROVOL
])
5676 volid
= entry
.volumeId
[ROVOL
];
5678 MapHostToNetwork(&entry
);
5679 for (i
= 0; i
< entry
.nServers
; i
++) {
5680 if (entry
.serverFlags
[i
] & ITSRWVOL
) {
5682 rwserver
= entry
.serverNumber
[i
];
5683 rwpartition
= entry
.serverPartition
[i
];
5686 } else if ((entry
.serverFlags
[i
] & ITSROVOL
) && !roserver
) {
5687 same
= VLDB_IsSameAddrs(server
, entry
.serverNumber
[i
], &code
);
5690 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
5696 roserver
= entry
.serverNumber
[i
];
5697 ropartition
= entry
.serverPartition
[i
];
5704 fprintf(STDERR
, "Warning: RO volume didn't exist in vldb!\n");
5706 if (roserver
&& (ropartition
!= partition
)) {
5708 "Warning: RO volume should be in partition %d instead of %d (vldb)\n",
5709 ropartition
, partition
);
5714 "VLDB indicates that a RW volume exists already on %s in partition %s.\n",
5715 hostutil_GetNameByINet(rwserver
),
5716 volutil_PartitionName(rwpartition
));
5718 fprintf(STDERR
, "Overwrite this VLDB entry? [y|n] (n)\n");
5720 while (!(dc
== EOF
|| dc
== '\n'))
5721 dc
= getchar(); /* goto end of line */
5722 if ((c
!= 'y') && (c
!= 'Y')) {
5723 fprintf(STDERR
, "aborted.\n");
5730 ubik_VL_SetLock(cstruct
, 0, entry
.volumeId
[RWVOL
], RWVOL
,
5734 "Unable to lock volume %lu, code %d\n",
5735 (unsigned long)entry
.volumeId
[RWVOL
],vcode
);
5736 PrintError("", vcode
);
5740 /* make sure the VLDB entry hasn't changed since we started */
5741 memset(&checkEntry
, 0, sizeof(checkEntry
));
5742 vcode
= VLDB_GetEntryByID(volid
, -1, &checkEntry
);
5745 "Could not fetch the entry for volume %lu from VLDB\n",
5746 (unsigned long)volid
);
5747 PrintError("convertROtoRW ", vcode
);
5752 MapHostToNetwork(&checkEntry
);
5753 entry
.flags
&= ~VLOP_ALLOPERS
; /* clear any stale lock operation flags */
5754 entry
.flags
|= VLOP_MOVE
; /* set to match SetLock operation above */
5755 if (memcmp(&entry
, &checkEntry
, sizeof(entry
)) != 0) {
5757 "VLDB entry for volume %lu has changed; please reissue the command.\n",
5758 (unsigned long)volid
);
5763 aconn
= UV_Bind(server
, AFSCONF_VOLUMEPORT
);
5764 code
= AFSVolConvertROtoRWvolume(aconn
, partition
, volid
);
5767 "Converting RO volume %lu to RW volume failed with code %d\n",
5768 (unsigned long)volid
, code
);
5769 PrintError("convertROtoRW ", code
);
5772 /* Update the VLDB to match what we did on disk as much as possible. */
5773 /* If the converted RO was in the VLDB, make it look like the new RW. */
5775 entry
.serverFlags
[roindex
] = ITSRWVOL
;
5777 /* Add a new site entry for the newly created RW. It's possible
5778 * (but unlikely) that we are already at MAXNSERVERS and that this
5779 * new site will invalidate the whole VLDB entry; however,
5780 * VLDB_ReplaceEntry will detect this and return VL_BADSERVER,
5781 * so we need no extra guard logic here.
5783 afs_int32 newrwindex
= entry
.nServers
;
5785 entry
.serverNumber
[newrwindex
] = server
;
5786 entry
.serverPartition
[newrwindex
] = partition
;
5787 entry
.serverFlags
[newrwindex
] = ITSRWVOL
;
5789 entry
.flags
|= RW_EXISTS
;
5790 entry
.flags
&= ~BACK_EXISTS
;
5792 /* if the old RW was in the VLDB, remove it by decrementing the number */
5793 /* of servers, replacing the RW entry with the last entry, and zeroing */
5794 /* out the last entry. */
5797 if (rwindex
!= entry
.nServers
) {
5798 entry
.serverNumber
[rwindex
] = entry
.serverNumber
[entry
.nServers
];
5799 entry
.serverPartition
[rwindex
] =
5800 entry
.serverPartition
[entry
.nServers
];
5801 entry
.serverFlags
[rwindex
] = entry
.serverFlags
[entry
.nServers
];
5802 entry
.serverNumber
[entry
.nServers
] = 0;
5803 entry
.serverPartition
[entry
.nServers
] = 0;
5804 entry
.serverFlags
[entry
.nServers
] = 0;
5807 entry
.flags
&= ~RO_EXISTS
;
5808 for (i
= 0; i
< entry
.nServers
; i
++) {
5809 if (entry
.serverFlags
[i
] & ITSROVOL
) {
5810 if (!(entry
.serverFlags
[i
] & (RO_DONTUSE
| NEW_REPSITE
)))
5811 entry
.flags
|= RO_EXISTS
;
5814 MapNetworkToHost(&entry
, &storeEntry
);
5816 VLDB_ReplaceEntry(entry
.volumeId
[RWVOL
], RWVOL
, &storeEntry
,
5817 (LOCKREL_OPCODE
| LOCKREL_AFSID
|
5818 LOCKREL_TIMESTAMP
));
5821 "Warning: volume converted, but vldb update failed with code %d!\n",
5826 vcode
= UV_LockRelease(entry
.volumeId
[RWVOL
]);
5829 "Unable to unlock volume %lu, code %d\n",
5830 (unsigned long)entry
.volumeId
[RWVOL
],vcode
);
5831 PrintError("", vcode
);
5837 Sizes(struct cmd_syndesc
*as
, void *arock
)
5841 afs_int32 apart
, voltype
, fromdate
= 0, code
, err
, i
;
5842 struct nvldbentry entry
;
5843 volintSize vol_size
;
5845 rx_SetRxDeadTime(60 * 10);
5846 for (i
= 0; i
< MAXSERVERS
; i
++) {
5847 struct rx_connection
*rxConn
= ubik_GetRPCConn(cstruct
, i
);
5850 rx_SetConnDeadTime(rxConn
, rx_connDeadTime
);
5851 if (rxConn
->service
)
5852 rxConn
->service
->connDeadTime
= rx_connDeadTime
;
5855 avolid
= vsu_GetVolumeID(as
->parms
[0].items
->data
, cstruct
, &err
);
5858 PrintError("", err
);
5860 fprintf(STDERR
, "vos: can't find volume '%s'\n",
5861 as
->parms
[0].items
->data
);
5865 if (as
->parms
[1].items
|| as
->parms
[2].items
) {
5866 if (!as
->parms
[1].items
|| !as
->parms
[2].items
) {
5868 "Must specify both -server and -partition options\n");
5871 aserver
= GetServer(as
->parms
[2].items
->data
);
5873 fprintf(STDERR
, "Invalid server name\n");
5876 apart
= volutil_GetPartitionID(as
->parms
[1].items
->data
);
5878 fprintf(STDERR
, "Invalid partition name\n");
5882 code
= GetVolumeInfo(avolid
, &aserver
, &apart
, &voltype
, &entry
);
5889 if (as
->parms
[4].items
&& strcmp(as
->parms
[4].items
->data
, "0")) {
5890 code
= ktime_DateToInt32(as
->parms
[4].items
->data
, &fromdate
);
5892 fprintf(STDERR
, "vos: failed to parse date '%s' (error=%d))\n",
5893 as
->parms
[4].items
->data
, code
);
5898 fprintf(STDOUT
, "Volume: %s\n", as
->parms
[0].items
->data
);
5900 if (as
->parms
[3].items
) { /* do the dump estimate */
5901 #ifdef AFS_64BIT_ENV
5902 vol_size
.dump_size
= 0;
5904 FillInt64(vol_size
.dump_size
,0, 1);
5906 code
= UV_GetSize(avolid
, aserver
, apart
, fromdate
, &vol_size
);
5908 PrintDiagnostics("size", code
);
5911 /* presumably the size info is now gathered in pntr */
5912 /* now we display it */
5914 fprintf(STDOUT
, "dump_size: %llu\n", vol_size
.dump_size
);
5923 EndTrans(struct cmd_syndesc
*as
, void *arock
)
5926 afs_int32 code
, tid
, rcode
;
5927 struct rx_connection
*aconn
;
5929 server
= GetServer(as
->parms
[0].items
->data
);
5931 fprintf(STDERR
, "vos: host '%s' not found in host table\n",
5932 as
->parms
[0].items
->data
);
5936 code
= util_GetInt32(as
->parms
[1].items
->data
, &tid
);
5938 fprintf(STDERR
, "vos: bad integer specified for transaction ID.\n");
5942 aconn
= UV_Bind(server
, AFSCONF_VOLUMEPORT
);
5943 code
= AFSVolEndTrans(aconn
, tid
, &rcode
);
5949 PrintDiagnostics("endtrans", code
);
5957 PrintDiagnostics(char *astring
, afs_int32 acode
)
5962 "You are not authorized to perform the 'vos %s' command (%d)\n",
5966 fprintf(STDERR
, "Error in vos %s command.\n", astring
);
5967 fprintf(STDERR
, "Clone volume is not in the same partition as the read-write volume.\n");
5970 fprintf(STDERR
, "Error in vos %s command.\n", astring
);
5971 PrintError("", acode
);
5980 win32_enableCrypt(void)
5987 /* Look up configuration parameters in Registry */
5988 code
= RegOpenKeyEx(HKEY_LOCAL_MACHINE
, AFSREG_CLT_SVC_PARAM_SUBKEY
,
5989 0, (IsWow64()?KEY_WOW64_64KEY
:0)|KEY_QUERY_VALUE
, &parmKey
);
5990 if (code
!= ERROR_SUCCESS
) {
5991 dummyLen
= sizeof(cryptall
);
5992 RegQueryValueEx(parmKey
, "SecurityLevel", NULL
, NULL
,
5993 (BYTE
*) &cryptall
, &dummyLen
);
5995 RegCloseKey (parmKey
);
5999 #endif /* AFS_NT40_ENV */
6002 MyBeforeProc(struct cmd_syndesc
*as
, void *arock
)
6008 /* Initialize the ubik_client connection */
6009 rx_SetRxDeadTime(90);
6010 cstruct
= (struct ubik_client
*)0;
6014 if (as
->parms
[12].items
) /* if -cell specified */
6015 tcell
= as
->parms
[12].items
->data
;
6016 if (as
->parms
[14].items
) /* -serverauth specified */
6018 if (as
->parms
[16].items
/* -encrypt specified */
6020 || win32_enableCrypt()
6021 #endif /* AFS_NT40_ENV */
6025 vsu_ClientInit((as
->parms
[13].items
!= 0), confdir
, tcell
, sauth
,
6026 &cstruct
, UV_SetSecurity
))) {
6027 fprintf(STDERR
, "could not initialize VLDB library (code=%lu) \n",
6028 (unsigned long)code
);
6032 if (as
->parms
[15].items
) /* -verbose flag set */
6036 if (as
->parms
[17].items
) /* -noresolve flag set */
6046 /* this sucks but it works for now.
6051 #include "AFS_component_version_number.c"
6054 main(int argc
, char **argv
)
6058 struct cmd_syndesc
*ts
;
6060 #ifdef AFS_AIX32_ENV
6062 * The following signal action for AIX is necessary so that in case of a
6063 * crash (i.e. core is generated) we can include the user's data section
6064 * in the core dump. Unfortunately, by default, only a partial core is
6065 * generated which, in many cases, isn't too useful.
6067 struct sigaction nsa
;
6069 sigemptyset(&nsa
.sa_mask
);
6070 nsa
.sa_handler
= SIG_DFL
;
6071 nsa
.sa_flags
= SA_FULLDUMP
;
6072 sigaction(SIGSEGV
, &nsa
, NULL
);
6075 confdir
= AFSDIR_CLIENT_ETC_DIRPATH
;
6077 cmd_SetBeforeProc(MyBeforeProc
, NULL
);
6079 ts
= cmd_CreateSyntax("create", CreateVolume
, NULL
, "create a new volume");
6080 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
6081 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, 0, "partition name");
6082 cmd_AddParm(ts
, "-name", CMD_SINGLE
, 0, "volume name");
6083 cmd_AddParm(ts
, "-maxquota", CMD_SINGLE
, CMD_OPTIONAL
,
6084 "initial quota (KB)");
6085 cmd_AddParm(ts
, "-id", CMD_SINGLE
, CMD_OPTIONAL
, "volume ID");
6086 cmd_AddParm(ts
, "-roid", CMD_SINGLE
, CMD_OPTIONAL
, "readonly volume ID");
6088 cmd_AddParm(ts
, "-minquota", CMD_SINGLE
, CMD_OPTIONAL
, "");
6092 ts
= cmd_CreateSyntax("remove", DeleteVolume
, NULL
, "delete a volume");
6093 cmd_AddParm(ts
, "-server", CMD_SINGLE
, CMD_OPTIONAL
, "machine name");
6094 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, CMD_OPTIONAL
, "partition name");
6095 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume name or ID");
6099 ts
= cmd_CreateSyntax("move", MoveVolume
, NULL
, "move a volume");
6100 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume name or ID");
6101 cmd_AddParm(ts
, "-fromserver", CMD_SINGLE
, 0, "machine name on source");
6102 cmd_AddParm(ts
, "-frompartition", CMD_SINGLE
, 0,
6103 "partition name on source");
6104 cmd_AddParm(ts
, "-toserver", CMD_SINGLE
, 0,
6105 "machine name on destination");
6106 cmd_AddParm(ts
, "-topartition", CMD_SINGLE
, 0,
6107 "partition name on destination");
6108 cmd_AddParm(ts
, "-live", CMD_FLAG
, CMD_OPTIONAL
,
6109 "copy live volume without cloning");
6112 ts
= cmd_CreateSyntax("copy", CopyVolume
, NULL
, "copy a volume");
6113 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume name or ID on source");
6114 cmd_AddParm(ts
, "-fromserver", CMD_SINGLE
, 0, "machine name on source");
6115 cmd_AddParm(ts
, "-frompartition", CMD_SINGLE
, 0,
6116 "partition name on source");
6117 cmd_AddParm(ts
, "-toname", CMD_SINGLE
, 0, "volume name on destination");
6118 cmd_AddParm(ts
, "-toserver", CMD_SINGLE
, 0,
6119 "machine name on destination");
6120 cmd_AddParm(ts
, "-topartition", CMD_SINGLE
, 0,
6121 "partition name on destination");
6122 cmd_AddParm(ts
, "-offline", CMD_FLAG
, CMD_OPTIONAL
,
6123 "leave new volume offline");
6124 cmd_AddParm(ts
, "-readonly", CMD_FLAG
, CMD_OPTIONAL
,
6125 "make new volume read-only");
6126 cmd_AddParm(ts
, "-live", CMD_FLAG
, CMD_OPTIONAL
,
6127 "copy live volume without cloning");
6130 ts
= cmd_CreateSyntax("shadow", ShadowVolume
, NULL
,
6131 "make or update a shadow volume");
6132 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume name or ID on source");
6133 cmd_AddParm(ts
, "-fromserver", CMD_SINGLE
, 0, "machine name on source");
6134 cmd_AddParm(ts
, "-frompartition", CMD_SINGLE
, 0,
6135 "partition name on source");
6136 cmd_AddParm(ts
, "-toserver", CMD_SINGLE
, 0,
6137 "machine name on destination");
6138 cmd_AddParm(ts
, "-topartition", CMD_SINGLE
, 0,
6139 "partition name on destination");
6140 cmd_AddParm(ts
, "-toname", CMD_SINGLE
, CMD_OPTIONAL
,
6141 "volume name on destination");
6142 cmd_AddParm(ts
, "-toid", CMD_SINGLE
, CMD_OPTIONAL
,
6143 "volume ID on destination");
6144 cmd_AddParm(ts
, "-offline", CMD_FLAG
, CMD_OPTIONAL
,
6145 "leave shadow volume offline");
6146 cmd_AddParm(ts
, "-readonly", CMD_FLAG
, CMD_OPTIONAL
,
6147 "make shadow volume read-only");
6148 cmd_AddParm(ts
, "-live", CMD_FLAG
, CMD_OPTIONAL
,
6149 "copy live volume without cloning");
6150 cmd_AddParm(ts
, "-incremental", CMD_FLAG
, CMD_OPTIONAL
,
6151 "do incremental update if target exists");
6154 ts
= cmd_CreateSyntax("backup", BackupVolume
, NULL
,
6155 "make backup of a volume");
6156 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume name or ID");
6159 ts
= cmd_CreateSyntax("clone", CloneVolume
, NULL
,
6160 "make clone of a volume");
6161 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume name or ID");
6162 cmd_AddParm(ts
, "-server", CMD_SINGLE
, CMD_OPTIONAL
, "server");
6163 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, CMD_OPTIONAL
, "partition");
6164 cmd_AddParm(ts
, "-toname", CMD_SINGLE
, CMD_OPTIONAL
,
6165 "volume name on destination");
6166 cmd_AddParm(ts
, "-toid", CMD_SINGLE
, CMD_OPTIONAL
,
6167 "volume ID on destination");
6168 cmd_AddParm(ts
, "-offline", CMD_FLAG
, CMD_OPTIONAL
,
6169 "leave clone volume offline");
6170 cmd_AddParm(ts
, "-readonly", CMD_FLAG
, CMD_OPTIONAL
,
6171 "make clone volume read-only, not readwrite");
6172 cmd_AddParm(ts
, "-readwrite", CMD_FLAG
, CMD_OPTIONAL
,
6173 "make clone volume readwrite, not read-only");
6176 ts
= cmd_CreateSyntax("release", ReleaseVolume
, NULL
, "release a volume");
6177 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume name or ID");
6178 cmd_AddParm(ts
, "-force", CMD_FLAG
, CMD_OPTIONAL
,
6179 "force a complete release");
6180 cmd_AddParm(ts
, "-stayonline", CMD_FLAG
, CMD_OPTIONAL
,
6181 "release to cloned temp vol, then clone back to repsite RO");
6184 ts
= cmd_CreateSyntax("dump", DumpVolumeCmd
, NULL
, "dump a volume");
6185 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume name or ID");
6186 cmd_AddParm(ts
, "-time", CMD_SINGLE
, CMD_OPTIONAL
, "dump from time");
6187 cmd_AddParm(ts
, "-file", CMD_SINGLE
, CMD_OPTIONAL
, "dump file");
6188 cmd_AddParm(ts
, "-server", CMD_SINGLE
, CMD_OPTIONAL
, "server");
6189 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, CMD_OPTIONAL
, "partition");
6190 cmd_AddParm(ts
, "-clone", CMD_FLAG
, CMD_OPTIONAL
,
6191 "dump a clone of the volume");
6192 cmd_AddParm(ts
, "-omitdirs", CMD_FLAG
, CMD_OPTIONAL
,
6193 "omit unchanged directories from an incremental dump");
6196 ts
= cmd_CreateSyntax("restore", RestoreVolumeCmd
, NULL
,
6197 "restore a volume");
6198 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
6199 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, 0, "partition name");
6200 cmd_AddParm(ts
, "-name", CMD_SINGLE
, 0, "name of volume to be restored");
6201 cmd_AddParm(ts
, "-file", CMD_SINGLE
, CMD_OPTIONAL
, "dump file");
6202 cmd_AddParm(ts
, "-id", CMD_SINGLE
, CMD_OPTIONAL
, "volume ID");
6203 cmd_AddParm(ts
, "-overwrite", CMD_SINGLE
, CMD_OPTIONAL
,
6204 "abort | full | incremental");
6205 cmd_AddParm(ts
, "-offline", CMD_FLAG
, CMD_OPTIONAL
,
6206 "leave restored volume offline");
6207 cmd_AddParm(ts
, "-readonly", CMD_FLAG
, CMD_OPTIONAL
,
6208 "make restored volume read-only");
6209 cmd_AddParm(ts
, "-creation", CMD_SINGLE
, CMD_OPTIONAL
,
6210 "dump | keep | new");
6211 cmd_AddParm(ts
, "-lastupdate", CMD_SINGLE
, CMD_OPTIONAL
,
6212 "dump | keep | new");
6213 cmd_AddParm(ts
, "-nodelete", CMD_FLAG
, CMD_OPTIONAL
,
6214 "do not delete old site when restoring to a new site");
6217 ts
= cmd_CreateSyntax("unlock", LockReleaseCmd
, NULL
,
6218 "release lock on VLDB entry for a volume");
6219 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume name or ID");
6222 ts
= cmd_CreateSyntax("changeloc", ChangeLocation
, NULL
,
6223 "change an RW volume's location in the VLDB");
6224 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0,
6225 "machine name for new location");
6226 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, 0,
6227 "partition name for new location");
6228 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume name or ID");
6231 ts
= cmd_CreateSyntax("addsite", AddSite
, NULL
, "add a replication site");
6232 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name for new site");
6233 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, 0,
6234 "partition name for new site");
6235 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume name or ID");
6236 cmd_AddParm(ts
, "-roid", CMD_SINGLE
, CMD_OPTIONAL
, "volume name or ID for RO");
6237 cmd_AddParm(ts
, "-valid", CMD_FLAG
, CMD_OPTIONAL
, "publish as an up-to-date site in VLDB");
6240 ts
= cmd_CreateSyntax("remsite", RemoveSite
, NULL
,
6241 "remove a replication site");
6242 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
6243 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, 0, "partition name");
6244 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume name or ID");
6247 ts
= cmd_CreateSyntax("listpart", ListPartitions
, NULL
, "list partitions");
6248 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
6251 ts
= cmd_CreateSyntax("listvol", ListVolumes
, NULL
,
6252 "list volumes on server (bypass VLDB)");
6253 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
6254 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, CMD_OPTIONAL
, "partition name");
6255 cmd_AddParm(ts
, "-fast", CMD_FLAG
, CMD_OPTIONAL
, "minimal listing");
6256 cmd_AddParm(ts
, "-long", CMD_FLAG
, CMD_OPTIONAL
,
6257 "list all normal volume fields");
6258 cmd_AddParm(ts
, "-quiet", CMD_FLAG
, CMD_OPTIONAL
,
6259 "generate minimal information");
6260 cmd_AddParm(ts
, "-extended", CMD_FLAG
, CMD_OPTIONAL
,
6261 "list extended volume fields");
6262 cmd_AddParm(ts
, "-format", CMD_FLAG
, CMD_OPTIONAL
,
6263 "machine readable format");
6266 ts
= cmd_CreateSyntax("syncvldb", SyncVldb
, NULL
,
6267 "synchronize VLDB with server");
6268 cmd_AddParm(ts
, "-server", CMD_SINGLE
, CMD_OPTIONAL
, "machine name");
6269 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, CMD_OPTIONAL
, "partition name");
6270 cmd_AddParm(ts
, "-volume", CMD_SINGLE
, CMD_OPTIONAL
, "volume name or ID");
6271 cmd_AddParm(ts
, "-dryrun", CMD_FLAG
, CMD_OPTIONAL
, "list what would be done, don't do it");
6274 ts
= cmd_CreateSyntax("syncserv", SyncServer
, NULL
,
6275 "synchronize server with VLDB");
6276 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
6277 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, CMD_OPTIONAL
, "partition name");
6278 cmd_AddParm(ts
, "-dryrun", CMD_FLAG
, CMD_OPTIONAL
, "list what would be done, don't do it");
6281 ts
= cmd_CreateSyntax("examine", ExamineVolume
, NULL
,
6282 "everything about the volume");
6283 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume name or ID");
6284 cmd_AddParm(ts
, "-extended", CMD_FLAG
, CMD_OPTIONAL
,
6285 "list extended volume fields");
6286 cmd_AddParm(ts
, "-format", CMD_FLAG
, CMD_OPTIONAL
,
6287 "machine readable format");
6289 cmd_CreateAlias(ts
, "volinfo");
6290 cmd_CreateAlias(ts
, "e");
6292 ts
= cmd_CreateSyntax("setfields", SetFields
, NULL
,
6293 "change volume info fields");
6294 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume name or ID");
6295 cmd_AddParm(ts
, "-maxquota", CMD_SINGLE
, CMD_OPTIONAL
, "quota (KB)");
6296 cmd_AddParm(ts
, "-clearuse", CMD_FLAG
, CMD_OPTIONAL
, "clear dayUse");
6297 cmd_AddParm(ts
, "-clearVolUpCounter", CMD_FLAG
, CMD_OPTIONAL
, "clear volUpdateCounter");
6300 ts
= cmd_CreateSyntax("offline", volOffline
, NULL
, "force the volume status to offline");
6301 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "server name");
6302 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, 0, "partition name");
6303 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume name or ID");
6304 cmd_AddParm(ts
, "-sleep", CMD_SINGLE
, CMD_OPTIONAL
, "seconds to sleep");
6305 cmd_AddParm(ts
, "-busy", CMD_FLAG
, CMD_OPTIONAL
, "busy volume");
6308 ts
= cmd_CreateSyntax("online", volOnline
, NULL
, "force the volume status to online");
6309 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "server name");
6310 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, 0, "partition name");
6311 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume name or ID");
6314 ts
= cmd_CreateSyntax("zap", VolumeZap
, NULL
,
6315 "delete the volume, don't bother with VLDB");
6316 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
6317 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, 0, "partition name");
6318 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume ID");
6319 cmd_AddParm(ts
, "-force", CMD_FLAG
, CMD_OPTIONAL
,
6320 "force deletion of bad volumes");
6321 cmd_AddParm(ts
, "-backup", CMD_FLAG
, CMD_OPTIONAL
,
6322 "also delete backup volume if one is found");
6325 ts
= cmd_CreateSyntax("status", VolserStatus
, NULL
,
6326 "report on volser status");
6327 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
6330 ts
= cmd_CreateSyntax("rename", RenameVolume
, NULL
, "rename a volume");
6331 cmd_AddParm(ts
, "-oldname", CMD_SINGLE
, 0, "old volume name ");
6332 cmd_AddParm(ts
, "-newname", CMD_SINGLE
, 0, "new volume name ");
6335 ts
= cmd_CreateSyntax("listvldb", ListVLDB
, NULL
,
6336 "list volumes in the VLDB");
6337 cmd_AddParm(ts
, "-name", CMD_SINGLE
, CMD_OPTIONAL
, "volume name or ID");
6338 cmd_AddParm(ts
, "-server", CMD_SINGLE
, CMD_OPTIONAL
, "machine name");
6339 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, CMD_OPTIONAL
, "partition name");
6340 cmd_AddParm(ts
, "-locked", CMD_FLAG
, CMD_OPTIONAL
, "locked volumes only");
6341 cmd_AddParm(ts
, "-quiet", CMD_FLAG
, CMD_OPTIONAL
,
6342 "generate minimal information");
6343 cmd_AddParm(ts
, "-nosort", CMD_FLAG
, CMD_OPTIONAL
,
6344 "do not alphabetically sort the volume names");
6347 ts
= cmd_CreateSyntax("backupsys", BackSys
, NULL
, "en masse backups");
6348 cmd_AddParm(ts
, "-prefix", CMD_LIST
, CMD_OPTIONAL
,
6349 "common prefix on volume(s)");
6350 cmd_AddParm(ts
, "-server", CMD_SINGLE
, CMD_OPTIONAL
, "machine name");
6351 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, CMD_OPTIONAL
, "partition name");
6352 cmd_AddParm(ts
, "-exclude", CMD_FLAG
, CMD_OPTIONAL
,
6353 "exclude common prefix volumes");
6354 cmd_AddParm(ts
, "-xprefix", CMD_LIST
, CMD_OPTIONAL
,
6355 "negative prefix on volume(s)");
6356 cmd_AddParm(ts
, "-dryrun", CMD_FLAG
, CMD_OPTIONAL
, "list what would be done, don't do it");
6359 ts
= cmd_CreateSyntax("delentry", DeleteEntry
, NULL
,
6360 "delete VLDB entry for a volume");
6361 cmd_AddParm(ts
, "-id", CMD_LIST
, CMD_OPTIONAL
, "volume name or ID");
6362 cmd_AddParm(ts
, "-prefix", CMD_SINGLE
, CMD_OPTIONAL
,
6363 "prefix of the volume whose VLDB entry is to be deleted");
6364 cmd_AddParm(ts
, "-server", CMD_SINGLE
, CMD_OPTIONAL
, "machine name");
6365 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, CMD_OPTIONAL
, "partition name");
6366 cmd_AddParm(ts
, "-noexecute", CMD_FLAG
, CMD_OPTIONAL
|CMD_HIDDEN
, "");
6367 cmd_AddParm(ts
, "-dryrun", CMD_FLAG
, CMD_OPTIONAL
,
6368 "list what would be done, don't do it");
6371 ts
= cmd_CreateSyntax("partinfo", PartitionInfo
, NULL
,
6372 "list partition information");
6373 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
6374 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, CMD_OPTIONAL
, "partition name");
6375 cmd_AddParm(ts
, "-summary", CMD_FLAG
, CMD_OPTIONAL
,
6376 "print storage summary");
6379 ts
= cmd_CreateSyntax("unlockvldb", UnlockVLDB
, NULL
,
6380 "unlock all the locked entries in the VLDB");
6381 cmd_AddParm(ts
, "-server", CMD_SINGLE
, CMD_OPTIONAL
, "machine name");
6382 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, CMD_OPTIONAL
, "partition name");
6385 ts
= cmd_CreateSyntax("lock", LockEntry
, NULL
,
6386 "lock VLDB entry for a volume");
6387 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume name or ID");
6390 ts
= cmd_CreateSyntax("changeaddr", ChangeAddr
, NULL
,
6391 "change the IP address of a file server");
6392 cmd_AddParm(ts
, "-oldaddr", CMD_SINGLE
, 0, "original IP address");
6393 cmd_AddParm(ts
, "-newaddr", CMD_SINGLE
, CMD_OPTIONAL
, "new IP address");
6394 cmd_AddParm(ts
, "-remove", CMD_FLAG
, CMD_OPTIONAL
,
6395 "remove the IP address from the VLDB");
6396 cmd_AddParm(ts
, "-force", CMD_FLAG
, CMD_OPTIONAL
,
6397 "allow multi-homed server entry change (not recommended)");
6400 ts
= cmd_CreateSyntax("listaddrs", ListAddrs
, NULL
,
6401 "list the IP address of all file servers registered in the VLDB");
6402 cmd_AddParm(ts
, "-uuid", CMD_SINGLE
, CMD_OPTIONAL
, "uuid of server");
6403 cmd_AddParm(ts
, "-host", CMD_SINGLE
, CMD_OPTIONAL
, "address of host");
6404 cmd_AddParm(ts
, "-printuuid", CMD_FLAG
, CMD_OPTIONAL
,
6405 "print uuid of hosts");
6408 ts
= cmd_CreateSyntax("convertROtoRW", ConvertRO
, NULL
,
6409 "convert a RO volume into a RW volume (after loss of old RW volume)");
6410 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
6411 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, 0, "partition name");
6412 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume name or ID");
6413 cmd_AddParm(ts
, "-force", CMD_FLAG
, CMD_OPTIONAL
, "don't ask");
6416 ts
= cmd_CreateSyntax("size", Sizes
, NULL
,
6417 "obtain various sizes of the volume.");
6418 cmd_AddParm(ts
, "-id", CMD_SINGLE
, 0, "volume name or ID");
6419 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, CMD_OPTIONAL
, "partition name");
6420 cmd_AddParm(ts
, "-server", CMD_SINGLE
, CMD_OPTIONAL
, "machine name");
6421 cmd_AddParm(ts
, "-dump", CMD_FLAG
, CMD_OPTIONAL
,
6422 "Obtain the size of the dump");
6423 cmd_AddParm(ts
, "-time", CMD_SINGLE
, CMD_OPTIONAL
, "dump from time");
6426 ts
= cmd_CreateSyntax("endtrans", EndTrans
, NULL
,
6427 "end a volserver transaction");
6428 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
6429 cmd_AddParm(ts
, "-transaction", CMD_SINGLE
, 0,
6433 ts
= cmd_CreateSyntax("setaddrs", SetAddrs
, NULL
,
6434 "set the list of IP addresses for a given UUID in the VLDB");
6435 cmd_AddParm(ts
, "-uuid", CMD_SINGLE
, 0, "uuid of server");
6436 cmd_AddParm(ts
, "-host", CMD_LIST
, 0, "address of host");
6439 ts
= cmd_CreateSyntax("remaddrs", RemoveAddrs
, NULL
,
6440 "remove the list of IP addresses for a given UUID in the VLDB");
6441 cmd_AddParm(ts
, "-uuid", CMD_SINGLE
, 0, "uuid of server");
6444 code
= cmd_Dispatch(argc
, argv
);
6446 /* Shut down the ubik_client and rx connections */
6448 (void)ubik_ClientDestroy(cstruct
);
6454 exit((code
? -1 : 0));