Rename printf cast helpers and clean up format string warnings
[openafs.git] / src / libadmin / test / vos.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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
8  */
9
10 /*
11  * This file implements the vos related funtions for afscp
12  */
13
14 #include <afsconfig.h>
15 #include <afs/param.h>
16 #ifndef AFS_NT40_ENV
17 #include <netdb.h>
18 #include <netinet/in.h>
19 #include <arpa/inet.h>
20 #include <afs/afsutil.h>
21 #endif
22
23
24 #include "vos.h"
25
26 /*
27  * Utility functions
28  */
29
30 /*
31  * Generic fuction for converting input string to an integer.  Pass
32  * the error_msg you want displayed if there is an error converting
33  * the string.
34  */
35
36 static unsigned int
37 GetIntFromString(const char *int_str, const char *error_msg)
38 {
39     unsigned int i;
40     char *bad_char = NULL;
41
42     i = strtoul(int_str, &bad_char, 10);
43     if ((bad_char == NULL) || (*bad_char == 0)) {
44         return i;
45     }
46
47     ERR_EXT(error_msg);
48 }
49
50 /*
51  * Generic fuction for converting input string to a volume number
52  * It will accept integer strings as well as volume names.
53  */
54
55 static unsigned int
56 GetVolumeIdFromString(const char *volume)
57 {
58     unsigned int volume_id;
59     char *bad_char = NULL;
60     afs_status_t st = 0;
61     vos_vldbEntry_t entry;
62
63     volume_id = strtoul(volume, &bad_char, 10);
64     if ((bad_char == NULL) || (*bad_char == 0)) {
65         return volume_id;
66     }
67
68     /*
69      * We failed to convert the string to a number, so see if it
70      * is a volume name
71      */
72     if (vos_VLDBGet
73         (cellHandle, 0, (const unsigned int *)0, volume, &entry, &st)) {
74         return entry.volumeId[VOS_READ_WRITE_VOLUME];
75     } else {
76         ERR_EXT("failed to convert specified volume to an id");
77     }
78 }
79
80 /*
81  * Generic fuction for converting input string to a partition number
82  * It will accept integer strings as well as partition names.
83  */
84
85 static unsigned int
86 GetPartitionIdFromString(const char *partition)
87 {
88     unsigned int partition_id;
89     char *bad_char = NULL;
90     afs_status_t st = 0;
91     char pname[20];
92     int pname_len;
93
94     partition_id = strtoul(partition, &bad_char, 10);
95     if ((bad_char == NULL) || (*bad_char == 0)) {
96         return partition_id;
97     }
98
99     /*
100      * We failed to convert the string to a number, so see if it
101      * is a partition name
102      */
103
104     pname_len = strlen(partition);
105
106     sprintf(pname, "%s", "/vicep");
107     if (pname_len <= 2) {
108         strcat(pname, partition);
109     } else if (!strncmp(partition, "/vicep", 6)) {
110         strcat(pname, partition + 6);
111     } else if (!strncmp(partition, "vicep", 5)) {
112         strcat(pname, partition + 5);
113     } else {
114         ERR_EXT("invalid partition");
115     }
116
117     if (!vos_PartitionNameToId((const char *)pname, &partition_id, &st)) {
118         ERR_ST_EXT("invalid partition", st);
119     }
120
121     return partition_id;
122 }
123
124 /*
125  * Generic fuction for converting input string to an address in host order. 
126  * It will accept strings in the form "128.98.12.1"
127  */
128
129 static int
130 GetAddressFromString(const char *addr_str)
131 {
132     int addr = inet_addr(addr_str);
133
134     if (addr == -1) {
135         ERR_EXT("failed to convert specified address");
136     }
137
138     return ntohl(addr);
139 }
140
141 #if 0
142 static void
143 PrintMessage(vos_messageType_t type, char *message)
144 {
145     printf("%s\n", message);
146 }
147 #endif
148
149 int
150 DoVosBackupVolumeCreate(struct cmd_syndesc *as, void *arock)
151 {
152     typedef enum { VOLUME } DoVosBackupVolumeCreate_parm_t;
153     afs_status_t st = 0;
154     unsigned int volume_id = 0;
155
156     if (as->parms[VOLUME].items) {
157         const char *volume = as->parms[VOLUME].items->data;
158         volume_id = GetVolumeIdFromString(volume);
159     }
160
161     if (!vos_BackupVolumeCreate(cellHandle, 0, volume_id, &st)) {
162         ERR_ST_EXT("vos_BackupVolumeCreate", st);
163     }
164     return 0;
165 }
166
167 int
168 DoVosBackupVolumeCreateMultiple(struct cmd_syndesc *as, void *arock)
169 {
170     typedef enum { SERVER, PARTITION, PREFIX,
171         EXCLUDE
172     } DoVosBackupVolumeCreate_parm_t;
173     afs_status_t st = 0;
174     void *vos_server = NULL;
175     unsigned int partition_id;
176     const unsigned int *part_ptr = NULL;
177     const char *prefix = NULL;
178     vos_exclude_t exclude = VOS_INCLUDE;
179
180     if (as->parms[SERVER].items) {
181         if (!vos_ServerOpen
182             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
183             ERR_ST_EXT("vos_ServerOpen", st);
184         }
185     }
186
187     if (as->parms[PARTITION].items) {
188         partition_id =
189             GetPartitionIdFromString(as->parms[PARTITION].items->data);
190         part_ptr = &partition_id;
191     }
192
193     if (as->parms[PREFIX].items) {
194         prefix = as->parms[PREFIX].items->data;
195     }
196
197     if (as->parms[EXCLUDE].items) {
198         exclude = VOS_EXCLUDE;
199     }
200
201     if (!vos_BackupVolumeCreateMultiple
202         (cellHandle, vos_server, (vos_MessageCallBack_t) 0, part_ptr, prefix,
203          exclude, &st)) {
204         ERR_ST_EXT("vos_BackupVolumeCreate", st);
205     }
206     return 0;
207 }
208
209 static void
210 Print_vos_partitionEntry_p(vos_partitionEntry_p part, const char *prefix)
211 {
212     printf("%sInformation for partition %s\n", prefix, part->name);
213     printf("%s\tDevice name: %s\n", prefix, part->deviceName);
214     printf("%s\tlockFileDescriptor: %d\n", prefix, part->lockFileDescriptor);
215     printf("%s\tTotal space: %d\n", prefix, part->totalSpace);
216     printf("%s\tTotal Free space: %d\n", prefix, part->totalFreeSpace);
217 }
218
219 int
220 DoVosPartitionGet(struct cmd_syndesc *as, void *arock)
221 {
222     typedef enum { SERVER, PARTITION } DoVosPartitionGet_parm_t;
223     afs_status_t st = 0;
224     void *vos_server = NULL;
225     unsigned int partition_id = 0;
226     vos_partitionEntry_t entry;
227
228     if (as->parms[SERVER].items) {
229         if (!vos_ServerOpen
230             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
231             ERR_ST_EXT("vos_ServerOpen", st);
232         }
233     }
234
235     if (as->parms[PARTITION].items) {
236         partition_id =
237             GetPartitionIdFromString(as->parms[PARTITION].items->data);
238     }
239
240     if (!vos_PartitionGet
241         (cellHandle, vos_server, 0, partition_id, &entry, &st)) {
242         ERR_ST_EXT("vos_PartitionGet", st);
243     }
244
245     Print_vos_partitionEntry_p(&entry, "");
246
247     return 0;
248 }
249
250 int
251 DoVosPartitionList(struct cmd_syndesc *as, void *arock)
252 {
253     typedef enum { SERVER } DoVosPartitionGet_parm_t;
254     afs_status_t st = 0;
255     void *vos_server = NULL;
256     void *iter;
257     vos_partitionEntry_t entry;
258
259     if (as->parms[SERVER].items) {
260         if (!vos_ServerOpen
261             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
262             ERR_ST_EXT("vos_ServerOpen", st);
263         }
264     }
265
266     if (!vos_PartitionGetBegin(cellHandle, vos_server, 0, &iter, &st)) {
267         ERR_ST_EXT("vos_PartitionGetBegin", st);
268     }
269
270     printf("Listing partitions at server %s\n",
271            as->parms[SERVER].items->data);
272     while (vos_PartitionGetNext(iter, &entry, &st)) {
273         Print_vos_partitionEntry_p(&entry, "    ");
274     }
275
276     if (st != ADMITERATORDONE) {
277         ERR_ST_EXT("vos_PartitionGetNext", st);
278     }
279
280     if (!vos_PartitionGetDone(iter, &st)) {
281         ERR_ST_EXT("vos_PartitionGetDone", st);
282     }
283     return 0;
284 }
285
286 int
287 DoVosServerSync(struct cmd_syndesc *as, void *arock)
288 {
289     typedef enum { SERVER, PARTITION } DoVosServerSync_parm_t;
290     afs_status_t st = 0;
291     void *vos_server = NULL;
292     unsigned int partition_id;
293     const unsigned int *part_ptr = NULL;
294
295     if (as->parms[SERVER].items) {
296         if (!vos_ServerOpen
297             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
298             ERR_ST_EXT("vos_ServerOpen", st);
299         }
300     }
301
302     if (as->parms[PARTITION].items) {
303         partition_id =
304             GetPartitionIdFromString(as->parms[PARTITION].items->data);
305         part_ptr = &partition_id;
306     }
307
308     if (!vos_ServerSync(cellHandle, vos_server, 0, part_ptr, &st)) {
309         ERR_ST_EXT("vos_PartitionGetDone", st);
310     }
311     return 0;
312 }
313
314 int
315 DoVosFileServerAddressChange(struct cmd_syndesc *as, void *arock)
316 {
317     typedef enum { OLDADDRESS,
318         NEWADDRESS
319     } DoVosFileServerAddressChange_parm_t;
320     afs_status_t st = 0;
321     int old_addr = 0;
322     int new_addr = 0;
323
324     if (as->parms[OLDADDRESS].items) {
325         const char *addr = as->parms[OLDADDRESS].items->data;
326         old_addr = GetAddressFromString(addr);
327     }
328
329     if (as->parms[NEWADDRESS].items) {
330         const char *addr = as->parms[OLDADDRESS].items->data;
331         new_addr = GetAddressFromString(addr);
332     }
333
334     if (!vos_FileServerAddressChange(cellHandle, 0, old_addr, new_addr, &st)) {
335         ERR_ST_EXT("vos_FileServerAddressChange", st);
336     }
337     return 0;
338 }
339
340 int
341 DoVosFileServerAddressRemove(struct cmd_syndesc *as, void *arock)
342 {
343     typedef enum { ADDRESS } DoVosFileServerAddressRemove_parm_t;
344     afs_status_t st = 0;
345     int address = 0;
346
347     if (as->parms[ADDRESS].items) {
348         const char *addr = as->parms[ADDRESS].items->data;
349         address = GetAddressFromString(addr);
350     }
351
352     if (!vos_FileServerAddressRemove(cellHandle, 0, address, &st)) {
353         ERR_ST_EXT("vos_FileServerAddressRemove", st);
354     }
355     return 0;
356 }
357
358 static void
359 Print_vos_fileServerEntry_p(vos_fileServerEntry_p serv, const char *prefix)
360 {
361     int i;
362
363     for (i = 0; i < serv->count; i++) {
364         printf("%s%x ", prefix, serv->serverAddress[i]);
365     }
366     printf("\n");
367 }
368
369 int
370 DoVosFileServerList(struct cmd_syndesc *as, void *arock)
371 {
372     afs_status_t st = 0;
373     void *iter;
374     vos_fileServerEntry_t entry;
375
376     if (!vos_FileServerGetBegin(cellHandle, 0, &iter, &st)) {
377         ERR_ST_EXT("vos_FileServerGetBegin", st);
378     }
379
380     while (vos_FileServerGetNext(iter, &entry, &st)) {
381         Print_vos_fileServerEntry_p(&entry, "");
382     }
383
384     if (st != ADMITERATORDONE) {
385         ERR_ST_EXT("vos_FileServerGetNext", st);
386     }
387
388     if (!vos_FileServerGetDone(iter, &st)) {
389         ERR_ST_EXT("vos_FileServerGetDone", st);
390     }
391
392     return 0;
393 }
394
395 static void
396 Print_vos_serverTransactionStatus_p(vos_serverTransactionStatus_p tran,
397                                     const char *prefix)
398 {
399     printf("%sTransaction id\t\t\t%d\n", prefix, tran->transactionId);
400     printf("%sLast active time\t\t\t%d\n", prefix, tran->lastActiveTime);
401     printf("%sCreation time\t\t\t%d\n", prefix, tran->creationTime);
402     printf("%sError code\t\t\t%d\n", prefix, tran->errorCode);
403     printf("%sVolume id\t\t\t\t%u\n", prefix, tran->volumeId);
404     printf("%sPartition\t\t\t\t%d\n", prefix, tran->partition);
405     printf("%sLast procedure name\t\t\t%s\n", prefix,
406            tran->lastProcedureName);
407     printf("%sNext receive packet seq num\t\t\t%d\n", prefix,
408            tran->nextReceivePacketSequenceNumber);
409     printf("%sNext send packet seq num\t\t\t%d\n", prefix,
410            tran->nextSendPacketSequenceNumber);
411     printf("%sLast receive time\t\t\t%d\n", prefix, tran->lastReceiveTime);
412     printf("%sLast send time\t\t\t%d\n", prefix, tran->lastSendTime);
413     printf("%sVolume attach mode\t\t\t%d\n", prefix, tran->volumeAttachMode);
414     printf("%sVolume active status\t\t\t%d\n", prefix,
415            tran->volumeActiveStatus);
416     printf("%sVolume tran status\t\t\t%d\n", prefix,
417            tran->volumeTransactionStatus);
418 }
419
420 int
421 DoVosServerTransactionStatusList(struct cmd_syndesc *as, void *arock)
422 {
423     typedef enum { SERVER } DoVosServerTransactionStatusList_parm_t;
424     afs_status_t st = 0;
425     void *vos_server = NULL;
426     void *iter = NULL;
427     vos_serverTransactionStatus_t tran;
428
429
430     if (as->parms[SERVER].items) {
431         if (!vos_ServerOpen
432             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
433             ERR_ST_EXT("vos_ServerOpen", st);
434         }
435     }
436
437     if (!vos_ServerTransactionStatusGetBegin
438         (cellHandle, vos_server, 0, &iter, &st)) {
439         ERR_ST_EXT("vos_ServerTransactionStatusGetBegin", st);
440     }
441
442     while (vos_ServerTransactionStatusGetNext(iter, &tran, &st)) {
443         Print_vos_serverTransactionStatus_p(&tran, "");
444     }
445
446     if (st != ADMITERATORDONE) {
447         ERR_ST_EXT("vos_ServerTransactionStatusGetNext", st);
448     }
449
450     if (!vos_ServerTransactionStatusGetDone(iter, &st)) {
451         ERR_ST_EXT("vos_ServerTransactionStatusGetDone", st);
452     }
453     return 0;
454 }
455
456 static void
457 Print_vos_vldbEntry_p(vos_vldbEntry_p entry, const char *prefix)
458 {
459     int i;
460
461     printf("%sVolume entry %s\n", prefix, entry->name);
462     printf("%sNumber of servers %d\n", prefix, entry->numServers);
463     printf("%sRead write volume %u\n", prefix,
464            entry->volumeId[VOS_READ_WRITE_VOLUME]);
465     printf("%sRead only volume %u\n", prefix,
466            entry->volumeId[VOS_READ_ONLY_VOLUME]);
467     printf("%sBackup volume %u\n", prefix,
468            entry->volumeId[VOS_BACKUP_VOLUME]);
469     printf("%sClone volume %u\n", prefix, entry->cloneId);
470
471     printf("%sVolume entry status:\n", prefix);
472     if (entry->status & VOS_VLDB_ENTRY_OK) {
473         printf("%s\tVOS_VLDB_ENTRY_OK\n", prefix);
474     }
475     if (entry->status & VOS_VLDB_ENTRY_MOVE) {
476         printf("%s\tVOS_VLDB_ENTRY_MOVE\n", prefix);
477     }
478     if (entry->status & VOS_VLDB_ENTRY_RELEASE) {
479         printf("%s\tVOS_VLDB_ENTRY_RELEASE\n", prefix);
480     }
481     if (entry->status & VOS_VLDB_ENTRY_BACKUP) {
482         printf("%s\tVOS_VLDB_ENTRY_BACKUP\n", prefix);
483     }
484     if (entry->status & VOS_VLDB_ENTRY_DELETE) {
485         printf("%s\tVOS_VLDB_ENTRY_DELETE\n", prefix);
486     }
487     if (entry->status & VOS_VLDB_ENTRY_DUMP) {
488         printf("%s\tVOS_VLDB_ENTRY_DUMP\n", prefix);
489     }
490     if (entry->status & VOS_VLDB_ENTRY_LOCKED) {
491         printf("%s\tVOS_VLDB_ENTRY_LOCKED\n", prefix);
492     }
493     if (entry->status & VOS_VLDB_ENTRY_RWEXISTS) {
494         printf("%s\tVOS_VLDB_ENTRY_RWEXISTS\n", prefix);
495     }
496     if (entry->status & VOS_VLDB_ENTRY_ROEXISTS) {
497         printf("%s\tVOS_VLDB_ENTRY_ROEXISTS\n", prefix);
498     }
499     if (entry->status & VOS_VLDB_ENTRY_BACKEXISTS) {
500         printf("%s\tVOS_VLDB_ENTRY_BACKEXISTS\n", prefix);
501     }
502
503     printf("%sVolume location information for replicas:\n", prefix);
504     for (i = 0; i < entry->numServers; i++) {
505         printf("%s\tServer %x\n", prefix,
506                entry->volumeSites[i].serverAddress);
507         printf("%s\tPartition %x\n", prefix,
508                entry->volumeSites[i].serverPartition);
509         if (entry->volumeSites[i].serverFlags & VOS_VLDB_NEW_REPSITE) {
510             printf("%s\tVOS_VLDB_NEW_REPSITE\n", prefix);
511         }
512         if (entry->volumeSites[i].serverFlags & VOS_VLDB_READ_ONLY) {
513             printf("%s\tVOS_VLDB_READ_ONLY\n", prefix);
514         }
515         if (entry->volumeSites[i].serverFlags & VOS_VLDB_READ_WRITE) {
516             printf("%s\tVOS_VLDB_READ_WRITE\n", prefix);
517         }
518         if (entry->volumeSites[i].serverFlags & VOS_VLDB_BACKUP) {
519             printf("%s\tVOS_VLDB_BACKUP\n", prefix);
520         }
521         if (entry->volumeSites[i].serverFlags & VOS_VLDB_DONT_USE) {
522             printf("%s\tVOS_VLDB_DONT_USE\n", prefix);
523         }
524     }
525     printf("\n");
526 }
527
528 int
529 DoVosVLDBGet(struct cmd_syndesc *as, void *arock)
530 {
531     typedef enum { VOLUME } DoVosVLDBGet_parm_t;
532     afs_status_t st = 0;
533     vos_vldbEntry_t entry;
534     unsigned int volume_id;
535     const char *volume_name = NULL;
536
537     if (as->parms[VOLUME].items) {
538         const char *volume = as->parms[VOLUME].items->data;
539         volume_id = GetVolumeIdFromString(volume);
540     }
541
542
543     if (!vos_VLDBGet(cellHandle, 0, &volume_id, volume_name, &entry, &st)) {
544         ERR_ST_EXT("vos_VLDBGet", st);
545     }
546
547     Print_vos_vldbEntry_p(&entry, "");
548
549     return 0;
550 }
551
552 int
553 DoVosVLDBList(struct cmd_syndesc *as, void *arock)
554 {
555     typedef enum { SERVER, PARTITION } DoVosVLDBList_parm_t;
556     afs_status_t st = 0;
557     void *vos_server = NULL;
558     unsigned int partition_id;
559     unsigned int *part_ptr = NULL;
560     int have_server = 0;
561     vos_vldbEntry_t entry;
562     void *iter = NULL;
563
564     if (as->parms[SERVER].items) {
565         if (!vos_ServerOpen
566             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
567             ERR_ST_EXT("vos_ServerOpen", st);
568         }
569         have_server = 1;
570     }
571
572     if (as->parms[PARTITION].items) {
573         if (!have_server) {
574             ERR_EXT("must specify server when specifying partition");
575         }
576         partition_id =
577             GetPartitionIdFromString(as->parms[PARTITION].items->data);
578         part_ptr = &partition_id;
579     }
580
581     if (!vos_VLDBGetBegin(cellHandle, vos_server, 0, part_ptr, &iter, &st)) {
582         ERR_ST_EXT("vos_VLDBGetBegin", st);
583     }
584
585     while (vos_VLDBGetNext(iter, &entry, &st)) {
586         Print_vos_vldbEntry_p(&entry, "");
587     }
588
589     if (st != ADMITERATORDONE) {
590         ERR_ST_EXT("vos_VLDBGetNext", st);
591     }
592
593     if (!vos_VLDBGetDone(iter, &st)) {
594         ERR_ST_EXT("vos_VLDBGetDone", st);
595     }
596
597     return 0;
598 }
599
600 int
601 DoVosVLDBEntryRemove(struct cmd_syndesc *as, void *arock)
602 {
603     typedef enum { SERVER, PARTITION, VOLUME } DoVosVLDBEntryRemove_parm_t;
604     afs_status_t st = 0;
605     void *vos_server = NULL;
606     unsigned int partition_id;
607     unsigned int *part_ptr = NULL;
608     int have_server = 0;
609     unsigned int volume_id;
610     unsigned int *vol_ptr = NULL;
611
612     if (as->parms[SERVER].items) {
613         if (!vos_ServerOpen
614             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
615             ERR_ST_EXT("vos_ServerOpen", st);
616         }
617         have_server = 1;
618     }
619
620     if (as->parms[PARTITION].items) {
621         if (!have_server) {
622             ERR_EXT("must specify server when specifying partition");
623         }
624         partition_id =
625             GetPartitionIdFromString(as->parms[PARTITION].items->data);
626         part_ptr = &partition_id;
627     }
628
629     if (as->parms[VOLUME].items) {
630         const char *volume = as->parms[VOLUME].items->data;
631         volume_id = GetVolumeIdFromString(volume);
632         vol_ptr = &volume_id;
633     }
634
635     if (!vos_VLDBEntryRemove
636         (cellHandle, vos_server, 0, part_ptr, vol_ptr, &st)) {
637         ERR_ST_EXT("vos_VLDBEntryRemove", st);
638     }
639
640     return 0;
641 }
642
643 int
644 DoVosVLDBUnlock(struct cmd_syndesc *as, void *arock)
645 {
646     typedef enum { SERVER, PARTITION } DoVosVLDBUnlock_parm_t;
647     afs_status_t st = 0;
648     void *vos_server = NULL;
649     unsigned int partition_id;
650     unsigned int *part_ptr = NULL;
651     int have_server = 0;
652
653     if (as->parms[SERVER].items) {
654         if (!vos_ServerOpen
655             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
656             ERR_ST_EXT("vos_ServerOpen", st);
657         }
658         have_server = 1;
659     }
660
661     if (as->parms[PARTITION].items) {
662         if (!have_server) {
663             ERR_EXT("must specify server when specifying partition");
664         }
665         partition_id =
666             GetPartitionIdFromString(as->parms[PARTITION].items->data);
667         part_ptr = &partition_id;
668     }
669
670     if (!vos_VLDBUnlock(cellHandle, vos_server, 0, part_ptr, &st)) {
671         ERR_ST_EXT("vos_VLDBUnlock", st);
672     }
673
674     return 0;
675 }
676
677 int
678 DoVosVLDBEntryLock(struct cmd_syndesc *as, void *arock)
679 {
680     typedef enum { VOLUME } DoVosVLDBEntryLoc_parm_tk;
681     afs_status_t st = 0;
682     unsigned int volume_id = 0;
683
684     if (as->parms[VOLUME].items) {
685         const char *volume = as->parms[VOLUME].items->data;
686         volume_id = GetVolumeIdFromString(volume);
687     }
688
689     if (!vos_VLDBEntryLock(cellHandle, 0, volume_id, &st)) {
690         ERR_ST_EXT("vos_VLDBEntryLock", st);
691     }
692
693     return 0;
694 }
695
696 int
697 DoVosVLDBEntryUnlock(struct cmd_syndesc *as, void *arock)
698 {
699     typedef enum { VOLUME } DoVosVLDBEntryUnlock_parm_t;
700     afs_status_t st = 0;
701     unsigned int volume_id = 0;
702
703     if (as->parms[VOLUME].items) {
704         const char *volume = as->parms[VOLUME].items->data;
705         volume_id = GetVolumeIdFromString(volume);
706     }
707
708     if (!vos_VLDBEntryUnlock(cellHandle, 0, volume_id, &st)) {
709         ERR_ST_EXT("vos_VLDBEntryUnlock", st);
710     }
711
712     return 0;
713 }
714
715 int
716 DoVosVLDBReadOnlySiteCreate(struct cmd_syndesc *as, void *arock)
717 {
718     typedef enum { SERVER, PARTITION,
719         VOLUME
720     } DoVosVLDBReadOnlySiteCreate_parm_t;
721     afs_status_t st = 0;
722     void *vos_server = NULL;
723     unsigned int partition_id = 0;
724     unsigned int volume_id = 0;
725
726     if (as->parms[SERVER].items) {
727         if (!vos_ServerOpen
728             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
729             ERR_ST_EXT("vos_ServerOpen", st);
730         }
731     }
732
733     if (as->parms[PARTITION].items) {
734         partition_id =
735             GetPartitionIdFromString(as->parms[PARTITION].items->data);
736     }
737
738     if (as->parms[VOLUME].items) {
739         const char *volume = as->parms[VOLUME].items->data;
740         volume_id = GetVolumeIdFromString(volume);
741     }
742
743     if (!vos_VLDBReadOnlySiteCreate
744         (cellHandle, vos_server, 0, partition_id, volume_id, &st)) {
745         ERR_ST_EXT("vos_VLDBReadOnlySiteCreate", st);
746     }
747     return 0;
748 }
749
750 int
751 DoVosVLDBReadOnlySiteDelete(struct cmd_syndesc *as, void *arock)
752 {
753     typedef enum { SERVER, PARTITION,
754         VOLUME
755     } DoVosVLDBReadOnlySiteDelete_parm_t;
756     afs_status_t st = 0;
757     void *vos_server = NULL;
758     unsigned int partition_id = 0;
759     unsigned int volume_id = 0;
760
761     if (as->parms[SERVER].items) {
762         if (!vos_ServerOpen
763             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
764             ERR_ST_EXT("vos_ServerOpen", st);
765         }
766     }
767
768     if (as->parms[PARTITION].items) {
769         partition_id =
770             GetPartitionIdFromString(as->parms[PARTITION].items->data);
771     }
772
773     if (as->parms[VOLUME].items) {
774         const char *volume = as->parms[VOLUME].items->data;
775         volume_id = GetVolumeIdFromString(volume);
776     }
777
778     if (!vos_VLDBReadOnlySiteDelete
779         (cellHandle, vos_server, 0, partition_id, volume_id, &st)) {
780         ERR_ST_EXT("vos_VLDBReadOnlySiteDelete", st);
781     }
782
783     return 0;
784 }
785
786 int
787 DoVosVLDBSync(struct cmd_syndesc *as, void *arock)
788 {
789     typedef enum { SERVER, PARTITION, FORCE } DoVosVLDBSync_parm_t;
790     afs_status_t st = 0;
791     void *vos_server = NULL;
792     unsigned int partition_id;
793     unsigned int *part_ptr = NULL;
794     int have_server = 0;
795     vos_force_t force = VOS_NORMAL;
796
797     if (as->parms[SERVER].items) {
798         if (!vos_ServerOpen
799             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
800             ERR_ST_EXT("vos_ServerOpen", st);
801         }
802         have_server = 1;
803     }
804
805     if (as->parms[PARTITION].items) {
806         if (!have_server) {
807             ERR_EXT("must specify server when specifying partition");
808         }
809         partition_id =
810             GetPartitionIdFromString(as->parms[PARTITION].items->data);
811         part_ptr = &partition_id;
812     }
813
814     if (as->parms[FORCE].items) {
815         force = VOS_FORCE;
816     }
817
818     if (!vos_VLDBSync(cellHandle, vos_server, 0, part_ptr, force, &st)) {
819         ERR_ST_EXT("vos_VLDBSync", st);
820     }
821
822     return 0;
823 }
824
825 int
826 DoVosVolumeCreate(struct cmd_syndesc *as, void *arock)
827 {
828     typedef enum { SERVER, PARTITION, VOLUME,
829         QUOTA
830     } DoVosVolumeCreate_parm_t;
831     afs_status_t st = 0;
832     void *vos_server = NULL;
833     unsigned int partition_id = 0;
834     unsigned int volume_id;
835     const char *volume = NULL;
836     unsigned int quota = 0;
837
838     if (as->parms[SERVER].items) {
839         if (!vos_ServerOpen
840             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
841             ERR_ST_EXT("vos_ServerOpen", st);
842         }
843     }
844
845     if (as->parms[PARTITION].items) {
846         partition_id =
847             GetPartitionIdFromString(as->parms[PARTITION].items->data);
848     }
849
850     if (as->parms[VOLUME].items) {
851         volume = as->parms[VOLUME].items->data;
852     }
853
854     if (as->parms[QUOTA].items) {
855         quota =
856             GetIntFromString(as->parms[QUOTA].items->data, "invalid quota");
857     }
858
859     if (!vos_VolumeCreate
860         (cellHandle, vos_server, 0, partition_id, volume, quota, &volume_id,
861          &st)) {
862         ERR_ST_EXT("vos_VolumeCreate", st);
863     }
864
865     printf("Created volume %u\n", volume_id);
866
867     return 0;
868 }
869
870 int
871 DoVosVolumeDelete(struct cmd_syndesc *as, void *arock)
872 {
873     typedef enum { SERVER, PARTITION, VOLUME } DoVosVolumeDelete_parm_t;
874     afs_status_t st = 0;
875     void *vos_server = NULL;
876     unsigned int partition_id = 0;
877     unsigned int volume_id = 0;
878
879     if (as->parms[SERVER].items) {
880         if (!vos_ServerOpen
881             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
882             ERR_ST_EXT("vos_ServerOpen", st);
883         }
884     }
885
886     if (as->parms[PARTITION].items) {
887         partition_id =
888             GetPartitionIdFromString(as->parms[PARTITION].items->data);
889     }
890
891     if (as->parms[VOLUME].items) {
892         const char *volume = as->parms[VOLUME].items->data;
893         volume_id = GetVolumeIdFromString(volume);
894     }
895
896     if (!vos_VolumeDelete
897         (cellHandle, vos_server, 0, partition_id, volume_id, &st)) {
898         ERR_ST_EXT("vos_VolumeDelete", st);
899     }
900
901     return 0;
902 }
903
904 int
905 DoVosVolumeRename(struct cmd_syndesc *as, void *arock)
906 {
907     typedef enum { OLDVOLUME, NEWVOLUME } DoVosVolumeRename_parm_t;
908     afs_status_t st = 0;
909     unsigned int old_volume = 0;
910     const char *new_volume = 0;
911
912     if (as->parms[OLDVOLUME].items) {
913         const char *volume = as->parms[OLDVOLUME].items->data;
914         old_volume = GetVolumeIdFromString(volume);
915     }
916
917     if (as->parms[NEWVOLUME].items) {
918         new_volume = as->parms[NEWVOLUME].items->data;
919     }
920
921     if (!vos_VolumeRename(cellHandle, 0, old_volume, new_volume, &st)) {
922         ERR_ST_EXT("vos_VolumeRename", st);
923     }
924
925     return 0;
926 }
927
928 int
929 DoVosVolumeDump(struct cmd_syndesc *as, void *arock)
930 {
931     typedef enum { SERVER, PARTITION, VOLUME, STARTTIME,
932         DUMPFILE
933     } DoVosVolumeDump_parm_t;
934     afs_status_t st = 0;
935     void *vos_server = NULL;
936     unsigned int partition_id;
937     unsigned int *part_ptr = NULL;
938     int have_server = 0;
939     unsigned int volume_id = 0;
940     unsigned int start_time = 0;
941     const char *dumpfile = NULL;
942
943     if (as->parms[SERVER].items) {
944         if (!vos_ServerOpen
945             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
946             ERR_ST_EXT("vos_ServerOpen", st);
947         }
948         have_server = 1;
949     }
950
951     if (as->parms[PARTITION].items) {
952         if (!have_server) {
953             ERR_EXT("must specify server when specifying partition");
954         }
955         partition_id =
956             GetPartitionIdFromString(as->parms[PARTITION].items->data);
957         part_ptr = &partition_id;
958     }
959
960     if (as->parms[VOLUME].items) {
961         const char *volume = as->parms[VOLUME].items->data;
962         volume_id = GetVolumeIdFromString(volume);
963     }
964
965     if (as->parms[STARTTIME].items) {
966         start_time =
967             GetIntFromString(as->parms[STARTTIME].items->data,
968                              "invalid start time");
969     }
970
971     if (as->parms[DUMPFILE].items) {
972         dumpfile = as->parms[DUMPFILE].items->data;
973     }
974
975     if (!vos_VolumeDump
976         (cellHandle, vos_server, 0, part_ptr, volume_id, start_time, dumpfile,
977          &st)) {
978         ERR_ST_EXT("vos_VolumeDump", st);
979     }
980
981     return 0;
982 }
983
984 int
985 DoVosVolumeRestore(struct cmd_syndesc *as, void *arock)
986 {
987     typedef enum { SERVER, PARTITION, ID, VOLUME, DUMPFILE,
988         FULL
989     } DoVosVolumeRestore_parm_t;
990     afs_status_t st = 0;
991     void *vos_server = NULL;
992     unsigned int partition_id = 0;
993     unsigned int volume_id;
994     unsigned int *vol_ptr = NULL;
995     const char *dumpfile = NULL;
996     const char *volume_name = NULL;
997     vos_volumeRestoreType_t restore = VOS_RESTORE_INCREMENTAL;
998
999     if (as->parms[SERVER].items) {
1000         if (!vos_ServerOpen
1001             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
1002             ERR_ST_EXT("vos_ServerOpen", st);
1003         }
1004     }
1005
1006     if (as->parms[PARTITION].items) {
1007         partition_id =
1008             GetPartitionIdFromString(as->parms[PARTITION].items->data);
1009     }
1010
1011     if (as->parms[VOLUME].items) {
1012         volume_name = as->parms[VOLUME].items->data;
1013     }
1014
1015     if (as->parms[ID].items) {
1016         const char *volume = as->parms[ID].items->data;
1017         volume_id = GetVolumeIdFromString(volume);
1018         vol_ptr = &volume_id;
1019     }
1020
1021     if (as->parms[DUMPFILE].items) {
1022         dumpfile = as->parms[DUMPFILE].items->data;
1023     }
1024
1025     if (as->parms[FULL].items) {
1026         restore = VOS_RESTORE_FULL;
1027     }
1028
1029     if (!vos_VolumeRestore
1030         (cellHandle, vos_server, 0, partition_id, vol_ptr, volume_name,
1031          dumpfile, restore, &st)) {
1032         ERR_ST_EXT("vos_VolumeRestore", st);
1033     }
1034
1035     return 0;
1036 }
1037
1038 int
1039 DoVosVolumeOnline(struct cmd_syndesc *as, void *arock)
1040 {
1041     typedef enum { SERVER, PARTITION, VOLUME, SLEEP,
1042         BUSY
1043     } DoVosVolumeOnline_parm_t;
1044     afs_status_t st = 0;
1045     void *vos_server = NULL;
1046     unsigned int partition_id = 0;
1047     unsigned int volume_id = 0;
1048     unsigned int sleep = 0;
1049     vos_volumeOnlineType_t type = VOS_ONLINE_OFFLINE;
1050
1051     if (as->parms[SERVER].items) {
1052         if (!vos_ServerOpen
1053             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
1054             ERR_ST_EXT("vos_ServerOpen", st);
1055         }
1056     }
1057
1058     if (as->parms[PARTITION].items) {
1059         partition_id =
1060             GetPartitionIdFromString(as->parms[PARTITION].items->data);
1061     }
1062
1063     if (as->parms[VOLUME].items) {
1064         const char *volume = as->parms[VOLUME].items->data;
1065         volume_id = GetVolumeIdFromString(volume);
1066     }
1067
1068     if (as->parms[SLEEP].items) {
1069         sleep =
1070             GetIntFromString(as->parms[SLEEP].items->data,
1071                              "invalid sleep time");
1072     }
1073
1074     if (as->parms[BUSY].items) {
1075         type = VOS_ONLINE_BUSY;
1076     }
1077
1078     if (!vos_VolumeOnline
1079         (vos_server, 0, partition_id, volume_id, sleep, type, &st)) {
1080         ERR_ST_EXT("vos_VolumeOnline", st);
1081     }
1082
1083     return 0;
1084 }
1085
1086 int
1087 DoVosVolumeOffline(struct cmd_syndesc *as, void *arock)
1088 {
1089     typedef enum { SERVER, PARTITION, VOLUME } DoVosVolumeOffline_parm_t;
1090     afs_status_t st = 0;
1091     void *vos_server = NULL;
1092     unsigned int partition_id = 0;
1093     unsigned int volume_id = 0;
1094
1095     if (as->parms[SERVER].items) {
1096         if (!vos_ServerOpen
1097             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
1098             ERR_ST_EXT("vos_ServerOpen", st);
1099         }
1100     }
1101
1102     if (as->parms[PARTITION].items) {
1103         partition_id =
1104             GetPartitionIdFromString(as->parms[PARTITION].items->data);
1105     }
1106
1107     if (as->parms[VOLUME].items) {
1108         const char *volume = as->parms[VOLUME].items->data;
1109         volume_id = GetVolumeIdFromString(volume);
1110     }
1111
1112     if (!vos_VolumeOffline(vos_server, 0, partition_id, volume_id, &st)) {
1113         ERR_ST_EXT("vos_VolumeOffline", st);
1114     }
1115
1116     return 0;
1117 }
1118
1119 static void
1120 Print_vos_volumeEntry_p(vos_volumeEntry_p entry, const char *prefix)
1121 {
1122     if (entry->status == VOS_OK) {
1123         printf("%sVolume name %s id %u\n", prefix, entry->name, entry->id);
1124         printf("%sRead write id %u\n", prefix, entry->readWriteId);
1125         printf("%sRead only id %u\n", prefix, entry->readOnlyId);
1126         printf("%sBackup id %u\n", prefix, entry->backupId);
1127         printf("%sCreation date %lu\n", prefix, entry->creationDate);
1128         printf("%sLast access date %lu\n", prefix, entry->lastAccessDate);
1129         printf("%sLast update date %lu\n", prefix, entry->lastUpdateDate);
1130         printf("%sLast backup date %lu\n", prefix, entry->lastBackupDate);
1131         printf("%sLast copy creation date %lu\n", prefix,
1132                entry->copyCreationDate);
1133         printf("%sAccesses since midnight %d\n", prefix,
1134                entry->accessesSinceMidnight);
1135         printf("%sFile count %d\n", prefix, entry->fileCount);
1136         printf("%sMax quota %d\n", prefix, entry->maxQuota);
1137         printf("%sCurrent size %d\n", prefix, entry->currentSize);
1138
1139         printf("%sVolume status: VOS_OK\n", prefix);
1140
1141         printf("%sVolume disposition:\n", prefix);
1142
1143         switch (entry->volumeDisposition) {
1144         case VOS_OK:
1145             printf("%s\tVOS_OK\n", prefix);
1146             break;
1147         case VOS_SALVAGE:
1148             printf("%s\tVOS_SALVAGE\n", prefix);
1149             break;
1150         case VOS_NO_VNODE:
1151             printf("%s\tVOS_NO_VNODE\n", prefix);
1152             break;
1153         case VOS_NO_VOL:
1154             printf("%s\tVOS_NO_VOL\n", prefix);
1155             break;
1156         case VOS_VOL_EXISTS:
1157             printf("%s\tVOS_VOL_EXISTS\n", prefix);
1158             break;
1159         case VOS_NO_SERVICE:
1160             printf("%s\tVOS_NO_SERVICE\n", prefix);
1161             break;
1162         case VOS_OFFLINE:
1163             printf("%s\tVOS_OFFLINE\n", prefix);
1164             break;
1165         case VOS_ONLINE:
1166             printf("%s\tVOS_ONLINE\n", prefix);
1167             break;
1168         case VOS_DISK_FULL:
1169             printf("%s\tVOS_DISK_FULL\n", prefix);
1170             break;
1171         case VOS_OVER_QUOTA:
1172             printf("%s\tVOS_OVER_QUOTA\n", prefix);
1173             break;
1174         case VOS_BUSY:
1175             printf("%s\tVOS_BUSY\n", prefix);
1176             break;
1177         case VOS_MOVED:
1178             printf("%s\tVOS_MOVED\n", prefix);
1179             break;
1180         default:
1181             printf("Unknown volume disposition %d\n",
1182                    entry->volumeDisposition);
1183             break;
1184         }
1185
1186         printf("%sVolume type: ", prefix);
1187
1188         if (entry->type == VOS_READ_WRITE_VOLUME) {
1189             printf("read write\n");
1190         } else if (entry->type == VOS_READ_ONLY_VOLUME) {
1191             printf("read only\n");
1192         } else {
1193             printf("backup\n");
1194         }
1195
1196         printf("\n%s\tSame Network\tSame Network Authenticated"
1197                "\tDifferent Network\tDifferent Network Authenticated\n\n",
1198                prefix);
1199         printf("%sRead\t%d\t%d\t%d\t%d\n", prefix,
1200                entry->readStats[VOS_VOLUME_READ_WRITE_STATS_SAME_NETWORK],
1201                entry->
1202                readStats
1203                [VOS_VOLUME_READ_WRITE_STATS_SAME_NETWORK_AUTHENTICATED],
1204                entry->
1205                readStats[VOS_VOLUME_READ_WRITE_STATS_DIFFERENT_NETWORK],
1206                entry->
1207                readStats
1208                [VOS_VOLUME_READ_WRITE_STATS_DIFFERENT_NETWORK_AUTHENTICATED]);
1209         printf("%sWrite\t%d\t%d\t%d\t%d\n", prefix,
1210                entry->writeStats[VOS_VOLUME_READ_WRITE_STATS_SAME_NETWORK],
1211                entry->
1212                writeStats
1213                [VOS_VOLUME_READ_WRITE_STATS_SAME_NETWORK_AUTHENTICATED],
1214                entry->
1215                writeStats[VOS_VOLUME_READ_WRITE_STATS_DIFFERENT_NETWORK],
1216                entry->
1217                writeStats
1218                [VOS_VOLUME_READ_WRITE_STATS_DIFFERENT_NETWORK_AUTHENTICATED]);
1219
1220         printf
1221             ("\n%s\t0 to 60 secs\t1 to 10 mins\t10 to 60 mins\t1 to 24 hrs\t1 to 7 days\t more than 7 days\n",
1222              prefix);
1223         printf("%sFile Author Write Same Network\t%d\t%d\t%d\t%d\t%d\t%d\n",
1224                prefix,
1225                entry->
1226                fileAuthorWriteSameNetwork
1227                [VOS_VOLUME_TIME_STATS_0_TO_60_SECONDS],
1228                entry->
1229                fileAuthorWriteSameNetwork
1230                [VOS_VOLUME_TIME_STATS_1_TO_10_MINUTES],
1231                entry->
1232                fileAuthorWriteSameNetwork
1233                [VOS_VOLUME_TIME_STATS_10_TO_60_MINUTES],
1234                entry->
1235                fileAuthorWriteSameNetwork
1236                [VOS_VOLUME_TIME_STATS_1_TO_24_HOURS],
1237                entry->
1238                fileAuthorWriteSameNetwork[VOS_VOLUME_TIME_STATS_1_TO_7_DAYS],
1239                entry->
1240                fileAuthorWriteSameNetwork
1241                [VOS_VOLUME_TIME_STATS_GREATER_THAN_7_DAYS]);
1242         printf("%sFile Author Write Diff Network\t%d\t%d\t%d\t%d\t%d\t%d\n",
1243                prefix,
1244                entry->
1245                fileAuthorWriteDifferentNetwork
1246                [VOS_VOLUME_TIME_STATS_0_TO_60_SECONDS],
1247                entry->
1248                fileAuthorWriteDifferentNetwork
1249                [VOS_VOLUME_TIME_STATS_1_TO_10_MINUTES],
1250                entry->
1251                fileAuthorWriteDifferentNetwork
1252                [VOS_VOLUME_TIME_STATS_10_TO_60_MINUTES],
1253                entry->
1254                fileAuthorWriteDifferentNetwork
1255                [VOS_VOLUME_TIME_STATS_1_TO_24_HOURS],
1256                entry->
1257                fileAuthorWriteDifferentNetwork
1258                [VOS_VOLUME_TIME_STATS_1_TO_7_DAYS],
1259                entry->
1260                fileAuthorWriteDifferentNetwork
1261                [VOS_VOLUME_TIME_STATS_GREATER_THAN_7_DAYS]);
1262         printf("%sDir Author Write Same Network\t%d\t%d\t%d\t%d\t%d\t%d\n",
1263                prefix,
1264                entry->
1265                dirAuthorWriteSameNetwork
1266                [VOS_VOLUME_TIME_STATS_0_TO_60_SECONDS],
1267                entry->
1268                dirAuthorWriteSameNetwork
1269                [VOS_VOLUME_TIME_STATS_1_TO_10_MINUTES],
1270                entry->
1271                dirAuthorWriteSameNetwork
1272                [VOS_VOLUME_TIME_STATS_10_TO_60_MINUTES],
1273                entry->
1274                dirAuthorWriteSameNetwork[VOS_VOLUME_TIME_STATS_1_TO_24_HOURS],
1275                entry->
1276                dirAuthorWriteSameNetwork[VOS_VOLUME_TIME_STATS_1_TO_7_DAYS],
1277                entry->
1278                dirAuthorWriteSameNetwork
1279                [VOS_VOLUME_TIME_STATS_GREATER_THAN_7_DAYS]);
1280         printf("%sDir Author Write Diff Network\t%d\t%d\t%d\t%d\t%d\t%d\n",
1281                prefix,
1282                entry->
1283                dirAuthorWriteDifferentNetwork
1284                [VOS_VOLUME_TIME_STATS_0_TO_60_SECONDS],
1285                entry->
1286                dirAuthorWriteDifferentNetwork
1287                [VOS_VOLUME_TIME_STATS_1_TO_10_MINUTES],
1288                entry->
1289                dirAuthorWriteDifferentNetwork
1290                [VOS_VOLUME_TIME_STATS_10_TO_60_MINUTES],
1291                entry->
1292                dirAuthorWriteDifferentNetwork
1293                [VOS_VOLUME_TIME_STATS_1_TO_24_HOURS],
1294                entry->
1295                dirAuthorWriteDifferentNetwork
1296                [VOS_VOLUME_TIME_STATS_1_TO_7_DAYS],
1297                entry->
1298                dirAuthorWriteDifferentNetwork
1299                [VOS_VOLUME_TIME_STATS_GREATER_THAN_7_DAYS]);
1300     } else {
1301         printf("%sUnable to print volume because volume status:\n", prefix);
1302         switch (entry->status) {
1303         case VOS_SALVAGE:
1304             printf("%s\tVOS_SALVAGE\n", prefix);
1305             break;
1306         case VOS_NO_VNODE:
1307             printf("%s\tVOS_NO_VNODE\n", prefix);
1308             break;
1309         case VOS_NO_VOL:
1310             printf("%s\tVOS_NO_VOL\n", prefix);
1311             break;
1312         case VOS_VOL_EXISTS:
1313             printf("%s\tVOS_VOL_EXISTS\n", prefix);
1314             break;
1315         case VOS_NO_SERVICE:
1316             printf("%s\tVOS_NO_SERVICE\n", prefix);
1317             break;
1318         case VOS_OFFLINE:
1319             printf("%s\tVOS_OFFLINE\n", prefix);
1320             break;
1321         case VOS_ONLINE:
1322             printf("%s\tVOS_ONLINE\n", prefix);
1323             break;
1324         case VOS_DISK_FULL:
1325             printf("%s\tVOS_DISK_FULL\n", prefix);
1326             break;
1327         case VOS_OVER_QUOTA:
1328             printf("%s\tVOS_OVER_QUOTA\n", prefix);
1329             break;
1330         case VOS_BUSY:
1331             printf("%s\tVOS_BUSY\n", prefix);
1332             break;
1333         case VOS_MOVED:
1334             printf("%s\tVOS_MOVED\n", prefix);
1335             break;
1336         default:
1337             printf("Unknown volume status %d\n", entry->status);
1338             break;
1339         }
1340     }
1341 }
1342
1343 int
1344 DoVosVolumeGet(struct cmd_syndesc *as, void *arock)
1345 {
1346     typedef enum { SERVER, PARTITION, VOLUME } DoVosVolumeGet_parm_t;
1347     afs_status_t st = 0;
1348     void *vos_server = NULL;
1349     unsigned int partition_id = 0;
1350     unsigned int volume_id = 0;
1351     vos_volumeEntry_t entry;
1352
1353     if (as->parms[SERVER].items) {
1354         if (!vos_ServerOpen
1355             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
1356             ERR_ST_EXT("vos_ServerOpen", st);
1357         }
1358     }
1359
1360     if (as->parms[PARTITION].items) {
1361         partition_id =
1362             GetPartitionIdFromString(as->parms[PARTITION].items->data);
1363     }
1364
1365     if (as->parms[VOLUME].items) {
1366         const char *volume = as->parms[VOLUME].items->data;
1367         volume_id = GetVolumeIdFromString(volume);
1368     }
1369
1370     if (!vos_VolumeGet
1371         (cellHandle, vos_server, 0, partition_id, volume_id, &entry, &st)) {
1372         ERR_ST_EXT("vos_VolumeGet", st);
1373     }
1374
1375     Print_vos_volumeEntry_p(&entry, "");
1376
1377     return 0;
1378 }
1379
1380 int
1381 DoVosVolumeList(struct cmd_syndesc *as, void *arock)
1382 {
1383     typedef enum { SERVER, PARTITION } DoVosVolumeList_parm_t;
1384     afs_status_t st = 0;
1385     void *vos_server = NULL;
1386     void *iter = NULL;
1387     unsigned int partition_id = 0;
1388     vos_volumeEntry_t entry;
1389
1390     if (as->parms[SERVER].items) {
1391         if (!vos_ServerOpen
1392             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
1393             ERR_ST_EXT("vos_ServerOpen", st);
1394         }
1395     }
1396
1397     if (as->parms[PARTITION].items) {
1398         partition_id =
1399             GetPartitionIdFromString(as->parms[PARTITION].items->data);
1400     }
1401
1402     if (!vos_VolumeGetBegin
1403         (cellHandle, vos_server, 0, partition_id, &iter, &st)) {
1404         ERR_ST_EXT("vos_VolumeGetBegin", st);
1405     }
1406
1407     printf("Volumes located at %s partition %s\n",
1408            as->parms[SERVER].items->data, as->parms[PARTITION].items->data);
1409
1410     while (vos_VolumeGetNext(iter, &entry, &st)) {
1411         Print_vos_volumeEntry_p(&entry, "    ");
1412         printf("\n");
1413     }
1414
1415     if (st != ADMITERATORDONE) {
1416         ERR_ST_EXT("vos_VolumeGetNext", st);
1417     }
1418
1419     if (!vos_VolumeGetDone(iter, &st)) {
1420         ERR_ST_EXT("vos_VolumeGetDone", st);
1421     }
1422
1423     return 0;
1424 }
1425
1426 int
1427 DoVosVolumeMove(struct cmd_syndesc *as, void *arock)
1428 {
1429     typedef enum { VOLUME, FROMSERVER, FROMPARTITION, TOSERVER,
1430         TOPARTITION
1431     } DoVosVolumeMove_parm_t;
1432     afs_status_t st = 0;
1433     void *from_server = NULL;
1434     void *to_server = NULL;
1435     unsigned int from_partition = 0;
1436     unsigned int to_partition = 0;
1437     unsigned int volume_id = 0;
1438
1439     if (as->parms[FROMSERVER].items) {
1440         if (!vos_ServerOpen
1441             (cellHandle, as->parms[FROMSERVER].items->data, &from_server,
1442              &st)) {
1443             ERR_ST_EXT("vos_ServerOpen", st);
1444         }
1445     }
1446
1447     if (as->parms[TOSERVER].items) {
1448         if (!vos_ServerOpen
1449             (cellHandle, as->parms[TOSERVER].items->data, &to_server, &st)) {
1450             ERR_ST_EXT("vos_ServerOpen", st);
1451         }
1452     }
1453
1454     if (as->parms[FROMPARTITION].items) {
1455         from_partition =
1456             GetPartitionIdFromString(as->parms[FROMPARTITION].items->data);
1457     }
1458
1459     if (as->parms[TOPARTITION].items) {
1460         to_partition =
1461             GetPartitionIdFromString(as->parms[TOPARTITION].items->data);
1462     }
1463
1464     if (as->parms[VOLUME].items) {
1465         const char *volume = as->parms[VOLUME].items->data;
1466         volume_id = GetVolumeIdFromString(volume);
1467     }
1468
1469     if (!vos_VolumeMove
1470         (cellHandle, 0, volume_id, from_server, from_partition, to_server,
1471          to_partition, &st)) {
1472         ERR_ST_EXT("vos_VolumeMove", st);
1473     }
1474
1475     return 0;
1476 }
1477
1478 int
1479 DoVosVolumeRelease(struct cmd_syndesc *as, void *arock)
1480 {
1481     typedef enum { VOLUME, FORCE } DoVosVolumeRelease_parm_t;
1482     afs_status_t st = 0;
1483     unsigned int volume_id = 0;
1484     vos_force_t force = VOS_NORMAL;
1485
1486     if (as->parms[VOLUME].items) {
1487         const char *volume = as->parms[VOLUME].items->data;
1488         volume_id = GetVolumeIdFromString(volume);
1489     }
1490
1491     if (as->parms[FORCE].items) {
1492         force = VOS_FORCE;
1493     }
1494
1495     if (!vos_VolumeRelease(cellHandle, 0, volume_id, force, &st)) {
1496         ERR_ST_EXT("vos_VolumeRelease", st);
1497     }
1498     return 0;
1499 }
1500
1501 int
1502 DoVosVolumeZap(struct cmd_syndesc *as, void *arock)
1503 {
1504     typedef enum { SERVER, PARTITION, VOLUME, FORCE } DoVosVolumeZap_parm_t;
1505     afs_status_t st = 0;
1506     void *vos_server = NULL;
1507     unsigned int partition_id = 0;
1508     unsigned int volume_id = 0;
1509     vos_force_t force = VOS_NORMAL;
1510
1511     if (as->parms[SERVER].items) {
1512         if (!vos_ServerOpen
1513             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
1514             ERR_ST_EXT("vos_ServerOpen", st);
1515         }
1516     }
1517
1518     if (as->parms[PARTITION].items) {
1519         partition_id =
1520             GetPartitionIdFromString(as->parms[PARTITION].items->data);
1521     }
1522
1523     if (as->parms[VOLUME].items) {
1524         const char *volume = as->parms[VOLUME].items->data;
1525         volume_id = GetVolumeIdFromString(volume);
1526     }
1527
1528     if (as->parms[FORCE].items) {
1529         force = VOS_FORCE;
1530     }
1531
1532     if (!vos_VolumeZap
1533         (cellHandle, vos_server, 0, partition_id, volume_id, force, &st)) {
1534         ERR_ST_EXT("vos_VolumeZap", st);
1535     }
1536
1537     return 0;
1538 }
1539
1540 int
1541 DoVosPartitionNameToId(struct cmd_syndesc *as, void *arock)
1542 {
1543     typedef enum { PARTITION } DoVosPartitionNameToId_parm_t;
1544     unsigned int partition_id = 0;
1545
1546     if (as->parms[PARTITION].items) {
1547         partition_id =
1548             GetPartitionIdFromString(as->parms[PARTITION].items->data);
1549     }
1550
1551     printf("The id for partition %s is %u\n",
1552            as->parms[PARTITION].items->data, partition_id);
1553
1554     return 0;
1555 }
1556
1557 int
1558 DoVosPartitionIdToName(struct cmd_syndesc *as, void *arock)
1559 {
1560     typedef enum { PARTITIONID } DoVosPartitionIdToName_parm_t;
1561     afs_status_t st = 0;
1562     unsigned int partition_id = 0;
1563     char partition[VOS_MAX_PARTITION_NAME_LEN];
1564
1565     if (as->parms[PARTITIONID].items) {
1566         partition_id =
1567             GetIntFromString(as->parms[PARTITIONID].items->data,
1568                              "bad partition id");
1569     }
1570
1571     if (!vos_PartitionIdToName(partition_id, partition, &st)) {
1572         ERR_ST_EXT("bad partition id", st);
1573     }
1574
1575     printf("The partition for id %u is %s\n", partition_id, partition);
1576
1577     return 0;
1578 }
1579
1580 int
1581 DoVosVolumeQuotaChange(struct cmd_syndesc *as, void *arock)
1582 {
1583     typedef enum { SERVER, PARTITION, VOLUME,
1584         QUOTA
1585     } DoVosVolumeQuotaChange_parm_t;
1586     afs_status_t st = 0;
1587     void *vos_server = NULL;
1588     unsigned int partition_id = 0;
1589     unsigned int volume_id = 0;
1590     unsigned int quota = 0;
1591
1592     if (as->parms[SERVER].items) {
1593         if (!vos_ServerOpen
1594             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
1595             ERR_ST_EXT("vos_ServerOpen", st);
1596         }
1597     }
1598
1599     if (as->parms[PARTITION].items) {
1600         partition_id =
1601             GetPartitionIdFromString(as->parms[PARTITION].items->data);
1602     }
1603
1604     if (as->parms[VOLUME].items) {
1605         const char *volume = as->parms[VOLUME].items->data;
1606         volume_id = GetVolumeIdFromString(volume);
1607     }
1608
1609     if (as->parms[QUOTA].items) {
1610         quota =
1611             GetIntFromString(as->parms[QUOTA].items->data, "invalid quota");
1612     }
1613
1614     if (!vos_VolumeQuotaChange
1615         (cellHandle, vos_server, 0, partition_id, volume_id, quota, &st)) {
1616         ERR_ST_EXT("vos_VolumeQuotaChange", st);
1617     }
1618
1619     return 0;
1620 }
1621
1622 /*
1623  * Parse a server name/address and return the address in HOST BYTE order
1624  */
1625 static afs_uint32
1626 GetServer(char *aname)
1627 {
1628     register struct hostent *th;
1629     afs_uint32 addr;
1630     int b1, b2, b3, b4;
1631     register afs_int32 code;
1632     char hostname[MAXHOSTCHARS];
1633
1634     code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
1635     if (code == 4) {
1636         addr = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
1637         addr = ntohl(addr);     /* convert to host order */
1638     } else {
1639         th = gethostbyname(aname);
1640         if (!th)
1641             return 0;
1642         memcpy(&addr, th->h_addr, sizeof(addr));
1643     }
1644
1645     if (addr == htonl(0x7f000001)) {    /* local host */
1646         code = gethostname(hostname, MAXHOSTCHARS);
1647         if (code)
1648             return 0;
1649         th = gethostbyname(hostname);   /* returns host byte order */
1650         if (!th)
1651             return 0;
1652         memcpy(&addr, th->h_addr, sizeof(addr));
1653     }
1654
1655     return (addr);
1656 }
1657
1658 static void
1659 Print_vos_volintInfo(afs_uint32 server, afs_uint32 partition, volintInfo* pinfo, const char *prefix)
1660 {
1661     static afs_uint32 server_cache;
1662     static int cache_valid = 0;
1663     static char hostname[256], address[32];
1664
1665     if (!cache_valid || server != server_cache) {
1666         struct in_addr s;
1667
1668         s.s_addr = server;
1669         strcpy(hostname, hostutil_GetNameByINet(server));
1670         strcpy(address, inet_ntoa(s));
1671         server_cache = server;
1672         cache_valid = 1;
1673     }
1674     
1675     
1676     printf("%sname\t\t%s\n",prefix, pinfo->name);
1677     printf("%sid\t\t%lu\n",prefix, afs_printable_uint32_lu(pinfo->volid));
1678     printf("%sserv\t\t%s\t%s\n",prefix, address,hostname);
1679     printf("%spart\t\t%u\n", prefix,partition);
1680     
1681     switch (pinfo->status) {
1682     case 2: /* VOK */
1683         printf("%sstatus\t\tOK\n",prefix);
1684         break;
1685     case 101: /* VBUSY */
1686         printf("%sstatus\t\tBUSY\n",prefix);
1687         return;
1688     default:
1689         printf("%sstatus\t\tUNATTACHABLE\n",prefix);
1690         return;
1691     }
1692     printf("%sbackupID\t%lu\n",prefix,
1693            afs_printable_uint32_lu(pinfo->backupID));
1694     printf("%sparentID\t%lu\n",prefix,
1695            afs_printable_uint32_lu(pinfo->parentID));
1696     printf("%scloneID\t%lu\n",prefix,
1697            afs_printable_uint32_lu(pinfo->cloneID));
1698     printf("%sinUse\t\t%s\n",prefix, pinfo->inUse ? "Y" : "N");
1699     printf("%sneedsSalvaged\t%s\n",prefix, pinfo->needsSalvaged ? "Y" : "N");
1700     /* 0xD3 is from afs/volume.h since I had trouble including the file */
1701     printf("%sdestroyMe\t%s\n",prefix, pinfo->destroyMe == 0xD3 ? "Y" : "N");
1702     switch (pinfo->type) {
1703     case 0:
1704         printf("%stype\t\tRW\n",prefix);
1705         break;
1706     case 1:
1707         printf("%stype\t\tRO\n",prefix);
1708         break;
1709     case 2:
1710         printf("%stype\t\tBK\n",prefix);
1711         break;
1712     default:
1713         printf("%stype\t\t?\n",prefix);
1714         break;
1715     }
1716     printf("%screationDate\t%-9lu\n", prefix,
1717            afs_printable_uint32_lu(pinfo->creationDate));
1718     printf("%saccessDate\t%-9lu\n", prefix,
1719            afs_printable_uint32_lu(pinfo->accessDate));
1720     printf("%supdateDate\t%-9lu\n", prefix,
1721            afs_printable_uint32_lu(pinfo->updateDate));
1722     printf("%sbackupDate\t%-9lu\n", prefix,
1723            afs_printable_uint32_lu(pinfo->backupDate));
1724     printf("%scopyDate\t%-9lu\n", prefix,
1725            afs_printable_uint32_lu(pinfo->copyDate));
1726             
1727     printf("%sflags\t\t%#lx\t(Optional)\n",prefix, pinfo->flags);
1728     printf("%sdiskused\t%u\n",prefix, pinfo->size);
1729     printf("%smaxquota\t%u\n",prefix, pinfo->maxquota);
1730     printf("%sminquota\t%lu\t(Optional)\n",prefix,
1731            afs_printable_uint32_lu(pinfo->spare0));
1732     printf("%sfilecount\t%u\n",prefix, pinfo->filecount);
1733     printf("%sdayUse\t\t%u\n",prefix, pinfo->dayUse);
1734     printf("%sweekUse\t%lu\t(Optional)\n",prefix,
1735            afs_printable_uint32_lu(pinfo->spare1));
1736     printf("%svolUpdateCounter\t\t%lu\t(Optional)\n",prefix,
1737            afs_printable_uint32_lu(pinfo->spare2));
1738     printf("%sspare3\t\t%lu\t(Optional)\n",prefix,
1739            afs_printable_uint32_lu(pinfo->spare3));
1740 }
1741
1742 int
1743 DoVosVolumeGet2(struct cmd_syndesc *as, void *arock)
1744 {
1745     typedef enum { SERVER, PARTITION, VOLUME } DoVosVolumeGet_parm_t;
1746     afs_status_t st = 0;
1747     void *vos_server = NULL;
1748     afs_uint32 partition_id = 0;
1749     afs_uint32 volume_id = 0;
1750
1751         volintInfo info;
1752         memset(&info, 0, sizeof(struct volintInfo));
1753
1754     if (as->parms[SERVER].items) {
1755         if (!vos_ServerOpen
1756             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
1757             ERR_ST_EXT("vos_ServerOpen", st);
1758         }
1759     }
1760
1761     if (as->parms[PARTITION].items) {
1762         partition_id =
1763             GetPartitionIdFromString(as->parms[PARTITION].items->data);
1764     }
1765
1766     if (as->parms[VOLUME].items) {
1767         const char *volume = as->parms[VOLUME].items->data;
1768         volume_id = GetVolumeIdFromString(volume);
1769     }
1770     
1771
1772         if (!vos_VolumeGet2
1773         (cellHandle, vos_server, 0, partition_id, volume_id, &info, &st)) {
1774         ERR_ST_EXT("vos_VolumeGet2", st);
1775     }
1776
1777
1778     Print_vos_volintInfo(GetServer(as->parms[SERVER].items->data),partition_id,&info," ");
1779
1780     return 0;
1781 }
1782
1783
1784 int
1785 DoVos_ClearVolUpdateCounter(struct cmd_syndesc *as, void *arock)
1786 {
1787     typedef enum { SERVER, PARTITION, VOLUME } DoVosVolumeGet_parm_t;
1788     afs_status_t st = 0;
1789     void *vos_server = NULL;
1790     unsigned int partition_id = 0;
1791     unsigned int volume_id = 0;
1792
1793     if (as->parms[SERVER].items) {
1794         if (!vos_ServerOpen
1795             (cellHandle, as->parms[SERVER].items->data, &vos_server, &st)) {
1796             ERR_ST_EXT("vos_ServerOpen", st);
1797         }
1798     }
1799
1800     if (as->parms[PARTITION].items) {
1801         partition_id =
1802             GetPartitionIdFromString(as->parms[PARTITION].items->data);
1803     }
1804
1805     if (as->parms[VOLUME].items) {
1806         const char *volume = as->parms[VOLUME].items->data;
1807         volume_id = GetVolumeIdFromString(volume);
1808     }
1809
1810     if (!vos_ClearVolUpdateCounter
1811         (cellHandle, vos_server,partition_id, volume_id, &st)) {
1812         ERR_ST_EXT("vos_ClearVolUpdateCounter", st);
1813     }
1814
1815     return 0;
1816 }
1817
1818 void
1819 SetupVosAdminCmd(void)
1820 {
1821     struct cmd_syndesc *ts;
1822
1823     ts = cmd_CreateSyntax("VosBackupVolumeCreate", DoVosBackupVolumeCreate, NULL,
1824                           "create a backup volume");
1825     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED, "volume to back up");
1826     SetupCommonCmdArgs(ts);
1827
1828     ts = cmd_CreateSyntax("VosBackupVolumeCreateMultiple",
1829                           DoVosBackupVolumeCreateMultiple, NULL,
1830                           "create a backup volume");
1831     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL,
1832                 "server housing volumes to back up");
1833     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1834                 "partition housing volumes to back up");
1835     cmd_AddParm(ts, "-prefix", CMD_SINGLE, CMD_OPTIONAL,
1836                 "common prefix of volumes to back up");
1837     cmd_AddParm(ts, "-exclude", CMD_FLAG, CMD_OPTIONAL,
1838                 "exclude volumes from backup that match prefix");
1839     SetupCommonCmdArgs(ts);
1840
1841     ts = cmd_CreateSyntax("VosPartitionGet", DoVosPartitionGet, NULL,
1842                           "get information about a partition");
1843     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED,
1844                 "server housing partition of interest");
1845     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_REQUIRED,
1846                 "partition to query");
1847     SetupCommonCmdArgs(ts);
1848
1849     ts = cmd_CreateSyntax("VosPartitionList", DoVosPartitionList, NULL,
1850                           "list information about all partitions at a server");
1851     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED,
1852                 "server housing partitions of interest");
1853     SetupCommonCmdArgs(ts);
1854
1855     ts = cmd_CreateSyntax("VosServerSync", DoVosServerSync, NULL,
1856                           "sync server with vldb");
1857     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "server to sync");
1858     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1859                 "partition to sync");
1860     SetupCommonCmdArgs(ts);
1861
1862     ts = cmd_CreateSyntax("VosFileServerAddressChange",
1863                           DoVosFileServerAddressChange, NULL,
1864                           "change a server's address in the vldb");
1865     cmd_AddParm(ts, "-oldaddress", CMD_SINGLE, CMD_REQUIRED,
1866                 "old address to change");
1867     cmd_AddParm(ts, "-newaddress", CMD_SINGLE, CMD_REQUIRED, "new address");
1868     SetupCommonCmdArgs(ts);
1869
1870     ts = cmd_CreateSyntax("VosFileServerAddressRemove",
1871                           DoVosFileServerAddressRemove, NULL,
1872                           "remove a server's address from the vldb");
1873     cmd_AddParm(ts, "-address", CMD_SINGLE, CMD_REQUIRED,
1874                 "address to remove");
1875     SetupCommonCmdArgs(ts);
1876
1877     ts = cmd_CreateSyntax("VosFileServerList", DoVosFileServerList, NULL,
1878                           "list the file servers in a cell");
1879     SetupCommonCmdArgs(ts);
1880
1881     ts = cmd_CreateSyntax("VosServerTransactionStatusList",
1882                           DoVosServerTransactionStatusList, NULL,
1883                           "list the active transactions at a server");
1884     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "server to query");
1885     SetupCommonCmdArgs(ts);
1886
1887     ts = cmd_CreateSyntax("VosVLDBGet", DoVosVLDBGet, NULL,
1888                           "get a vldb entry for a volume");
1889     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED,
1890                 "volume to retrieve");
1891     SetupCommonCmdArgs(ts);
1892
1893     ts = cmd_CreateSyntax("VosVLDBList", DoVosVLDBList, NULL,
1894                           "list a group of vldb entries");
1895     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL,
1896                 "limit entries to a particular server");
1897     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1898                 "limit entries to a particular partition");
1899     SetupCommonCmdArgs(ts);
1900
1901     ts = cmd_CreateSyntax("VosVLDBEntryRemove", DoVosVLDBEntryRemove, NULL,
1902                           "remove vldb entries");
1903     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL,
1904                 "limit entries to a particular server");
1905     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1906                 "limit entries to a particular partition");
1907     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL, "volume to remove");
1908     SetupCommonCmdArgs(ts);
1909
1910     ts = cmd_CreateSyntax("VosVLDBUnlock", DoVosVLDBUnlock, NULL,
1911                           "unlock a group of vldb entries");
1912     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL,
1913                 "limit entries to a particular server");
1914     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1915                 "limit entries to a particular partition");
1916     SetupCommonCmdArgs(ts);
1917
1918     ts = cmd_CreateSyntax("VosVLDBEntryLock", DoVosVLDBList, NULL,
1919                           "lock a single vldb entry");
1920     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED, "volume to lock");
1921     SetupCommonCmdArgs(ts);
1922
1923     ts = cmd_CreateSyntax("VosVLDBEntryUnlock", DoVosVLDBEntryUnlock, NULL,
1924                           "unlock a single vldb entry");
1925     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED, "volume to unlock");
1926     SetupCommonCmdArgs(ts);
1927
1928     ts = cmd_CreateSyntax("VosVLDBReadOnlySiteCreate",
1929                           DoVosVLDBReadOnlySiteCreate, NULL,
1930                           "create a read only site");
1931     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED,
1932                 "server where read only will be created");
1933     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_REQUIRED,
1934                 "partition where read only will be created");
1935     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED,
1936                 "volume to replicate");
1937     SetupCommonCmdArgs(ts);
1938
1939     ts = cmd_CreateSyntax("VosVLDBReadOnlySiteDelete",
1940                           DoVosVLDBReadOnlySiteDelete, NULL,
1941                           "delete a read only site before initial replication");
1942     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL,
1943                 "server where read only will be deleted");
1944     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1945                 "partition where read only will be deleted");
1946     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED, "volume to delete");
1947     SetupCommonCmdArgs(ts);
1948
1949     ts = cmd_CreateSyntax("VosVLDBSync", DoVosVLDBSync, NULL,
1950                           "sync vldb with server");
1951     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "server to sync");
1952     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1953                 "limit sync to a particular partition");
1954     cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, "force sync to occur");
1955     SetupCommonCmdArgs(ts);
1956
1957     ts = cmd_CreateSyntax("VosVolumeCreate", DoVosVolumeCreate, NULL,
1958                           "create a read write volume");
1959     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED,
1960                 "server where volume will be created");
1961     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_REQUIRED,
1962                 "partition where volume will be created");
1963     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED,
1964                 "name of new volume");
1965     cmd_AddParm(ts, "-quota", CMD_SINGLE, CMD_REQUIRED,
1966                 "size quota of new volume in 1kb units");
1967     SetupCommonCmdArgs(ts);
1968
1969     ts = cmd_CreateSyntax("VosVolumeDelete", DoVosVolumeDelete, NULL,
1970                           "delete a volume");
1971     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED,
1972                 "server where volume exists");
1973     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_REQUIRED,
1974                 "partition where volume exists");
1975     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED, "volume to delete");
1976     SetupCommonCmdArgs(ts);
1977
1978     ts = cmd_CreateSyntax("VosVolumeRename", DoVosVolumeRename, NULL,
1979                           "rename a volume");
1980     cmd_AddParm(ts, "-oldname", CMD_SINGLE, CMD_REQUIRED, "old volume name");
1981     cmd_AddParm(ts, "-newname", CMD_SINGLE, CMD_REQUIRED, "new volume name");
1982     SetupCommonCmdArgs(ts);
1983
1984     ts = cmd_CreateSyntax("VosVolumeDump", DoVosVolumeDump, NULL,
1985                           "dump a volume to a file");
1986     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL,
1987                 "dump volume at a particular server");
1988     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1989                 "dump volume at a particular partition");
1990     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED, "volume to dump");
1991     cmd_AddParm(ts, "-starttime", CMD_SINGLE, CMD_REQUIRED,
1992                 "files modified after this time will be dumped");
1993     cmd_AddParm(ts, "-dumpfile", CMD_SINGLE, CMD_REQUIRED,
1994                 "file to contain dump results");
1995     SetupCommonCmdArgs(ts);
1996
1997     ts = cmd_CreateSyntax("VosVolumeRestore", DoVosVolumeRestore, NULL,
1998                           "restore a volume from a dumpfile");
1999     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED,
2000                 "server that houses volume to restore");
2001     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_REQUIRED,
2002                 "partition that houses volume to restore");
2003     cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_OPTIONAL, "id of volume restored");
2004     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED,
2005                 "name of volume restored");
2006     cmd_AddParm(ts, "-dumpfile", CMD_SINGLE, CMD_REQUIRED,
2007                 "file contained dump of volume");
2008     cmd_AddParm(ts, "-full", CMD_FLAG, CMD_OPTIONAL,
2009                 "does a full restore of volume");
2010     SetupCommonCmdArgs(ts);
2011
2012     ts = cmd_CreateSyntax("VosVolumeOnline", DoVosVolumeOnline, NULL,
2013                           "bring a volume online");
2014     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED,
2015                 "server that houses volume");
2016     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_REQUIRED,
2017                 "partition that houses volume");
2018     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED,
2019                 "volume to bring online");
2020     cmd_AddParm(ts, "-sleep", CMD_SINGLE, CMD_REQUIRED, "seconds to sleep");
2021     cmd_AddParm(ts, "-busy", CMD_FLAG, CMD_OPTIONAL, "mark volume busy");
2022     SetupCommonCmdArgs(ts);
2023
2024     ts = cmd_CreateSyntax("VosVolumeOffline", DoVosVolumeOffline, NULL,
2025                           "take a volume offline");
2026     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED,
2027                 "server that houses volume");
2028     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_REQUIRED,
2029                 "partition that houses volume");
2030     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED,
2031                 "volume to bring offline");
2032     SetupCommonCmdArgs(ts);
2033
2034     ts = cmd_CreateSyntax("VosVolumeGet", DoVosVolumeGet, NULL,
2035                           "get a volume entry");
2036     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED,
2037                 "server that houses volume");
2038     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_REQUIRED,
2039                 "partition that houses volume");
2040     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED,
2041                 "volume to retrieve");
2042     SetupCommonCmdArgs(ts);
2043
2044     ts = cmd_CreateSyntax("VosVolumeList", DoVosVolumeList, NULL,
2045                           "list a group of volumes");
2046     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED,
2047                 "limit volumes to a particular server");
2048     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_REQUIRED,
2049                 "limit volumes to a particular partition");
2050     SetupCommonCmdArgs(ts);
2051
2052     ts = cmd_CreateSyntax("VosVolumeMove", DoVosVolumeMove, NULL,
2053                           "move a volume");
2054     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED, "volume to move");
2055     cmd_AddParm(ts, "-fromserver", CMD_SINGLE, CMD_REQUIRED, "source server");
2056     cmd_AddParm(ts, "-frompartition", CMD_SINGLE, CMD_REQUIRED,
2057                 "source partition");
2058     cmd_AddParm(ts, "-toserver", CMD_SINGLE, CMD_REQUIRED,
2059                 "destination server");
2060     cmd_AddParm(ts, "-topartition", CMD_SINGLE, CMD_REQUIRED,
2061                 "destination partition");
2062     SetupCommonCmdArgs(ts);
2063
2064     ts = cmd_CreateSyntax("VosVolumeRelease", DoVosVolumeRelease, NULL,
2065                           "release updates to read only");
2066     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED,
2067                 "volume to replicate");
2068     cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
2069                 "force release to occur");
2070     SetupCommonCmdArgs(ts);
2071
2072     ts = cmd_CreateSyntax("VosVolumeZap", DoVosVolumeZap, NULL, "zap a volume");
2073     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED,
2074                 "server that houses the volume to zap");
2075     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_REQUIRED,
2076                 "partition that houses the volume to zap");
2077     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED, "volume to zap");
2078     cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, "force zap");
2079     SetupCommonCmdArgs(ts);
2080
2081     ts = cmd_CreateSyntax("VosPartitionNameToId", DoVosPartitionNameToId, NULL,
2082                           "convert a partition name to a number");
2083     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_REQUIRED,
2084                 "partition to convert");
2085     SetupCommonCmdArgs(ts);
2086
2087     ts = cmd_CreateSyntax("VosPartitionIdToName", DoVosPartitionIdToName, NULL,
2088                           "convert a number to a partition");
2089     cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_REQUIRED, "number to convert");
2090     SetupCommonCmdArgs(ts);
2091
2092     ts = cmd_CreateSyntax("VosVolumeQuotaChange", DoVosVolumeQuotaChange, NULL,
2093                           "change the quota for a partition");
2094     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED,
2095                 "server that houses the volume");
2096     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_REQUIRED,
2097                 "partition that houses the volume");
2098     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED, "volume to change");
2099     cmd_AddParm(ts, "-quota", CMD_SINGLE, CMD_REQUIRED,
2100                 "new quota in 1kb units");
2101     SetupCommonCmdArgs(ts);
2102
2103     ts = cmd_CreateSyntax("VosVolumeGet2", DoVosVolumeGet2, NULL,
2104                           "get a volume entry");
2105     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED,
2106                 "server that houses volume");
2107     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_REQUIRED,
2108                 "partition that houses volume");
2109     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED,
2110                 "volume to retrieve");
2111     SetupCommonCmdArgs(ts);
2112     
2113     ts = cmd_CreateSyntax("ClearVolUpdateCounter", DoVos_ClearVolUpdateCounter, NULL,
2114                           "clear volUpdateCounter");
2115     cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED,
2116                 "server that houses volume");
2117     cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_REQUIRED,
2118                 "partition that houses volume");
2119     cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_REQUIRED,
2120                 "volume");
2121     SetupCommonCmdArgs(ts);
2122
2123 }
2124