Standardize License information
[openafs.git] / src / dir / test / physio.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 /*
11  * File         physio.cx
12  * NOTE         This is NOT the standard physio.cx for venus or, yet alone, vice.
13  *              It is a test one for use in src/dir.
14  *
15  */
16
17 /* First we have the kernel hacks' include files. */
18 #include <afs/param.h>
19 #include <sys/param.h>
20 #ifdef AFS_VFSINCL_ENV
21 #include <ufs/fsdir.h>
22 #else AFS_VFSINCL_ENV
23 #include <sys/dir.h>
24 #endif AFS_VFSINCL_ENV
25 #include <sys/user.h>
26 #define VIRTUE 1
27 #include <afs/remote.h>
28 #undef VIRTUE
29 #include <sys/file.h>
30 #include <sys/stat.h>
31 #include <errno.h>
32 #include <itc.h>
33 #include <stdio.h>
34 #include <rx/xdr.h>
35
36 /* Here are the include file(s) for the light-weight process facility. */
37 #include "lwp.h"
38 #include "lock.h"
39
40 #define PAGESIZE 2048
41
42 ReallyRead(fid, block, data)
43     long *fid;          /* View the fid as longs. */
44     long block;
45     char *data;
46     {/* Do a real read. */
47     char fname[100];
48     int s, code;
49     sprintf(fname, "F%d", *fid);
50     s = open(fname,O_RDONLY,0644);
51     if (s<0) Die("can't open cache file");
52     code=lseek(s,PAGESIZE*block,0);
53     if (code<0) Die("r:lseek");
54     code=read(s,data,PAGESIZE);
55     if (code<0) {
56         Die("read");
57     }
58     close(s);
59     return 0;
60     }
61
62 ReallyWrite(fid, block, data)
63     long *fid;          /* View the fid as longs. */
64     long block;
65     char *data;
66     {/* Do a real write. */
67     char fname[100];
68     int s, code;
69     sprintf(fname, "F%d", *fid);
70     s = open(fname,O_RDWR|O_CREAT,0644);
71     if (s<0) Die("can't find cache file");
72     code = lseek(s,PAGESIZE*block,0);
73     if (code<0) Die("w:lseek");
74     code=write(s,data,PAGESIZE);
75     if (code<0) Die("write");
76     close(s);
77     return 0;
78     }
79
80
81 /* The following three routines provide the fid routines used by the buffer and directory packages. */
82
83 int FidZap (afid)
84 register long *afid;
85     {/* Zero out a file */
86     *afid = 0;
87     }
88
89 int FidZero (afid)
90 register long *afid;
91     {/* Zero out a file */
92     *afid = 0;
93     }
94
95 int FidEq (afid, bfid)
96 register long *afid, *bfid;
97     {/* Compare two fids for equality. */
98     if (*afid != *bfid) return 0;
99     return 1;
100     }
101
102 int FidVolEq (afid, bfid)
103 register long *afid, *bfid;
104     {/* Is fid in a particular volume */
105     return 1;
106     }
107
108 int FidCpy (dfid,sfid)
109 register long *dfid, *sfid;
110     {/* Assign one fid to another. */
111     *dfid = *sfid;
112     }
113
114 Die(arg)
115 char *arg;
116     {/* Print an error message and then exit. */
117     int i,j;
118     printf("Fatal error: %s\n",arg);
119
120     i=1;
121     j=0;
122     i = i/j;
123
124     exit(1);
125     }