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