2 * Copyright (c) 2001 - 2002 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * Dump arla disk storage
38 #include "arla_local.h"
43 static char *prefix
= ARLACACHEDIR
;
44 static char *fcache_file
;
45 static char *volcache_file
;
46 static int local_version_flag
;
47 static int local_verbose_flag
;
48 static int local_help_flag
;
51 print_fcache_entry(struct fcache_store
*st
, void *ptr
)
53 printf("Fid: %s %d.%d.%d %02x/%02x\n", st
->cell
,
54 st
->fid
.Volume
, st
->fid
.Vnode
, st
->fid
.Unique
,
55 (st
->index
>> 8) & 0xff, st
->index
& 0xff );
56 if (local_verbose_flag
)
57 printf("Length: accounted: %ld fetched: %ld\n",
58 (long)st
->length
, (long)st
->fetched_length
);
63 print_vol(nvldbentry
*e
, const char *str
, int32_t flags
, int type
)
66 printf (" %s: %d", str
, e
->volumeId
[type
]);
70 print_volcache_entry(struct volcache_store
*st
, void *ptr
)
72 printf("Volume: %s %s\n", st
->cell
, st
->entry
.name
);
74 print_vol(&st
->entry
, "RW", VLF_RWEXISTS
, RWVOL
);
75 print_vol(&st
->entry
, "RO", VLF_ROEXISTS
, ROVOL
);
76 print_vol(&st
->entry
, "BU", VLF_BOEXISTS
, BACKVOL
);
81 static struct getargs args
[] = {
82 {"prefix", 'p', arg_string
, &prefix
,
83 "prefix to arla cache dir", "dir"},
84 {"verbose", 'v', arg_flag
, &local_verbose_flag
,
86 {"version", 0, arg_flag
, &local_version_flag
,
88 {"help", 0, arg_flag
, &local_help_flag
,
95 arg_printusage (args
, sizeof(args
)/sizeof(*args
), NULL
, "");
100 main(int argc
, char **argv
)
105 setprogname (argv
[0]);
107 if (getarg (args
, sizeof(args
)/sizeof(*args
), argc
, argv
, &optind
))
110 if (local_version_flag
) {
115 if (fcache_file
== NULL
)
116 asprintf(&fcache_file
, "%s/fcache", prefix
);
119 ret
= state_recover_fcache(fcache_file
, print_fcache_entry
, NULL
);
121 warn("failed with %d to dump fcache state (%s)", ret
, fcache_file
);
123 if (volcache_file
== NULL
)
124 asprintf(&volcache_file
, "%s/volcache", prefix
);
126 printf("volcache\n");
127 ret
= state_recover_volcache(volcache_file
, print_volcache_entry
, NULL
);
129 warn("failed with %d to dump volcache state (%s)", ret
, volcache_file
);