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