ZDR: New builtin replacement for RPC/XDR called ZDR
[deb_libnfs.git] / nfs / nfs.c
index 1daaa5681f657d0e6643e8b77b0f97f577562bbf..361502ff5b797998f60d5684bce826241f21e78a 100644 (file)
--- a/nfs/nfs.c
+++ b/nfs/nfs.c
    along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
 
+#ifdef WIN32
+#include "win32_compat.h"
+#else
+#include <sys/stat.h>
+#endif/*WIN32*/
+
 #include <stdio.h>
 #include <errno.h>
-#include <sys/stat.h>
 #include <string.h>
-#include <rpc/rpc.h>
-#include <rpc/xdr.h>
+#include "libnfs-zdr.h"
 #include "libnfs.h"
 #include "libnfs-raw.h"
 #include "libnfs-private.h"
 #include "libnfs-raw-nfs.h"
 
-
-
 char *nfsstat3_to_str(int error)
 {
        switch (error) {
@@ -105,7 +107,7 @@ int rpc_nfs_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data)
 {
        struct rpc_pdu *pdu;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_NULL, cb, private_data, (xdrproc_t)xdr_void, 0);
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_NULL, cb, private_data, (zdrproc_t)zdr_void, 0);
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/null call");
                return -1;
@@ -125,7 +127,7 @@ int rpc_nfs_getattr_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh
        struct rpc_pdu *pdu;
        GETATTR3args args;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_GETATTR, cb, private_data, (xdrproc_t)xdr_GETATTR3res, sizeof(GETATTR3res));
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_GETATTR, cb, private_data, (zdrproc_t)zdr_GETATTR3res, sizeof(GETATTR3res));
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/null call");
                return -1;
@@ -134,8 +136,8 @@ int rpc_nfs_getattr_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh
        args.object.data.data_len = fh->data.data_len; 
        args.object.data.data_val = fh->data.data_val; 
 
-       if (xdr_GETATTR3args(&pdu->xdr, &args) == 0) {
-               rpc_set_error(rpc, "XDR error: Failed to encode GETATTR3args");
+       if (zdr_GETATTR3args(&pdu->zdr, &args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode GETATTR3args");
                rpc_free_pdu(rpc, pdu);
                return -2;
        }
@@ -154,7 +156,7 @@ int rpc_nfs_lookup_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
        struct rpc_pdu *pdu;
        LOOKUP3args args;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_LOOKUP, cb, private_data, (xdrproc_t)xdr_LOOKUP3res, sizeof(LOOKUP3res));
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_LOOKUP, cb, private_data, (zdrproc_t)zdr_LOOKUP3res, sizeof(LOOKUP3res));
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/lookup call");
                return -1;
@@ -164,8 +166,8 @@ int rpc_nfs_lookup_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
        args.what.dir.data.data_val = fh->data.data_val; 
        args.what.name              = name;
 
-       if (xdr_LOOKUP3args(&pdu->xdr, &args) == 0) {
-               rpc_set_error(rpc, "XDR error: Failed to encode LOOKUP3args");
+       if (zdr_LOOKUP3args(&pdu->zdr, &args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode LOOKUP3args");
                rpc_free_pdu(rpc, pdu);
                return -2;
        }
@@ -185,7 +187,7 @@ int rpc_nfs_access_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
        struct rpc_pdu *pdu;
        ACCESS3args args;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_ACCESS, cb, private_data, (xdrproc_t)xdr_ACCESS3res, sizeof(ACCESS3res));
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_ACCESS, cb, private_data, (zdrproc_t)zdr_ACCESS3res, sizeof(ACCESS3res));
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/access call");
                return -1;
@@ -195,8 +197,8 @@ int rpc_nfs_access_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
        args.object.data.data_val = fh->data.data_val;
        args.access = access;
 
