venus: Remove dedebug
[openafs.git] / src / budb / struct_ops.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 #include <afsconfig.h>
11 #include <afs/param.h>
12 #include <afs/stds.h>
13
14 #include <roken.h>
15
16 #include <afs/bubasics.h>
17 #include <afs/afsutil.h>
18 #include <rx/xdr.h>
19 #include <rx/rx.h>
20
21 #include "budb.h"
22 #include "budb_errs.h"
23 #include "database.h"
24 #include "budb_internal.h"
25 #include "budb_prototypes.h"
26
27 /* ----------------------------------
28  * structure printing utilities
29  * ----------------------------------
30  */
31
32 void
33 printDbHeader(struct DbHeader *ptr)
34 {
35     time_t created = ptr->created;
36     printf("version = %d\n", ptr->dbversion);
37     printf("created = %s", ctime(&created));
38     printf("cell = %s\n", ptr->cell);
39     printf("lastDumpId = %u\n", ptr->lastDumpId);
40     printf("lastInstanceId = %d\n", ptr->lastInstanceId);
41     printf("lastTapeId = %d\n", ptr->lastTapeId);
42 }
43
44 void
45 printDump(FILE *fid, struct dump *dptr)
46 {
47     time_t created = dptr->created;
48     fprintf(fid, "id = %u\n", dptr->id);
49     fprintf(fid, "idHashChain = %d\n", dptr->idHashChain);
50     fprintf(fid, "name = %s\n", dptr->dumpName);
51     fprintf(fid, "vsname = %s\n", dptr->volumeSet);
52     fprintf(fid, "dumpPath = %s\n", dptr->dumpPath);
53     fprintf(fid, "nameHashChain = %d\n", dptr->nameHashChain);
54     fprintf(fid, "flags = 0x%x\n", dptr->flags);
55     fprintf(fid, "parent = %u\n", dptr->parent);
56     fprintf(fid, "created = %s", ctime(&created));
57     fprintf(fid, "nVolumes = %d\n", dptr->nVolumes);
58     /* printTapeSet(&dptr->tapes); */
59     fprintf(fid, "firstTape = %d\n", dptr->firstTape);
60     /* printKtcPrincipal(&dptr->dumper); */
61
62 }
63
64 void
65 printDumpEntry(struct budb_dumpEntry *deptr)
66 {
67     time_t created = deptr->created;
68     printf("id = %u\n", deptr->id);
69     printf("Initial id = %u\n", deptr->initialDumpID);
70     printf("Appended id = %u\n", deptr->appendedDumpID);
71     printf("parent = %u\n", deptr->parent);
72     printf("level = %d\n", deptr->level);
73     printf("flags = 0x%x", deptr->flags);
74     if (deptr->flags == 0)
75         printf(": Successful");
76     if (deptr->flags & BUDB_DUMP_INCOMPLETE)
77         printf(": Incomplete");
78     if (deptr->flags & BUDB_DUMP_TAPEERROR)
79         printf(": Tape error");
80     if (deptr->flags & BUDB_DUMP_INPROGRESS)
81         printf(": In progress");
82     if (deptr->flags & BUDB_DUMP_ABORTED)
83         printf(": Aborted");
84     if (deptr->flags & BUDB_DUMP_ADSM)
85         printf(": (ADSM)");     /* XBSA interface to ADSM */
86     if (deptr->flags & BUDB_DUMP_BUTA)
87         printf(": (BUTA)");     /* buta dump */
88     printf("\n");
89     printf("volumeSet = %s\n", deptr->volumeSetName);
90     printf("dump path = %s\n", deptr->dumpPath);
91     printf("name = %s\n", deptr->name);
92     printf("created = %s", ctime(&created));
93     printf("nVolumes = %d\n", deptr->nVolumes);
94
95     printTapeSet(&deptr->tapes, (deptr->flags & BUDB_DUMP_XBSA_NSS));
96     printPrincipal(&deptr->dumper);
97 }
98
99 /* printMemoryHashTable
100  *      print the hash table structure, i.e. the header structure.
101  */
102 int
103 printMemoryHashTable(FILE *fid, struct memoryHashTable *mhtptr)
104 {
105     fprintf(fid, "threadOffset = %d\n", mhtptr->threadOffset);
106     fprintf(fid, "length = %d\n", mhtptr->length);
107     fprintf(fid, "progress = %d\n", mhtptr->progress);
108     fprintf(fid, "size = %d\n", mhtptr->size);
109     fprintf(fid, "oldsize = %d\n", mhtptr->oldSize);
110     return 0;
111 }
112
113 int
114 printPrincipal(struct budb_principal *ptr)
115 {
116     printf("name = %s\n", ptr->name);
117     printf("instance = %s\n", ptr->instance);
118     printf("cell = %s\n", ptr->cell);
119     return 0;
120 }
121
122 int
123 printStructDumpHeader(struct structDumpHeader *ptr)
124 {
125     printf("type = %d\n", ptr->type);
126     printf("structure version = %d\n", ptr->structversion);
127     printf("size = %d bytes\n", ptr->size);
128     return 0;
129 }
130
131 int
132 printTape(FILE *fid, struct tape *tptr)
133 {
134     time_t written = tptr->written;
135     fprintf(fid, "name = %s\n", tptr->name);
136     fprintf(fid, "nameHashChain = %d\n", tptr->nameHashChain);
137     fprintf(fid, "flags = 0x%x\n", tptr->flags);
138     fprintf(fid, "written = %s", ctime(&written));
139     fprintf(fid, "nMBytes = %d\n", tptr->nMBytes);
140     fprintf(fid, "nBytes = %d\n", tptr->nBytes);
141     fprintf(fid, "nFiles = %d\n", tptr->nFiles);
142     fprintf(fid, "nVolumes = %d\n", tptr->nVolumes);
143     fprintf(fid, "seq = %d\n", tptr->seq);
144     fprintf(fid, "dump = %d\n", tptr->dump);
145     fprintf(fid, "nextTape = %d\n", tptr->nextTape);
146     fprintf(fid, "firstVol = %d\n", tptr->firstVol);
147     fprintf(fid, "labelPos = %d\n", tptr->labelpos);
148     fprintf(fid, "useCount = %d\n", tptr->useCount);
149     return 0;
150 }
151
152 int
153 printTapeEntry(struct budb_tapeEntry *teptr)
154 {
155     time_t written = teptr->written;
156     time_t expires = teptr->expires;
157
158     printf("name = %s\n", teptr->name);
159     printf("flags = 0x%x", teptr->flags);
160     if (teptr->flags & BUDB_TAPE_TAPEERROR)
161         printf(": Error");
162     if (teptr->flags & BUDB_TAPE_DELETED)
163         printf(": Deleted");
164     if (teptr->flags & BUDB_TAPE_BEINGWRITTEN)
165         printf(": In progress");
166     if (teptr->flags & BUDB_TAPE_ABORTED)
167         printf(": Aborted");
168     if (teptr->flags & BUDB_TAPE_STAGED)
169         printf(": Staged");
170     if (teptr->flags & BUDB_TAPE_WRITTEN)
171         printf(": Successful");
172     printf("\n");
173     printf("written = %s", ctime(&written));
174     printf("expires = %s", cTIME(&expires));
175     printf("kBytes Tape Used = %u\n", teptr->useKBytes);
176     printf("nMBytes Data = %d\n", teptr->nMBytes);
177     printf("nBytes  Data = %d\n", teptr->nBytes);
178     printf("nFiles = %d\n", teptr->nFiles);
179     printf("nVolumes = %d\n", teptr->nVolumes);
180     printf("seq = %d\n", teptr->seq);
181     printf("labelPos = %d\n", teptr->labelpos);
182     printf("useCount = %d\n", teptr->useCount);
183     printf("dump = %d\n", teptr->dump);
184     return 0;
185 }
186
187 int
188 printTapeSet(struct budb_tapeSet *tsptr,
189              afs_int32 nss)     /* is the tapeserver name an accurate name */
190 {
191     printf("Group id  = %d\n", tsptr->id);
192     printf("tapeServer = %s%s\n", tsptr->tapeServer,
193            (nss ? " (single server)" : ""));
194     printf("format = %s\n", tsptr->format);
195     printf("maxTapes = %d\n", tsptr->maxTapes);
196 /*  printf("a  = %d\n",tsptr->a ); */
197 /*  printf("b = %d\n",tsptr->b);   */
198     printf("Start Tape Seq = %d\n", tsptr->b);
199     return 0;
200 }
201
202 int
203 printVolumeEntry(struct budb_volumeEntry *veptr)
204 {
205     time_t clone = veptr->clone;
206     printf("name = %s\n", veptr->name);
207     printf("flags = 0x%x", veptr->flags);
208     if (veptr->flags & BUDB_VOL_TAPEERROR)
209         printf(": Tape Error");
210     if (veptr->flags & BUDB_VOL_FILEERROR)
211         printf(": File Error");
212     if (veptr->flags & BUDB_VOL_BEINGWRITTEN)
213         printf(": In progress");
214     if (veptr->flags & BUDB_VOL_FIRSTFRAG)
215         printf(": First fragment");
216     if (veptr->flags & BUDB_VOL_LASTFRAG)
217         printf(": Last fragment");
218     if (veptr->flags & BUDB_VOL_ABORTED)
219         printf(": Aborted");
220     printf("\n");
221     printf("id = %d\n", veptr->id);
222     printf("server = %s\n", veptr->server);
223     printf("partition = %d\n", veptr->partition);
224     printf("tapeSeq = %d\n", veptr->tapeSeq);
225
226     printf("position = %d\n", veptr->position);
227     printf("clone = %s", ctime(&clone));
228     printf("startByte = %d\n", veptr->startByte);
229     printf("nBytes = %d\n", veptr->nBytes);
230     printf("seq = %d\n", veptr->seq);
231
232     printf("dump = %d\n", veptr->dump);
233     printf("tape = %s\n", veptr->tape);
234     return 0;
235 }
236
237 int
238 printVolFragment(FILE *fid, struct volFragment *vfptr)
239 {
240     time_t clone = vfptr->clone;
241     time_t incTime = vfptr->incTime;
242     fprintf(fid, "vol = %d\n", vfptr->vol);
243     fprintf(fid, "sameNameChain = %d\n", vfptr->sameNameChain);
244     fprintf(fid, "tape = %d\n", vfptr->tape);
245     fprintf(fid, "sameTapeChain = %d\n", vfptr->sameTapeChain);
246     fprintf(fid, "position = %d\n", vfptr->position);
247     fprintf(fid, "clone = %s", ctime(&clone));
248     fprintf(fid, "incTime = %s", ctime(&incTime));
249     fprintf(fid, "startByte = %d\n", vfptr->startByte);
250     fprintf(fid, "nBytes = %d\n", vfptr->nBytes);
251     fprintf(fid, "flags = %d\n", vfptr->flags);
252     fprintf(fid, "sequence = %d\n", vfptr->sequence);
253     return 0;
254 }
255
256 int
257 printVolInfo(FILE *fid, struct volInfo *viptr)
258 {
259     fprintf(fid, "name = %s\n", viptr->name);
260     fprintf(fid, "nameHashChain = %d\n", viptr->nameHashChain);
261     fprintf(fid, "id = %d\n", viptr->id);
262     fprintf(fid, "server = %s\n", viptr->server);
263     fprintf(fid, "partition = %d\n", viptr->partition);
264     fprintf(fid, "flags = 0x%x\n", viptr->flags);
265     fprintf(fid, "sameNameHead = %d\n", viptr->sameNameHead);
266     fprintf(fid, "sameNameChain = %d\n", viptr->sameNameChain);
267     fprintf(fid, "firstFragment = %d\n", viptr->firstFragment);
268     fprintf(fid, "nFrags = %d\n", viptr->nFrags);
269     return 0;
270 }
271
272
273 /* -----------------------------------------
274  * structure xdr routines
275  * -----------------------------------------
276  */
277
278 /* utilities - network to host conversion
279  *      currently used for debug only
280  */
281
282 void
283 volFragment_ntoh(struct volFragment *netVfPtr,
284                  struct volFragment *hostVfPtr)
285 {
286     hostVfPtr->vol = ntohl(netVfPtr->vol);
287     hostVfPtr->sameNameChain = ntohl(netVfPtr->sameNameChain);
288     hostVfPtr->tape = ntohl(netVfPtr->tape);
289     hostVfPtr->sameTapeChain = ntohl(netVfPtr->sameTapeChain);
290     hostVfPtr->position = ntohl(netVfPtr->position);
291     hostVfPtr->clone = ntohl(netVfPtr->clone);
292     hostVfPtr->incTime = ntohl(netVfPtr->incTime);
293     hostVfPtr->startByte = ntohl(netVfPtr->startByte);
294     hostVfPtr->nBytes = ntohl(netVfPtr->nBytes);
295     hostVfPtr->flags = ntohs(netVfPtr->flags);
296     hostVfPtr->sequence = ntohs(netVfPtr->sequence);
297 }
298
299 void
300 volInfo_ntoh(struct volInfo *netViPtr,
301              struct volInfo *hostViPtr)
302 {
303     strcpy(hostViPtr->name, netViPtr->name);
304     hostViPtr->nameHashChain = ntohl(netViPtr->nameHashChain);
305     hostViPtr->id = ntohl(netViPtr->id);
306     strcpy(hostViPtr->server, netViPtr->server);
307     hostViPtr->partition = ntohl(netViPtr->partition);
308     hostViPtr->flags = ntohl(netViPtr->flags);
309     hostViPtr->sameNameHead = ntohl(netViPtr->sameNameHead);
310     hostViPtr->sameNameChain = ntohl(netViPtr->sameNameChain);
311     hostViPtr->firstFragment = ntohl(netViPtr->firstFragment);
312     hostViPtr->nFrags = ntohl(netViPtr->nFrags);
313 }
314
315 void
316 tape_ntoh(struct tape *netTapePtr,
317           struct tape *hostTapePtr)
318 {
319     strcpy(hostTapePtr->name, netTapePtr->name);
320     hostTapePtr->nameHashChain = ntohl(netTapePtr->nameHashChain);
321     hostTapePtr->flags = ntohl(netTapePtr->flags);
322
323     /* tape id conversion here */
324     hostTapePtr->written = ntohl(netTapePtr->written);
325     hostTapePtr->nMBytes = ntohl(netTapePtr->nMBytes);
326     hostTapePtr->nBytes = ntohl(netTapePtr->nBytes);
327     hostTapePtr->nFiles = ntohl(netTapePtr->nFiles);
328     hostTapePtr->nVolumes = ntohl(netTapePtr->nVolumes);
329     hostTapePtr->seq = ntohl(netTapePtr->seq);
330     hostTapePtr->dump = ntohl(netTapePtr->dump);
331     hostTapePtr->nextTape = ntohl(netTapePtr->nextTape);
332     hostTapePtr->labelpos = ntohl(netTapePtr->labelpos);
333     hostTapePtr->firstVol = ntohl(netTapePtr->firstVol);
334     hostTapePtr->useCount = ntohl(netTapePtr->useCount);
335 }
336
337 void
338 dump_ntoh(struct dump *netDumpPtr,
339           struct dump *hostDumpPtr)
340 {
341     hostDumpPtr->id = ntohl(netDumpPtr->id);
342     hostDumpPtr->idHashChain = ntohl(netDumpPtr->idHashChain);
343     strlcpy(hostDumpPtr->dumpName, netDumpPtr->dumpName,
344             sizeof(hostDumpPtr->dumpName));
345     strlcpy(hostDumpPtr->dumpPath, netDumpPtr->dumpPath,
346             sizeof(hostDumpPtr->dumpPath));
347     strlcpy(hostDumpPtr->volumeSet, netDumpPtr->volumeSet,
348             sizeof(hostDumpPtr->volumeSet));
349     hostDumpPtr->nameHashChain = ntohl(netDumpPtr->nameHashChain);
350     hostDumpPtr->flags = ntohl(netDumpPtr->flags);
351     hostDumpPtr->parent = ntohl(netDumpPtr->parent);
352     hostDumpPtr->created = ntohl(netDumpPtr->created);
353     hostDumpPtr->nVolumes = ntohl(netDumpPtr->nVolumes);
354     hostDumpPtr->level = ntohl(netDumpPtr->level);
355
356     tapeSet_ntoh(&netDumpPtr->tapes, &hostDumpPtr->tapes);
357
358     hostDumpPtr->firstTape = ntohl(netDumpPtr->firstTape);
359
360     hostDumpPtr->dumper = netDumpPtr->dumper;
361 }
362
363 void
364 DbHeader_ntoh(struct DbHeader *netptr,
365               struct DbHeader *hostptr)
366 {
367     hostptr->dbversion = ntohl(netptr->dbversion);
368     hostptr->created = ntohl(netptr->created);
369     strcpy(hostptr->cell, netptr->cell);
370     hostptr->lastDumpId = ntohl(netptr->lastDumpId);
371     hostptr->lastInstanceId = ntohl(netptr->lastInstanceId);
372     hostptr->lastTapeId = ntohl(netptr->lastTapeId);
373 }
374
375 void
376 dumpEntry_ntoh(struct budb_dumpEntry *netptr,
377                struct budb_dumpEntry *hostptr)
378 {
379     hostptr->id = ntohl(netptr->id);
380     hostptr->initialDumpID = ntohl(netptr->initialDumpID);
381     hostptr->appendedDumpID = ntohl(netptr->appendedDumpID);
382     hostptr->parent = ntohl(netptr->parent);
383     hostptr->level = ntohl(netptr->level);
384     hostptr->flags = ntohl(netptr->flags);
385     strcpy(hostptr->volumeSetName, netptr->volumeSetName);
386     strcpy(hostptr->dumpPath, netptr->dumpPath);
387     strcpy(hostptr->name, netptr->name);
388     hostptr->created = ntohl(netptr->created);
389     hostptr->incTime = ntohl(netptr->incTime);
390     hostptr->nVolumes = ntohl(netptr->nVolumes);
391
392     tapeSet_ntoh(&netptr->tapes, &hostptr->tapes);
393     principal_ntoh(&netptr->dumper, &hostptr->dumper);
394 }
395
396 void
397 principal_hton(struct budb_principal *hostptr,
398                struct budb_principal *netptr)
399 {
400     strcpy(netptr->name, hostptr->name);
401     strcpy(netptr->instance, hostptr->instance);
402     strcpy(netptr->cell, hostptr->cell);
403 }
404
405 void
406 principal_ntoh(struct budb_principal *netptr,
407                struct budb_principal *hostptr)
408 {
409     strcpy(hostptr->name, netptr->name);
410     strcpy(hostptr->instance, netptr->instance);
411     strcpy(hostptr->cell, netptr->cell);
412 }
413
414 void
415 structDumpHeader_hton(struct structDumpHeader *hostPtr,
416                       struct structDumpHeader *netPtr)
417 {
418     netPtr->type = htonl(hostPtr->type);
419     netPtr->structversion = htonl(hostPtr->structversion);
420     netPtr->size = htonl(hostPtr->size);
421 }
422
423 void
424 structDumpHeader_ntoh(struct structDumpHeader *netPtr,
425                       struct structDumpHeader *hostPtr)
426 {
427     hostPtr->type = ntohl(netPtr->type);
428     hostPtr->structversion = ntohl(netPtr->structversion);
429     hostPtr->size = ntohl(netPtr->size);
430 }
431
432 void
433 tapeEntry_ntoh(struct budb_tapeEntry *netptr,
434                struct budb_tapeEntry *hostptr)
435 {
436     strcpy(hostptr->name, netptr->name);
437     hostptr->flags = ntohl(netptr->flags);
438     hostptr->written = ntohl(netptr->written);
439     hostptr->expires = ntohl(netptr->expires);
440     hostptr->nMBytes = ntohl(netptr->nMBytes);
441     hostptr->nBytes = ntohl(netptr->nBytes);
442     hostptr->nFiles = ntohl(netptr->nFiles);
443     hostptr->nVolumes = ntohl(netptr->nVolumes);
444     hostptr->seq = ntohl(netptr->seq);
445     hostptr->labelpos = ntohl(netptr->labelpos);
446     hostptr->useCount = ntohl(netptr->useCount);
447     hostptr->useKBytes = ntohl(netptr->useKBytes);
448     hostptr->dump = ntohl(netptr->dump);
449 }
450
451 int
452 tapeSet_hton(struct budb_tapeSet *hostptr,
453              struct budb_tapeSet *netptr)
454 {
455     netptr->id = htonl(hostptr->id);
456     strcpy(netptr->tapeServer, hostptr->tapeServer);
457     strcpy(netptr->format, hostptr->format);
458     netptr->maxTapes = htonl(hostptr->maxTapes);
459     netptr->a = htonl(hostptr->a);
460     netptr->b = htonl(hostptr->b);
461     return 0;
462 }
463
464 int
465 tapeSet_ntoh(struct budb_tapeSet *netptr,
466              struct budb_tapeSet *hostptr)
467 {
468     hostptr->id = ntohl(netptr->id);
469     strcpy(hostptr->tapeServer, netptr->tapeServer);
470     strcpy(hostptr->format, netptr->format);
471     hostptr->maxTapes = ntohl(netptr->maxTapes);
472     hostptr->a = ntohl(netptr->a);
473     hostptr->b = ntohl(netptr->b);
474     return 0;
475 }
476
477 void
478 textBlock_hton(struct textBlock *hostptr,
479                struct textBlock *netptr)
480 {
481     netptr->version = htonl(hostptr->version);
482     netptr->size = htonl(hostptr->size);
483     netptr->textAddr = htonl(hostptr->textAddr);
484     netptr->newsize = htonl(hostptr->newsize);
485     netptr->newTextAddr = htonl(hostptr->newTextAddr);
486 }
487
488 void
489 textBlock_ntoh(struct textBlock *netptr,
490                struct textBlock *hostptr)
491 {
492     hostptr->version = ntohl(netptr->version);
493     hostptr->size = ntohl(netptr->size);
494     hostptr->textAddr = ntohl(netptr->textAddr);
495     hostptr->newsize = ntohl(netptr->newsize);
496     hostptr->newTextAddr = ntohl(netptr->newTextAddr);
497 }
498
499 void
500 textLock_hton(db_lockP hostptr, db_lockP netptr)
501 {
502     netptr->type = htonl(hostptr->type);
503     netptr->lockState = htonl(hostptr->lockState);
504     netptr->lockTime = htonl(hostptr->lockTime);
505     netptr->expires = htonl(hostptr->expires);
506     netptr->instanceId = htonl(hostptr->instanceId);
507     netptr->lockHost = htonl(hostptr->lockHost);
508 }
509
510 void
511 textLock_ntoh(db_lockP netptr, db_lockP hostptr)
512 {
513     hostptr->type = ntohl(netptr->type);
514     hostptr->lockState = ntohl(netptr->lockState);
515     hostptr->lockTime = ntohl(netptr->lockTime);
516     hostptr->expires = ntohl(netptr->expires);
517     hostptr->instanceId = ntohl(netptr->instanceId);
518     hostptr->lockHost = ntohl(netptr->lockHost);
519 }
520
521 void
522 volumeEntry_ntoh(struct budb_volumeEntry *netptr,
523                  struct budb_volumeEntry *hostptr)
524 {
525     strcpy(hostptr->name, netptr->name);
526     hostptr->flags = ntohl(netptr->flags);
527     hostptr->id = ntohl(netptr->id);
528     strcpy(hostptr->server, netptr->server);
529     hostptr->partition = ntohl(netptr->partition);
530     hostptr->tapeSeq = ntohl(netptr->tapeSeq);
531
532     hostptr->position = ntohl(netptr->position);
533     hostptr->clone = ntohl(netptr->clone);
534     hostptr->incTime = ntohl(netptr->incTime);
535     hostptr->startByte = ntohl(netptr->startByte);
536     hostptr->nBytes = ntohl(netptr->nBytes);
537     hostptr->seq = ntohl(netptr->seq);
538
539     hostptr->dump = ntohl(netptr->dump);
540     strcpy(hostptr->tape, netptr->tape);
541 }
542
543 /* -------------------------------------
544  * structure conversion & copy routines
545  * -------------------------------------
546  */
547
548 void
549 copy_ktcPrincipal_to_budbPrincipal(struct ktc_principal *ktcPtr,
550                                    struct budb_principal *budbPtr)
551 {
552     strncpy(budbPtr->name, ktcPtr->name, sizeof(budbPtr->name));
553     strncpy(budbPtr->instance, ktcPtr->instance, sizeof(budbPtr->instance));
554     strncpy(budbPtr->cell, ktcPtr->cell, sizeof(budbPtr->cell));
555 }
556
557 /* dumpToBudbDump
558  * entry:
559  *      dumpPtr - host format
560  */
561
562 int
563 dumpToBudbDump(dbDumpP dumpPtr, struct budb_dumpEntry *budbDumpPtr)
564 {
565     budbDumpPtr->id = dumpPtr->id;
566     budbDumpPtr->initialDumpID = dumpPtr->initialDumpID;
567     budbDumpPtr->parent = dumpPtr->parent;
568     budbDumpPtr->level = dumpPtr->level;
569     budbDumpPtr->flags = dumpPtr->flags;
570
571     strcpy(budbDumpPtr->volumeSetName, dumpPtr->volumeSet);
572     strcpy(budbDumpPtr->dumpPath, dumpPtr->dumpPath);
573     strcpy(budbDumpPtr->name, dumpPtr->dumpName);
574
575     budbDumpPtr->created = dumpPtr->created;
576     budbDumpPtr->nVolumes = dumpPtr->nVolumes;
577
578     memcpy(&budbDumpPtr->tapes, &dumpPtr->tapes, sizeof(struct budb_tapeSet));
579     copy_ktcPrincipal_to_budbPrincipal(&dumpPtr->dumper,
580                                        &budbDumpPtr->dumper);
581     return (0);
582 }
583
584 int
585 tapeToBudbTape(struct tape *tapePtr, struct budb_tapeEntry *budbTapePtr)
586 {
587     strcpy(budbTapePtr->name, tapePtr->name);
588     budbTapePtr->flags = tapePtr->flags;
589     budbTapePtr->written = tapePtr->written;
590     budbTapePtr->expires = tapePtr->expires;
591     budbTapePtr->nMBytes = tapePtr->nMBytes;
592     budbTapePtr->nBytes = tapePtr->nBytes;
593     budbTapePtr->nFiles = tapePtr->nFiles;
594     budbTapePtr->nVolumes = tapePtr->nVolumes;
595     budbTapePtr->seq = tapePtr->seq;
596     budbTapePtr->labelpos = tapePtr->labelpos;
597     budbTapePtr->useCount = tapePtr->useCount;
598     budbTapePtr->useKBytes = tapePtr->useKBytes;
599     return (0);
600 }
601
602 int
603 volsToBudbVol(struct volFragment *volFragPtr, struct volInfo *volInfoPtr,
604               struct budb_volumeEntry *budbVolPtr)
605 {
606     strcpy(budbVolPtr->name, volInfoPtr->name);
607     budbVolPtr->flags = volInfoPtr->flags;
608     budbVolPtr->id = volInfoPtr->id;
609     strcpy(budbVolPtr->server, volInfoPtr->server);
610     budbVolPtr->partition = volInfoPtr->partition;
611     budbVolPtr->tapeSeq = 0;    /* Don't know it so mark invalid */
612
613     budbVolPtr->position = volFragPtr->position;
614     budbVolPtr->clone = volFragPtr->clone;
615     budbVolPtr->incTime = volFragPtr->incTime;
616     budbVolPtr->startByte = volFragPtr->startByte;
617     budbVolPtr->nBytes = volFragPtr->nBytes;
618     budbVolPtr->seq = volFragPtr->sequence;
619     return (0);
620 }
621
622 /* ----------------------------------
623  * structure initialization routines
624  *  ---------------------------------
625  */
626
627 /* default_tapeset
628  *      this fills in the tape set with the current default tapeset
629  *      format;
630  * entry:
631  *      dumpname - volset.dumplevel
632  * exit:
633  *      0 - ok
634  *      n - error
635  */
636
637 int
638 default_tapeset(struct budb_tapeSet *tapesetPtr, char *dumpname)
639 {
640     memset(tapesetPtr, 0, sizeof(*tapesetPtr));
641
642     strcpy(tapesetPtr->format, dumpname);
643     strcat(tapesetPtr->format, ".%d");
644     tapesetPtr->a = 1;
645     tapesetPtr->b = 1;
646     tapesetPtr->maxTapes = 0;
647     return 0;
648 }