Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / dir / test / test-salvage.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
13
14 /* This is the salvage test program. */
15
16 main(argc, argv)
17 int argc;
18 char **argv;
19 {
20 long ofid, nfid, code, myFid[3], parentFid[3];
21 DInit(20);
22 if (argc == 2) {
23 ofid = atoi(argv[1]);
24 nfid = 0;
25 } else if (argc == 3) {
26 ofid = atoi(argv[1]);
27 nfid = atoi(argv[2]);
28 } else {
29 printf("usage is: test <ofid> <optional new fid>\n");
30 exit(1);
31 }
32 code = DirOK(&ofid);
33 printf("DirOK returned %d.\n");
34 if (nfid) {
35 printf("Salvaging from fid %d into fid %d.\n", ofid, nfid);
36 if (Lookup(&ofid, ".", myFid) || Lookup(&ofid, "..", parentFid)) {
37 printf("Lookup of \".\" and/or \"..\" failed: ");
38 printf("%d %d %d %d\n", myFid[1], myFid[2], parentFid[1],
39 parentFid[2]);
40 printf("Directory cannot be salvaged\n");
41 } else {
42 code =
43 DirSalvage(&ofid, &nfid, myFid[1], myFid[2], parentFid[1],
44 parentFid[2]);
45 printf("DirSalvage returned %d.\n", code);
46 }
47 }
48 DFlush();
49 }
50
51 Log(a, b, c, d, e, f, g, h, i, j, k, l, m, n)
52 {
53 printf(a, b, c, d, e, f, g, h, i, j, k, l, m, n);
54 }
55
56 /* the end */