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"
24 #include "libnfs-zdr.h"
26 #include "libnfs-raw.h"
27 #include "libnfs-private.h"
28 #include "libnfs-raw-rquota.h"
32 char *rquotastat_to_str(int error
)
35 case RQUOTA_OK
: return "RQUOTA_OK"; break;
36 case RQUOTA_NOQUOTA
: return "RQUOTA_NOQUOTA"; break;
37 case RQUOTA_EPERM
: return "RQUOTA_EPERM"; break;
39 return "unknown rquota error";
42 int rquotastat_to_errno(int error
)
45 case RQUOTA_OK
: return 0; break;
46 case RQUOTA_NOQUOTA
: return -ENOENT
; break;
47 case RQUOTA_EPERM
: return -EPERM
; break;
53 int rpc_rquota1_null_async(struct rpc_context
*rpc
, rpc_cb cb
, void *private_data
)
57 pdu
= rpc_allocate_pdu(rpc
, RQUOTA_PROGRAM
, RQUOTA_V1
, RQUOTA1_NULL
, cb
, private_data
, (zdrproc_t
)zdr_void
, 0);
59 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for rquota1/null call");
63 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
64 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for rquota1/null call");
65 rpc_free_pdu(rpc
, pdu
);
72 int rpc_rquota1_getquota_async(struct rpc_context
*rpc
, rpc_cb cb
, char *export
, int uid
, void *private_data
)
77 pdu
= rpc_allocate_pdu(rpc
, RQUOTA_PROGRAM
, RQUOTA_V1
, RQUOTA1_GETQUOTA
, cb
, private_data
, (zdrproc_t
)zdr_GETQUOTA1res
, sizeof(GETQUOTA1res
));
79 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for rquota1/getquota call");
86 if (zdr_GETQUOTA1args(&pdu
->zdr
, &args
) == 0) {
87 rpc_set_error(rpc
, "ZDR error: Failed to encode GETQUOTA1args");
88 rpc_free_pdu(rpc
, pdu
);
92 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
93 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for rquota1/getquota call");
94 rpc_free_pdu(rpc
, pdu
);
101 int rpc_rquota1_getactivequota_async(struct rpc_context
*rpc
, rpc_cb cb
, char *export
, int uid
, void *private_data
)
106 pdu
= rpc_allocate_pdu(rpc
, RQUOTA_PROGRAM
, RQUOTA_V1
, RQUOTA1_GETACTIVEQUOTA
, cb
, private_data
, (zdrproc_t
)zdr_GETQUOTA1res
, sizeof(GETQUOTA1res
));
108 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for rquota1/getactivequota call");
112 args
.export
= export
;
115 if (zdr_GETQUOTA1args(&pdu
->zdr
, &args
) == 0) {
116 rpc_set_error(rpc
, "ZDR error: Failed to encode GETQUOTA1args");
117 rpc_free_pdu(rpc
, pdu
);
121 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
122 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for rquota1/getactivequota call");
123 rpc_free_pdu(rpc
, pdu
);
131 int rpc_rquota2_null_async(struct rpc_context
*rpc
, rpc_cb cb
, void *private_data
)
135 pdu
= rpc_allocate_pdu(rpc
, RQUOTA_PROGRAM
, RQUOTA_V2
, RQUOTA2_NULL
, cb
, private_data
, (zdrproc_t
)zdr_void
, 0);
137 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for rquota2/null call");
141 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
142 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for rquota2/null call");
143 rpc_free_pdu(rpc
, pdu
);
150 int rpc_rquota2_getquota_async(struct rpc_context
*rpc
, rpc_cb cb
, char *export
, int type
, int uid
, void *private_data
)
155 pdu
= rpc_allocate_pdu(rpc
, RQUOTA_PROGRAM
, RQUOTA_V2
, RQUOTA2_GETQUOTA
, cb
, private_data
, (zdrproc_t
)zdr_GETQUOTA1res
, sizeof(GETQUOTA1res
));
157 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for rquota2/getquota call");
161 args
.export
= export
;
165 if (zdr_GETQUOTA2args(&pdu
->zdr
, &args
) == 0) {
166 rpc_set_error(rpc
, "ZDR error: Failed to encode GETQUOTA2args");
167 rpc_free_pdu(rpc
, pdu
);
171 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
172 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for rquota2/getquota call");
173 rpc_free_pdu(rpc
, pdu
);
180 int rpc_rquota2_getactivequota_async(struct rpc_context
*rpc
, rpc_cb cb
, char *export
, int type
, int uid
, void *private_data
)
185 pdu
= rpc_allocate_pdu(rpc
, RQUOTA_PROGRAM
, RQUOTA_V2
, RQUOTA2_GETACTIVEQUOTA
, cb
, private_data
, (zdrproc_t
)zdr_GETQUOTA1res
, sizeof(GETQUOTA1res
));
187 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for rquota2/getactivequota call");
191 args
.export
= export
;
195 if (zdr_GETQUOTA2args(&pdu
->zdr
, &args
) == 0) {
196 rpc_set_error(rpc
, "ZDR error: Failed to encode GETQUOTA2args");
197 rpc_free_pdu(rpc
, pdu
);
201 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
202 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for rquota2/getactivequota call");
203 rpc_free_pdu(rpc
, pdu
);