Commit | Line | Data |
---|---|---|
84004dbf RS |
1 | /* |
2 | Copyright (C) 2010 by Ronnie Sahlberg <ronniesahlberg@gmail.com> | |
3 | ||
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. | |
8 | ||
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. | |
13 | ||
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/>. | |
16 | */ | |
17 | ||
a8a1b858 M |
18 | #ifdef WIN32 |
19 | #include "win32_compat.h" | |
20 | #else | |
21 | #include <sys/stat.h> | |
22 | #endif/*WIN32*/ | |
eecdc4f3 | 23 | |
84004dbf RS |
24 | #include <stdio.h> |
25 | #include <errno.h> | |
98f5fee8 | 26 | #include <string.h> |
763cd6e3 | 27 | #include "libnfs-zdr.h" |
84004dbf RS |
28 | #include "libnfs.h" |
29 | #include "libnfs-raw.h" | |
30 | #include "libnfs-private.h" | |
31 | #include "libnfs-raw-nfs.h" | |
32 | ||
84004dbf RS |
33 | char *nfsstat3_to_str(int error) |
34 | { | |
35 | switch (error) { | |
36 | case NFS3_OK: return "NFS3_OK"; break; | |
37 | case NFS3ERR_PERM: return "NFS3ERR_PERM"; break; | |
38 | case NFS3ERR_NOENT: return "NFS3ERR_NOENT"; break; | |
39 | case NFS3ERR_IO: return "NFS3ERR_IO"; break; | |
40 | case NFS3ERR_NXIO: return "NFS3ERR_NXIO"; break; | |
41 | case NFS3ERR_ACCES: return "NFS3ERR_ACCES"; break; | |
42 | case NFS3ERR_EXIST: return "NFS3ERR_EXIST"; break; | |
43 | case NFS3ERR_XDEV: return "NFS3ERR_XDEV"; break; | |
44 | case NFS3ERR_NODEV: return "NFS3ERR_NODEV"; break; | |
45 | case NFS3ERR_NOTDIR: return "NFS3ERR_NOTDIR"; break; | |
46 | case NFS3ERR_ISDIR: return "NFS3ERR_ISDIR"; break; | |
47 | case NFS3ERR_INVAL: return "NFS3ERR_INVAL"; break; | |
48 | case NFS3ERR_FBIG: return "NFS3ERR_FBIG"; break; | |
49 | case NFS3ERR_NOSPC: return "NFS3ERR_NOSPC"; break; | |
50 | case NFS3ERR_ROFS: return "NFS3ERR_ROFS"; break; | |
51 | case NFS3ERR_MLINK: return "NFS3ERR_MLINK"; break; | |
52 | case NFS3ERR_NAMETOOLONG: return "NFS3ERR_NAMETOOLONG"; break; | |
53 | case NFS3ERR_NOTEMPTY: return "NFS3ERR_NOTEMPTY"; break; | |
54 | case NFS3ERR_DQUOT: return "NFS3ERR_DQUOT"; break; | |
55 | case NFS3ERR_STALE: return "NFS3ERR_STALE"; break; | |
56 | case NFS3ERR_REMOTE: return "NFS3ERR_REMOTE"; break; | |
57 | case NFS3ERR_BADHANDLE: return "NFS3ERR_BADHANDLE"; break; | |
58 | case NFS3ERR_NOT_SYNC: return "NFS3ERR_NOT_SYNC"; break; | |
59 | case NFS3ERR_BAD_COOKIE: return "NFS3ERR_BAD_COOKIE"; break; | |
60 | case NFS3ERR_NOTSUPP: return "NFS3ERR_NOTSUPP"; break; | |
61 | case NFS3ERR_TOOSMALL: return "NFS3ERR_TOOSMALL"; break; | |
62 | case NFS3ERR_SERVERFAULT: return "NFS3ERR_SERVERFAULT"; break; | |
63 | case NFS3ERR_BADTYPE: return "NFS3ERR_BADTYPE"; break; | |
64 | case NFS3ERR_JUKEBOX: return "NFS3ERR_JUKEBOX"; break; | |
65 | }; | |
66 | return "unknown nfs error"; | |
67 | } | |
68 | ||
69 | int nfsstat3_to_errno(int error) | |
70 | { | |
71 | switch (error) { | |
72 | case NFS3_OK: return 0; break; | |
73 | case NFS3ERR_PERM: return -EPERM; break; | |
74 | case NFS3ERR_NOENT: return -ENOENT; break; | |
75 | case NFS3ERR_IO: return -EIO; break; | |
76 | case NFS3ERR_NXIO: return -ENXIO; break; | |
77 | case NFS3ERR_ACCES: return -EACCES; break; | |
78 | case NFS3ERR_EXIST: return -EEXIST; break; | |
79 | case NFS3ERR_XDEV: return -EXDEV; break; | |
80 | case NFS3ERR_NODEV: return -ENODEV; break; | |
81 | case NFS3ERR_NOTDIR: return -ENOTDIR; break; | |
82 | case NFS3ERR_ISDIR: return -EISDIR; break; | |
83 | case NFS3ERR_INVAL: return -EINVAL; break; | |
84 | case NFS3ERR_FBIG: return -EFBIG; break; | |
85 | case NFS3ERR_NOSPC: return -ENOSPC; break; | |
86 | case NFS3ERR_ROFS: return -EROFS; break; | |
87 | case NFS3ERR_MLINK: return -EMLINK; break; | |
88 | case NFS3ERR_NAMETOOLONG: return -ENAMETOOLONG; break; | |
11cf77ce | 89 | case NFS3ERR_NOTEMPTY: return -ENOTEMPTY; break; |
84004dbf RS |
90 | case NFS3ERR_DQUOT: return -ERANGE; break; |
91 | case NFS3ERR_STALE: return -EIO; break; | |
92 | case NFS3ERR_REMOTE: return -EIO; break; | |
93 | case NFS3ERR_BADHANDLE: return -EIO; break; | |
94 | case NFS3ERR_NOT_SYNC: return -EIO; break; | |
95 | case NFS3ERR_BAD_COOKIE: return -EIO; break; | |
96 | case NFS3ERR_NOTSUPP: return -EINVAL; break; | |
97 | case NFS3ERR_TOOSMALL: return -EIO; break; | |
98 | case NFS3ERR_SERVERFAULT: return -EIO; break; | |
99 | case NFS3ERR_BADTYPE: return -EINVAL; break; | |
100 | case NFS3ERR_JUKEBOX: return -EAGAIN; break; | |
101 | }; | |
102 | return -ERANGE; | |
103 | } | |
104 | ||
105 | ||
463d59bf RS |
106 | /* |
107 | * NFSv3 | |
108 | */ | |
109 | int rpc_nfs3_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data) | |
84004dbf RS |
110 | { |
111 | struct rpc_pdu *pdu; | |
112 | ||
763cd6e3 | 113 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_NULL, cb, private_data, (zdrproc_t)zdr_void, 0); |
84004dbf | 114 | if (pdu == NULL) { |
463d59bf | 115 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/NULL call"); |
84004dbf RS |
116 | return -1; |
117 | } | |
118 | ||
119 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 120 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/NULL call"); |
84004dbf RS |
121 | rpc_free_pdu(rpc, pdu); |
122 | return -2; | |
123 | } | |
124 | ||
125 | return 0; | |
126 | } | |
127 | ||
463d59bf RS |
128 | int rpc_nfs_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data) |
129 | { | |
130 | return rpc_nfs3_null_async(rpc, cb, private_data); | |
131 | } | |
132 | ||
133 | int rpc_nfs3_getattr_async(struct rpc_context *rpc, rpc_cb cb, struct GETATTR3args *args, void *private_data) | |
84004dbf RS |
134 | { |
135 | struct rpc_pdu *pdu; | |
84004dbf | 136 | |
763cd6e3 | 137 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_GETATTR, cb, private_data, (zdrproc_t)zdr_GETATTR3res, sizeof(GETATTR3res)); |
84004dbf | 138 | if (pdu == NULL) { |
463d59bf | 139 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/GETATTR call"); |
84004dbf RS |
140 | return -1; |
141 | } | |
142 | ||
463d59bf | 143 | if (zdr_GETATTR3args(&pdu->zdr, args) == 0) { |
763cd6e3 | 144 | rpc_set_error(rpc, "ZDR error: Failed to encode GETATTR3args"); |
84004dbf RS |
145 | rpc_free_pdu(rpc, pdu); |
146 | return -2; | |
147 | } | |
148 | ||
149 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 150 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/GETATTR call"); |
6f914247 RS |
151 | rpc_free_pdu(rpc, pdu); |
152 | return -3; | |
153 | } | |
154 | ||
155 | return 0; | |
156 | } | |
157 | ||
463d59bf RS |
158 | int rpc_nfs_getattr_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data) |
159 | { | |
160 | GETATTR3args args; | |
161 | ||
162 | memset(&args, 0, sizeof(GETATTR3args)); | |
163 | args.object.data.data_len = fh->data.data_len; | |
164 | args.object.data.data_val = fh->data.data_val; | |
165 | ||
166 | return rpc_nfs3_getattr_async(rpc, cb, &args, private_data); | |
167 | } | |
168 | ||
169 | int rpc_nfs3_pathconf_async(struct rpc_context *rpc, rpc_cb cb, struct PATHCONF3args *args, void *private_data) | |
6f914247 RS |
170 | { |
171 | struct rpc_pdu *pdu; | |
6f914247 RS |
172 | |
173 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_PATHCONF, cb, private_data, (zdrproc_t)zdr_PATHCONF3res, sizeof(PATHCONF3res)); | |
174 | if (pdu == NULL) { | |
463d59bf | 175 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/PATHCONF call"); |
6f914247 RS |
176 | return -1; |
177 | } | |
178 | ||
463d59bf | 179 | if (zdr_PATHCONF3args(&pdu->zdr, args) == 0) { |
6f914247 RS |
180 | rpc_set_error(rpc, "ZDR error: Failed to encode PATHCONF3args"); |
181 | rpc_free_pdu(rpc, pdu); | |
182 | return -2; | |
183 | } | |
184 | ||
185 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 186 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/PATHCONF call"); |
84004dbf RS |
187 | rpc_free_pdu(rpc, pdu); |
188 | return -3; | |
189 | } | |
190 | ||
191 | return 0; | |
192 | } | |
193 | ||
463d59bf RS |
194 | int rpc_nfs_pathconf_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data) |
195 | { | |
196 | PATHCONF3args args; | |
197 | ||
198 | memset(&args, 0, sizeof(PATHCONF3args)); | |
199 | args.object.data.data_len = fh->data.data_len; | |
200 | args.object.data.data_val = fh->data.data_val; | |
201 | ||
202 | return rpc_nfs3_pathconf_async(rpc, cb, &args, private_data); | |
203 | } | |
204 | ||
205 | int rpc_nfs3_lookup_async(struct rpc_context *rpc, rpc_cb cb, struct LOOKUP3args *args, void *private_data) | |
84004dbf RS |
206 | { |
207 | struct rpc_pdu *pdu; | |
84004dbf | 208 | |
763cd6e3 | 209 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_LOOKUP, cb, private_data, (zdrproc_t)zdr_LOOKUP3res, sizeof(LOOKUP3res)); |
84004dbf | 210 | if (pdu == NULL) { |
463d59bf | 211 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/LOOKUP call"); |
84004dbf RS |
212 | return -1; |
213 | } | |
214 | ||
463d59bf | 215 | if (zdr_LOOKUP3args(&pdu->zdr, args) == 0) { |
763cd6e3 | 216 | rpc_set_error(rpc, "ZDR error: Failed to encode LOOKUP3args"); |
84004dbf RS |
217 | rpc_free_pdu(rpc, pdu); |
218 | return -2; | |
219 | } | |
220 | ||
221 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 222 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/LOOKUP call"); |
84004dbf RS |
223 | rpc_free_pdu(rpc, pdu); |
224 | return -3; | |
225 | } | |
226 | ||
227 | return 0; | |
228 | } | |
229 | ||
463d59bf RS |
230 | int rpc_nfs_lookup_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *name, void *private_data) |
231 | { | |
232 | LOOKUP3args args; | |
84004dbf | 233 | |
463d59bf RS |
234 | memset(&args, 0, sizeof(LOOKUP3args)); |
235 | args.what.dir.data.data_len = fh->data.data_len; | |
236 | args.what.dir.data.data_val = fh->data.data_val; | |
237 | args.what.name = name; | |
238 | ||
239 | return rpc_nfs3_lookup_async(rpc, cb, &args, private_data); | |
240 | } | |
241 | ||
242 | int rpc_nfs3_access_async(struct rpc_context *rpc, rpc_cb cb, struct ACCESS3args *args, void *private_data) | |
84004dbf RS |
243 | { |
244 | struct rpc_pdu *pdu; | |
84004dbf | 245 | |
763cd6e3 | 246 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_ACCESS, cb, private_data, (zdrproc_t)zdr_ACCESS3res, sizeof(ACCESS3res)); |
84004dbf | 247 | if (pdu == NULL) { |
463d59bf | 248 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/ACCESS call"); |
84004dbf RS |
249 | return -1; |
250 | } | |
251 | ||
463d59bf | 252 | if (zdr_ACCESS3args(&pdu->zdr, args) == 0) { |
763cd6e3 | 253 | rpc_set_error(rpc, "ZDR error: Failed to encode ACCESS3args"); |
84004dbf RS |
254 | rpc_free_pdu(rpc, pdu); |
255 | return -2; | |
256 | } | |
257 | ||
258 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 259 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/ACCESS call"); |
84004dbf RS |
260 | rpc_free_pdu(rpc, pdu); |
261 | return -3; | |
262 | } | |
263 | ||
264 | return 0; | |
265 | } | |
266 | ||
463d59bf RS |
267 | int rpc_nfs_access_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, int access, void *private_data) |
268 | { | |
269 | ACCESS3args args; | |
270 | ||
271 | memset(&args, 0, sizeof(ACCESS3args)); | |
272 | args.object.data.data_len = fh->data.data_len; | |
273 | args.object.data.data_val = fh->data.data_val; | |
274 | args.access = access; | |
84004dbf | 275 | |
463d59bf RS |
276 | return rpc_nfs3_access_async(rpc, cb, &args, private_data); |
277 | } | |
84004dbf | 278 | |
463d59bf | 279 | int rpc_nfs3_read_async(struct rpc_context *rpc, rpc_cb cb, struct READ3args *args, void *private_data) |
84004dbf RS |
280 | { |
281 | struct rpc_pdu *pdu; | |
84004dbf | 282 | |
763cd6e3 | 283 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READ, cb, private_data, (zdrproc_t)zdr_READ3res, sizeof(READ3res)); |
84004dbf | 284 | if (pdu == NULL) { |
463d59bf | 285 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/READ call"); |
84004dbf RS |
286 | return -1; |
287 | } | |
288 | ||
463d59bf | 289 | if (zdr_READ3args(&pdu->zdr, args) == 0) { |
763cd6e3 | 290 | rpc_set_error(rpc, "ZDR error: Failed to encode READ3args"); |
84004dbf RS |
291 | rpc_free_pdu(rpc, pdu); |
292 | return -2; | |
293 | } | |
294 | ||
295 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 296 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/READ call"); |
84004dbf RS |
297 | rpc_free_pdu(rpc, pdu); |
298 | return -3; | |
299 | } | |
300 | ||
301 | return 0; | |
302 | } | |
303 | ||
463d59bf RS |
304 | int rpc_nfs_read_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, uint64_t offset, uint64_t count, void *private_data) |
305 | { | |
306 | READ3args args; | |
84004dbf | 307 | |
463d59bf RS |
308 | memset(&args, 0, sizeof(READ3args)); |
309 | args.file.data.data_len = fh->data.data_len; | |
310 | args.file.data.data_val = fh->data.data_val; | |
311 | args.offset = offset; | |
312 | args.count = count; | |
313 | ||
314 | return rpc_nfs3_read_async(rpc, cb, &args, private_data); | |
315 | } | |
316 | ||
317 | int rpc_nfs3_write_async(struct rpc_context *rpc, rpc_cb cb, struct WRITE3args *args, void *private_data) | |
84004dbf RS |
318 | { |
319 | struct rpc_pdu *pdu; | |
84004dbf | 320 | |
763cd6e3 | 321 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_WRITE, cb, private_data, (zdrproc_t)zdr_WRITE3res, sizeof(WRITE3res)); |
84004dbf | 322 | if (pdu == NULL) { |
463d59bf | 323 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/WRITE call"); |
84004dbf RS |
324 | return -1; |
325 | } | |
326 | ||
463d59bf | 327 | if (zdr_WRITE3args(&pdu->zdr, args) == 0) { |
763cd6e3 | 328 | rpc_set_error(rpc, "ZDR error: Failed to encode WRITE3args"); |
84004dbf RS |
329 | rpc_free_pdu(rpc, pdu); |
330 | return -2; | |
331 | } | |
332 | ||
333 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 334 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/WRITE call"); |
84004dbf RS |
335 | rpc_free_pdu(rpc, pdu); |
336 | return -3; | |
337 | } | |
338 | ||
339 | return 0; | |
340 | } | |
341 | ||
463d59bf RS |
342 | int rpc_nfs_write_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *buf, uint64_t offset, uint64_t count, int stable_how, void *private_data) |
343 | { | |
344 | WRITE3args args; | |
345 | ||
346 | memset(&args, 0, sizeof(WRITE3args)); | |
347 | args.file.data.data_len = fh->data.data_len; | |
348 | args.file.data.data_val = fh->data.data_val; | |
349 | args.offset = offset; | |
350 | args.count = count; | |
351 | args.stable = stable_how; | |
352 | args.data.data_len = count; | |
353 | args.data.data_val = buf; | |
84004dbf | 354 | |
463d59bf RS |
355 | return rpc_nfs3_write_async(rpc, cb, &args, private_data); |
356 | } | |
84004dbf | 357 | |
463d59bf | 358 | int rpc_nfs3_commit_async(struct rpc_context *rpc, rpc_cb cb, struct COMMIT3args *args, void *private_data) |
84004dbf RS |
359 | { |
360 | struct rpc_pdu *pdu; | |
84004dbf | 361 | |
763cd6e3 | 362 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_COMMIT, cb, private_data, (zdrproc_t)zdr_COMMIT3res, sizeof(COMMIT3res)); |
84004dbf | 363 | if (pdu == NULL) { |
463d59bf | 364 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/COMMIT call"); |
84004dbf RS |
365 | return -1; |
366 | } | |
367 | ||
463d59bf RS |
368 | if (zdr_COMMIT3args(&pdu->zdr, args) == 0) { |
369 | rpc_set_error(rpc, "ZDR error: Failed to encode COMMIT3args"); | |
84004dbf RS |
370 | rpc_free_pdu(rpc, pdu); |
371 | return -2; | |
372 | } | |
373 | ||
374 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 375 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/COMMIT call"); |
84004dbf RS |
376 | rpc_free_pdu(rpc, pdu); |
377 | return -3; | |
378 | } | |
379 | ||
380 | return 0; | |
381 | } | |
382 | ||
463d59bf RS |
383 | int rpc_nfs_commit_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data) |
384 | { | |
385 | COMMIT3args args; | |
84004dbf | 386 | |
463d59bf RS |
387 | memset(&args, 0, sizeof(COMMIT3args)); |
388 | args.file.data.data_len = fh->data.data_len; | |
389 | args.file.data.data_val = fh->data.data_val; | |
390 | args.offset = 0; | |
391 | args.count = 0; | |
392 | ||
393 | return rpc_nfs3_commit_async(rpc, cb, &args, private_data); | |
394 | } | |
395 | ||
396 | int rpc_nfs3_setattr_async(struct rpc_context *rpc, rpc_cb cb, SETATTR3args *args, void *private_data) | |
84004dbf RS |
397 | { |
398 | struct rpc_pdu *pdu; | |
399 | ||
763cd6e3 | 400 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_SETATTR, cb, private_data, (zdrproc_t)zdr_SETATTR3res, sizeof(SETATTR3res)); |
84004dbf | 401 | if (pdu == NULL) { |
463d59bf | 402 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/SETATTR call"); |
84004dbf RS |
403 | return -1; |
404 | } | |
405 | ||
763cd6e3 RS |
406 | if (zdr_SETATTR3args(&pdu->zdr, args) == 0) { |
407 | rpc_set_error(rpc, "ZDR error: Failed to encode SETATTR3args"); | |
84004dbf RS |
408 | rpc_free_pdu(rpc, pdu); |
409 | return -2; | |
410 | } | |
411 | ||
412 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 413 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/SETATTR call"); |
84004dbf RS |
414 | rpc_free_pdu(rpc, pdu); |
415 | return -3; | |
416 | } | |
417 | ||
418 | return 0; | |
419 | } | |
420 | ||
463d59bf RS |
421 | int rpc_nfs_setattr_async(struct rpc_context *rpc, rpc_cb cb, SETATTR3args *args, void *private_data) |
422 | { | |
423 | return rpc_nfs3_setattr_async(rpc, cb, args, private_data); | |
424 | } | |
84004dbf | 425 | |
463d59bf | 426 | int rpc_nfs3_mkdir_async(struct rpc_context *rpc, rpc_cb cb, MKDIR3args *args, void *private_data) |
84004dbf RS |
427 | { |
428 | struct rpc_pdu *pdu; | |
84004dbf | 429 | |
763cd6e3 | 430 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_MKDIR, cb, private_data, (zdrproc_t)zdr_MKDIR3res, sizeof(MKDIR3res)); |
84004dbf | 431 | if (pdu == NULL) { |
463d59bf | 432 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/MKDIR call"); |
84004dbf RS |
433 | return -1; |
434 | } | |
435 | ||
763cd6e3 RS |
436 | if (zdr_MKDIR3args(&pdu->zdr, args) == 0) { |
437 | rpc_set_error(rpc, "ZDR error: Failed to encode MKDIR3args"); | |
84004dbf RS |
438 | rpc_free_pdu(rpc, pdu); |
439 | return -2; | |
440 | } | |
441 | ||
442 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 443 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/MKDIR call"); |
84004dbf RS |
444 | rpc_free_pdu(rpc, pdu); |
445 | return -3; | |
446 | } | |
447 | ||
448 | return 0; | |
449 | } | |
450 | ||
463d59bf RS |
451 | int rpc_nfs_mkdir_async(struct rpc_context *rpc, rpc_cb cb, MKDIR3args *args, void *private_data) |
452 | { | |
453 | return rpc_nfs3_mkdir_async(rpc, cb, args, private_data); | |
454 | } | |
84004dbf | 455 | |
463d59bf | 456 | int rpc_nfs3_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct RMDIR3args *args, void *private_data) |
84004dbf RS |
457 | { |
458 | struct rpc_pdu *pdu; | |
84004dbf | 459 | |
763cd6e3 | 460 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_RMDIR, cb, private_data, (zdrproc_t)zdr_RMDIR3res, sizeof(RMDIR3res)); |
84004dbf | 461 | if (pdu == NULL) { |
463d59bf | 462 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/RMDIR call"); |
84004dbf RS |
463 | return -1; |
464 | } | |
465 | ||
463d59bf | 466 | if (zdr_RMDIR3args(&pdu->zdr, args) == 0) { |
763cd6e3 | 467 | rpc_set_error(rpc, "ZDR error: Failed to encode RMDIR3args"); |
84004dbf RS |
468 | rpc_free_pdu(rpc, pdu); |
469 | return -2; | |
470 | } | |
471 | ||
472 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 473 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/RMDIR call"); |
84004dbf RS |
474 | rpc_free_pdu(rpc, pdu); |
475 | return -3; | |
476 | } | |
477 | ||
478 | return 0; | |
479 | } | |
480 | ||
463d59bf RS |
481 | int rpc_nfs_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *dir, void *private_data) |
482 | { | |
483 | RMDIR3args args; | |
484 | ||
485 | memset(&args, 0, sizeof(RMDIR3args)); | |
486 | args.object.dir.data.data_len = fh->data.data_len; | |
487 | args.object.dir.data.data_val = fh->data.data_val; | |
488 | args.object.name = dir; | |
84004dbf | 489 | |
463d59bf RS |
490 | return rpc_nfs3_rmdir_async(rpc, cb, &args, private_data); |
491 | } | |
84004dbf | 492 | |
463d59bf | 493 | int rpc_nfs3_create_async(struct rpc_context *rpc, rpc_cb cb, CREATE3args *args, void *private_data) |
84004dbf RS |
494 | { |
495 | struct rpc_pdu *pdu; | |
84004dbf | 496 | |
763cd6e3 | 497 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_CREATE, cb, private_data, (zdrproc_t)zdr_CREATE3res, sizeof(CREATE3res)); |
84004dbf | 498 | if (pdu == NULL) { |
463d59bf | 499 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/CREATE call"); |
84004dbf RS |
500 | return -1; |
501 | } | |
502 | ||
763cd6e3 RS |
503 | if (zdr_CREATE3args(&pdu->zdr, args) == 0) { |
504 | rpc_set_error(rpc, "ZDR error: Failed to encode CREATE3args"); | |
84004dbf RS |
505 | rpc_free_pdu(rpc, pdu); |
506 | return -2; | |
507 | } | |
508 | ||
509 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 510 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/CREATE call"); |
84004dbf RS |
511 | rpc_free_pdu(rpc, pdu); |
512 | return -3; | |
513 | } | |
514 | ||
515 | return 0; | |
516 | } | |
517 | ||
463d59bf RS |
518 | int rpc_nfs_create_async(struct rpc_context *rpc, rpc_cb cb, CREATE3args *args, void *private_data) |
519 | { | |
520 | return rpc_nfs3_create_async(rpc, cb, args, private_data); | |
521 | } | |
84004dbf | 522 | |
463d59bf | 523 | int rpc_nfs3_mknod_async(struct rpc_context *rpc, rpc_cb cb, struct MKNOD3args *args, void *private_data) |
1ec6b50a RS |
524 | { |
525 | struct rpc_pdu *pdu; | |
1ec6b50a | 526 | |
763cd6e3 | 527 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_MKNOD, cb, private_data, (zdrproc_t)zdr_MKNOD3res, sizeof(MKNOD3res)); |
1ec6b50a | 528 | if (pdu == NULL) { |
463d59bf | 529 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/MKNOD call"); |
1ec6b50a RS |
530 | return -1; |
531 | } | |
532 | ||
463d59bf RS |
533 | if (zdr_MKNOD3args(&pdu->zdr, args) == 0) { |
534 | rpc_set_error(rpc, "ZDR error: Failed to encode MKNOD3args"); | |
535 | rpc_free_pdu(rpc, pdu); | |
536 | return -2; | |
537 | } | |
538 | ||
539 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
540 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/MKNOD call"); | |
541 | rpc_free_pdu(rpc, pdu); | |
542 | return -3; | |
543 | } | |
544 | ||
545 | return 0; | |
546 | } | |
547 | ||
548 | int rpc_nfs_mknod_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *file, int mode, int major, int minor, void *private_data) | |
549 | { | |
550 | MKNOD3args args; | |
551 | ||
1ec6b50a RS |
552 | memset(&args, 0, sizeof(MKNOD3args)); |
553 | args.where.dir.data.data_len = fh->data.data_len; | |
554 | args.where.dir.data.data_val = fh->data.data_val; | |
555 | args.where.name = file; | |
463d59bf | 556 | |
1ec6b50a RS |
557 | switch (mode & S_IFMT) { |
558 | case S_IFCHR: | |
559 | args.what.type = NF3CHR; | |
560 | args.what.mknoddata3_u.chr_device.dev_attributes.mode.set_it = 1; | |
561 | args.what.mknoddata3_u.chr_device.dev_attributes.mode.set_mode3_u.mode = mode & (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH); | |
562 | args.what.mknoddata3_u.chr_device.spec.specdata1 = major; | |
563 | args.what.mknoddata3_u.chr_device.spec.specdata2 = minor; | |
564 | break; | |
565 | case S_IFBLK: | |
566 | args.what.type = NF3BLK; | |
567 | args.what.mknoddata3_u.blk_device.dev_attributes.mode.set_it = 1; | |
568 | args.what.mknoddata3_u.blk_device.dev_attributes.mode.set_mode3_u.mode = mode & (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH); | |
569 | args.what.mknoddata3_u.blk_device.spec.specdata1 = major; | |
570 | args.what.mknoddata3_u.blk_device.spec.specdata2 = minor; | |
571 | case S_IFSOCK: | |
572 | args.what.type = NF3SOCK; | |
573 | args.what.mknoddata3_u.sock_attributes.mode.set_it = 1; | |
574 | args.what.mknoddata3_u.sock_attributes.mode.set_mode3_u.mode = mode & (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH); | |
575 | break; | |
576 | case S_IFIFO: | |
577 | args.what.type = NF3FIFO; | |
578 | args.what.mknoddata3_u.pipe_attributes.mode.set_it = 1; | |
579 | args.what.mknoddata3_u.pipe_attributes.mode.set_mode3_u.mode = mode & (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH); | |
580 | break; | |
581 | default: | |
463d59bf | 582 | rpc_set_error(rpc, "Invalid file type for NFS3/MKNOD call"); |
1ec6b50a RS |
583 | return -1; |
584 | } | |
585 | ||
463d59bf RS |
586 | return rpc_nfs3_mknod_async(rpc, cb, &args, private_data); |
587 | } | |
588 | ||
589 | int rpc_nfs3_remove_async(struct rpc_context *rpc, rpc_cb cb, struct REMOVE3args *args, void *private_data) | |
590 | { | |
591 | struct rpc_pdu *pdu; | |
592 | ||
593 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_REMOVE, cb, private_data, (zdrproc_t)zdr_REMOVE3res, sizeof(REMOVE3res)); | |
594 | if (pdu == NULL) { | |
595 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/REMOVE call"); | |
596 | return -1; | |
597 | } | |
598 | ||
599 | if (zdr_REMOVE3args(&pdu->zdr, args) == 0) { | |
600 | rpc_set_error(rpc, "ZDR error: Failed to encode REMOVE3args"); | |
1ec6b50a RS |
601 | rpc_free_pdu(rpc, pdu); |
602 | return -2; | |
603 | } | |
604 | ||
605 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 606 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/REMOVE call"); |
1ec6b50a RS |
607 | rpc_free_pdu(rpc, pdu); |
608 | return -3; | |
609 | } | |
610 | ||
611 | return 0; | |
612 | } | |
613 | ||
84004dbf RS |
614 | int rpc_nfs_remove_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *file, void *private_data) |
615 | { | |
84004dbf RS |
616 | REMOVE3args args; |
617 | ||
ea98629a | 618 | memset(&args, 0, sizeof(REMOVE3args)); |
84004dbf RS |
619 | args.object.dir.data.data_len = fh->data.data_len; |
620 | args.object.dir.data.data_val = fh->data.data_val; | |
621 | args.object.name = file; | |
622 | ||
463d59bf RS |
623 | return rpc_nfs3_remove_async(rpc, cb, &args, private_data); |
624 | } | |
625 | ||
626 | int rpc_nfs3_readdir_async(struct rpc_context *rpc, rpc_cb cb, struct READDIR3args *args, void *private_data) | |
627 | { | |
628 | struct rpc_pdu *pdu; | |
629 | ||
630 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READDIR, cb, private_data, (zdrproc_t)zdr_READDIR3res, sizeof(READDIR3res)); | |
631 | if (pdu == NULL) { | |
632 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/READDIR call"); | |
633 | return -1; | |
634 | } | |
635 | ||
636 | if (zdr_READDIR3args(&pdu->zdr, args) == 0) { | |
637 | rpc_set_error(rpc, "ZDR error: Failed to encode READDIR3args"); | |
84004dbf RS |
638 | rpc_free_pdu(rpc, pdu); |
639 | return -2; | |
640 | } | |
641 | ||
642 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 643 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/READDIR call"); |
84004dbf RS |
644 | rpc_free_pdu(rpc, pdu); |
645 | return -3; | |
646 | } | |
647 | ||
648 | return 0; | |
649 | } | |
650 | ||
84004dbf RS |
651 | int rpc_nfs_readdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, uint64_t cookie, char *cookieverf, int count, void *private_data) |
652 | { | |
84004dbf RS |
653 | READDIR3args args; |
654 | ||
ea98629a | 655 | memset(&args, 0, sizeof(READDIR3args)); |
84004dbf RS |
656 | args.dir.data.data_len = fh->data.data_len; |
657 | args.dir.data.data_val = fh->data.data_val; | |
658 | args.cookie = cookie; | |
659 | memcpy(&args.cookieverf, cookieverf, sizeof(cookieverf3)); | |
660 | args.count = count; | |
661 | ||
463d59bf RS |
662 | return rpc_nfs3_readdir_async(rpc, cb, &args, private_data); |
663 | } | |
664 | ||
665 | int rpc_nfs3_readdirplus_async(struct rpc_context *rpc, rpc_cb cb, struct READDIRPLUS3args *args, void *private_data) | |
666 | { | |
667 | struct rpc_pdu *pdu; | |
668 | ||
669 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READDIRPLUS, cb, private_data, (zdrproc_t)zdr_READDIRPLUS3res, sizeof(READDIRPLUS3res)); | |
670 | if (pdu == NULL) { | |
671 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/READDIRPLUS call"); | |
672 | return -1; | |
673 | } | |
674 | ||
675 | if (zdr_READDIRPLUS3args(&pdu->zdr, args) == 0) { | |
676 | rpc_set_error(rpc, "ZDR error: Failed to encode READDIRPLUS3args"); | |
84004dbf RS |
677 | rpc_free_pdu(rpc, pdu); |
678 | return -2; | |
679 | } | |
680 | ||
681 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 682 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/READDIRPLUS call"); |
84004dbf RS |
683 | rpc_free_pdu(rpc, pdu); |
684 | return -3; | |
685 | } | |
686 | ||
687 | return 0; | |
688 | } | |
689 | ||
f390f181 RS |
690 | int rpc_nfs_readdirplus_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, uint64_t cookie, char *cookieverf, int count, void *private_data) |
691 | { | |
f390f181 RS |
692 | READDIRPLUS3args args; |
693 | ||
ea98629a | 694 | memset(&args, 0, sizeof(READDIRPLUS3args)); |
f390f181 RS |
695 | args.dir.data.data_len = fh->data.data_len; |
696 | args.dir.data.data_val = fh->data.data_val; | |
697 | args.cookie = cookie; | |
698 | memcpy(&args.cookieverf, cookieverf, sizeof(cookieverf3)); | |
699 | args.dircount = count; | |
700 | args.maxcount = count; | |
701 | ||
463d59bf | 702 | return rpc_nfs3_readdirplus_async(rpc, cb, &args, private_data); |
f390f181 RS |
703 | } |
704 | ||
463d59bf | 705 | int rpc_nfs3_fsstat_async(struct rpc_context *rpc, rpc_cb cb, struct FSSTAT3args *args, void *private_data) |
84004dbf RS |
706 | { |
707 | struct rpc_pdu *pdu; | |
84004dbf | 708 | |
763cd6e3 | 709 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_FSSTAT, cb, private_data, (zdrproc_t)zdr_FSSTAT3res, sizeof(FSSTAT3res)); |
84004dbf | 710 | if (pdu == NULL) { |
463d59bf | 711 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/FSSTAT call"); |
84004dbf RS |
712 | return -1; |
713 | } | |
714 | ||
463d59bf | 715 | if (zdr_FSSTAT3args(&pdu->zdr, args) == 0) { |
763cd6e3 | 716 | rpc_set_error(rpc, "ZDR error: Failed to encode FSSTAT3args"); |
84004dbf RS |
717 | rpc_free_pdu(rpc, pdu); |
718 | return -2; | |
719 | } | |
720 | ||
721 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 722 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/FSSTAT call"); |
84004dbf RS |
723 | rpc_free_pdu(rpc, pdu); |
724 | return -3; | |
725 | } | |
726 | ||
727 | return 0; | |
728 | } | |
729 | ||
463d59bf RS |
730 | int rpc_nfs_fsstat_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data) |
731 | { | |
732 | FSSTAT3args args; | |
733 | ||
734 | memset(&args, 0, sizeof(FSSTAT3args)); | |
735 | args.fsroot.data.data_len = fh->data.data_len; | |
736 | args.fsroot.data.data_val = fh->data.data_val; | |
737 | ||
738 | return rpc_nfs3_fsstat_async(rpc, cb, &args, private_data); | |
739 | } | |
740 | ||
741 | int rpc_nfs3_fsinfo_async(struct rpc_context *rpc, rpc_cb cb, struct FSINFO3args *args, void *private_data) | |
1058201e RS |
742 | { |
743 | struct rpc_pdu *pdu; | |
1058201e | 744 | |
763cd6e3 | 745 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_FSINFO, cb, private_data, (zdrproc_t)zdr_FSINFO3res, sizeof(FSINFO3res)); |
1058201e | 746 | if (pdu == NULL) { |
463d59bf | 747 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/FSINFO call"); |
1058201e RS |
748 | return -1; |
749 | } | |
750 | ||
463d59bf | 751 | if (zdr_FSINFO3args(&pdu->zdr, args) == 0) { |
763cd6e3 | 752 | rpc_set_error(rpc, "ZDR error: Failed to encode FSINFO3args"); |
1058201e RS |
753 | rpc_free_pdu(rpc, pdu); |
754 | return -2; | |
755 | } | |
756 | ||
757 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 758 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/FSINFO call"); |
1058201e RS |
759 | rpc_free_pdu(rpc, pdu); |
760 | return -3; | |
761 | } | |
762 | ||
763 | return 0; | |
764 | } | |
84004dbf | 765 | |
463d59bf RS |
766 | int rpc_nfs_fsinfo_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data) |
767 | { | |
768 | FSINFO3args args; | |
769 | ||
770 | memset(&args, 0, sizeof(FSINFO3args)); | |
771 | args.fsroot.data.data_len = fh->data.data_len; | |
772 | args.fsroot.data.data_val = fh->data.data_val; | |
773 | ||
dc3ed8c3 | 774 | return rpc_nfs3_fsinfo_async(rpc, cb, &args, private_data); |
463d59bf RS |
775 | } |
776 | ||
777 | int rpc_nfs3_readlink_async(struct rpc_context *rpc, rpc_cb cb, READLINK3args *args, void *private_data) | |
84004dbf RS |
778 | { |
779 | struct rpc_pdu *pdu; | |
84004dbf | 780 | |
763cd6e3 | 781 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READLINK, cb, private_data, (zdrproc_t)zdr_READLINK3res, sizeof(READLINK3res)); |
84004dbf | 782 | if (pdu == NULL) { |
463d59bf | 783 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/READLINK call"); |
84004dbf RS |
784 | return -1; |
785 | } | |
786 | ||
763cd6e3 RS |
787 | if (zdr_READLINK3args(&pdu->zdr, args) == 0) { |
788 | rpc_set_error(rpc, "ZDR error: Failed to encode READLINK3args"); | |
84004dbf RS |
789 | rpc_free_pdu(rpc, pdu); |
790 | return -2; | |
791 | } | |
792 | ||
793 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 794 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/READLINK call"); |
84004dbf RS |
795 | rpc_free_pdu(rpc, pdu); |
796 | return -3; | |
797 | } | |
798 | ||
799 | return 0; | |
800 | } | |
801 | ||
463d59bf RS |
802 | int rpc_nfs_readlink_async(struct rpc_context *rpc, rpc_cb cb, READLINK3args *args, void *private_data) |
803 | { | |
804 | return rpc_nfs3_readlink_async(rpc, cb, args, private_data); | |
805 | } | |
84004dbf | 806 | |
463d59bf | 807 | int rpc_nfs3_symlink_async(struct rpc_context *rpc, rpc_cb cb, SYMLINK3args *args, void *private_data) |
84004dbf RS |
808 | { |
809 | struct rpc_pdu *pdu; | |
84004dbf | 810 | |
763cd6e3 | 811 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_SYMLINK, cb, private_data, (zdrproc_t)zdr_SYMLINK3res, sizeof(SYMLINK3res)); |
84004dbf | 812 | if (pdu == NULL) { |
463d59bf | 813 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/SYMLINK call"); |
84004dbf RS |
814 | return -1; |
815 | } | |
816 | ||
763cd6e3 RS |
817 | if (zdr_SYMLINK3args(&pdu->zdr, args) == 0) { |
818 | rpc_set_error(rpc, "ZDR error: Failed to encode SYMLINK3args"); | |
84004dbf RS |
819 | rpc_free_pdu(rpc, pdu); |
820 | return -2; | |
821 | } | |
822 | ||
823 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 824 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/SYMLINK call"); |
84004dbf RS |
825 | rpc_free_pdu(rpc, pdu); |
826 | return -3; | |
827 | } | |
828 | ||
829 | return 0; | |
830 | } | |
831 | ||
463d59bf RS |
832 | int rpc_nfs_symlink_async(struct rpc_context *rpc, rpc_cb cb, SYMLINK3args *args, void *private_data) |
833 | { | |
834 | return rpc_nfs3_symlink_async(rpc, cb, args, private_data); | |
835 | } | |
84004dbf | 836 | |
463d59bf | 837 | int rpc_nfs3_rename_async(struct rpc_context *rpc, rpc_cb cb, struct RENAME3args *args, void *private_data) |
84004dbf RS |
838 | { |
839 | struct rpc_pdu *pdu; | |
84004dbf | 840 | |
763cd6e3 | 841 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_RENAME, cb, private_data, (zdrproc_t)zdr_RENAME3res, sizeof(RENAME3res)); |
84004dbf | 842 | if (pdu == NULL) { |
463d59bf | 843 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/RENAME call"); |
84004dbf RS |
844 | return -1; |
845 | } | |
846 | ||
463d59bf | 847 | if (zdr_RENAME3args(&pdu->zdr, args) == 0) { |
763cd6e3 | 848 | rpc_set_error(rpc, "ZDR error: Failed to encode RENAME3args"); |
84004dbf RS |
849 | rpc_free_pdu(rpc, pdu); |
850 | return -2; | |
851 | } | |
852 | ||
853 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 854 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/RENAME call"); |
84004dbf RS |
855 | rpc_free_pdu(rpc, pdu); |
856 | return -3; | |
857 | } | |
858 | ||
859 | return 0; | |
860 | } | |
861 | ||
463d59bf RS |
862 | int rpc_nfs_rename_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *olddir, char *oldname, struct nfs_fh3 *newdir, char *newname, void *private_data) |
863 | { | |
864 | RENAME3args args; | |
84004dbf | 865 | |
463d59bf RS |
866 | memset(&args, 0, sizeof(RENAME3args)); |
867 | args.from.dir.data.data_len = olddir->data.data_len; | |
868 | args.from.dir.data.data_val = olddir->data.data_val; | |
869 | args.from.name = oldname; | |
870 | args.to.dir.data.data_len = newdir->data.data_len; | |
871 | args.to.dir.data.data_val = newdir->data.data_val; | |
872 | args.to.name = newname; | |
84004dbf | 873 | |
463d59bf RS |
874 | return rpc_nfs3_rename_async(rpc, cb, &args, private_data); |
875 | } | |
84004dbf | 876 | |
463d59bf | 877 | int rpc_nfs3_link_async(struct rpc_context *rpc, rpc_cb cb, struct LINK3args *args, void *private_data) |
84004dbf RS |
878 | { |
879 | struct rpc_pdu *pdu; | |
84004dbf | 880 | |
763cd6e3 | 881 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_LINK, cb, private_data, (zdrproc_t)zdr_LINK3res, sizeof(LINK3res)); |
84004dbf | 882 | if (pdu == NULL) { |
463d59bf | 883 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/LINK call"); |
84004dbf RS |
884 | return -1; |
885 | } | |
886 | ||
463d59bf | 887 | if (zdr_LINK3args(&pdu->zdr, args) == 0) { |
763cd6e3 | 888 | rpc_set_error(rpc, "ZDR error: Failed to encode LINK3args"); |
84004dbf RS |
889 | rpc_free_pdu(rpc, pdu); |
890 | return -2; | |
891 | } | |
892 | ||
893 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
463d59bf | 894 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/LINK call"); |
84004dbf RS |
895 | rpc_free_pdu(rpc, pdu); |
896 | return -3; | |
897 | } | |
898 | ||
899 | return 0; | |
900 | } | |
901 | ||
463d59bf RS |
902 | int rpc_nfs_link_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *file, struct nfs_fh3 *newdir, char *newname, void *private_data) |
903 | { | |
904 | LINK3args args; | |
905 | ||
906 | memset(&args, 0, sizeof(LINK3args)); | |
907 | args.file.data.data_len = file->data.data_len; | |
908 | args.file.data.data_val = file->data.data_val; | |
909 | args.link.dir.data.data_len = newdir->data.data_len; | |
910 | args.link.dir.data.data_val = newdir->data.data_val; | |
911 | args.link.name = newname; | |
912 | ||
913 | return rpc_nfs3_link_async(rpc, cb, &args, private_data); | |
914 | } | |
84004dbf | 915 | |
f38aacf8 RS |
916 | /* |
917 | * NFSv2 | |
918 | */ | |
919 | int rpc_nfs2_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data) | |
920 | { | |
921 | struct rpc_pdu *pdu; | |
922 | ||
923 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V2, NFS2_NULL, cb, private_data, (zdrproc_t)zdr_void, 0); | |
924 | if (pdu == NULL) { | |
925 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS2/NULL call"); | |
926 | return -1; | |
927 | } | |
928 | ||
929 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
930 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS2/NULL call"); | |
931 | rpc_free_pdu(rpc, pdu); | |
932 | return -2; | |
933 | } | |
934 | ||
935 | return 0; | |
936 | } | |
937 | ||
938 | int rpc_nfs2_getattr_async(struct rpc_context *rpc, rpc_cb cb, struct GETATTR2args *args, void *private_data) | |
939 | { | |
940 | struct rpc_pdu *pdu; | |
941 | ||
942 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V2, NFS2_GETATTR, cb, private_data, (zdrproc_t)zdr_GETATTR2res, sizeof(GETATTR2res)); | |
943 | if (pdu == NULL) { | |
944 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS2/GETATTR call"); | |
945 | return -1; | |
946 | } | |
947 | ||
948 | if (zdr_GETATTR2args(&pdu->zdr, args) == 0) { | |
949 | rpc_set_error(rpc, "ZDR error: Failed to encode GETATTR2args"); | |
950 | rpc_free_pdu(rpc, pdu); | |
951 | return -2; | |
952 | } | |
953 | ||
954 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
955 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS2/GETATTR call"); | |
956 | rpc_free_pdu(rpc, pdu); | |
957 | return -3; | |
958 | } | |
959 | ||
960 | return 0; | |
961 | } | |
962 | ||
963 | int rpc_nfs2_setattr_async(struct rpc_context *rpc, rpc_cb cb, SETATTR2args *args, void *private_data) | |
964 | { | |
965 | struct rpc_pdu *pdu; | |
966 | ||
967 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V2, NFS2_SETATTR, cb, private_data, (zdrproc_t)zdr_SETATTR2res, sizeof(SETATTR2res)); | |
968 | if (pdu == NULL) { | |
969 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS2/SETATTR call"); | |
970 | return -1; | |
971 | } | |
972 | ||
973 | if (zdr_SETATTR2args(&pdu->zdr, args) == 0) { | |
974 | rpc_set_error(rpc, "ZDR error: Failed to encode SETATTR2args"); | |
975 | rpc_free_pdu(rpc, pdu); | |
976 | return -2; | |
977 | } | |
978 | ||
979 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
980 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS2/SETATTR call"); | |
981 | rpc_free_pdu(rpc, pdu); | |
982 | return -3; | |
983 | } | |
984 | ||
985 | return 0; | |
986 | } | |
987 | ||
988 | int rpc_nfs2_lookup_async(struct rpc_context *rpc, rpc_cb cb, struct LOOKUP2args *args, void *private_data) | |
989 | { | |
990 | struct rpc_pdu *pdu; | |
991 | ||
992 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V2, NFS2_LOOKUP, cb, private_data, (zdrproc_t)zdr_LOOKUP2res, sizeof(LOOKUP2res)); | |
993 | if (pdu == NULL) { | |
994 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS2/LOOKUP call"); | |
995 | return -1; | |
996 | } | |
997 | ||
998 | if (zdr_LOOKUP2args(&pdu->zdr, args) == 0) { | |
999 | rpc_set_error(rpc, "ZDR error: Failed to encode LOOKUP2args"); | |
1000 | rpc_free_pdu(rpc, pdu); | |
1001 | return -2; | |
1002 | } | |
1003 | ||
1004 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
1005 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS2/LOOKUP call"); | |
1006 | rpc_free_pdu(rpc, pdu); | |
1007 | return -3; | |
1008 | } | |
1009 | ||
1010 | return 0; | |
1011 | } | |
1012 | ||
1013 | int rpc_nfs2_readlink_async(struct rpc_context *rpc, rpc_cb cb, READLINK2args *args, void *private_data) | |
1014 | { | |
1015 | struct rpc_pdu *pdu; | |
1016 | ||
1017 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V2, NFS2_READLINK, cb, private_data, (zdrproc_t)zdr_READLINK2res, sizeof(READLINK2res)); | |
1018 | if (pdu == NULL) { | |
1019 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS2/READLINK call"); | |
1020 | return -1; | |
1021 | } | |
1022 | ||
1023 | if (zdr_READLINK2args(&pdu->zdr, args) == 0) { | |
1024 | rpc_set_error(rpc, "ZDR error: Failed to encode READLINK2args"); | |
1025 | rpc_free_pdu(rpc, pdu); | |
1026 | return -2; | |
1027 | } | |
1028 | ||
1029 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
1030 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS2/READLINK call"); | |
1031 | rpc_free_pdu(rpc, pdu); | |
1032 | return -3; | |
1033 | } | |
1034 | ||
1035 | return 0; | |
1036 | } | |
1037 | ||
1038 | int rpc_nfs2_read_async(struct rpc_context *rpc, rpc_cb cb, struct READ2args *args, void *private_data) | |
1039 | { | |
1040 | struct rpc_pdu *pdu; | |
1041 | ||
1042 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V2, NFS2_READ, cb, private_data, (zdrproc_t)zdr_READ2res, sizeof(READ2res)); | |
1043 | if (pdu == NULL) { | |
1044 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS2/READ call"); | |
1045 | return -1; | |
1046 | } | |
1047 | ||
1048 | if (zdr_READ2args(&pdu->zdr, args) == 0) { | |
1049 | rpc_set_error(rpc, "ZDR error: Failed to encode READ2args"); | |
1050 | rpc_free_pdu(rpc, pdu); | |
1051 | return -2; | |
1052 | } | |
1053 | ||
1054 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
1055 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS2/READ call"); | |
1056 | rpc_free_pdu(rpc, pdu); | |
1057 | return -3; | |
1058 | } | |
1059 | ||
1060 | return 0; | |
1061 | } | |
1062 | ||
1063 | int rpc_nfs2_write_async(struct rpc_context *rpc, rpc_cb cb, struct WRITE2args *args, void *private_data) | |
1064 | { | |
1065 | struct rpc_pdu *pdu; | |
1066 | ||
1067 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V2, NFS2_WRITE, cb, private_data, (zdrproc_t)zdr_WRITE2res, sizeof(WRITE2res)); | |
1068 | if (pdu == NULL) { | |
1069 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS2/WRITE call"); | |
1070 | return -1; | |
1071 | } | |
1072 | ||
1073 | if (zdr_WRITE2args(&pdu->zdr, args) == 0) { | |
1074 | rpc_set_error(rpc, "ZDR error: Failed to encode WRITE2args"); | |
1075 | rpc_free_pdu(rpc, pdu); | |
1076 | return -2; | |
1077 | } | |
1078 | ||
1079 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
1080 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS2/WRITE call"); | |
1081 | rpc_free_pdu(rpc, pdu); | |
1082 | return -3; | |
1083 | } | |
1084 | ||
1085 | return 0; | |
1086 | } | |
1087 | ||
1088 | int rpc_nfs2_create_async(struct rpc_context *rpc, rpc_cb cb, CREATE2args *args, void *private_data) | |
1089 | { | |
1090 | struct rpc_pdu *pdu; | |
1091 | ||
1092 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V2, NFS2_CREATE, cb, private_data, (zdrproc_t)zdr_CREATE2res, sizeof(CREATE2res)); | |
1093 | if (pdu == NULL) { | |
1094 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS2/CREATE call"); | |
1095 | return -1; | |
1096 | } | |
1097 | ||
1098 | if (zdr_CREATE2args(&pdu->zdr, args) == 0) { | |
1099 | rpc_set_error(rpc, "ZDR error: Failed to encode CREATE2args"); | |
1100 | rpc_free_pdu(rpc, pdu); | |
1101 | return -2; | |
1102 | } | |
1103 | ||
1104 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
1105 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS2/CREATE call"); | |
1106 | rpc_free_pdu(rpc, pdu); | |
1107 | return -3; | |
1108 | } | |
1109 | ||
1110 | return 0; | |
1111 | } | |
1112 | ||
1113 | int rpc_nfs2_remove_async(struct rpc_context *rpc, rpc_cb cb, struct REMOVE2args *args, void *private_data) | |
1114 | { | |
1115 | struct rpc_pdu *pdu; | |
1116 | ||
1117 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V2, NFS2_REMOVE, cb, private_data, (zdrproc_t)zdr_REMOVE2res, sizeof(REMOVE2res)); | |
1118 | if (pdu == NULL) { | |
1119 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/REMOVE call"); | |
1120 | return -1; | |
1121 | } | |
1122 | ||
1123 | if (zdr_REMOVE2args(&pdu->zdr, args) == 0) { | |
1124 | rpc_set_error(rpc, "ZDR error: Failed to encode REMOVE2args"); | |
1125 | rpc_free_pdu(rpc, pdu); | |
1126 | return -2; | |
1127 | } | |
1128 | ||
1129 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
1130 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS2/REMOVE call"); | |
1131 | rpc_free_pdu(rpc, pdu); | |
1132 | return -3; | |
1133 | } | |
1134 | ||
1135 | return 0; | |
1136 | } | |
1137 | ||
1138 | int rpc_nfs2_rename_async(struct rpc_context *rpc, rpc_cb cb, struct RENAME2args *args, void *private_data) | |
1139 | { | |
1140 | struct rpc_pdu *pdu; | |
1141 | ||
1142 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V2, NFS2_RENAME, cb, private_data, (zdrproc_t)zdr_RENAME2res, sizeof(RENAME2res)); | |
1143 | if (pdu == NULL) { | |
1144 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS2/RENAME call"); | |
1145 | return -1; | |
1146 | } | |
1147 | ||
1148 | if (zdr_RENAME2args(&pdu->zdr, args) == 0) { | |
1149 | rpc_set_error(rpc, "ZDR error: Failed to encode RENAME2args"); | |
1150 | rpc_free_pdu(rpc, pdu); | |
1151 | return -2; | |
1152 | } | |
1153 | ||
1154 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
1155 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS2/RENAME call"); | |
1156 | rpc_free_pdu(rpc, pdu); | |
1157 | return -3; | |
1158 | } | |
1159 | ||
1160 | return 0; | |
1161 | } | |
1162 | ||
1163 | int rpc_nfs2_link_async(struct rpc_context *rpc, rpc_cb cb, LINK2args *args, void *private_data) | |
1164 | { | |
1165 | struct rpc_pdu *pdu; | |
1166 | ||
1167 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V2, NFS2_LINK, cb, private_data, (zdrproc_t)zdr_LINK2res, sizeof(LINK2res)); | |
1168 | if (pdu == NULL) { | |
1169 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS2/LINK call"); | |
1170 | return -1; | |
1171 | } | |
1172 | ||
1173 | if (zdr_LINK2args(&pdu->zdr, args) == 0) { | |
1174 | rpc_set_error(rpc, "ZDR error: Failed to encode LINK2args"); | |
1175 | rpc_free_pdu(rpc, pdu); | |
1176 | return -2; | |
1177 | } | |
1178 | ||
1179 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
1180 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS2/LINK call"); | |
1181 | rpc_free_pdu(rpc, pdu); | |
1182 | return -3; | |
1183 | } | |
1184 | ||
1185 | return 0; | |
1186 | } | |
1187 | ||
1188 | int rpc_nfs2_symlink_async(struct rpc_context *rpc, rpc_cb cb, SYMLINK2args *args, void *private_data) | |
1189 | { | |
1190 | struct rpc_pdu *pdu; | |
1191 | ||
1192 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V2, NFS2_SYMLINK, cb, private_data, (zdrproc_t)zdr_SYMLINK2res, sizeof(SYMLINK2res)); | |
1193 | if (pdu == NULL) { | |
1194 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS2/SYMLINK call"); | |
1195 | return -1; | |
1196 | } | |
1197 | ||
1198 | if (zdr_SYMLINK2args(&pdu->zdr, args) == 0) { | |
1199 | rpc_set_error(rpc, "ZDR error: Failed to encode SYMLINK2args"); | |
1200 | rpc_free_pdu(rpc, pdu); | |
1201 | return -2; | |
1202 | } | |
1203 | ||
1204 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
1205 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS2/SYMLINK call"); | |
1206 | rpc_free_pdu(rpc, pdu); | |
1207 | return -3; | |
1208 | } | |
1209 | ||
1210 | return 0; | |
1211 | } | |
1212 | ||
1213 | int rpc_nfs2_mkdir_async(struct rpc_context *rpc, rpc_cb cb, MKDIR2args *args, void *private_data) | |
1214 | { | |
1215 | struct rpc_pdu *pdu; | |
1216 | ||
1217 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V2, NFS2_MKDIR, cb, private_data, (zdrproc_t)zdr_MKDIR2res, sizeof(MKDIR2res)); | |
1218 | if (pdu == NULL) { | |
1219 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS2/MKDIR call"); | |
1220 | return -1; | |
1221 | } | |
1222 | ||
1223 | if (zdr_MKDIR2args(&pdu->zdr, args) == 0) { | |
1224 | rpc_set_error(rpc, "ZDR error: Failed to encode MKDIR2args"); | |
1225 | rpc_free_pdu(rpc, pdu); | |
1226 | return -2; | |
1227 | } | |
1228 | ||
1229 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
1230 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS2/MKDIR call"); | |
1231 | rpc_free_pdu(rpc, pdu); | |
1232 | return -3; | |
1233 | } | |
1234 | ||
1235 | return 0; | |
1236 | } | |
1237 | ||
1238 | int rpc_nfs2_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct RMDIR2args *args, void *private_data) | |
1239 | { | |
1240 | struct rpc_pdu *pdu; | |
1241 | ||
1242 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V2, NFS2_RMDIR, cb, private_data, (zdrproc_t)zdr_RMDIR2res, sizeof(RMDIR2res)); | |
1243 | if (pdu == NULL) { | |
1244 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS2/RMDIR call"); | |
1245 | return -1; | |
1246 | } | |
84004dbf | 1247 | |
f38aacf8 RS |
1248 | if (zdr_RMDIR2args(&pdu->zdr, args) == 0) { |
1249 | rpc_set_error(rpc, "ZDR error: Failed to encode RMDIR2args"); | |
1250 | rpc_free_pdu(rpc, pdu); | |
1251 | return -2; | |
1252 | } | |
1253 | ||
1254 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
1255 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS2/RMDIR call"); | |
1256 | rpc_free_pdu(rpc, pdu); | |
1257 | return -3; | |
1258 | } | |
1259 | ||
1260 | return 0; | |
1261 | } | |
84004dbf | 1262 | |
f38aacf8 RS |
1263 | int rpc_nfs2_readdir_async(struct rpc_context *rpc, rpc_cb cb, struct READDIR2args *args, void *private_data) |
1264 | { | |
1265 | struct rpc_pdu *pdu; | |
1266 | ||
1267 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V2, NFS2_READDIR, cb, private_data, (zdrproc_t)zdr_READDIR2res, sizeof(READDIR2res)); | |
1268 | if (pdu == NULL) { | |
1269 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS2/READDIR call"); | |
1270 | return -1; | |
1271 | } | |
1272 | ||
1273 | if (zdr_READDIR2args(&pdu->zdr, args) == 0) { | |
1274 | rpc_set_error(rpc, "ZDR error: Failed to encode READDIR2args"); | |
1275 | rpc_free_pdu(rpc, pdu); | |
1276 | return -2; | |
1277 | } | |
1278 | ||
1279 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
1280 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS2/READDIR call"); | |
1281 | rpc_free_pdu(rpc, pdu); | |
1282 | return -3; | |
1283 | } | |
1284 | ||
1285 | return 0; | |
1286 | } | |
1287 | ||
1288 | int rpc_nfs2_statfs_async(struct rpc_context *rpc, rpc_cb cb, struct STATFS2args *args, void *private_data) | |
1289 | { | |
1290 | struct rpc_pdu *pdu; | |
1291 | ||
1292 | pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V2, NFS2_STATFS, cb, private_data, (zdrproc_t)zdr_STATFS2res, sizeof(STATFS2res)); | |
1293 | if (pdu == NULL) { | |
1294 | rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS2/STATFS call"); | |
1295 | return -1; | |
1296 | } | |
1297 | ||
1298 | if (zdr_STATFS2args(&pdu->zdr, args) == 0) { | |
1299 | rpc_set_error(rpc, "ZDR error: Failed to encode STATFS2args"); | |
1300 | rpc_free_pdu(rpc, pdu); | |
1301 | return -2; | |
1302 | } | |
1303 | ||
1304 | if (rpc_queue_pdu(rpc, pdu) != 0) { | |
1305 | rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS2/STATFS call"); | |
1306 | rpc_free_pdu(rpc, pdu); | |
1307 | return -3; | |
1308 | } | |
1309 | ||
1310 | return 0; | |
1311 | } |