-       if (xdr_ACCESS3args(&pdu->xdr, &args) == 0) {
-               rpc_set_error(rpc, "XDR error: Failed to encode ACCESS3args");
+       if (zdr_ACCESS3args(&pdu->zdr, &args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode ACCESS3args");
                rpc_free_pdu(rpc, pdu);
                return -2;
        }
@@ -212,12 +214,12 @@ int rpc_nfs_access_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
 
 
 
-int rpc_nfs_read_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, off_t offset, size_t count, void *private_data)
+int rpc_nfs_read_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, uint64_t offset, uint64_t count, void *private_data)
 {
        struct rpc_pdu *pdu;
        READ3args args;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READ, cb, private_data, (xdrproc_t)xdr_READ3res, sizeof(READ3res));
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READ, cb, private_data, (zdrproc_t)zdr_READ3res, sizeof(READ3res));
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/read call");
                return -1;
@@ -228,8 +230,8 @@ int rpc_nfs_read_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, o
        args.offset = offset;
        args.count = count;
 
-       if (xdr_READ3args(&pdu->xdr, &args) == 0) {
-               rpc_set_error(rpc, "XDR error: Failed to encode READ3args");
+       if (zdr_READ3args(&pdu->zdr, &args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode READ3args");
                rpc_free_pdu(rpc, pdu);
                return -2;
        }
@@ -244,12 +246,12 @@ int rpc_nfs_read_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, o
 }
 
 
-int rpc_nfs_write_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *buf, off_t offset, size_t count, int stable_how, void *private_data)
+int rpc_nfs_write_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *buf, uint64_t offset, uint64_t count, int stable_how, void *private_data)
 {
        struct rpc_pdu *pdu;
        WRITE3args args;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_WRITE, cb, private_data, (xdrproc_t)xdr_WRITE3res, sizeof(WRITE3res));
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_WRITE, cb, private_data, (zdrproc_t)zdr_WRITE3res, sizeof(WRITE3res));
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/write call");
                return -1;
@@ -263,8 +265,8 @@ int rpc_nfs_write_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
        args.data.data_len = count;
        args.data.data_val = buf;
 
-       if (xdr_WRITE3args(&pdu->xdr, &args) == 0) {
-               rpc_set_error(rpc, "XDR error: Failed to encode WRITE3args");
+       if (zdr_WRITE3args(&pdu->zdr, &args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode WRITE3args");
                rpc_free_pdu(rpc, pdu);
                return -2;
        }
@@ -285,7 +287,7 @@ int rpc_nfs_commit_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
        struct rpc_pdu *pdu;
        COMMIT3args args;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_COMMIT, cb, private_data, (xdrproc_t)xdr_COMMIT3res, sizeof(COMMIT3res));
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_COMMIT, cb, private_data, (zdrproc_t)zdr_COMMIT3res, sizeof(COMMIT3res));
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/commit call");
                return -1;
@@ -296,8 +298,8 @@ int rpc_nfs_commit_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
        args.offset = 0;
        args.count  = 0;
 
-       if (xdr_COMMIT3args(&pdu->xdr, &args) == 0) {
-               rpc_set_error(rpc, "XDR error: Failed to encode WRITE3args");
+       if (zdr_COMMIT3args(&pdu->zdr, &args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode WRITE3args");
                rpc_free_pdu(rpc, pdu);
                return -2;
        }
@@ -316,14 +318,14 @@ int rpc_nfs_setattr_async(struct rpc_context *rpc, rpc_cb cb, SETATTR3args *args
 {
        struct rpc_pdu *pdu;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_SETATTR, cb, private_data, (xdrproc_t)xdr_SETATTR3res, sizeof(SETATTR3res));
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_SETATTR, cb, private_data, (zdrproc_t)zdr_SETATTR3res, sizeof(SETATTR3res));
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/setattr call");
                return -1;
        }
 
-       if (xdr_SETATTR3args(&pdu->xdr, args) == 0) {
-               rpc_set_error(rpc, "XDR error: Failed to encode SETATTR3args");
+       if (zdr_SETATTR3args(&pdu->zdr, args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode SETATTR3args");
                rpc_free_pdu(rpc, pdu);
                return -2;
        }
@@ -339,26 +341,18 @@ int rpc_nfs_setattr_async(struct rpc_context *rpc, rpc_cb cb, SETATTR3args *args
 
 
 
-int rpc_nfs_mkdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *dir, void *private_data)
+int rpc_nfs_mkdir_async(struct rpc_context *rpc, rpc_cb cb, MKDIR3args *args, void *private_data)
 {
        struct rpc_pdu *pdu;
-       MKDIR3args args;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_MKDIR, cb, private_data, (xdrproc_t)xdr_MKDIR3res, sizeof(MKDIR3res));
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_MKDIR, cb, private_data, (zdrproc_t)zdr_MKDIR3res, sizeof(MKDIR3res));
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/setattr call");
                return -1;
        }
 
-       bzero((char *)&args, sizeof(MKDIR3args));
-       args.where.dir.data.data_len = fh->data.data_len;
-       args.where.dir.data.data_val = fh->data.data_val;
-       args.where.name = dir;
-       args.attributes.mode.set_it = 1;
-       args.attributes.mode.set_mode3_u.mode = 0755;
-
-       if (xdr_MKDIR3args(&pdu->xdr, &args) == 0) {
-               rpc_set_error(rpc, "XDR error: Failed to encode MKDIR3args");
+       if (zdr_MKDIR3args(&pdu->zdr, args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode MKDIR3args");
                rpc_free_pdu(rpc, pdu);
                return -2;
        }
@@ -380,19 +374,19 @@ int rpc_nfs_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
        struct rpc_pdu *pdu;
        RMDIR3args args;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_RMDIR, cb, private_data, (xdrproc_t)xdr_RMDIR3res, sizeof(RMDIR3res));
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_RMDIR, cb, private_data, (zdrproc_t)zdr_RMDIR3res, sizeof(RMDIR3res));
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/rmdir call");
                return -1;
        }
 
