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