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/>.
19 #include "win32_compat.h"
27 #include "libnfs-zdr.h"
29 #include "libnfs-raw.h"
30 #include "libnfs-private.h"
31 #include "libnfs-raw-nfs.h"
33 char *nfsstat3_to_str(int 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;
66 return "unknown nfs error";
69 int nfsstat3_to_errno(int 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;
89 case NFS3ERR_NOTEMPTY
: return -EEXIST
; break;
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;
109 int rpc_nfs3_null_async(struct rpc_context
*rpc
, rpc_cb cb
, void *private_data
)
113 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_NULL
, cb
, private_data
, (zdrproc_t
)zdr_void
, 0);
115 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/NULL call");
119 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
120 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/NULL call");
121 rpc_free_pdu(rpc
, pdu
);
128 int rpc_nfs_null_async(struct rpc_context
*rpc
, rpc_cb cb
, void *private_data
)
130 return rpc_nfs3_null_async(rpc
, cb
, private_data
);
133 int rpc_nfs3_getattr_async(struct rpc_context
*rpc
, rpc_cb cb
, struct GETATTR3args
*args
, void *private_data
)
137 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_GETATTR
, cb
, private_data
, (zdrproc_t
)zdr_GETATTR3res
, sizeof(GETATTR3res
));
139 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/GETATTR call");
143 if (zdr_GETATTR3args(&pdu
->zdr
, args
) == 0) {
144 rpc_set_error(rpc
, "ZDR error: Failed to encode GETATTR3args");
145 rpc_free_pdu(rpc
, pdu
);
149 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
150 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/GETATTR call");
151 rpc_free_pdu(rpc
, pdu
);
158 int rpc_nfs_getattr_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, void *private_data
)
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
;
166 return rpc_nfs3_getattr_async(rpc
, cb
, &args
, private_data
);
169 int rpc_nfs3_pathconf_async(struct rpc_context
*rpc
, rpc_cb cb
, struct PATHCONF3args
*args
, void *private_data
)
173 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_PATHCONF
, cb
, private_data
, (zdrproc_t
)zdr_PATHCONF3res
, sizeof(PATHCONF3res
));
175 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/PATHCONF call");
179 if (zdr_PATHCONF3args(&pdu
->zdr
, args
) == 0) {
180 rpc_set_error(rpc
, "ZDR error: Failed to encode PATHCONF3args");
181 rpc_free_pdu(rpc
, pdu
);
185 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
186 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/PATHCONF call");
187 rpc_free_pdu(rpc
, pdu
);
194 int rpc_nfs_pathconf_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, void *private_data
)
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
;
202 return rpc_nfs3_pathconf_async(rpc
, cb
, &args
, private_data
);
205 int rpc_nfs3_lookup_async(struct rpc_context
*rpc
, rpc_cb cb
, struct LOOKUP3args
*args
, void *private_data
)
209 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_LOOKUP
, cb
, private_data
, (zdrproc_t
)zdr_LOOKUP3res
, sizeof(LOOKUP3res
));
211 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/LOOKUP call");
215 if (zdr_LOOKUP3args(&pdu
->zdr
, args
) == 0) {
216 rpc_set_error(rpc
, "ZDR error: Failed to encode LOOKUP3args");
217 rpc_free_pdu(rpc
, pdu
);
221 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
222 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/LOOKUP call");
223 rpc_free_pdu(rpc
, pdu
);
230 int rpc_nfs_lookup_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, char *name
, void *private_data
)
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
;
239 return rpc_nfs3_lookup_async(rpc
, cb
, &args
, private_data
);
242 int rpc_nfs3_access_async(struct rpc_context
*rpc
, rpc_cb cb
, struct ACCESS3args
*args
, void *private_data
)
246 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_ACCESS
, cb
, private_data
, (zdrproc_t
)zdr_ACCESS3res
, sizeof(ACCESS3res
));
248 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/ACCESS call");
252 if (zdr_ACCESS3args(&pdu
->zdr
, args
) == 0) {
253 rpc_set_error(rpc
, "ZDR error: Failed to encode ACCESS3args");
254 rpc_free_pdu(rpc
, pdu
);
258 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
259 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/ACCESS call");
260 rpc_free_pdu(rpc
, pdu
);
267 int rpc_nfs_access_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, int access
, void *private_data
)
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
;
276 return rpc_nfs3_access_async(rpc
, cb
, &args
, private_data
);
279 int rpc_nfs3_read_async(struct rpc_context
*rpc
, rpc_cb cb
, struct READ3args
*args
, void *private_data
)
283 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_READ
, cb
, private_data
, (zdrproc_t
)zdr_READ3res
, sizeof(READ3res
));
285 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/READ call");
289 if (zdr_READ3args(&pdu
->zdr
, args
) == 0) {
290 rpc_set_error(rpc
, "ZDR error: Failed to encode READ3args");
291 rpc_free_pdu(rpc
, pdu
);
295 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
296 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/READ call");
297 rpc_free_pdu(rpc
, pdu
);
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
)
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
;
314 return rpc_nfs3_read_async(rpc
, cb
, &args
, private_data
);
317 int rpc_nfs3_write_async(struct rpc_context
*rpc
, rpc_cb cb
, struct WRITE3args
*args
, void *private_data
)
321 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_WRITE
, cb
, private_data
, (zdrproc_t
)zdr_WRITE3res
, sizeof(WRITE3res
));
323 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/WRITE call");
327 if (zdr_WRITE3args(&pdu
->zdr
, args
) == 0) {
328 rpc_set_error(rpc
, "ZDR error: Failed to encode WRITE3args");
329 rpc_free_pdu(rpc
, pdu
);
333 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
334 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/WRITE call");
335 rpc_free_pdu(rpc
, pdu
);
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
)
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
;
351 args
.stable
= stable_how
;
352 args
.data
.data_len
= count
;
353 args
.data
.data_val
= buf
;
355 return rpc_nfs3_write_async(rpc
, cb
, &args
, private_data
);
358 int rpc_nfs3_commit_async(struct rpc_context
*rpc
, rpc_cb cb
, struct COMMIT3args
*args
, void *private_data
)
362 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_COMMIT
, cb
, private_data
, (zdrproc_t
)zdr_COMMIT3res
, sizeof(COMMIT3res
));
364 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/COMMIT call");
368 if (zdr_COMMIT3args(&pdu
->zdr
, args
) == 0) {
369 rpc_set_error(rpc
, "ZDR error: Failed to encode COMMIT3args");
370 rpc_free_pdu(rpc
, pdu
);
374 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
375 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/COMMIT call");
376 rpc_free_pdu(rpc
, pdu
);
383 int rpc_nfs_commit_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, void *private_data
)
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
;
393 return rpc_nfs3_commit_async(rpc
, cb
, &args
, private_data
);
396 int rpc_nfs3_setattr_async(struct rpc_context
*rpc
, rpc_cb cb
, SETATTR3args
*args
, void *private_data
)
400 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_SETATTR
, cb
, private_data
, (zdrproc_t
)zdr_SETATTR3res
, sizeof(SETATTR3res
));
402 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/SETATTR call");
406 if (zdr_SETATTR3args(&pdu
->zdr
, args
) == 0) {
407 rpc_set_error(rpc
, "ZDR error: Failed to encode SETATTR3args");
408 rpc_free_pdu(rpc
, pdu
);
412 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
413 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/SETATTR call");
414 rpc_free_pdu(rpc
, pdu
);
421 int rpc_nfs_setattr_async(struct rpc_context
*rpc
, rpc_cb cb
, SETATTR3args
*args
, void *private_data
)
423 return rpc_nfs3_setattr_async(rpc
, cb
, args
, private_data
);
426 int rpc_nfs3_mkdir_async(struct rpc_context
*rpc
, rpc_cb cb
, MKDIR3args
*args
, void *private_data
)
430 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_MKDIR
, cb
, private_data
, (zdrproc_t
)zdr_MKDIR3res
, sizeof(MKDIR3res
));
432 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/MKDIR call");
436 if (zdr_MKDIR3args(&pdu
->zdr
, args
) == 0) {
437 rpc_set_error(rpc
, "ZDR error: Failed to encode MKDIR3args");
438 rpc_free_pdu(rpc
, pdu
);
442 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
443 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/MKDIR call");
444 rpc_free_pdu(rpc
, pdu
);
451 int rpc_nfs_mkdir_async(struct rpc_context
*rpc
, rpc_cb cb
, MKDIR3args
*args
, void *private_data
)
453 return rpc_nfs3_mkdir_async(rpc
, cb
, args
, private_data
);
456 int rpc_nfs3_rmdir_async(struct rpc_context
*rpc
, rpc_cb cb
, struct RMDIR3args
*args
, void *private_data
)
460 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_RMDIR
, cb
, private_data
, (zdrproc_t
)zdr_RMDIR3res
, sizeof(RMDIR3res
));
462 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/RMDIR call");
466 if (zdr_RMDIR3args(&pdu
->zdr
, args
) == 0) {
467 rpc_set_error(rpc
, "ZDR error: Failed to encode RMDIR3args");
468 rpc_free_pdu(rpc
, pdu
);
472 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
473 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/RMDIR call");
474 rpc_free_pdu(rpc
, pdu
);
481 int rpc_nfs_rmdir_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, char *dir
, void *private_data
)
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
;
490 return rpc_nfs3_rmdir_async(rpc
, cb
, &args
, private_data
);
493 int rpc_nfs3_create_async(struct rpc_context
*rpc
, rpc_cb cb
, CREATE3args
*args
, void *private_data
)
497 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_CREATE
, cb
, private_data
, (zdrproc_t
)zdr_CREATE3res
, sizeof(CREATE3res
));
499 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/CREATE call");
503 if (zdr_CREATE3args(&pdu
->zdr
, args
) == 0) {
504 rpc_set_error(rpc
, "ZDR error: Failed to encode CREATE3args");
505 rpc_free_pdu(rpc
, pdu
);
509 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
510 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/CREATE call");
511 rpc_free_pdu(rpc
, pdu
);
518 int rpc_nfs_create_async(struct rpc_context
*rpc
, rpc_cb cb
, CREATE3args
*args
, void *private_data
)
520 return rpc_nfs3_create_async(rpc
, cb
, args
, private_data
);
523 int rpc_nfs3_mknod_async(struct rpc_context
*rpc
, rpc_cb cb
, struct MKNOD3args
*args
, void *private_data
)
527 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_MKNOD
, cb
, private_data
, (zdrproc_t
)zdr_MKNOD3res
, sizeof(MKNOD3res
));
529 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/MKNOD call");
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
);
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
);
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
)
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
;
557 switch (mode
& S_IFMT
) {
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
;
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
;
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
);
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
);
582 rpc_set_error(rpc
, "Invalid file type for NFS3/MKNOD call");
586 return rpc_nfs3_mknod_async(rpc
, cb
, &args
, private_data
);
589 int rpc_nfs3_remove_async(struct rpc_context
*rpc
, rpc_cb cb
, struct REMOVE3args
*args
, void *private_data
)
593 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_REMOVE
, cb
, private_data
, (zdrproc_t
)zdr_REMOVE3res
, sizeof(REMOVE3res
));
595 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/REMOVE call");
599 if (zdr_REMOVE3args(&pdu
->zdr
, args
) == 0) {
600 rpc_set_error(rpc
, "ZDR error: Failed to encode REMOVE3args");
601 rpc_free_pdu(rpc
, pdu
);
605 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
606 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/REMOVE call");
607 rpc_free_pdu(rpc
, pdu
);
614 int rpc_nfs_remove_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, char *file
, void *private_data
)
618 memset(&args
, 0, sizeof(REMOVE3args
));
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
;
623 return rpc_nfs3_remove_async(rpc
, cb
, &args
, private_data
);
626 int rpc_nfs3_readdir_async(struct rpc_context
*rpc
, rpc_cb cb
, struct READDIR3args
*args
, void *private_data
)
630 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_READDIR
, cb
, private_data
, (zdrproc_t
)zdr_READDIR3res
, sizeof(READDIR3res
));
632 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/READDIR call");
636 if (zdr_READDIR3args(&pdu
->zdr
, args
) == 0) {
637 rpc_set_error(rpc
, "ZDR error: Failed to encode READDIR3args");
638 rpc_free_pdu(rpc
, pdu
);
642 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
643 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/READDIR call");
644 rpc_free_pdu(rpc
, pdu
);
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
)
655 memset(&args
, 0, sizeof(READDIR3args
));
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
));
662 return rpc_nfs3_readdir_async(rpc
, cb
, &args
, private_data
);
665 int rpc_nfs3_readdirplus_async(struct rpc_context
*rpc
, rpc_cb cb
, struct READDIRPLUS3args
*args
, void *private_data
)
669 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_READDIRPLUS
, cb
, private_data
, (zdrproc_t
)zdr_READDIRPLUS3res
, sizeof(READDIRPLUS3res
));
671 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/READDIRPLUS call");
675 if (zdr_READDIRPLUS3args(&pdu
->zdr
, args
) == 0) {
676 rpc_set_error(rpc
, "ZDR error: Failed to encode READDIRPLUS3args");
677 rpc_free_pdu(rpc
, pdu
);
681 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
682 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/READDIRPLUS call");
683 rpc_free_pdu(rpc
, pdu
);
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
)
692 READDIRPLUS3args args
;
694 memset(&args
, 0, sizeof(READDIRPLUS3args
));
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
;
702 return rpc_nfs3_readdirplus_async(rpc
, cb
, &args
, private_data
);
705 int rpc_nfs3_fsstat_async(struct rpc_context
*rpc
, rpc_cb cb
, struct FSSTAT3args
*args
, void *private_data
)
709 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_FSSTAT
, cb
, private_data
, (zdrproc_t
)zdr_FSSTAT3res
, sizeof(FSSTAT3res
));
711 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/FSSTAT call");
715 if (zdr_FSSTAT3args(&pdu
->zdr
, args
) == 0) {
716 rpc_set_error(rpc
, "ZDR error: Failed to encode FSSTAT3args");
717 rpc_free_pdu(rpc
, pdu
);
721 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
722 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/FSSTAT call");
723 rpc_free_pdu(rpc
, pdu
);
730 int rpc_nfs_fsstat_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, void *private_data
)
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
;
738 return rpc_nfs3_fsstat_async(rpc
, cb
, &args
, private_data
);
741 int rpc_nfs3_fsinfo_async(struct rpc_context
*rpc
, rpc_cb cb
, struct FSINFO3args
*args
, void *private_data
)
745 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_FSINFO
, cb
, private_data
, (zdrproc_t
)zdr_FSINFO3res
, sizeof(FSINFO3res
));
747 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/FSINFO call");
751 if (zdr_FSINFO3args(&pdu
->zdr
, args
) == 0) {
752 rpc_set_error(rpc
, "ZDR error: Failed to encode FSINFO3args");
753 rpc_free_pdu(rpc
, pdu
);
757 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
758 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/FSINFO call");
759 rpc_free_pdu(rpc
, pdu
);
766 int rpc_nfs_fsinfo_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, void *private_data
)
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
;
774 return rpc_nfs3_fsinfo_async(rpc
, cb
, &args
, private_data
);
777 int rpc_nfs3_readlink_async(struct rpc_context
*rpc
, rpc_cb cb
, READLINK3args
*args
, void *private_data
)
781 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_READLINK
, cb
, private_data
, (zdrproc_t
)zdr_READLINK3res
, sizeof(READLINK3res
));
783 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/READLINK call");
787 if (zdr_READLINK3args(&pdu
->zdr
, args
) == 0) {
788 rpc_set_error(rpc
, "ZDR error: Failed to encode READLINK3args");
789 rpc_free_pdu(rpc
, pdu
);
793 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
794 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/READLINK call");
795 rpc_free_pdu(rpc
, pdu
);
802 int rpc_nfs_readlink_async(struct rpc_context
*rpc
, rpc_cb cb
, READLINK3args
*args
, void *private_data
)
804 return rpc_nfs3_readlink_async(rpc
, cb
, args
, private_data
);
807 int rpc_nfs3_symlink_async(struct rpc_context
*rpc
, rpc_cb cb
, SYMLINK3args
*args
, void *private_data
)
811 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_SYMLINK
, cb
, private_data
, (zdrproc_t
)zdr_SYMLINK3res
, sizeof(SYMLINK3res
));
813 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/SYMLINK call");
817 if (zdr_SYMLINK3args(&pdu
->zdr
, args
) == 0) {
818 rpc_set_error(rpc
, "ZDR error: Failed to encode SYMLINK3args");
819 rpc_free_pdu(rpc
, pdu
);
823 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
824 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/SYMLINK call");
825 rpc_free_pdu(rpc
, pdu
);
832 int rpc_nfs_symlink_async(struct rpc_context
*rpc
, rpc_cb cb
, SYMLINK3args
*args
, void *private_data
)
834 return rpc_nfs3_symlink_async(rpc
, cb
, args
, private_data
);
837 int rpc_nfs3_rename_async(struct rpc_context
*rpc
, rpc_cb cb
, struct RENAME3args
*args
, void *private_data
)
841 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_RENAME
, cb
, private_data
, (zdrproc_t
)zdr_RENAME3res
, sizeof(RENAME3res
));
843 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/RENAME call");
847 if (zdr_RENAME3args(&pdu
->zdr
, args
) == 0) {
848 rpc_set_error(rpc
, "ZDR error: Failed to encode RENAME3args");
849 rpc_free_pdu(rpc
, pdu
);
853 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
854 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/RENAME call");
855 rpc_free_pdu(rpc
, pdu
);
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
)
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
;
874 return rpc_nfs3_rename_async(rpc
, cb
, &args
, private_data
);
877 int rpc_nfs3_link_async(struct rpc_context
*rpc
, rpc_cb cb
, struct LINK3args
*args
, void *private_data
)
881 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_LINK
, cb
, private_data
, (zdrproc_t
)zdr_LINK3res
, sizeof(LINK3res
));
883 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/LINK call");
887 if (zdr_LINK3args(&pdu
->zdr
, args
) == 0) {
888 rpc_set_error(rpc
, "ZDR error: Failed to encode LINK3args");
889 rpc_free_pdu(rpc
, pdu
);
893 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
894 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for NFS3/LINK call");
895 rpc_free_pdu(rpc
, pdu
);
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
)
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
;
913 return rpc_nfs3_link_async(rpc
, cb
, &args
, private_data
);
919 int rpc_nfs2_null_async(struct rpc_context
*rpc
, rpc_cb cb
, void *private_data
)
923 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V2
, NFS2_NULL
, cb
, private_data
, (zdrproc_t
)zdr_void
, 0);
925 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS2/NULL call");
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
);
938 int rpc_nfs2_getattr_async(struct rpc_context
*rpc
, rpc_cb cb
, struct GETATTR2args
*args
, void *private_data
)
942 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V2
, NFS2_GETATTR
, cb
, private_data
, (zdrproc_t
)zdr_GETATTR2res
, sizeof(GETATTR2res
));
944 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS2/GETATTR call");
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
);
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
);
963 int rpc_nfs2_setattr_async(struct rpc_context
*rpc
, rpc_cb cb
, SETATTR2args
*args
, void *private_data
)
967 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V2
, NFS2_SETATTR
, cb
, private_data
, (zdrproc_t
)zdr_SETATTR2res
, sizeof(SETATTR2res
));
969 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS2/SETATTR call");
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
);
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
);
988 int rpc_nfs2_lookup_async(struct rpc_context
*rpc
, rpc_cb cb
, struct LOOKUP2args
*args
, void *private_data
)
992 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V2
, NFS2_LOOKUP
, cb
, private_data
, (zdrproc_t
)zdr_LOOKUP2res
, sizeof(LOOKUP2res
));
994 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS2/LOOKUP call");
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
);
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
);
1013 int rpc_nfs2_readlink_async(struct rpc_context
*rpc
, rpc_cb cb
, READLINK2args
*args
, void *private_data
)
1015 struct rpc_pdu
*pdu
;
1017 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V2
, NFS2_READLINK
, cb
, private_data
, (zdrproc_t
)zdr_READLINK2res
, sizeof(READLINK2res
));
1019 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS2/READLINK call");
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
);
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
);
1038 int rpc_nfs2_read_async(struct rpc_context
*rpc
, rpc_cb cb
, struct READ2args
*args
, void *private_data
)
1040 struct rpc_pdu
*pdu
;
1042 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V2
, NFS2_READ
, cb
, private_data
, (zdrproc_t
)zdr_READ2res
, sizeof(READ2res
));
1044 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS2/READ call");
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
);
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
);
1063 int rpc_nfs2_write_async(struct rpc_context
*rpc
, rpc_cb cb
, struct WRITE2args
*args
, void *private_data
)
1065 struct rpc_pdu
*pdu
;
1067 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V2
, NFS2_WRITE
, cb
, private_data
, (zdrproc_t
)zdr_WRITE2res
, sizeof(WRITE2res
));
1069 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS2/WRITE call");
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
);
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
);
1088 int rpc_nfs2_create_async(struct rpc_context
*rpc
, rpc_cb cb
, CREATE2args
*args
, void *private_data
)
1090 struct rpc_pdu
*pdu
;
1092 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V2
, NFS2_CREATE
, cb
, private_data
, (zdrproc_t
)zdr_CREATE2res
, sizeof(CREATE2res
));
1094 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS2/CREATE call");
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
);
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
);
1113 int rpc_nfs2_remove_async(struct rpc_context
*rpc
, rpc_cb cb
, struct REMOVE2args
*args
, void *private_data
)
1115 struct rpc_pdu
*pdu
;
1117 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V2
, NFS2_REMOVE
, cb
, private_data
, (zdrproc_t
)zdr_REMOVE2res
, sizeof(REMOVE2res
));
1119 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS3/REMOVE call");
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
);
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
);
1138 int rpc_nfs2_rename_async(struct rpc_context
*rpc
, rpc_cb cb
, struct RENAME2args
*args
, void *private_data
)
1140 struct rpc_pdu
*pdu
;
1142 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V2
, NFS2_RENAME
, cb
, private_data
, (zdrproc_t
)zdr_RENAME2res
, sizeof(RENAME2res
));
1144 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS2/RENAME call");
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
);
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
);
1163 int rpc_nfs2_link_async(struct rpc_context
*rpc
, rpc_cb cb
, LINK2args
*args
, void *private_data
)
1165 struct rpc_pdu
*pdu
;
1167 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V2
, NFS2_LINK
, cb
, private_data
, (zdrproc_t
)zdr_LINK2res
, sizeof(LINK2res
));
1169 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS2/LINK call");
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
);
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
);
1188 int rpc_nfs2_symlink_async(struct rpc_context
*rpc
, rpc_cb cb
, SYMLINK2args
*args
, void *private_data
)
1190 struct rpc_pdu
*pdu
;
1192 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V2
, NFS2_SYMLINK
, cb
, private_data
, (zdrproc_t
)zdr_SYMLINK2res
, sizeof(SYMLINK2res
));
1194 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS2/SYMLINK call");
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
);
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
);
1213 int rpc_nfs2_mkdir_async(struct rpc_context
*rpc
, rpc_cb cb
, MKDIR2args
*args
, void *private_data
)
1215 struct rpc_pdu
*pdu
;
1217 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V2
, NFS2_MKDIR
, cb
, private_data
, (zdrproc_t
)zdr_MKDIR2res
, sizeof(MKDIR2res
));
1219 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS2/MKDIR call");
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
);
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
);
1238 int rpc_nfs2_rmdir_async(struct rpc_context
*rpc
, rpc_cb cb
, struct RMDIR2args
*args
, void *private_data
)
1240 struct rpc_pdu
*pdu
;
1242 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V2
, NFS2_RMDIR
, cb
, private_data
, (zdrproc_t
)zdr_RMDIR2res
, sizeof(RMDIR2res
));
1244 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS2/RMDIR call");
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
);
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
);
1263 int rpc_nfs2_readdir_async(struct rpc_context
*rpc
, rpc_cb cb
, struct READDIR2args
*args
, void *private_data
)
1265 struct rpc_pdu
*pdu
;
1267 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V2
, NFS2_READDIR
, cb
, private_data
, (zdrproc_t
)zdr_READDIR2res
, sizeof(READDIR2res
));
1269 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS2/READDIR call");
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
);
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
);
1288 int rpc_nfs2_statfs_async(struct rpc_context
*rpc
, rpc_cb cb
, struct STATFS2args
*args
, void *private_data
)
1290 struct rpc_pdu
*pdu
;
1292 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V2
, NFS2_STATFS
, cb
, private_data
, (zdrproc_t
)zdr_STATFS2res
, sizeof(STATFS2res
));
1294 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for NFS2/STATFS call");
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
);
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
);