-       bzero((char *)&args, sizeof(RMDIR3args));
+       memset(&args, 0, sizeof(RMDIR3args));
        args.object.dir.data.data_len = fh->data.data_len;
        args.object.dir.data.data_val = fh->data.data_val;
        args.object.name = dir;
 
-       if (xdr_RMDIR3args(&pdu->xdr, &args) == 0) {
-               rpc_set_error(rpc, "XDR error: Failed to encode RMDIR3args");
+       if (zdr_RMDIR3args(&pdu->zdr, &args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode RMDIR3args");
                rpc_free_pdu(rpc, pdu);
                return -2;
        }
@@ -408,33 +402,86 @@ int rpc_nfs_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
 
 
 
-int rpc_nfs_create_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *file, int mode, void *private_data)
+int rpc_nfs_create_async(struct rpc_context *rpc, rpc_cb cb, CREATE3args *args, void *private_data)
 {
        struct rpc_pdu *pdu;
-       CREATE3args args;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_CREATE, cb, private_data, (xdrproc_t)xdr_CREATE3res, sizeof(CREATE3res));
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_CREATE, cb, private_data, (zdrproc_t)zdr_CREATE3res, sizeof(CREATE3res));
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/create call");
                return -1;
        }
 
-       bzero((char *)&args, sizeof(CREATE3args));
+       if (zdr_CREATE3args(&pdu->zdr, args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode CREATE3args");
+               rpc_free_pdu(rpc, pdu);
+               return -2;
+       }
+
+       if (rpc_queue_pdu(rpc, pdu) != 0) {
+               rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/create call");
+               rpc_free_pdu(rpc, pdu);
+               return -3;
+       }
+
+       return 0;
+}
+
+
+
+int rpc_nfs_mknod_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *file, int mode, int major, int minor, void *private_data)
+{
+       struct rpc_pdu *pdu;
+       MKNOD3args args;
+
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_MKNOD, cb, private_data, (zdrproc_t)zdr_MKNOD3res, sizeof(MKNOD3res));
+       if (pdu == NULL) {
+               rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/mknod call");
+               return -1;
+       }
+
+       memset(&args, 0, sizeof(MKNOD3args));
        args.where.dir.data.data_len = fh->data.data_len;
        args.where.dir.data.data_val = fh->data.data_val;
        args.where.name = file;
