2 Copyright (C) 2010 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>.
18 #include "win32_compat.h"
31 #include "libnfs-raw.h"
32 #include "libnfs-private.h"
33 #include "libnfs-raw-rquota.h"
37 char *rquotastat_to_str(int error
)
40 case RQUOTA_OK
: return "RQUOTA_OK"; break;
41 case RQUOTA_NOQUOTA
: return "RQUOTA_NOQUOTA"; break;
42 case RQUOTA_EPERM
: return "RQUOTA_EPERM"; break;
44 return "unknown rquota error";
47 int rquotastat_to_errno(int error
)
50 case RQUOTA_OK
: return 0; break;
51 case RQUOTA_NOQUOTA
: return -ENOENT
; break;
52 case RQUOTA_EPERM
: return -EPERM
; break;
58 int rpc_rquota1_null_async(struct rpc_context
*rpc
, rpc_cb cb
, void *private_data
)
62 pdu
= rpc_allocate_pdu(rpc
, RQUOTA_PROGRAM
, RQUOTA_V1
, RQUOTA1_NULL
, cb
, private_data
, (xdrproc_t
)xdr_void
, 0);
64 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for rquota1/null call");
68 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
69 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for rquota1/null call");
70 rpc_free_pdu(rpc
, pdu
);
77 int rpc_rquota1_getquota_async(struct rpc_context
*rpc
, rpc_cb cb
, char *export
, int uid
, void *private_data
)
82 pdu
= rpc_allocate_pdu(rpc
, RQUOTA_PROGRAM
, RQUOTA_V1
, RQUOTA1_GETQUOTA
, cb
, private_data
, (xdrproc_t
)xdr_GETQUOTA1res
, sizeof(GETQUOTA1res
));
84 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for rquota1/getquota call");
91 if (xdr_GETQUOTA1args(&pdu
->xdr
, &args
) == 0) {
92 rpc_set_error(rpc
, "XDR error: Failed to encode GETQUOTA1args");
93 rpc_free_pdu(rpc
, pdu
);
97 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
98 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for rquota1/getquota call");
99 rpc_free_pdu(rpc
, pdu
);
106 int rpc_rquota1_getactivequota_async(struct rpc_context
*rpc
, rpc_cb cb
, char *export
, int uid
, void *private_data
)
111 pdu
= rpc_allocate_pdu(rpc
, RQUOTA_PROGRAM
, RQUOTA_V1
, RQUOTA1_GETACTIVEQUOTA
, cb
, private_data
, (xdrproc_t
)xdr_GETQUOTA1res
, sizeof(GETQUOTA1res
));
113 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for rquota1/getactivequota call");
117 args
.export
= export
;
120 if (xdr_GETQUOTA1args(&pdu
->xdr
, &args
) == 0) {
121 rpc_set_error(rpc
, "XDR error: Failed to encode GETQUOTA1args");
122 rpc_free_pdu(rpc
, pdu
);
126 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
127 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for rquota1/getactivequota call");
128 rpc_free_pdu(rpc
, pdu
);
136 int rpc_rquota2_null_async(struct rpc_context
*rpc
, rpc_cb cb
, void *private_data
)
140 pdu
= rpc_allocate_pdu(rpc
, RQUOTA_PROGRAM
, RQUOTA_V2
, RQUOTA2_NULL
, cb
, private_data
, (xdrproc_t
)xdr_void
, 0);
142 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for rquota2/null call");
146 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
147 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for rquota2/null call");
148 rpc_free_pdu(rpc
, pdu
);
155 int rpc_rquota2_getquota_async(struct rpc_context
*rpc
, rpc_cb cb
, char *export
, int type
, int uid
, void *private_data
)
160 pdu
= rpc_allocate_pdu(rpc
, RQUOTA_PROGRAM
, RQUOTA_V2
, RQUOTA2_GETQUOTA
, cb
, private_data
, (xdrproc_t
)xdr_GETQUOTA1res
, sizeof(GETQUOTA1res
));
162 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for rquota2/getquota call");
166 args
.export
= export
;
170 if (xdr_GETQUOTA2args(&pdu
->xdr
, &args
) == 0) {
171 rpc_set_error(rpc
, "XDR error: Failed to encode GETQUOTA2args");
172 rpc_free_pdu(rpc
, pdu
);
176 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
177 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for rquota2/getquota call");
178 rpc_free_pdu(rpc
, pdu
);
185 int rpc_rquota2_getactivequota_async(struct rpc_context
*rpc
, rpc_cb cb
, char *export
, int type
, int uid
, void *private_data
)
190 pdu
= rpc_allocate_pdu(rpc
, RQUOTA_PROGRAM
, RQUOTA_V2
, RQUOTA2_GETACTIVEQUOTA
, cb
, private_data
, (xdrproc_t
)xdr_GETQUOTA1res
, sizeof(GETQUOTA1res
));
192 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for rquota2/getactivequota call");
196 args
.export
= export
;
200 if (xdr_GETQUOTA2args(&pdu
->xdr
, &args
) == 0) {
201 rpc_set_error(rpc
, "XDR error: Failed to encode GETQUOTA2args");
202 rpc_free_pdu(rpc
, pdu
);
206 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
207 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for rquota2/getactivequota call");
208 rpc_free_pdu(rpc
, pdu
);