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