122 lines · 2.3 KB · C
RawDownload
#include <u.h>#include <libc.h>#include <thread.h>#include <sunrpc.h>#include <nfs3.h>#include <diskfs.h> int allowall; static Fsys *(*opentab[])(Disk*, u32int, u64int) ={	fsysopenffs,	fsysopenhfs,	fsysopenkfs,	fsysopenext2,	fsysopenfat,	fsysopenraw,}; Fsys*fsysopen_new(Disk *disk, u32int bs, u64int off){	int i;	Fsys *fsys; 	for(i=0; i<nelem(opentab); i++)		if((fsys = (*opentab[i])(disk, bs, off)) != nil)			return fsys;	return nil;} Fsys*fsysopen(Disk *disk){	return fsysopen_new(disk, DEFAULT_BLOCKSIZE, 0);} Block*fsysreadblock(Fsys *fsys, u64int blockno){	if(!fsys->_readblock){		werrstr("no read dispatch function");		return nil;	}	return (*fsys->_readblock)(fsys, blockno);} intfsyssync(Fsys *fsys){	if(disksync(fsys->disk) < 0)		return -1;	if(!fsys->_sync)		return 0;	return (*fsys->_sync)(fsys);} voidfsysclose(Fsys *fsys){	if(!fsys->_close){		fprint(2, "no fsysClose\n");		abort();	}	(*fsys->_close)(fsys);} Nfs3Statusfsysroot(Fsys *fsys, Nfs3Handle *h){	if(!fsys->_root)		return Nfs3ErrNxio;	return (*fsys->_root)(fsys, h);} Nfs3Statusfsyslookup(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, char *name, Nfs3Handle *nh){	if(!fsys->_lookup)		return Nfs3ErrNxio;	return (*fsys->_lookup)(fsys, au, h, name, nh);} Nfs3Statusfsysgetattr(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, Nfs3Attr *attr){	if(!fsys->_getattr)		return Nfs3ErrNxio;	return (*fsys->_getattr)(fsys, au, h, attr);} Nfs3Statusfsysreaddir(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, u32int count, u64int cookie, uchar **e, u32int *ne, u1int *peof){	if(!fsys->_readdir)		return Nfs3ErrNxio;	return (*fsys->_readdir)(fsys, au, h, count, cookie, e, ne, peof);} Nfs3Statusfsysreadfile(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, u32int count, u64int offset, uchar **data, u32int *pcount, uchar *peof){	if(!fsys->_readfile)		return Nfs3ErrNxio;	return (*fsys->_readfile)(fsys, au, h, count, offset, data, pcount, peof);} Nfs3Statusfsysreadlink(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, char **plink){	if(!fsys->_readlink)		return Nfs3ErrNxio;	return (*fsys->_readlink)(fsys, au, h, plink);} Nfs3Statusfsysaccess(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, u32int want, u32int *got, Nfs3Attr *attr){	if(!fsys->_access)		return Nfs3ErrNxio;	return (*fsys->_access)(fsys, au, h, want, got, attr);}