3 * - gc of file systems (not going to do just yet?)
5 * - configure on amsterdam
20 #define trace if(!tracecalls){}else print
22 typedef struct Ipokay Ipokay;
23 typedef struct Config Config;
24 typedef struct Ctree Ctree;
25 typedef struct Cnode Cnode;
31 uchar mask[IPaddrlen];
47 int encryptedhandles = 1;
58 void timerthread(void*);
59 void timerproc(void*);
61 extern void handleunparse(Fsys*, Nfs3Handle*, Nfs3Handle*, int);
62 extern Nfs3Status handleparse(Nfs3Handle*, Fsys**, Nfs3Handle*, int);
64 Nfs3Status logread(Cnode*, u32int, u64int, uchar**, u32int*, u1int*);
65 Nfs3Status refreshdiskread(Cnode*, u32int, u64int, uchar**, u32int*, u1int*);
66 Nfs3Status refreshconfigread(Cnode*, u32int, u64int, uchar**, u32int*, u1int*);
68 int readconfigfile(Config *cp);
69 void setrootfid(void);
70 int ipokay(uchar *ip, ushort port);
72 u64int unittoull(char*);
77 fprint(2, "usage: vnfs [-LLRVir] [-a addr] [-b blocksize] [-c cachesize] configfile\n");
78 threadexitsall("usage");
82 threadmain(int argc, char **argv)
84 fmtinstall('B', sunrpcfmt);
85 fmtinstall('C', suncallfmt);
86 fmtinstall('F', vtfcallfmt);
87 fmtinstall('H', encodefmt);
88 fmtinstall('I', eipfmt);
89 fmtinstall('V', vtscorefmt);
90 sunfmtinstall(&nfs3prog);
91 sunfmtinstall(&nfsmount3prog);
104 encryptedhandles = 0;
107 if(srv->localonly == 0)
110 srv->localparanoia = 1;
123 addr = EARGF(usage());
126 blocksize = unittoull(EARGF(usage()));
129 cachesize = unittoull(EARGF(usage()));
142 if((z = vtdial(nil)) == nil)
143 sysfatal("vtdial: %r");
145 sysfatal("vtconnect: %r");
146 if((vcache = vtcachealloc(z, blocksize*cachesize)) == nil)
147 sysfatal("vtcache: %r");
149 configfile = argv[0];
150 if(readconfigfile(&config) < 0)
151 sysfatal("readConfig: %r");
154 nfschan = chancreate(sizeof(SunMsg*), 0);
155 mountchan = chancreate(sizeof(SunMsg*), 0);
156 timerchan = chancreate(sizeof(void*), 0);
158 if(sunsrvudp(srv, addr) < 0)
159 sysfatal("starting server: %r");
161 sunsrvthreadcreate(srv, nfs3proc, nfschan);
162 sunsrvthreadcreate(srv, mount3proc, mountchan);
163 sunsrvthreadcreate(srv, timerthread, nil);
164 proccreate(timerproc, nil, 32768);
166 sunsrvprog(srv, &nfs3prog, nfschan);
167 sunsrvprog(srv, &nfsmount3prog, mountchan);
172 #define TWID64 ((u64int)~(u64int)0)
182 n = strtoul(s, &es, 0);
183 if(*es == 'k' || *es == 'K'){
186 }else if(*es == 'm' || *es == 'M'){
189 }else if(*es == 'g' || *es == 'G'){
192 }else if(*es == 't' || *es == 'T'){
204 * We store all the state about which file a client is accessing in
205 * the handle, so that we don't have to maintain any per-client state
206 * ourselves. In order to avoid leaking handles or letting clients
207 * create arbitrary handles, we sign and encrypt each handle with
208 * AES using a key selected randomly when the server starts.
209 * Thus, handles cannot be used across sessions.
211 * The decrypted handles begin with the following header:
213 * sessid[8] random session id chosen at start time
214 * len[4] length of handle that follows
216 * If we're pressed for space in the rest of the handle, we could
217 * probably reduce the amount of sessid bytes. Note that the sessid
218 * bytes must be consistent during a run of vnfs, or else some
219 * clients (e.g., Linux 2.4) eventually notice that successive TLookups
220 * return different handles, and they return "Stale NFS file handle"
221 * errors to system calls in response (even though we never sent
224 * Security woes aside, the fact that we have to shove everything
225 * into the handles is quite annoying. We have to encode, in 40 bytes:
227 * - position in the synthesized config tree
228 * - enough of the path to do glob matching
229 * - position in an archived file system image
231 * and the handles need to be stable across changes in the config file
232 * (though not across server restarts since encryption screws
235 * We encode each of the first two as a 10-byte hash that is
236 * the first half of a SHA1 hash.
242 HeaderSize = SessidSize+4,
243 MaxHandleSize = Nfs3MaxHandleSize - HeaderSize
247 uchar sessid[SessidSize];
250 hencrypt(Nfs3Handle *h)
256 * root handle has special encryption - a single 0 byte - so that it
259 if(h->len == root.len && memcmp(h->h, root.h, root.len) == 0){
265 if(!encryptedhandles)
268 if(h->len > MaxHandleSize){
270 fprint(2, "handle too long: %.*lH\n", h->len, h->h);
271 memset(h->h, 'X', Nfs3MaxHandleSize);
272 h->len = Nfs3MaxHandleSize;
277 memmove(p+HeaderSize, p, h->len);
278 memmove(p, sessid, SessidSize);
279 *(u32int*)(p+SessidSize) = h->len;
280 h->len += HeaderSize;
282 if(encryptedhandles){
283 while(h->len < MaxHandleSize)
286 aesCBCencrypt(h->h, MaxHandleSize, &aes);
291 hdecrypt(Nfs3Handle *h)
295 if(h->len == 1 && h->h[0] == 0){ /* single 0 byte is root */
300 if(!encryptedhandles)
303 if(h->len <= HeaderSize)
304 return Nfs3ErrBadHandle;
305 if(encryptedhandles){
306 if(h->len != MaxHandleSize)
307 return Nfs3ErrBadHandle;
309 aesCBCdecrypt(h->h, h->len, &aes);
311 if(memcmp(h->h, sessid, SessidSize) != 0)
312 return Nfs3ErrStale; /* give benefit of doubt */
313 h->len = *(u32int*)(h->h+SessidSize);
314 if(h->len >= MaxHandleSize-HeaderSize)
315 return Nfs3ErrBadHandle;
316 memmove(h->h, h->h+HeaderSize, h->len);
323 uchar key[32], ivec[AESbsize];
328 memmove(sessid, &u32, 4);
329 for(i=0; i<nelem(key); i+=4) {
331 memmove(key+i, &u32, 4);
333 for(i=0; i<nelem(ivec); i++)
334 ivec[i] = fastrand();
335 setupAESstate(&aesstate, key, sizeof key, ivec);
341 * The main purpose of the configuration file is to define a tree
342 * in which the archived file system images are mounted.
343 * The tree is stored as Entry structures, defined below.
345 * The configuration file also allows one to define shell-like
346 * glob expressions matching paths that are not to be displayed.
347 * The matched files or directories are shown in directory listings
348 * (could suppress these if we cared) but they cannot be opened,
349 * read, or written, and getattr returns zeroed data.
353 /* sizes used in handles; see nfs server below */
355 FsysHandleOffset = CnodeHandleSize
369 char *name; /* path element */
370 Cnode *parent; /* in tree */
371 Cnode *nextsib; /* in tree */
372 Cnode *kidlist; /* in tree */
373 Cnode *nexthash; /* in hash list */
375 Nfs3Status (*read)(Cnode*, u32int, u64int, uchar**, u32int*, u1int*); /* synthesized read fn */
377 uchar handle[VtScoreSize]; /* sha1(path to here) */
378 ulong mtime; /* mtime for this directory entry */
380 /* fsys overlay on this node */
381 Fsys *fsys; /* cache of memory structure */
382 Nfs3Handle fsyshandle;
383 int isblackhole; /* walking down keeps you here */
387 * if a mount point is inside another file system,
388 * the fsys and fsyshandle above have the old fs info,
389 * the mfsys and mfsyshandle below have the new one.
390 * getattrs must use the old info for consistency.
392 int ismtpt; /* whether there is an fsys mounted here */
393 uchar fsysscore[VtScoreSize]; /* score of fsys image on venti */
394 char *fsysimage; /* raw disk image */
395 Fsys *mfsys; /* mounted file system (nil until walked) */
396 Nfs3Handle mfsyshandle; /* handle to root of mounted fsys */
404 return (s[0]<<2)|(s[1]>>6); /* first 10 bits */
408 mkcnode(Ctree *t, Cnode *parent, char *elem, uint elen, char *path, uint plen)
413 n = emalloc(sizeof *n + elen+1);
414 n->name = (char*)(n+1);
415 memmove(n->name, elem, elen);
419 n->nextsib = parent->kidlist;
423 sha1((uchar*)path, plen, n->handle, nil);
424 h = dumbhash(n->handle);
425 n->nexthash = t->hash[h];
437 for(i=0; i<nelem(t->hash); i++)
438 for(n=t->hash[i]; n; n=n->nexthash)
439 if(n->name[0] != '+')
451 for(i=0; i<nelem(t->hash); i++)
452 for(n=t->hash[i]; n; n=n->nexthash){
454 disksync(n->mfsys->disk);
456 disksync(n->fsys->disk);
467 /* just zero all the garbage and leave it linked into the tree */
468 for(i=0; i<nelem(t->hash); i++){
469 for(n=t->hash[i]; n; n=n->nexthash){
475 memset(n->fsysscore, 0, sizeof n->fsysscore);
478 memset(&n->fsyshandle, 0, sizeof n->fsyshandle);
479 memset(&n->mfsyshandle, 0, sizeof n->mfsyshandle);
485 cnodewalk(Cnode *n, char *name, uint len, int markokay)
489 for(nn=n->kidlist; nn; nn=nn->nextsib)
490 if(strncmp(nn->name, name, len) == 0 && nn->name[len] == 0)
491 if(!nn->mark || markokay)
497 ctreewalkpath(Ctree *t, char *name, ulong createmtime)
508 nextp = strchr(p, '/');
511 if((nn = cnodewalk(n, p, nextp-p, 1)) == nil){
514 nn = mkcnode(t, n, p, nextp-p, name, nextp-name);
515 nn->mtime = createmtime;
530 t = emalloc(sizeof *t);
531 t->root = mkcnode(t, nil, "", 0, "", 0);
533 ctreewalkpath(t, "/+log", time(0))->read = logread;
534 ctreewalkpath(t, "/+refreshdisk", time(0))->read = refreshdiskread;
535 ctreewalkpath(t, "/+refreshconfig", time(0))->read = refreshconfigread;
541 ctreemountfsys(Ctree *t, char *path, ulong time, uchar *score, char *file)
547 n = ctreewalkpath(t, path, time);
549 if(n->ismtpt && (n->fsysimage || memcmp(n->fsysscore, score, VtScoreSize) != 0)){
552 n->fsys = nil; /* leak (might be other refs) */
554 memmove(n->fsysscore, score, VtScoreSize);
556 if(n->ismtpt && (n->fsysimage==nil || strcmp(n->fsysimage, file) != 0)){
559 n->fsys = nil; /* leak (might be other refs) */
561 n->fsysimage = emalloc(strlen(file)+1);
562 strcpy(n->fsysimage, file);
569 cnodebyhandle(Ctree *t, uchar *p)
575 for(n=t->hash[h]; n; n=n->nexthash)
576 if(memcmp(n->handle, p, CnodeHandleSize) == 0)
582 parseipandmask(char *s, uchar *ip, uchar *mask)
589 if(parseip(ip, s) == ~0UL)
592 memset(mask, 0xFF, IPaddrlen);
594 if(isdigit((uchar)*p) && strtol(p, &q, 10)>=0 && *q==0)
596 if(parseipmask(mask, p) == ~0UL)
601 /*fprint(2, "parseipandmask %s => %I %I\n", s, ip, mask); */
606 parsetime(char *s, ulong *time)
613 /* decimal integer is seconds since 1970 */
614 x = strtoul(s, &p, 10);
615 if(x > 0 && *p == 0){
620 /* otherwise expect yyyy/mmdd/hhmm */
621 if(strlen(s) != 14 || s[4] != '/' || s[9] != '/')
624 if(!isdigit((uchar)s[i]) || !isdigit((uchar)s[i+5]) || !isdigit((uchar)s[i+10]))
626 memset(&tm, 0, sizeof tm);
627 tm.year = atoi(s)-1900;
628 if(tm.year < 0 || tm.year > 200)
630 tm.mon = (s[5]-'0')*10+s[6]-'0' - 1;
631 if(tm.mon < 0 || tm.mon > 11)
633 tm.mday = (s[7]-'0')*10+s[8]-'0';
634 if(tm.mday < 0 || tm.mday > 31)
636 tm.hour = (s[10]-'0')*10+s[11]-'0';
637 if(tm.hour < 0 || tm.hour > 23)
639 tm.min = (s[12]-'0')*10+s[13]-'0';
640 if(tm.min < 0 || tm.min > 59)
642 strcpy(tm.zone, "XXX"); /* anything but GMT */
644 print("tm2sec %d/%d/%d/%d/%d\n",
645 tm.year, tm.mon, tm.mday, tm.hour, tm.min);
648 if(0) print("time %lud\n", *time);
654 readconfigfile(Config *cp)
656 char *f[10], *image, *p, *pref, *q, *name;
658 uchar scorebuf[VtScoreSize], *score;
666 if((dir = dirstat(name)) == nil)
668 if(c.mtime == dir->mtime){
672 c.mtime = dir->mtime;
674 if((b = Bopen(name, OREAD)) == nil)
678 * Reuse old tree, garbage collecting entries that
679 * are not mentioned in the new config file.
689 for(; (p=Brdstr(b, '\n', 1)) != nil; free(p)){
691 if((q = strchr(p, '#')) != nil)
693 nf = tokenize(p, f, nelem(f));
696 if(strcmp(f[0], "mount") == 0){
698 werrstr("syntax error: mount /path /dev|score mtime");
702 werrstr("unrooted path %s", f[1]);
708 if(access(f[2], AEXIST) < 0){
709 werrstr("image %s does not exist", f[2]);
714 if(vtparsescore(f[2], &pref, scorebuf) < 0){
715 werrstr("bad score %s", f[2]);
720 if(parsetime(f[3], &time) < 0){
721 fprint(2, "%s:%d: bad time %s\n", name, line, f[3]);
724 ctreemountfsys(c.ctree, f[1], time, score, image);
727 if(strcmp(f[0], "allow") == 0 || strcmp(f[0], "deny") == 0){
729 werrstr("syntax error: allow|deny ip[/mask]");
732 c.ok = erealloc(c.ok, (c.nok+1)*sizeof(c.ok[0]));
733 if(parseipandmask(f[1], c.ok[c.nok].ip, c.ok[c.nok].mask) < 0){
734 werrstr("bad ip[/mask]: %s", f[1]);
737 c.ok[c.nok].okay = (strcmp(f[0], "allow") == 0);
741 werrstr("unknown verb '%s'", f[0]);
743 fprint(2, "%s:%d: %r\n", name, line);
754 ipokay(uchar *ip, ushort port)
757 uchar ipx[IPaddrlen];
760 for(i=0; i<config.nok; i++){
762 maskip(ip, ok->mask, ipx);
763 if(0) fprint(2, "%I & %I = %I (== %I?)\n",
764 ip, ok->mask, ipx, ok->ip);
765 if(memcmp(ipx, ok->ip, IPaddrlen) == 0)
768 if(config.nok == 0) /* all is permitted */
770 /* otherwise default is none allowed */
775 cnodelookup(Ctree *t, Cnode **np, char *name)
782 if((nn = cnodewalk(n, name, strlen(name), 0)) == nil){
783 if(n->ismtpt || n->fsys){
784 if((nn = cnodewalk(n, "", 0, 1)) == nil){
785 nn = mkcnode(t, n, "", 0, (char*)n->handle, SHA1dlen);
798 cnodegetattr(Cnode *n, Nfs3Attr *attr)
802 memset(attr, 0, sizeof *attr);
804 attr->type = Nfs3FileReg;
809 attr->type = Nfs3FileDir;
814 memmove(&u64, n->handle, 8);
816 attr->atime.sec = n->mtime;
817 attr->mtime.sec = n->mtime;
818 attr->ctime.sec = n->mtime;
823 cnodereaddir(Cnode *n, u32int count, u64int cookie, uchar **pdata, u32int *pcount, u1int *peof)
825 uchar *data, *p, *ep, *np;
841 data = emalloc(count);
845 if(n->mark || n->name[0] == '+'){
851 ne.namelen = strlen(n->name);
852 ne.cookie = ++cookie;
853 memmove(&u64, n->handle, 8);
855 if(nfs3entrypack(p, ep, &np, &ne) < 0)
880 /* refreshconfig(); */
885 * Actually serve the NFS requests. Called from nfs3srv.c.
886 * Each request runs in its own thread (coroutine).
888 * Decrypted handles have the form:
890 * config[20] - SHA1 hash identifying a config tree node
891 * glob[10] - SHA1 hash prefix identifying a glob state
892 * fsyshandle[<=10] - disk file system handle (usually 4 bytes)
896 * A fid represents a point in the file tree.
897 * There are three components, all derived from the handle:
899 * - config tree position (also used to find fsys)
900 * - glob state for exclusions
901 * - file system position
911 typedef struct Fid Fid;
916 Nfs3Handle fsyshandle;
920 handlecmp(Nfs3Handle *h, Nfs3Handle *h1)
922 if(h->len != h1->len)
923 return h->len - h1->len;
924 return memcmp(h->h, h1->h, h->len);
928 handletofid(Nfs3Handle *eh, Fid *fid, int mode)
935 Nfs3Handle h2, *h, *fh;
937 memset(fid, 0, sizeof *fid);
943 * Not necessary, but speeds up ls -l /dump/2005
944 * HAttr and HAccess must be handled the same way
945 * because both can be used to fetch attributes.
946 * Acting differently yields inconsistencies at mount points,
947 * and causes FreeBSD ls -l to fail.
949 if(mode == HAttr || mode == HAccess)
957 if((ok = hdecrypt(h)) != Nfs3Ok)
959 trace("handletofid: decrypted %.*lH\n", h->len, h->h);
960 if(h->len < FsysHandleOffset)
961 return Nfs3ErrBadHandle;
964 * Find place in config tree.
966 if((n = cnodebyhandle(config.ctree, h->h)) == nil)
970 if(n->ismtpt && domount){
972 * Open fsys for mount point if needed.
975 trace("handletofid: mounting %V/%s\n", n->fsysscore, n->fsysimage);
977 if(strcmp(n->fsysimage, "/dev/null") == 0)
979 if((disk = diskopenfile(n->fsysimage)) == nil){
980 fprint(2, "cannot open disk %s: %r\n", n->fsysimage);
983 if((cdisk = diskcache(disk, blocksize, 64)) == nil){
984 fprint(2, "cannot cache disk %s: %r\n", n->fsysimage);
989 if((disk = diskopenventi(vcache, n->fsysscore)) == nil){
990 fprint(2, "cannot open venti disk %V: %r\n", n->fsysscore);
994 if((fsys = fsysopen(disk)) == nil){
995 fprint(2, "cannot open fsys on %V: %r\n", n->fsysscore);
1000 fsysroot(fsys, &n->mfsyshandle);
1006 fid->fsys = n->mfsys;
1007 fid->fsyshandle = n->mfsyshandle;
1010 * Use fsys handle from tree or from handle.
1011 * This assumes that fsyshandle was set by fidtohandle
1012 * earlier, so it's not okay to reuse handles (except the root)
1013 * across sessions. The encryption above makes and
1014 * enforces the same restriction, so this is okay.
1016 fid->fsys = n->fsys;
1017 fh = &fid->fsyshandle;
1019 fh->len = h->len-FsysHandleOffset;
1020 memmove(fh->h, h->h+FsysHandleOffset, fh->len);
1022 *fh = n->fsyshandle;
1023 trace("handletofid: fsyshandle %.*lH\n", fh->len, fh->h);
1027 * TO DO (maybe): some sort of path restriction here.
1029 trace("handletofid: cnode %s fsys %p fsyshandle %.*lH\n",
1030 n->name, fid->fsys, fid->fsyshandle.len, fid->fsyshandle.h);
1035 _fidtohandle(Fid *fid, Nfs3Handle *h)
1041 * Record fsys handle in n, don't bother sending it to client
1044 n->fsys = fid->fsys;
1045 if(!n->isblackhole){
1046 n->fsyshandle = fid->fsyshandle;
1047 fid->fsyshandle.len = 0;
1049 memmove(h->h, n->handle, CnodeHandleSize);
1050 memmove(h->h+FsysHandleOffset, fid->fsyshandle.h, fid->fsyshandle.len);
1051 h->len = FsysHandleOffset+fid->fsyshandle.len;
1055 fidtohandle(Fid *fid, Nfs3Handle *h)
1057 _fidtohandle(fid, h);
1066 memset(&fid, 0, sizeof fid);
1067 fid.cnode = config.ctree->root;
1068 _fidtohandle(&fid, &root);
1072 fsgetroot(Nfs3Handle *h)
1079 fsgetattr(SunAuthUnix *au, Nfs3Handle *h, Nfs3Attr *attr)
1084 trace("getattr %.*lH\n", h->len, h->h);
1085 if((ok = handletofid(h, &fid, HAttr)) != Nfs3Ok)
1088 return fsysgetattr(fid.fsys, au, &fid.fsyshandle, attr);
1090 return cnodegetattr(fid.cnode, attr);
1094 * Lookup is always the hard part.
1097 fslookup(SunAuthUnix *au, Nfs3Handle *h, char *name, Nfs3Handle *nh)
1105 trace("lookup %.*lH %s\n", h->len, h->h, name);
1108 if(strcmp(name, "..") == 0 || strcmp(name, ".") == 0)
1110 if((ok = handletofid(h, &fid, mode)) != Nfs3Ok){
1112 trace("lookup: handletofid %r\n");
1116 if(strcmp(name, ".") == 0){
1117 fidtohandle(&fid, nh);
1122 * Walk down file system and cnode simultaneously.
1123 * If dotdot and file system doesn't move, need to walk
1124 * up cnode. Save the corresponding fsys handles in
1125 * the cnode as we walk down so that we'll have them
1126 * for dotdotting back up.
1131 * Walk down config tree and file system simultaneously.
1133 if((ok = cnodelookup(config.ctree, &n, name)) != Nfs3Ok){
1135 trace("lookup: cnodelookup: %r\n");
1140 if((ok = fsyslookup(fid.fsys, au, &fid.fsyshandle, name, &xh)) != Nfs3Ok){
1142 trace("lookup: fsyslookup: %r\n");
1145 fid.fsyshandle = xh;
1149 * Walking dotdot. Ick.
1151 trace("lookup dotdot fsys=%p\n", fid.fsys);
1154 * Walk up file system, then try up config tree.
1156 if((ok = fsyslookup(fid.fsys, au, &fid.fsyshandle, "..", &xh)) != Nfs3Ok){
1158 trace("lookup fsyslookup: %r\n");
1161 fid.fsyshandle = xh;
1164 * Usually just go to n->parent.
1166 * If we're in a subtree of the mounted file system that
1167 * isn't represented explicitly by the config tree (instead
1168 * the black hole node represents the entire file tree),
1169 * then we only go to n->parent when we've dotdotted back
1170 * to the right handle.
1172 if(n->parent == nil)
1173 trace("lookup dotdot: no parent\n");
1175 trace("lookup dotdot: parent %.*lH, have %.*lH\n",
1176 n->parent->fsyshandle.len, n->parent->fsyshandle.h,
1181 if(handlecmp(&n->parent->mfsyshandle, &xh) == 0)
1189 * No file system, just walk up.
1196 fid.fsyshandle = n->fsyshandle;
1199 fidtohandle(&fid, nh);
1204 fsaccess(SunAuthUnix *au, Nfs3Handle *h, u32int want, u32int *got, Nfs3Attr *attr)
1209 trace("access %.*lH 0x%ux\n", h->len, h->h, want);
1210 if((ok = handletofid(h, &fid, HAccess)) != Nfs3Ok)
1213 return fsysaccess(fid.fsys, au, &fid.fsyshandle, want, got, attr);
1214 *got = want & (Nfs3AccessRead|Nfs3AccessLookup|Nfs3AccessExecute);
1215 return cnodegetattr(fid.cnode, attr);
1219 fsreadlink(SunAuthUnix *au, Nfs3Handle *h, char **link)
1224 trace("readlink %.*lH\n", h->len, h->h);
1225 if((ok = handletofid(h, &fid, HRead)) != Nfs3Ok)
1228 return fsysreadlink(fid.fsys, au, &fid.fsyshandle, link);
1230 return Nfs3ErrNotSupp;
1234 fsreadfile(SunAuthUnix *au, Nfs3Handle *h, u32int count, u64int offset, uchar **data, u32int *pcount, u1int *peof)
1239 trace("readfile %.*lH\n", h->len, h->h);
1240 if((ok = handletofid(h, &fid, HRead)) != Nfs3Ok)
1243 return fid.cnode->read(fid.cnode, count, offset, data, pcount, peof);
1245 return fsysreadfile(fid.fsys, au, &fid.fsyshandle, count, offset, data, pcount, peof);
1246 return Nfs3ErrNotSupp;
1250 fsreaddir(SunAuthUnix *au, Nfs3Handle *h, u32int len, u64int cookie, uchar **pdata, u32int *pcount, u1int *peof)
1255 trace("readdir %.*lH\n", h->len, h->h);
1256 if((ok = handletofid(h, &fid, HRead)) != Nfs3Ok)
1259 return fsysreaddir(fid.fsys, au, &fid.fsyshandle, len, cookie, pdata, pcount, peof);
1260 return cnodereaddir(fid.cnode, len, cookie, pdata, pcount, peof);
1264 logread(Cnode *n, u32int count, u64int offset, uchar **data, u32int *pcount, u1int *peof)
1272 refreshdiskread(Cnode *n, u32int count, u64int offset, uchar **data, u32int *pcount, u1int *peof)
1281 if(refreshdisk() < 0)
1282 snprint(buf, sizeof buf, "refreshdisk: %r\n");
1284 strcpy(buf, "ok\n");
1285 *data = emalloc(strlen(buf));
1286 strcpy((char*)*data, buf);
1287 *pcount = strlen(buf);
1293 refreshconfigread(Cnode *n, u32int count, u64int offset, uchar **data, u32int *pcount, u1int *peof)
1302 if(readconfigfile(&config) < 0)
1303 snprint(buf, sizeof buf, "readconfig: %r\n");
1305 strcpy(buf, "ok\n");
1306 *data = emalloc(strlen(buf));
1307 strcpy((char*)*data, buf);
1308 *pcount = strlen(buf);