-       args.how.mode = UNCHECKED;
-       args.how.createhow3_u.obj_attributes.mode.set_it = 1;
-       args.how.createhow3_u.obj_attributes.mode.set_mode3_u.mode = mode;
+       switch (mode & S_IFMT) {
+       case S_IFCHR:
+               args.what.type = NF3CHR;
+               args.what.mknoddata3_u.chr_device.dev_attributes.mode.set_it = 1;
+               args.what.mknoddata3_u.chr_device.dev_attributes.mode.set_mode3_u.mode = mode & (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH);
+               args.what.mknoddata3_u.chr_device.spec.specdata1 = major;
+               args.what.mknoddata3_u.chr_device.spec.specdata2 = minor;
+               break;
+       case S_IFBLK:
+               args.what.type = NF3BLK;
+               args.what.mknoddata3_u.blk_device.dev_attributes.mode.set_it = 1;
+               args.what.mknoddata3_u.blk_device.dev_attributes.mode.set_mode3_u.mode = mode & (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH);
+               args.what.mknoddata3_u.blk_device.spec.specdata1 = major;
+               args.what.mknoddata3_u.blk_device.spec.specdata2 = minor;
+       case S_IFSOCK:
+               args.what.type = NF3SOCK;
+               args.what.mknoddata3_u.sock_attributes.mode.set_it = 1;
+               args.what.mknoddata3_u.sock_attributes.mode.set_mode3_u.mode = mode & (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH);
+               break;
+       case S_IFIFO:
+               args.what.type = NF3FIFO;
+               args.what.mknoddata3_u.pipe_attributes.mode.set_it = 1;
+               args.what.mknoddata3_u.pipe_attributes.mode.set_mode3_u.mode = mode & (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH);
+               break;
+       default:
+               rpc_set_error(rpc, "Invalid file type for nfs/mknod call");
+               rpc_free_pdu(rpc, pdu);
+               return -1;
+       }
 
-       if (xdr_CREATE3args(&pdu->xdr, &args) == 0) {
-               rpc_set_error(rpc, "XDR error: Failed to encode CREATE3args");
+       if (zdr_MKNOD3args(&pdu->zdr, &args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode MKNOD3args");
                rpc_free_pdu(rpc, pdu);
                return -2;
        }
 
        if (rpc_queue_pdu(rpc, pdu) != 0) {
-               rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/create call");
+               rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/mknod call");
                rpc_free_pdu(rpc, pdu);
                return -3;
        }
@@ -443,26 +490,24 @@ int rpc_nfs_create_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
 }
 
 
-
-
 int rpc_nfs_remove_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *file, void *private_data)
 {
        struct rpc_pdu *pdu;
        REMOVE3args args;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_REMOVE, cb, private_data, (xdrproc_t)xdr_REMOVE3res, sizeof(REMOVE3res));
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_REMOVE, cb, private_data, (zdrproc_t)zdr_REMOVE3res, sizeof(REMOVE3res));
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/remove call");
                return -1;
        }
 
-       bzero((char *)&args, sizeof(REMOVE3args));
+       memset(&args, 0, sizeof(REMOVE3args));
        args.object.dir.data.data_len = fh->data.data_len;
        args.object.dir.data.data_val = fh->data.data_val;
        args.object.name = file;
 
-       if (xdr_REMOVE3args(&pdu->xdr, &args) == 0) {
-               rpc_set_error(rpc, "XDR error: Failed to encode REMOVE3args");
+       if (zdr_REMOVE3args(&pdu->zdr, &args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode REMOVE3args");
                rpc_free_pdu(rpc, pdu);
                return -2;
        }
@@ -481,21 +526,21 @@ int rpc_nfs_readdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh
        struct rpc_pdu *pdu;
        READDIR3args args;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READDIR, cb, private_data, (xdrproc_t)xdr_READDIR3res, sizeof(READDIR3res));
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READDIR, cb, private_data, (zdrproc_t)zdr_READDIR3res, sizeof(READDIR3res));
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/readdir call");
                return -1;
        }
 
-       bzero((char *)&args, sizeof(READDIR3args));
+       memset(&args, 0, sizeof(READDIR3args));
        args.dir.data.data_len = fh->data.data_len;
        args.dir.data.data_val = fh->data.data_val;
        args.cookie = cookie;
        memcpy(&args.cookieverf, cookieverf, sizeof(cookieverf3)); 
        args.count = count;
 
