Add support for version 2 of the rquota protocol
parent
19e74f5a32
commit
77c23b46c0
|
@ -605,3 +605,54 @@ int rpc_rquota1_getquota_async(struct rpc_context *rpc, rpc_cb cb, char *export,
|
|||
* data is NULL.
|
||||
*/
|
||||
int rpc_rquota1_getactivequota_async(struct rpc_context *rpc, rpc_cb cb, char *export, int uid, void *private_data);
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Call RQUOTA2/NULL
|
||||
* 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 NULL.
|
||||
* 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_rquota2_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
|
||||
|
||||
/*
|
||||
* Call RQUOTA2/GETQUOTA
|
||||
* 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_rquota2_getquota_async(struct rpc_context *rpc, rpc_cb cb, char *export, int type, int uid, void *private_data);
|
||||
|
||||
/*
|
||||
* Call RQUOTA2/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_rquota2_getactivequota_async(struct rpc_context *rpc, rpc_cb cb, char *export, int type, int uid, void *private_data);
|
||||
|
|
|
@ -54,12 +54,12 @@ int rpc_rquota1_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_dat
|
|||
|
||||
pdu = rpc_allocate_pdu(rpc, RQUOTA_PROGRAM, RQUOTA_V1, RQUOTA1_NULL, cb, private_data, (xdrproc_t)xdr_void, 0);
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for rquota/null call");
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for rquota1/null call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (rpc_queue_pdu(rpc, pdu) != 0) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to queue pdu for rquota/null call");
|
||||
rpc_set_error(rpc, "Out of memory. Failed to queue pdu for rquota1/null call");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ int rpc_rquota1_getquota_async(struct rpc_context *rpc, rpc_cb cb, char *export,
|
|||
|
||||
pdu = rpc_allocate_pdu(rpc, RQUOTA_PROGRAM, RQUOTA_V1, RQUOTA1_GETQUOTA, 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/getquota call");
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for rquota1/getquota call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ int rpc_rquota1_getquota_async(struct rpc_context *rpc, rpc_cb cb, char *export,
|
|||
}
|
||||
|
||||
if (rpc_queue_pdu(rpc, pdu) != 0) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to queue pdu for rquota/getquota call");
|
||||
rpc_set_error(rpc, "Out of memory. Failed to queue pdu for rquota1/getquota call");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -3;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ int rpc_rquota1_getactivequota_async(struct rpc_context *rpc, rpc_cb cb, char *e
|
|||
|
||||
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");
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for rquota1/getactivequota call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,87 @@ int rpc_rquota1_getactivequota_async(struct rpc_context *rpc, rpc_cb cb, char *e
|
|||
}
|
||||
|
||||
if (rpc_queue_pdu(rpc, pdu) != 0) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to queue pdu for rquota/getactivequota call");
|
||||
rpc_set_error(rpc, "Out of memory. Failed to queue pdu for rquota1/getactivequota call");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int rpc_rquota2_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data)
|
||||
{
|
||||
struct rpc_pdu *pdu;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, RQUOTA_PROGRAM, RQUOTA_V2, RQUOTA2_NULL, cb, private_data, (xdrproc_t)xdr_void, 0);
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for rquota2/null call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (rpc_queue_pdu(rpc, pdu) != 0) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to queue pdu for rquota2/null call");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rpc_rquota2_getquota_async(struct rpc_context *rpc, rpc_cb cb, char *export, int type, int uid, void *private_data)
|
||||
{
|
||||
struct rpc_pdu *pdu;
|
||||
GETQUOTA2args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, RQUOTA_PROGRAM, RQUOTA_V2, RQUOTA2_GETQUOTA, cb, private_data, (xdrproc_t)xdr_GETQUOTA1res, sizeof(GETQUOTA1res));
|
||||
if (pdu == NULL) {
|
||||
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for rquota2/getquota call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
args.export = export;
|
||||
args.type = type;
|
||||
args.uid = uid;
|
||||
|
||||
if (xdr_GETQUOTA2args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode GETQUOTA2args");
|
||||
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 rquota2/getquota call");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rpc_rquota2_getactivequota_async(struct rpc_context *rpc, rpc_cb cb, char *export, int type, int uid, void *private_data)
|
||||
{
|
||||
struct rpc_pdu *pdu;
|
||||
GETQUOTA2args args;
|
||||
|
||||
pdu = rpc_allocate_pdu(rpc, RQUOTA_PROGRAM, RQUOTA_V2, RQUOTA2_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 rquota2/getactivequota call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
args.export = export;
|
||||
args.type = type;
|
||||
args.uid = uid;
|
||||
|
||||
if (xdr_GETQUOTA2args(&pdu->xdr, &args) == 0) {
|
||||
rpc_set_error(rpc, "XDR error: Failed to encode GETQUOTA2args");
|
||||
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 rquota2/getactivequota call");
|
||||
rpc_free_pdu(rpc, pdu);
|
||||
return -3;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,17 @@ struct GETQUOTA1args {
|
|||
int uid;
|
||||
};
|
||||
|
||||
enum quotatype {
|
||||
RQUOTA_TYPE_UID = 0,
|
||||
RQUOTA_TYPE_GID = 1
|
||||
};
|
||||
|
||||
struct GETQUOTA2args {
|
||||
exportpath export;
|
||||
quotatype type;
|
||||
int uid;
|
||||
};
|
||||
|
||||
struct GETQUOTA1res_ok {
|
||||
int bsize;
|
||||
int active;
|
||||
|
@ -46,5 +57,16 @@ program RQUOTA_PROGRAM {
|
|||
GETQUOTA1res
|
||||
RQUOTA1_GETACTIVEQUOTA(GETQUOTA1args) = 2;
|
||||
} = 1;
|
||||
|
||||
version RQUOTA_V2 {
|
||||
void
|
||||
RQUOTA2_NULL(void) = 0;
|
||||
|
||||
GETQUOTA1res
|
||||
RQUOTA2_GETQUOTA(GETQUOTA2args) = 1;
|
||||
|
||||
GETQUOTA1res
|
||||
RQUOTA2_GETACTIVEQUOTA(GETQUOTA2args) = 2;
|
||||
} = 2;
|
||||
} = 100011;
|
||||
|
||||
|
|
Loading…
Reference in New Issue