From: Ronnie Sahlberg Date: Thu, 2 Jun 2011 12:06:25 +0000 (+1000) Subject: Add RQUOTA1/GETACTIVEQUOTA call to the raw low level API X-Git-Tag: upstream/1.9.6^2~408 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=19e74f5a322739990fd47260f3b3347fbd49c302;p=deb_libnfs.git Add RQUOTA1/GETACTIVEQUOTA call to the raw low level API --- diff --git a/include/libnfs-raw.h b/include/libnfs-raw.h index 8ba8e98..dab5418 100644 --- a/include/libnfs-raw.h +++ b/include/libnfs-raw.h @@ -589,3 +589,19 @@ int rpc_rquota1_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_dat * data is NULL. */ int rpc_rquota1_getquota_async(struct rpc_context *rpc, rpc_cb cb, char *export, int uid, void *private_data); + +/* + * Call RQUOTA1/GETACTIVEQUOTA + * Function returns + * 0 : The call was initiated. The callback will be invoked when the call completes. + * <0 : An error occured when trying to set up the call. The callback will not be invoked. + * + * When the callback is invoked, status indicates the result: + * RPC_STATUS_SUCCESS : We got a successful response from the rquota daemon. + * data is a RQUOTA1res structure. + * RPC_STATUS_ERROR : An error occured when trying to contact the rquota daemon. + * data is the error string. + * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. + * data is NULL. + */ +int rpc_rquota1_getactivequota_async(struct rpc_context *rpc, rpc_cb cb, char *export, int uid, void *private_data); diff --git a/rquota/rquota.c b/rquota/rquota.c index 640549b..4397ec8 100644 --- a/rquota/rquota.c +++ b/rquota/rquota.c @@ -95,3 +95,32 @@ int rpc_rquota1_getquota_async(struct rpc_context *rpc, rpc_cb cb, char *export, return 0; } + +int rpc_rquota1_getactivequota_async(struct rpc_context *rpc, rpc_cb cb, char *export, int uid, void *private_data) +{ + struct rpc_pdu *pdu; + GETQUOTA1args args; + + pdu = rpc_allocate_pdu(rpc, RQUOTA_PROGRAM, RQUOTA_V1, RQUOTA1_GETACTIVEQUOTA, cb, private_data, (xdrproc_t)xdr_GETQUOTA1res, sizeof(GETQUOTA1res)); + if (pdu == NULL) { + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for rquota/getactivequota call"); + return -1; + } + + args.export = export; + args.uid = uid; + + if (xdr_GETQUOTA1args(&pdu->xdr, &args) == 0) { + rpc_set_error(rpc, "XDR error: Failed to encode GETQUOTA1args"); + 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 rquota/getactivequota call"); + rpc_free_pdu(rpc, pdu); + return -3; + } + + return 0; +} diff --git a/rquota/rquota.x b/rquota/rquota.x index 0efc16d..43d3655 100644 --- a/rquota/rquota.x +++ b/rquota/rquota.x @@ -42,6 +42,9 @@ program RQUOTA_PROGRAM { GETQUOTA1res RQUOTA1_GETQUOTA(GETQUOTA1args) = 1; + + GETQUOTA1res + RQUOTA1_GETACTIVEQUOTA(GETQUOTA1args) = 2; } = 1; } = 100011;