-       if (xdr_READDIR3args(&pdu->xdr, &args) == 0) {
-               rpc_set_error(rpc, "XDR error: Failed to encode READDIR3args");
+       if (zdr_READDIR3args(&pdu->zdr, &args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode READDIR3args");
                rpc_free_pdu(rpc, pdu);
                return -2;
        }
@@ -514,13 +559,13 @@ int rpc_nfs_readdirplus_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3
        struct rpc_pdu *pdu;
        READDIRPLUS3args args;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READDIRPLUS, cb, private_data, (xdrproc_t)xdr_READDIRPLUS3res, sizeof(READDIRPLUS3res));
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READDIRPLUS, cb, private_data, (zdrproc_t)zdr_READDIRPLUS3res, sizeof(READDIRPLUS3res));
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/readdirplus call");
                return -1;
        }
 
-       bzero((char *)&args, sizeof(READDIRPLUS3args));
+       memset(&args, 0, sizeof(READDIRPLUS3args));
        args.dir.data.data_len = fh->data.data_len;
        args.dir.data.data_val = fh->data.data_val;
        args.cookie = cookie;
@@ -528,8 +573,8 @@ int rpc_nfs_readdirplus_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3
        args.dircount = count;
        args.maxcount = count;
 
-       if (xdr_READDIRPLUS3args(&pdu->xdr, &args) == 0) {
-               rpc_set_error(rpc, "XDR error: Failed to encode READDIRPLUS3args");
+       if (zdr_READDIRPLUS3args(&pdu->zdr, &args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode READDIRPLUS3args");
                rpc_free_pdu(rpc, pdu);
                return -2;
        }
@@ -548,7 +593,7 @@ int rpc_nfs_fsstat_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
        struct rpc_pdu *pdu;
        FSSTAT3args args;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_FSSTAT, cb, private_data, (xdrproc_t)xdr_FSSTAT3res, sizeof(FSSTAT3res));
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_FSSTAT, cb, private_data, (zdrproc_t)zdr_FSSTAT3res, sizeof(FSSTAT3res));
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/fsstat call");
                return -1;
@@ -557,8 +602,8 @@ int rpc_nfs_fsstat_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
        args.fsroot.data.data_len = fh->data.data_len; 
        args.fsroot.data.data_val = fh->data.data_val; 
 
-       if (xdr_FSSTAT3args(&pdu->xdr, &args) == 0) {
-               rpc_set_error(rpc, "XDR error: Failed to encode FSSTAT3args");
+       if (zdr_FSSTAT3args(&pdu->zdr, &args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode FSSTAT3args");
                rpc_free_pdu(rpc, pdu);
                return -2;
        }
@@ -577,7 +622,7 @@ int rpc_nfs_fsinfo_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
        struct rpc_pdu *pdu;
        FSINFO3args args;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_FSINFO, cb, private_data, (xdrproc_t)xdr_FSINFO3res, sizeof(FSINFO3res));
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_FSINFO, cb, private_data, (zdrproc_t)zdr_FSINFO3res, sizeof(FSINFO3res));
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/fsinfo call");
                return -1;
@@ -586,8 +631,8 @@ int rpc_nfs_fsinfo_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
        args.fsroot.data.data_len = fh->data.data_len; 
        args.fsroot.data.data_val = fh->data.data_val; 
 
-       if (xdr_FSINFO3args(&pdu->xdr, &args) == 0) {
-               rpc_set_error(rpc, "XDR error: Failed to encode FSINFO3args");
+       if (zdr_FSINFO3args(&pdu->zdr, &args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode FSINFO3args");
                rpc_free_pdu(rpc, pdu);
                return -2;
        }
@@ -601,22 +646,18 @@ int rpc_nfs_fsinfo_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh,
        return 0;
 }
 
-int rpc_nfs_readlink_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data)
+int rpc_nfs_readlink_async(struct rpc_context *rpc, rpc_cb cb, READLINK3args *args, void *private_data)
 {
        struct rpc_pdu *pdu;
-       READLINK3args args;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READLINK, cb, private_data, (xdrproc_t)xdr_READLINK3res, sizeof(READLINK3res));
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READLINK, cb, private_data, (zdrproc_t)zdr_READLINK3res, sizeof(READLINK3res));
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/readlink call");
                return -1;
        }
 
