afsconfig-and-rcsid-all-around-20010705
[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 <afs/param.h>
11 #include <afsconfig.h>
12
13 RCSID("$Header$");
14
15 /* This is the salvage test program. */
16
17 main (argc, argv)
18     int argc;
19     char **argv;
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         }
26     else if (argc == 3)
27         {ofid = atoi(argv[1]);
28         nfid = atoi(argv[2]);
29         }
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          {
40             printf("Lookup of \".\" and/or \"..\" failed: ");
41             printf("%d %d %d %d\n",myFid[1],myFid[2],parentFid[1],parentFid[2]);
42             printf("Directory cannot be salvaged\n");
43          }
44          else
45          {
46             code = DirSalvage(&ofid, &nfid, myFid[1],myFid[2],
47                         parentFid[1],parentFid[2]);
48             printf("DirSalvage returned %d.\n", code);
49          }
50         }
51     DFlush();
52     }
53
54 Log(a,b,c,d,e,f,g,h,i,j,k,l,m,n) {
55         printf(a,b,c,d,e,f,g,h,i,j,k,l,m,n);
56 }
57
58 /* the end */