blob: 3875e50b9a3e08567dfad8ba3564bce34a54ec05 [file] [log] [blame]
rsc0c98da82005-07-13 03:48:35 +00001#include <u.h>
2#include <libc.h>
3#include <thread.h>
4#include <sunrpc.h>
5#include <nfs3.h>
6#include <diskfs.h>
7
8int allowall;
9
10static Fsys *(*opentab[])(Disk*) =
11{
12 fsysopenffs,
13 fsysopenkfs,
14 fsysopenext2,
15 fsysopenfat,
16};
17
18Fsys*
19fsysopen(Disk *disk)
20{
21 int i;
22 Fsys *fsys;
23
24 for(i=0; i<nelem(opentab); i++)
25 if((fsys = (*opentab[i])(disk)) != nil)
26 return fsys;
27 return nil;
28}
29
30Block*
31fsysreadblock(Fsys *fsys, u64int blockno)
32{
33 if(!fsys->_readblock){
34 werrstr("no read dispatch function");
35 return nil;
36 }
37 return (*fsys->_readblock)(fsys, blockno);
38}
39
40int
41fsyssync(Fsys *fsys)
42{
43 if(disksync(fsys->disk) < 0)
44 return -1;
45 if(!fsys->_sync)
46 return 0;
47 return (*fsys->_sync)(fsys);
48}
49
50void
51fsysclose(Fsys *fsys)
52{
53 if(!fsys->_close){
54 fprint(2, "no fsysClose\n");
55 abort();
56 }
57 (*fsys->_close)(fsys);
58}
59
60Nfs3Status
61fsysroot(Fsys *fsys, Nfs3Handle *h)
62{
63 if(!fsys->_root)
64 return Nfs3ErrNxio;
65 return (*fsys->_root)(fsys, h);
66}
67
68Nfs3Status
69fsyslookup(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, char *name, Nfs3Handle *nh)
70{
71 if(!fsys->_lookup)
72 return Nfs3ErrNxio;
73 return (*fsys->_lookup)(fsys, au, h, name, nh);
74}
75
76Nfs3Status
77fsysgetattr(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, Nfs3Attr *attr)
78{
79 if(!fsys->_getattr)
80 return Nfs3ErrNxio;
81 return (*fsys->_getattr)(fsys, au, h, attr);
82}
83
84Nfs3Status
85fsysreaddir(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, u32int count, u64int cookie, uchar **e, u32int *ne, u1int *peof)
86{
87 if(!fsys->_readdir)
88 return Nfs3ErrNxio;
89 return (*fsys->_readdir)(fsys, au, h, count, cookie, e, ne, peof);
90}
91
92Nfs3Status
93fsysreadfile(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, u32int count, u64int offset, uchar **data, u32int *pcount, uchar *peof)
94{
95 if(!fsys->_readfile)
96 return Nfs3ErrNxio;
97 return (*fsys->_readfile)(fsys, au, h, count, offset, data, pcount, peof);
98}
99
100Nfs3Status
101fsysreadlink(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, char **plink)
102{
103 if(!fsys->_readlink)
104 return Nfs3ErrNxio;
105 return (*fsys->_readlink)(fsys, au, h, plink);
106}
107
108Nfs3Status
109fsysaccess(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, u32int want, u32int *got, Nfs3Attr *attr)
110{
111 if(!fsys->_access)
112 return Nfs3ErrNxio;
113 return (*fsys->_access)(fsys, au, h, want, got, attr);
114}