From 49890fe1b1a1f181304853103013ad0d5930f5e5 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 14 Jun 2011 09:12:13 -0400 Subject: [PATCH] namedattr: xdr for OPENATTR Signed-off-by: Casey Bodley --- daemon/nfs41_ops.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ daemon/nfs41_ops.h | 16 ++++++++++++++++ daemon/nfs41_xdr.c | 30 +++++++++++++++++++++++++++++- 3 files changed, 89 insertions(+), 1 deletion(-) diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c index d1a6a90..46c3f06 100644 --- a/daemon/nfs41_ops.c +++ b/daemon/nfs41_ops.c @@ -1934,3 +1934,47 @@ enum nfsstat4 pnfs_rpc_getdeviceinfo( out: return status; } + +enum nfsstat4 nfs41_rpc_openattr( + IN nfs41_session *session, + IN nfs41_path_fh *file, + IN bool_t createdir, + OUT nfs41_fh *fh_out) +{ + enum nfsstat4 status; + nfs41_compound compound; + nfs_argop4 argops[4]; + nfs_resop4 resops[4]; + nfs41_sequence_args sequence_args; + nfs41_sequence_res sequence_res; + nfs41_putfh_args putfh_args; + nfs41_putfh_res putfh_res; + nfs41_openattr_args openattr_args; + nfs41_openattr_res openattr_res; + nfs41_getfh_res getfh_res; + + compound_init(&compound, argops, resops, "openattr"); + + compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res); + status = nfs41_session_sequence(&sequence_args, session, 0); + if (status) + goto out; + + compound_add_op(&compound, OP_PUTFH, &putfh_args, &putfh_res); + putfh_args.file = file; + putfh_args.in_recovery = FALSE; + + compound_add_op(&compound, OP_OPENATTR, &openattr_args, &openattr_res); + openattr_args.createdir = createdir; + + compound_add_op(&compound, OP_GETFH, NULL, &getfh_res); + getfh_res.fh = fh_out; + + status = compound_encode_send_decode(session, &compound, TRUE); + if (status) + goto out; + + compound_error(status = compound.res.status); +out: + return status; +} diff --git a/daemon/nfs41_ops.h b/daemon/nfs41_ops.h index 3b296f8..1dfb3ca 100644 --- a/daemon/nfs41_ops.h +++ b/daemon/nfs41_ops.h @@ -640,6 +640,16 @@ typedef struct __nfs41_op_open_res { } nfs41_op_open_res; +/* OP_OPENATTR */ +typedef struct __nfs41_openattr_args { + bool_t createdir; +} nfs41_openattr_args; + +typedef struct __nfs41_openattr_res { + uint32_t status; +} nfs41_openattr_res; + + /* OP_READ */ typedef struct __nfs41_read_args { stateid_arg *stateid; /* -> nfs41_op_open_res_ok.stateid */ @@ -1168,4 +1178,10 @@ enum nfsstat4 pnfs_rpc_getdeviceinfo( IN unsigned char *deviceid, OUT pnfs_file_device *device); +enum nfsstat4 nfs41_rpc_openattr( + IN nfs41_session *session, + IN nfs41_path_fh *file, + IN bool_t createdir, + OUT nfs41_fh *fh_out); + #endif /* !__NFS41_NFS_OPS_H__ */ diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c index 4e84ee3..2c2270c 100644 --- a/daemon/nfs41_xdr.c +++ b/daemon/nfs41_xdr.c @@ -2097,6 +2097,34 @@ static bool_t decode_op_open( } +/* + * OP_OPENATTR + */ +static bool_t encode_op_openattr( + XDR *xdr, + nfs_argop4 *argop) +{ + nfs41_openattr_args *args = (nfs41_openattr_args*)argop->arg; + + if (unexpected_op(argop->op, OP_OPENATTR)) + return FALSE; + + return xdr_bool(xdr, &args->createdir); +} + +static bool_t decode_op_openattr( + XDR *xdr, + nfs_resop4 *resop) +{ + nfs41_openattr_res *res = (nfs41_openattr_res*)resop->res; + + if (unexpected_op(resop->op, OP_OPENATTR)) + return FALSE; + + return xdr_u_int32_t(xdr, &res->status); +} + + /* * OP_READ */ @@ -3301,7 +3329,7 @@ static const op_table_entry g_op_table[] = { { NULL, NULL }, /* OP_LOOKUPP = 16 */ { NULL, NULL }, /* OP_NVERIFY = 17 */ { encode_op_open, decode_op_open }, /* OP_OPEN = 18 */ - { NULL, NULL }, /* OP_OPENATTR = 19 */ + { encode_op_openattr, decode_op_openattr }, /* OP_OPENATTR = 19 */ { NULL, NULL }, /* OP_OPEN_CONFIRM = 20 */ { NULL, NULL }, /* OP_OPEN_DOWNGRADE = 21 */ { encode_op_putfh, decode_op_putfh }, /* OP_PUTFH = 22 */