-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbackuphdr.c
88 lines (79 loc) · 2.93 KB
/
backuphdr.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* CMUCS AFStools
* dumpscan - routines for scanning and manipulating AFS volume dumps
*
* Copyright (c) 1998, 2001 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or [email protected]
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/* backuphdr.c - Parse and print backup system headers */
#include <stdlib.h>
#include "dumpscan.h"
#include "dumpscan_errs.h"
#include "stagehdr.h"
afs_uint32 try_backuphdr(XFILE *X, char *tag, tagged_field *field,
afs_uint32 value, tag_parse_info *pi,
void *g_refcon, void *l_refcon)
{
dump_parser *p = (dump_parser *)g_refcon;
backup_system_header bh;
u_int64 where;
afs_uint32 r;
/* Which header should we try (if any)? */
switch (*tag) {
case V20_VERSMIN: r = ParseStageV20Hdr(X, (unsigned char*)tag, &bh); break;
case 'S': r = ParseStageHdr(X, (unsigned char*)tag, &bh); break;
default: return DSERR_MAGIC;
}
if (r) return r;
/* Do something with it... */
if (p->print_flags & DSPRINT_BCKHDR) PrintBackupHdr(&bh);
if (p->cb_bckhdr) {
r = xftell(X, &where);
if (!r && p->cb_bckhdr)
r = (p->cb_bckhdr)(&bh, X, p->refcon);
if (p->flags & DSFLAG_SEEK) {
if (!r) r = xfseek(X, &where);
else xfseek(X, &where);
}
}
if (bh.server) free(bh.server);
if (bh.part) free(bh.part);
if (bh.volname) free(bh.volname);
return r;
}
void PrintBackupHdr(backup_system_header *hdr)
{
time_t from = hdr->from_date, to = hdr->to_date, dd = hdr->dump_date;
printf("* BACKUP SYSTEM HEADER\n");
printf(" Version: %d\n", hdr->version);
printf(" Volume: %s (%d)\n", hdr->volname, hdr->volid);
printf(" Location: %s %s\n", hdr->server, hdr->part);
printf(" Level: %d\n", hdr->level);
printf(" Range: %d => %d\n", hdr->from_date, hdr->to_date);
printf(" == %s", ctime(&from));
printf(" => %s", ctime(&to));
printf(" Dump Time: %d == %s", hdr->dump_date, ctime(&dd));
printf(" Dump Flags: 0x%08x\n", hdr->flags);
printf(" Length: %s\n", decimate_int64(&hdr->dumplen, 0));
printf(" File Num: %d\n", hdr->filenum);
}