X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=nfs%2Fnfs.c;h=c3cebc47517090f07328ce06f106096c7541c132;hb=6f914247fb78dd70cd700f302c62a7144e4f61df;hp=9d8086f7ca1e5611ad907128526f2eb2938b5c3f;hpb=1e1b70a24a025f6102357d1c6293e3064d31ee2a;p=deb_libnfs.git diff --git a/nfs/nfs.c b/nfs/nfs.c index 9d8086f..c3cebc4 100644 --- a/nfs/nfs.c +++ b/nfs/nfs.c @@ -24,8 +24,7 @@ #include #include #include -#include -#include +#include "libnfs-zdr.h" #include "libnfs.h" #include "libnfs-raw.h" #include "libnfs-private.h" @@ -108,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; @@ -128,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; @@ -137,14 +136,43 @@ 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; } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/null call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/getattr call"); + rpc_free_pdu(rpc, pdu); + return -3; + } + + return 0; +} + +int rpc_nfs_pathconf_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data) +{ + struct rpc_pdu *pdu; + PATHCONF3args args; + + pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_PATHCONF, cb, private_data, (zdrproc_t)zdr_PATHCONF3res, sizeof(PATHCONF3res)); + if (pdu == NULL) { + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/pathconf call"); + return -1; + } + + args.object.data.data_len = fh->data.data_len; + args.object.data.data_val = fh->data.data_val; + + if (zdr_PATHCONF3args(&pdu->zdr, &args) == 0) { + rpc_set_error(rpc, "ZDR error: Failed to encode PATHCONF3args"); + 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/pathconf call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -157,7 +185,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; @@ -167,8 +195,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; } @@ -188,7 +216,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; @@ -198,8 +226,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; } @@ -215,12 +243,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; @@ -231,8 +259,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; } @@ -247,12 +275,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; @@ -262,12 +290,12 @@ int rpc_nfs_write_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, args.file.data.data_val = fh->data.data_val; args.offset = offset; args.count = count; - args.stable = stable_how;; + args.stable = stable_how; 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; } @@ -288,7 +316,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; @@ -299,8 +327,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; } @@ -319,14 +347,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; } @@ -342,26 +370,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; } - memset(&args, 0, 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; } @@ -383,7 +403,7 @@ 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; @@ -394,8 +414,8 @@ int rpc_nfs_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, 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; } @@ -411,33 +431,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; } - memset(&args, 0, 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; } @@ -446,14 +519,12 @@ 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; @@ -464,8 +535,8 @@ int rpc_nfs_remove_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, 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; } @@ -484,7 +555,7 @@ 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; @@ -497,8 +568,8 @@ int rpc_nfs_readdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh 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; } @@ -517,7 +588,7 @@ 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; @@ -531,8 +602,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; } @@ -551,7 +622,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; @@ -560,8 +631,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; } @@ -580,7 +651,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; @@ -589,8 +660,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; } @@ -604,22 +675,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; } @@ -634,27 +701,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; } - memset(&args, 0, 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; } @@ -676,7 +734,7 @@ 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; @@ -690,8 +748,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; } @@ -713,7 +771,7 @@ 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; @@ -726,8 +784,8 @@ int rpc_nfs_link_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *file, 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; }