-       args.symlink.data.data_len = fh->data.data_len; 
-       args.symlink.data.data_val = fh->data.data_val; 
-
-       if (xdr_READLINK3args(&pdu->xdr, &args) == 0) {
-               rpc_set_error(rpc, "XDR error: Failed to encode READLINK3args");
+       if (zdr_READLINK3args(&pdu->zdr, args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode READLINK3args");
                rpc_free_pdu(rpc, pdu);
                return -2;
        }
@@ -631,27 +672,18 @@ int rpc_nfs_readlink_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *f
 }
 
 
-int rpc_nfs_symlink_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *newname, char *oldpath, void *private_data)
+int rpc_nfs_symlink_async(struct rpc_context *rpc, rpc_cb cb, SYMLINK3args *args, void *private_data)
 {
        struct rpc_pdu *pdu;
-       SYMLINK3args args;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_SYMLINK, cb, private_data, (xdrproc_t)xdr_SYMLINK3res, sizeof(SYMLINK3res));
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_SYMLINK, cb, private_data, (zdrproc_t)zdr_SYMLINK3res, sizeof(SYMLINK3res));
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/symlink call");
                return -1;
        }
 
-       bzero((char *)&args, sizeof(SYMLINK3args));
-       args.where.dir.data.data_len = fh->data.data_len;
-       args.where.dir.data.data_val = fh->data.data_val;
-       args.where.name = newname;
-       args.symlink.symlink_attributes.mode.set_it = 1;
-       args.symlink.symlink_attributes.mode.set_mode3_u.mode = S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH;
-       args.symlink.symlink_data = oldpath;
-
-       if (xdr_SYMLINK3args(&pdu->xdr, &args) == 0) {
-               rpc_set_error(rpc, "XDR error: Failed to encode SYMLINK3args");
+       if (zdr_SYMLINK3args(&pdu->zdr, args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode SYMLINK3args");
                rpc_free_pdu(rpc, pdu);
                return -2;
        }
@@ -673,13 +705,13 @@ int rpc_nfs_rename_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *old
        struct rpc_pdu *pdu;
        RENAME3args args;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_RENAME, cb, private_data, (xdrproc_t)xdr_RENAME3res, sizeof(RENAME3res));
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_RENAME, cb, private_data, (zdrproc_t)zdr_RENAME3res, sizeof(RENAME3res));
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/rename call");
                return -1;
        }
 
-       bzero((char *)&args, sizeof(RENAME3args));
+       memset(&args, 0, sizeof(RENAME3args));
        args.from.dir.data.data_len = olddir->data.data_len;
        args.from.dir.data.data_val = olddir->data.data_val;
        args.from.name = oldname;
@@ -687,8 +719,8 @@ int rpc_nfs_rename_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *old
        args.to.dir.data.data_val = newdir->data.data_val;
        args.to.name = newname;
 
-       if (xdr_RENAME3args(&pdu->xdr, &args) == 0) {
-               rpc_set_error(rpc, "XDR error: Failed to encode RENAME3args");
+       if (zdr_RENAME3args(&pdu->zdr, &args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode RENAME3args");
                rpc_free_pdu(rpc, pdu);
                return -2;
        }
@@ -710,21 +742,21 @@ int rpc_nfs_link_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *file,
        struct rpc_pdu *pdu;
        LINK3args args;
 
-       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_LINK, cb, private_data, (xdrproc_t)xdr_LINK3res, sizeof(LINK3res));
+       pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_LINK, cb, private_data, (zdrproc_t)zdr_LINK3res, sizeof(LINK3res));
        if (pdu == NULL) {
                rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/link call");
                return -1;
        }
 
-       bzero((char *)&args, sizeof(LINK3args));
+       memset(&args, 0, sizeof(LINK3args));
        args.file.data.data_len = file->data.data_len;
        args.file.data.data_val = file->data.data_val;
        args.link.dir.data.data_len = newdir->data.data_len;
        args.link.dir.data.data_val = newdir->data.data_val;
        args.link.name = newname;
 
-       if (xdr_LINK3args(&pdu->xdr, &args) == 0) {
-               rpc_set_error(rpc, "XDR error: Failed to encode LINK3args");
+       if (zdr_LINK3args(&pdu->zdr, &args) == 0) {
+               rpc_set_error(rpc, "ZDR error: Failed to encode LINK3args");
                rpc_free_pdu(rpc, pdu);
                return -2;
        }