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