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