plan9port

[fork] Plan 9 from user space
git clone git://src.adamsgaard.dk/plan9port # fast
git clone https://src.adamsgaard.dk/plan9port.git # slow
Log | Files | Refs | README | LICENSE Back to index

fsys.c (2224B)


      1 #include <u.h>
      2 #include <libc.h>
      3 #include <thread.h>
      4 #include <sunrpc.h>
      5 #include <nfs3.h>
      6 #include <diskfs.h>
      7 
      8 int allowall;
      9 
     10 static Fsys *(*opentab[])(Disk*) =
     11 {
     12 	fsysopenffs,
     13 	fsysopenhfs,
     14 	fsysopenkfs,
     15 	fsysopenext2,
     16 	fsysopenfat,
     17 };
     18 
     19 Fsys*
     20 fsysopen(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 
     31 Block*
     32 fsysreadblock(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 
     41 int
     42 fsyssync(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 
     51 void
     52 fsysclose(Fsys *fsys)
     53 {
     54 	if(!fsys->_close){
     55 		fprint(2, "no fsysClose\n");
     56 		abort();
     57 	}
     58 	(*fsys->_close)(fsys);
     59 }
     60 
     61 Nfs3Status
     62 fsysroot(Fsys *fsys, Nfs3Handle *h)
     63 {
     64 	if(!fsys->_root)
     65 		return Nfs3ErrNxio;
     66 	return (*fsys->_root)(fsys, h);
     67 }
     68 
     69 Nfs3Status
     70 fsyslookup(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 
     77 Nfs3Status
     78 fsysgetattr(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 
     85 Nfs3Status
     86 fsysreaddir(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 
     93 Nfs3Status
     94 fsysreadfile(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 
    101 Nfs3Status
    102 fsysreadlink(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 
    109 Nfs3Status
    110 fsysaccess(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 }