namedattr: xdr for OPENATTR

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
This commit is contained in:
Casey Bodley 2011-06-14 09:12:13 -04:00
parent fd59b56add
commit 49890fe1b1
3 changed files with 89 additions and 1 deletions

View file

@ -1934,3 +1934,47 @@ enum nfsstat4 pnfs_rpc_getdeviceinfo(
out: out:
return status; 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;
}

View file

@ -640,6 +640,16 @@ typedef struct __nfs41_op_open_res {
} 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 */ /* OP_READ */
typedef struct __nfs41_read_args { typedef struct __nfs41_read_args {
stateid_arg *stateid; /* -> nfs41_op_open_res_ok.stateid */ stateid_arg *stateid; /* -> nfs41_op_open_res_ok.stateid */
@ -1168,4 +1178,10 @@ enum nfsstat4 pnfs_rpc_getdeviceinfo(
IN unsigned char *deviceid, IN unsigned char *deviceid,
OUT pnfs_file_device *device); 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__ */ #endif /* !__NFS41_NFS_OPS_H__ */

View file

@ -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 * OP_READ
*/ */
@ -3301,7 +3329,7 @@ static const op_table_entry g_op_table[] = {
{ NULL, NULL }, /* OP_LOOKUPP = 16 */ { NULL, NULL }, /* OP_LOOKUPP = 16 */
{ NULL, NULL }, /* OP_NVERIFY = 17 */ { NULL, NULL }, /* OP_NVERIFY = 17 */
{ encode_op_open, decode_op_open }, /* OP_OPEN = 18 */ { 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_CONFIRM = 20 */
{ NULL, NULL }, /* OP_OPEN_DOWNGRADE = 21 */ { NULL, NULL }, /* OP_OPEN_DOWNGRADE = 21 */
{ encode_op_putfh, decode_op_putfh }, /* OP_PUTFH = 22 */ { encode_op_putfh, decode_op_putfh }, /* OP_PUTFH = 22 */