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