/* * This file is part of the UCB release of Plan 9. It is subject to the license * terms in the LICENSE file found in the top-level directory of this * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No * part of the UCB release of Plan 9, including this file, may be copied, * modified, propagated, or distributed except according to the terms contained * in the LICENSE file. */ #include <u.h>#include <libc.h>#include <thread.h>#include <sunrpc.h>#include <nfs3.h> char*nfs3StatusStr(Nfs3Status x){ switch(x){ case Nfs3Ok: return "Nfs3Ok"; case Nfs3ErrNotOwner: return "Nfs3ErrNotOwner"; case Nfs3ErrNoEnt: return "Nfs3ErrNoEnt"; case Nfs3ErrNoMem: return "Nfs3ErrNoMem"; case Nfs3ErrIo: return "Nfs3ErrIo"; case Nfs3ErrNxio: return "Nfs3ErrNxio"; case Nfs3ErrAcces: return "Nfs3ErrAcces"; case Nfs3ErrExist: return "Nfs3ErrExist"; case Nfs3ErrXDev: return "Nfs3ErrXDev"; case Nfs3ErrNoDev: return "Nfs3ErrNoDev"; case Nfs3ErrNotDir: return "Nfs3ErrNotDir"; case Nfs3ErrIsDir: return "Nfs3ErrIsDir"; case Nfs3ErrInval: return "Nfs3ErrInval"; case Nfs3ErrFbig: return "Nfs3ErrFbig"; case Nfs3ErrNoSpc: return "Nfs3ErrNoSpc"; case Nfs3ErrRoFs: return "Nfs3ErrRoFs"; case Nfs3ErrMLink: return "Nfs3ErrMLink"; case Nfs3ErrNameTooLong: return "Nfs3ErrNameTooLong"; case Nfs3ErrNotEmpty: return "Nfs3ErrNotEmpty"; case Nfs3ErrDQuot: return "Nfs3ErrDQuot"; case Nfs3ErrStale: return "Nfs3ErrStale"; case Nfs3ErrRemote: return "Nfs3ErrRemote"; case Nfs3ErrBadHandle: return "Nfs3ErrBadHandle"; case Nfs3ErrNotSync: return "Nfs3ErrNotSync"; case Nfs3ErrBadCookie: return "Nfs3ErrBadCookie"; case Nfs3ErrNotSupp: return "Nfs3ErrNotSupp"; case Nfs3ErrTooSmall: return "Nfs3ErrTooSmall"; case Nfs3ErrServerFault: return "Nfs3ErrServerFault"; case Nfs3ErrBadType: return "Nfs3ErrBadType"; case Nfs3ErrJukebox: return "Nfs3ErrJukebox"; case Nfs3ErrFprintNotFound: return "Nfs3ErrFprintNotFound"; case Nfs3ErrAborted: return "Nfs3ErrAborted"; default: return "unknown"; }} static struct { SunStatus status; char *msg;} etab[] = { Nfs3ErrNotOwner, "not owner", Nfs3ErrNoEnt, "directory entry not found", Nfs3ErrIo, "i/o error", Nfs3ErrNxio, "no such device", Nfs3ErrNoMem, "out of memory", Nfs3ErrAcces, "access denied", Nfs3ErrExist, "file or directory exists", Nfs3ErrXDev, "cross-device operation", Nfs3ErrNoDev, "no such device", Nfs3ErrNotDir, "not a directory", Nfs3ErrIsDir, "is a directory", Nfs3ErrInval, "invalid arguments", Nfs3ErrFbig, "file too big", Nfs3ErrNoSpc, "no space left on device", Nfs3ErrRoFs, "read-only file system", Nfs3ErrMLink, "too many links", Nfs3ErrNameTooLong, "name too long", Nfs3ErrNotEmpty, "directory not empty", Nfs3ErrDQuot, "dquot", Nfs3ErrStale, "stale handle", Nfs3ErrRemote, "remote error", Nfs3ErrBadHandle, "bad handle", Nfs3ErrNotSync, "out of sync with server", Nfs3ErrBadCookie, "bad cookie", Nfs3ErrNotSupp, "not supported", Nfs3ErrTooSmall, "too small", Nfs3ErrServerFault, "server fault", Nfs3ErrBadType, "bad type", Nfs3ErrJukebox, "jukebox -- try again later", Nfs3ErrFprintNotFound, "fprint not found", Nfs3ErrAborted, "aborted",}; voidnfs3Errstr(SunStatus status){ int i; for(i=0; i<nelem(etab); i++){ if(etab[i].status == status){ werrstr(etab[i].msg); return; } } werrstr("unknown nfs3 error %d", (int)status);} char*nfs3FileTypeStr(Nfs3FileType x){ switch(x){ case Nfs3FileReg: return "Nfs3FileReg"; case Nfs3FileDir: return "Nfs3FileDir"; case Nfs3FileBlock: return "Nfs3FileBlock"; case Nfs3FileChar: return "Nfs3FileChar"; case Nfs3FileSymlink: return "Nfs3FileSymlink"; case Nfs3FileSocket: return "Nfs3FileSocket"; case Nfs3FileFifo: return "Nfs3FileFifo"; default: return "unknown"; }} voidnfs3HandlePrint(Fmt *fmt, Nfs3Handle *x){ fmtprint(fmt, "%s\n", "Nfs3Handle"); fmtprint(fmt, "\t%s=", "handle"); if(x->len > 64) fmtprint(fmt, "%.*H... (%d)", 64, x->h, x->len); else fmtprint(fmt, "%.*H", x->len, x->h); fmtprint(fmt, "\n");}uintnfs3HandleSize(Nfs3Handle *x){ uint a; USED(x); a = 0 + sunVarOpaqueSize(x->len); return a;}intnfs3HandlePack(uchar *a, uchar *ea, uchar **pa, Nfs3Handle *x){ if(x->len > Nfs3MaxHandleSize || sunUint32Pack(a, ea, &a, &x->len) < 0 || sunFixedOpaquePack(a, ea, &a, x->h, x->len) < 0) goto Err; *pa = a; return 0;Err: *pa = ea; return -1;}intnfs3HandleUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3Handle *x){ uchar *ha; u32int n; if(sunUint32Unpack(a, ea, &a, &n) < 0 || n > Nfs3MaxHandleSize) goto Err; ha = a; a += (n+3)&~3; if(a > ea) goto Err; memmove(x->h, ha, n); x->len = n; *pa = a; return 0;Err: *pa = ea; return -1;}voidnfs3TimePrint(Fmt *fmt, Nfs3Time *x){ fmtprint(fmt, "%s\n", "Nfs3Time"); fmtprint(fmt, "\t%s=", "sec"); fmtprint(fmt, "%ud", x->sec); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "nsec"); fmtprint(fmt, "%ud", x->nsec); fmtprint(fmt, "\n");}uintnfs3TimeSize(Nfs3Time *x){ uint a; USED(x); a = 0 + 4 + 4; return a;}intnfs3TimePack(uchar *a, uchar *ea, uchar **pa, Nfs3Time *x){ if(sunUint32Pack(a, ea, &a, &x->sec) < 0) goto Err; if(sunUint32Pack(a, ea, &a, &x->nsec) < 0) goto Err; *pa = a; return 0;Err: *pa = ea; return -1;}intnfs3TimeUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3Time *x){ if(sunUint32Unpack(a, ea, &a, &x->sec) < 0) goto Err; if(sunUint32Unpack(a, ea, &a, &x->nsec) < 0) goto Err; *pa = a; return 0;Err: *pa = ea; return -1;}voidnfs3AttrPrint(Fmt *fmt, Nfs3Attr *x){ fmtprint(fmt, "%s\n", "Nfs3Attr"); fmtprint(fmt, "\t%s=", "type"); fmtprint(fmt, "%s", nfs3FileTypeStr(x->type)); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "mode"); fmtprint(fmt, "%ud", x->mode); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "nlink"); fmtprint(fmt, "%ud", x->nlink); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "uid"); fmtprint(fmt, "%ud", x->uid); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "gid"); fmtprint(fmt, "%ud", x->gid); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "size"); fmtprint(fmt, "%llud", x->size); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "used"); fmtprint(fmt, "%llud", x->used); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "major"); fmtprint(fmt, "%ud", x->major); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "minor"); fmtprint(fmt, "%ud", x->minor); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "fsid"); fmtprint(fmt, "%llud", x->fsid); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "fileid"); fmtprint(fmt, "%llud", x->fileid); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "atime"); nfs3TimePrint(fmt, &x->atime); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "mtime"); nfs3TimePrint(fmt, &x->mtime); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "ctime"); nfs3TimePrint(fmt, &x->ctime); fmtprint(fmt, "\n");}uintnfs3AttrSize(Nfs3Attr *x){ uint a; USED(x); a = 0 + 4 + 4 + 4 + 4 + 4 + 8 + 8 + 4 + 4 + 8 + 8 + nfs3TimeSize(&x->atime) + nfs3TimeSize(&x->mtime) + nfs3TimeSize(&x->ctime); return a;}intnfs3AttrPack(uchar *a, uchar *ea, uchar **pa, Nfs3Attr *x){ int i; if(i=x->type, sunEnumPack(a, ea, &a, &i) < 0) goto Err; if(sunUint32Pack(a, ea, &a, &x->mode) < 0) goto Err; if(sunUint32Pack(a, ea, &a, &x->nlink) < 0) goto Err; if(sunUint32Pack(a, ea, &a, &x->uid) < 0) goto Err; if(sunUint32Pack(a, ea, &a, &x->gid) < 0) goto Err; if(sunUint64Pack(a, ea, &a, &x->size) < 0) goto Err; if(sunUint64Pack(a, ea, &a, &x->used) < 0) goto Err; if(sunUint32Pack(a, ea, &a, &x->major) < 0) goto Err; if(sunUint32Pack(a, ea, &a, &x->minor) < 0) goto Err; if(sunUint64Pack(a, ea, &a, &x->fsid) < 0) goto Err; if(sunUint64Pack(a, ea, &a, &x->fileid) < 0) goto Err; if(nfs3TimePack(a, ea, &a, &x->atime) < 0) goto Err; if(nfs3TimePack(a, ea, &a, &x->mtime) < 0) goto Err; if(nfs3TimePack(a, ea, &a, &x->ctime) < 0) goto Err; *pa = a; return 0;Err: *pa = ea; return -1;}intnfs3AttrUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3Attr *x){ int i; if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->type = i; if(sunUint32Unpack(a, ea, &a, &x->mode) < 0) goto Err; if(sunUint32Unpack(a, ea, &a, &x->nlink) < 0) goto Err; if(sunUint32Unpack(a, ea, &a, &x->uid) < 0) goto Err; if(sunUint32Unpack(a, ea, &a, &x->gid) < 0) goto Err; if(sunUint64Unpack(a, ea, &a, &x->size) < 0) goto Err; if(sunUint64Unpack(a, ea, &a, &x->used) < 0) goto Err; if(sunUint32Unpack(a, ea, &a, &x->major) < 0) goto Err; if(sunUint32Unpack(a, ea, &a, &x->minor) < 0) goto Err; if(sunUint64Unpack(a, ea, &a, &x->fsid) < 0) goto Err; if(sunUint64Unpack(a, ea, &a, &x->fileid) < 0) goto Err; if(nfs3TimeUnpack(a, ea, &a, &x->atime) < 0) goto Err; if(nfs3TimeUnpack(a, ea, &a, &x->mtime) < 0) goto Err; if(nfs3TimeUnpack(a, ea, &a, &x->ctime) < 0) goto Err; *pa = a; return 0;Err: *pa = ea; return -1;}voidnfs3WccAttrPrint(Fmt *fmt, Nfs3WccAttr *x){ fmtprint(fmt, "%s\n", "Nfs3WccAttr"); fmtprint(fmt, "\t%s=", "size"); fmtprint(fmt, "%llud", x->size); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "mtime"); nfs3TimePrint(fmt, &x->mtime); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "ctime"); nfs3TimePrint(fmt, &x->ctime); fmtprint(fmt, "\n");}uintnfs3WccAttrSize(Nfs3WccAttr *x){ uint a; USED(x); a = 0 + 8 + nfs3TimeSize(&x->mtime) + nfs3TimeSize(&x->ctime); return a;}intnfs3WccAttrPack(uchar *a, uchar *ea, uchar **pa, Nfs3WccAttr *x){ if(sunUint64Pack(a, ea, &a, &x->size) < 0) goto Err; if(nfs3TimePack(a, ea, &a, &x->mtime) < 0) goto Err; if(nfs3TimePack(a, ea, &a, &x->ctime) < 0) goto Err; *pa = a; return 0;Err: *pa = ea; return -1;}intnfs3WccAttrUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3WccAttr *x){ if(sunUint64Unpack(a, ea, &a, &x->size) < 0) goto Err; if(nfs3TimeUnpack(a, ea, &a, &x->mtime) < 0) goto Err; if(nfs3TimeUnpack(a, ea, &a, &x->ctime) < 0) goto Err; *pa = a; return 0;Err: *pa = ea; return -1;}voidnfs3WccPrint(Fmt *fmt, Nfs3Wcc *x){ fmtprint(fmt, "%s\n", "Nfs3Wcc"); fmtprint(fmt, "\t%s=", "haveWccAttr"); fmtprint(fmt, "%d", x->haveWccAttr); fmtprint(fmt, "\n"); switch(x->haveWccAttr){ case 1: fmtprint(fmt, "\t%s=", "wccAttr"); nfs3WccAttrPrint(fmt, &x->wccAttr); fmtprint(fmt, "\n"); break; } fmtprint(fmt, "\t%s=", "haveAttr"); fmtprint(fmt, "%d", x->haveAttr); fmtprint(fmt, "\n"); switch(x->haveAttr){ case 1: fmtprint(fmt, "\t%s=", "attr"); nfs3AttrPrint(fmt, &x->attr); fmtprint(fmt, "\n"); break; }}uintnfs3WccSize(Nfs3Wcc *x){ uint a; USED(x); a = 0 + 4; switch(x->haveWccAttr){ case 1: a = a + nfs3WccAttrSize(&x->wccAttr); break; } a = a + 4; switch(x->haveAttr){ case 1: a = a + nfs3AttrSize(&x->attr); break; } return a;}intnfs3WccPack(uchar *a, uchar *ea, uchar **pa, Nfs3Wcc *x){ if(sunUint1Pack(a, ea, &a, &x->haveWccAttr) < 0) goto Err; switch(x->haveWccAttr){ case 1: if(nfs3WccAttrPack(a, ea, &a, &x->wccAttr) < 0) goto Err; break; } if(sunUint1Pack(a, ea, &a, &x->haveAttr) < 0) goto Err; switch(x->haveAttr){ case 1: if(nfs3AttrPack(a, ea, &a, &x->attr) < 0) goto Err; break; } *pa = a; return 0;Err: *pa = ea; return -1;}intnfs3WccUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3Wcc *x){ if(sunUint1Unpack(a, ea, &a, &x->haveWccAttr) < 0) goto Err; switch(x->haveWccAttr){ case 1: if(nfs3WccAttrUnpack(a, ea, &a, &x->wccAttr) < 0) goto Err; break; } if(sunUint1Unpack(a, ea, &a, &x->haveAttr) < 0) goto Err; switch(x->haveAttr){ case 1: if(nfs3AttrUnpack(a, ea, &a, &x->attr) < 0) goto Err; break; } *pa = a; return 0;Err: *pa = ea; return -1;}char*nfs3SetTimeStr(Nfs3SetTime x){ switch(x){ case Nfs3SetTimeDont: return "Nfs3SetTimeDont"; case Nfs3SetTimeServer: return "Nfs3SetTimeServer"; case Nfs3SetTimeClient: return "Nfs3SetTimeClient";Lines 1–500 of 4054. Load more
/* * This file is part of the UCB release of Plan 9. It is subject to the license * terms in the LICENSE file found in the top-level directory of this * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No * part of the UCB release of Plan 9, including this file, may be copied, * modified, propagated, or distributed except according to the terms contained * in the LICENSE file. */ #include <u.h> #include <libc.h> #include <thread.h> #include <sunrpc.h> #include <nfs3.h> char* nfs3StatusStr(Nfs3Status x) { switch(x){ case Nfs3Ok: return "Nfs3Ok"; case Nfs3ErrNotOwner: return "Nfs3ErrNotOwner"; case Nfs3ErrNoEnt: return "Nfs3ErrNoEnt"; case Nfs3ErrNoMem: return "Nfs3ErrNoMem"; case Nfs3ErrIo: return "Nfs3ErrIo"; case Nfs3ErrNxio: return "Nfs3ErrNxio"; case Nfs3ErrAcces: return "Nfs3ErrAcces"; case Nfs3ErrExist: return "Nfs3ErrExist"; case Nfs3ErrXDev: return "Nfs3ErrXDev"; case Nfs3ErrNoDev: return "Nfs3ErrNoDev"; case Nfs3ErrNotDir: return "Nfs3ErrNotDir"; case Nfs3ErrIsDir: return "Nfs3ErrIsDir"; case Nfs3ErrInval: return "Nfs3ErrInval"; case Nfs3ErrFbig: return "Nfs3ErrFbig"; case Nfs3ErrNoSpc: return "Nfs3ErrNoSpc"; case Nfs3ErrRoFs: return "Nfs3ErrRoFs"; case Nfs3ErrMLink: return "Nfs3ErrMLink"; case Nfs3ErrNameTooLong: return "Nfs3ErrNameTooLong"; case Nfs3ErrNotEmpty: return "Nfs3ErrNotEmpty"; case Nfs3ErrDQuot: return "Nfs3ErrDQuot"; case Nfs3ErrStale: return "Nfs3ErrStale"; case Nfs3ErrRemote: return "Nfs3ErrRemote"; case Nfs3ErrBadHandle: return "Nfs3ErrBadHandle"; case Nfs3ErrNotSync: return "Nfs3ErrNotSync"; case Nfs3ErrBadCookie: return "Nfs3ErrBadCookie"; case Nfs3ErrNotSupp: return "Nfs3ErrNotSupp"; case Nfs3ErrTooSmall: return "Nfs3ErrTooSmall"; case Nfs3ErrServerFault: return "Nfs3ErrServerFault"; case Nfs3ErrBadType: return "Nfs3ErrBadType"; case Nfs3ErrJukebox: return "Nfs3ErrJukebox"; case Nfs3ErrFprintNotFound: return "Nfs3ErrFprintNotFound"; case Nfs3ErrAborted: return "Nfs3ErrAborted"; default: return "unknown"; } } static struct { SunStatus status; char *msg; } etab[] = { Nfs3ErrNotOwner, "not owner", Nfs3ErrNoEnt, "directory entry not found", Nfs3ErrIo, "i/o error", Nfs3ErrNxio, "no such device", Nfs3ErrNoMem, "out of memory", Nfs3ErrAcces, "access denied", Nfs3ErrExist, "file or directory exists", Nfs3ErrXDev, "cross-device operation", Nfs3ErrNoDev, "no such device", Nfs3ErrNotDir, "not a directory", Nfs3ErrIsDir, "is a directory", Nfs3ErrInval, "invalid arguments", Nfs3ErrFbig, "file too big", Nfs3ErrNoSpc, "no space left on device", Nfs3ErrRoFs, "read-only file system", Nfs3ErrMLink, "too many links", Nfs3ErrNameTooLong, "name too long", Nfs3ErrNotEmpty, "directory not empty", Nfs3ErrDQuot, "dquot", Nfs3ErrStale, "stale handle", Nfs3ErrRemote, "remote error", Nfs3ErrBadHandle, "bad handle", Nfs3ErrNotSync, "out of sync with server", Nfs3ErrBadCookie, "bad cookie", Nfs3ErrNotSupp, "not supported", Nfs3ErrTooSmall, "too small", Nfs3ErrServerFault, "server fault", Nfs3ErrBadType, "bad type", Nfs3ErrJukebox, "jukebox -- try again later", Nfs3ErrFprintNotFound, "fprint not found", Nfs3ErrAborted, "aborted", }; void nfs3Errstr(SunStatus status) { int i; for(i=0; i<nelem(etab); i++){ if(etab[i].status == status){ werrstr(etab[i].msg); return; } } werrstr("unknown nfs3 error %d", (int)status); } char* nfs3FileTypeStr(Nfs3FileType x) { switch(x){ case Nfs3FileReg: return "Nfs3FileReg"; case Nfs3FileDir: return "Nfs3FileDir"; case Nfs3FileBlock: return "Nfs3FileBlock"; case Nfs3FileChar: return "Nfs3FileChar"; case Nfs3FileSymlink: return "Nfs3FileSymlink"; case Nfs3FileSocket: return "Nfs3FileSocket"; case Nfs3FileFifo: return "Nfs3FileFifo"; default: return "unknown"; } } void nfs3HandlePrint(Fmt *fmt, Nfs3Handle *x) { fmtprint(fmt, "%s\n", "Nfs3Handle"); fmtprint(fmt, "\t%s=", "handle"); if(x->len > 64) fmtprint(fmt, "%.*H... (%d)", 64, x->h, x->len); else fmtprint(fmt, "%.*H", x->len, x->h); fmtprint(fmt, "\n"); } uint nfs3HandleSize(Nfs3Handle *x) { uint a; USED(x); a = 0 + sunVarOpaqueSize(x->len); return a; } int nfs3HandlePack(uchar *a, uchar *ea, uchar **pa, Nfs3Handle *x) { if(x->len > Nfs3MaxHandleSize || sunUint32Pack(a, ea, &a, &x->len) < 0 || sunFixedOpaquePack(a, ea, &a, x->h, x->len) < 0) goto Err; *pa = a; return 0; Err: *pa = ea; return -1; } int nfs3HandleUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3Handle *x) { uchar *ha; u32int n; if(sunUint32Unpack(a, ea, &a, &n) < 0 || n > Nfs3MaxHandleSize) goto Err; ha = a; a += (n+3)&~3; if(a > ea) goto Err; memmove(x->h, ha, n); x->len = n; *pa = a; return 0; Err: *pa = ea; return -1; } void nfs3TimePrint(Fmt *fmt, Nfs3Time *x) { fmtprint(fmt, "%s\n", "Nfs3Time"); fmtprint(fmt, "\t%s=", "sec"); fmtprint(fmt, "%ud", x->sec); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "nsec"); fmtprint(fmt, "%ud", x->nsec); fmtprint(fmt, "\n"); } uint nfs3TimeSize(Nfs3Time *x) { uint a; USED(x); a = 0 + 4 + 4; return a; } int nfs3TimePack(uchar *a, uchar *ea, uchar **pa, Nfs3Time *x) { if(sunUint32Pack(a, ea, &a, &x->sec) < 0) goto Err; if(sunUint32Pack(a, ea, &a, &x->nsec) < 0) goto Err; *pa = a; return 0; Err: *pa = ea; return -1; } int nfs3TimeUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3Time *x) { if(sunUint32Unpack(a, ea, &a, &x->sec) < 0) goto Err; if(sunUint32Unpack(a, ea, &a, &x->nsec) < 0) goto Err; *pa = a; return 0; Err: *pa = ea; return -1; } void nfs3AttrPrint(Fmt *fmt, Nfs3Attr *x) { fmtprint(fmt, "%s\n", "Nfs3Attr"); fmtprint(fmt, "\t%s=", "type"); fmtprint(fmt, "%s", nfs3FileTypeStr(x->type)); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "mode"); fmtprint(fmt, "%ud", x->mode); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "nlink"); fmtprint(fmt, "%ud", x->nlink); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "uid"); fmtprint(fmt, "%ud", x->uid); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "gid"); fmtprint(fmt, "%ud", x->gid); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "size"); fmtprint(fmt, "%llud", x->size); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "used"); fmtprint(fmt, "%llud", x->used); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "major"); fmtprint(fmt, "%ud", x->major); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "minor"); fmtprint(fmt, "%ud", x->minor); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "fsid"); fmtprint(fmt, "%llud", x->fsid); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "fileid"); fmtprint(fmt, "%llud", x->fileid); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "atime"); nfs3TimePrint(fmt, &x->atime); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "mtime"); nfs3TimePrint(fmt, &x->mtime); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "ctime"); nfs3TimePrint(fmt, &x->ctime); fmtprint(fmt, "\n"); } uint nfs3AttrSize(Nfs3Attr *x) { uint a; USED(x); a = 0 + 4 + 4 + 4 + 4 + 4 + 8 + 8 + 4 + 4 + 8 + 8 + nfs3TimeSize(&x->atime) + nfs3TimeSize(&x->mtime) + nfs3TimeSize(&x->ctime); return a; } int nfs3AttrPack(uchar *a, uchar *ea, uchar **pa, Nfs3Attr *x) { int i; if(i=x->type, sunEnumPack(a, ea, &a, &i) < 0) goto Err; if(sunUint32Pack(a, ea, &a, &x->mode) < 0) goto Err; if(sunUint32Pack(a, ea, &a, &x->nlink) < 0) goto Err; if(sunUint32Pack(a, ea, &a, &x->uid) < 0) goto Err; if(sunUint32Pack(a, ea, &a, &x->gid) < 0) goto Err; if(sunUint64Pack(a, ea, &a, &x->size) < 0) goto Err; if(sunUint64Pack(a, ea, &a, &x->used) < 0) goto Err; if(sunUint32Pack(a, ea, &a, &x->major) < 0) goto Err; if(sunUint32Pack(a, ea, &a, &x->minor) < 0) goto Err; if(sunUint64Pack(a, ea, &a, &x->fsid) < 0) goto Err; if(sunUint64Pack(a, ea, &a, &x->fileid) < 0) goto Err; if(nfs3TimePack(a, ea, &a, &x->atime) < 0) goto Err; if(nfs3TimePack(a, ea, &a, &x->mtime) < 0) goto Err; if(nfs3TimePack(a, ea, &a, &x->ctime) < 0) goto Err; *pa = a; return 0; Err: *pa = ea; return -1; } int nfs3AttrUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3Attr *x) { int i; if(sunEnumUnpack(a, ea, &a, &i) < 0) goto Err; x->type = i; if(sunUint32Unpack(a, ea, &a, &x->mode) < 0) goto Err; if(sunUint32Unpack(a, ea, &a, &x->nlink) < 0) goto Err; if(sunUint32Unpack(a, ea, &a, &x->uid) < 0) goto Err; if(sunUint32Unpack(a, ea, &a, &x->gid) < 0) goto Err; if(sunUint64Unpack(a, ea, &a, &x->size) < 0) goto Err; if(sunUint64Unpack(a, ea, &a, &x->used) < 0) goto Err; if(sunUint32Unpack(a, ea, &a, &x->major) < 0) goto Err; if(sunUint32Unpack(a, ea, &a, &x->minor) < 0) goto Err; if(sunUint64Unpack(a, ea, &a, &x->fsid) < 0) goto Err; if(sunUint64Unpack(a, ea, &a, &x->fileid) < 0) goto Err; if(nfs3TimeUnpack(a, ea, &a, &x->atime) < 0) goto Err; if(nfs3TimeUnpack(a, ea, &a, &x->mtime) < 0) goto Err; if(nfs3TimeUnpack(a, ea, &a, &x->ctime) < 0) goto Err; *pa = a; return 0; Err: *pa = ea; return -1; } void nfs3WccAttrPrint(Fmt *fmt, Nfs3WccAttr *x) { fmtprint(fmt, "%s\n", "Nfs3WccAttr"); fmtprint(fmt, "\t%s=", "size"); fmtprint(fmt, "%llud", x->size); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "mtime"); nfs3TimePrint(fmt, &x->mtime); fmtprint(fmt, "\n"); fmtprint(fmt, "\t%s=", "ctime"); nfs3TimePrint(fmt, &x->ctime); fmtprint(fmt, "\n"); } uint nfs3WccAttrSize(Nfs3WccAttr *x) { uint a; USED(x); a = 0 + 8 + nfs3TimeSize(&x->mtime) + nfs3TimeSize(&x->ctime); return a; } int nfs3WccAttrPack(uchar *a, uchar *ea, uchar **pa, Nfs3WccAttr *x) { if(sunUint64Pack(a, ea, &a, &x->size) < 0) goto Err; if(nfs3TimePack(a, ea, &a, &x->mtime) < 0) goto Err; if(nfs3TimePack(a, ea, &a, &x->ctime) < 0) goto Err; *pa = a; return 0; Err: *pa = ea; return -1; } int nfs3WccAttrUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3WccAttr *x) { if(sunUint64Unpack(a, ea, &a, &x->size) < 0) goto Err; if(nfs3TimeUnpack(a, ea, &a, &x->mtime) < 0) goto Err; if(nfs3TimeUnpack(a, ea, &a, &x->ctime) < 0) goto Err; *pa = a; return 0; Err: *pa = ea; return -1; } void nfs3WccPrint(Fmt *fmt, Nfs3Wcc *x) { fmtprint(fmt, "%s\n", "Nfs3Wcc"); fmtprint(fmt, "\t%s=", "haveWccAttr"); fmtprint(fmt, "%d", x->haveWccAttr); fmtprint(fmt, "\n"); switch(x->haveWccAttr){ case 1: fmtprint(fmt, "\t%s=", "wccAttr"); nfs3WccAttrPrint(fmt, &x->wccAttr); fmtprint(fmt, "\n"); break; } fmtprint(fmt, "\t%s=", "haveAttr"); fmtprint(fmt, "%d", x->haveAttr); fmtprint(fmt, "\n"); switch(x->haveAttr){ case 1: fmtprint(fmt, "\t%s=", "attr"); nfs3AttrPrint(fmt, &x->attr); fmtprint(fmt, "\n"); break; } } uint nfs3WccSize(Nfs3Wcc *x) { uint a; USED(x); a = 0 + 4; switch(x->haveWccAttr){ case 1: a = a + nfs3WccAttrSize(&x->wccAttr); break; } a = a + 4; switch(x->haveAttr){ case 1: a = a + nfs3AttrSize(&x->attr); break; } return a; } int nfs3WccPack(uchar *a, uchar *ea, uchar **pa, Nfs3Wcc *x) { if(sunUint1Pack(a, ea, &a, &x->haveWccAttr) < 0) goto Err; switch(x->haveWccAttr){ case 1: if(nfs3WccAttrPack(a, ea, &a, &x->wccAttr) < 0) goto Err; break; } if(sunUint1Pack(a, ea, &a, &x->haveAttr) < 0) goto Err; switch(x->haveAttr){ case 1: if(nfs3AttrPack(a, ea, &a, &x->attr) < 0) goto Err; break; } *pa = a; return 0; Err: *pa = ea; return -1; } int nfs3WccUnpack(uchar *a, uchar *ea, uchar **pa, Nfs3Wcc *x) { if(sunUint1Unpack(a, ea, &a, &x->haveWccAttr) < 0) goto Err; switch(x->haveWccAttr){ case 1: if(nfs3WccAttrUnpack(a, ea, &a, &x->wccAttr) < 0) goto Err; break; } if(sunUint1Unpack(a, ea, &a, &x->haveAttr) < 0) goto Err; switch(x->haveAttr){ case 1: if(nfs3AttrUnpack(a, ea, &a, &x->attr) < 0) goto Err; break; } *pa = a; return 0; Err: *pa = ea; return -1; } char* nfs3SetTimeStr(Nfs3SetTime x) { switch(x){ case Nfs3SetTimeDont: return "Nfs3SetTimeDont"; case Nfs3SetTimeServer: return "Nfs3SetTimeServer"; case Nfs3SetTimeClient: return "Nfs3SetTimeClient";