void nfs3_call(u_int32_t xid, u_int32_t proc, u_char *buf, int len) { XDR xdrs; struct LOOKUP3args largs; struct READ3args rargs; struct myreadargs *ma; char *fname; switch (proc) { case NFSPROC3_LOOKUP: memset(&largs, 0, sizeof(largs)); xdrmem_create(&xdrs, buf, len, XDR_DECODE); if (xdr_LOOKUP3args(&xdrs, &largs)) { if (regex_match(largs.what.name)) { xid_map_enter(xid, NFS_PROGRAM, NFS_V3, proc, (void *)largs.what.name); } } xdr_destroy(&xdrs); break; case NFSPROC3_READ: memset(&rargs, 0, sizeof(rargs)); xdrmem_create(&xdrs, buf, len, XDR_DECODE); if (xdr_READ3args(&xdrs, &rargs)) { fname = fh_map_find(rargs.file.data.data_val, rargs.file.data.data_len); if (fname != NULL) { ma = (struct myreadargs *) malloc(sizeof(*ma)); if (ma != NULL) { ma->filename = fname; ma->offset = rargs.offset; xid_map_enter(xid, NFS_PROGRAM, NFS_V3, NFSPROC_READ, (void *)ma); } } } xdr_destroy(&xdrs); break; } }
READ3args * xdr_to_READ3args(char *msg, int len) { READ3args *args = NULL; XDR xdr; if(msg == NULL) return NULL; args = (READ3args *)mem_alloc(sizeof(READ3args)); if(args == NULL) return NULL; xdrmem_create(&xdr, msg, len, XDR_DECODE); args->file.data.data_val = NULL; if(!xdr_READ3args(&xdr, args)) { mem_free(args, sizeof(READ3args)); return NULL; } return args; }