a32521e4a8b1e6d24ab1b21ce978586ec89b0264
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/>.
20 #define S_IRUSR 0000400
21 #define S_IWUSR 0000200
22 #define S_IXUSR 0000100
23 #define S_IRGRP 0000040
24 #define S_IWGRP 0000020
25 #define S_IXGRP 0000010
26 #define S_IROTH 0000004
27 #define S_IWOTH 0000002
28 #define S_IXOTH 0000001
38 #include "libnfs-raw.h"
39 #include "libnfs-private.h"
40 #include "libnfs-raw-nfs.h"
44 char *nfsstat3_to_str(int error
)
47 case NFS3_OK
: return "NFS3_OK"; break;
48 case NFS3ERR_PERM
: return "NFS3ERR_PERM"; break;
49 case NFS3ERR_NOENT
: return "NFS3ERR_NOENT"; break;
50 case NFS3ERR_IO
: return "NFS3ERR_IO"; break;
51 case NFS3ERR_NXIO
: return "NFS3ERR_NXIO"; break;
52 case NFS3ERR_ACCES
: return "NFS3ERR_ACCES"; break;
53 case NFS3ERR_EXIST
: return "NFS3ERR_EXIST"; break;
54 case NFS3ERR_XDEV
: return "NFS3ERR_XDEV"; break;
55 case NFS3ERR_NODEV
: return "NFS3ERR_NODEV"; break;
56 case NFS3ERR_NOTDIR
: return "NFS3ERR_NOTDIR"; break;
57 case NFS3ERR_ISDIR
: return "NFS3ERR_ISDIR"; break;
58 case NFS3ERR_INVAL
: return "NFS3ERR_INVAL"; break;
59 case NFS3ERR_FBIG
: return "NFS3ERR_FBIG"; break;
60 case NFS3ERR_NOSPC
: return "NFS3ERR_NOSPC"; break;
61 case NFS3ERR_ROFS
: return "NFS3ERR_ROFS"; break;
62 case NFS3ERR_MLINK
: return "NFS3ERR_MLINK"; break;
63 case NFS3ERR_NAMETOOLONG
: return "NFS3ERR_NAMETOOLONG"; break;
64 case NFS3ERR_NOTEMPTY
: return "NFS3ERR_NOTEMPTY"; break;
65 case NFS3ERR_DQUOT
: return "NFS3ERR_DQUOT"; break;
66 case NFS3ERR_STALE
: return "NFS3ERR_STALE"; break;
67 case NFS3ERR_REMOTE
: return "NFS3ERR_REMOTE"; break;
68 case NFS3ERR_BADHANDLE
: return "NFS3ERR_BADHANDLE"; break;
69 case NFS3ERR_NOT_SYNC
: return "NFS3ERR_NOT_SYNC"; break;
70 case NFS3ERR_BAD_COOKIE
: return "NFS3ERR_BAD_COOKIE"; break;
71 case NFS3ERR_NOTSUPP
: return "NFS3ERR_NOTSUPP"; break;
72 case NFS3ERR_TOOSMALL
: return "NFS3ERR_TOOSMALL"; break;
73 case NFS3ERR_SERVERFAULT
: return "NFS3ERR_SERVERFAULT"; break;
74 case NFS3ERR_BADTYPE
: return "NFS3ERR_BADTYPE"; break;
75 case NFS3ERR_JUKEBOX
: return "NFS3ERR_JUKEBOX"; break;
77 return "unknown nfs error";
80 int nfsstat3_to_errno(int error
)
83 case NFS3_OK
: return 0; break;
84 case NFS3ERR_PERM
: return -EPERM
; break;
85 case NFS3ERR_NOENT
: return -ENOENT
; break;
86 case NFS3ERR_IO
: return -EIO
; break;
87 case NFS3ERR_NXIO
: return -ENXIO
; break;
88 case NFS3ERR_ACCES
: return -EACCES
; break;
89 case NFS3ERR_EXIST
: return -EEXIST
; break;
90 case NFS3ERR_XDEV
: return -EXDEV
; break;
91 case NFS3ERR_NODEV
: return -ENODEV
; break;
92 case NFS3ERR_NOTDIR
: return -ENOTDIR
; break;
93 case NFS3ERR_ISDIR
: return -EISDIR
; break;
94 case NFS3ERR_INVAL
: return -EINVAL
; break;
95 case NFS3ERR_FBIG
: return -EFBIG
; break;
96 case NFS3ERR_NOSPC
: return -ENOSPC
; break;
97 case NFS3ERR_ROFS
: return -EROFS
; break;
98 case NFS3ERR_MLINK
: return -EMLINK
; break;
99 case NFS3ERR_NAMETOOLONG
: return -ENAMETOOLONG
; break;
100 case NFS3ERR_NOTEMPTY
: return -EEXIST
; break;
101 case NFS3ERR_DQUOT
: return -ERANGE
; break;
102 case NFS3ERR_STALE
: return -EIO
; break;
103 case NFS3ERR_REMOTE
: return -EIO
; break;
104 case NFS3ERR_BADHANDLE
: return -EIO
; break;
105 case NFS3ERR_NOT_SYNC
: return -EIO
; break;
106 case NFS3ERR_BAD_COOKIE
: return -EIO
; break;
107 case NFS3ERR_NOTSUPP
: return -EINVAL
; break;
108 case NFS3ERR_TOOSMALL
: return -EIO
; break;
109 case NFS3ERR_SERVERFAULT
: return -EIO
; break;
110 case NFS3ERR_BADTYPE
: return -EINVAL
; break;
111 case NFS3ERR_JUKEBOX
: return -EAGAIN
; break;
117 int rpc_nfs_null_async(struct rpc_context
*rpc
, rpc_cb cb
, void *private_data
)
121 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_NULL
, cb
, private_data
, (xdrproc_t
)xdr_void
, 0);
123 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nfs/null call");
127 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
128 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nfs/null call");
129 rpc_free_pdu(rpc
, pdu
);
136 int rpc_nfs_getattr_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, void *private_data
)
141 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_GETATTR
, cb
, private_data
, (xdrproc_t
)xdr_GETATTR3res
, sizeof(GETATTR3res
));
143 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nfs/null call");
147 args
.object
.data
.data_len
= fh
->data
.data_len
;
148 args
.object
.data
.data_val
= fh
->data
.data_val
;
150 if (xdr_GETATTR3args(&pdu
->xdr
, &args
) == 0) {
151 rpc_set_error(rpc
, "XDR error: Failed to encode GETATTR3args");
152 rpc_free_pdu(rpc
, pdu
);
156 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
157 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nfs/null call");
158 rpc_free_pdu(rpc
, pdu
);
165 int rpc_nfs_lookup_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, char *name
, void *private_data
)
170 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_LOOKUP
, cb
, private_data
, (xdrproc_t
)xdr_LOOKUP3res
, sizeof(LOOKUP3res
));
172 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nfs/lookup call");
176 args
.what
.dir
.data
.data_len
= fh
->data
.data_len
;
177 args
.what
.dir
.data
.data_val
= fh
->data
.data_val
;
178 args
.what
.name
= name
;
180 if (xdr_LOOKUP3args(&pdu
->xdr
, &args
) == 0) {
181 rpc_set_error(rpc
, "XDR error: Failed to encode LOOKUP3args");
182 rpc_free_pdu(rpc
, pdu
);
186 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
187 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nfs/lookup call");
188 rpc_free_pdu(rpc
, pdu
);
196 int rpc_nfs_access_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, int access
, void *private_data
)
201 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_ACCESS
, cb
, private_data
, (xdrproc_t
)xdr_ACCESS3res
, sizeof(ACCESS3res
));
203 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nfs/access call");
207 args
.object
.data
.data_len
= fh
->data
.data_len
;
208 args
.object
.data
.data_val
= fh
->data
.data_val
;
209 args
.access
= access
;
211 if (xdr_ACCESS3args(&pdu
->xdr
, &args
) == 0) {
212 rpc_set_error(rpc
, "XDR error: Failed to encode ACCESS3args");
213 rpc_free_pdu(rpc
, pdu
);
217 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
218 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nfs/access call");
219 rpc_free_pdu(rpc
, pdu
);
228 int rpc_nfs_read_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, off_t offset
, size_t count
, void *private_data
)
233 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_READ
, cb
, private_data
, (xdrproc_t
)xdr_READ3res
, sizeof(READ3res
));
235 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nfs/read call");
239 args
.file
.data
.data_len
= fh
->data
.data_len
;
240 args
.file
.data
.data_val
= fh
->data
.data_val
;
241 args
.offset
= offset
;
244 if (xdr_READ3args(&pdu
->xdr
, &args
) == 0) {
245 rpc_set_error(rpc
, "XDR error: Failed to encode READ3args");
246 rpc_free_pdu(rpc
, pdu
);
250 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
251 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nfs/read call");
252 rpc_free_pdu(rpc
, pdu
);
260 int rpc_nfs_write_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, char *buf
, off_t offset
, size_t count
, int stable_how
, void *private_data
)
265 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_WRITE
, cb
, private_data
, (xdrproc_t
)xdr_WRITE3res
, sizeof(WRITE3res
));
267 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nfs/write call");
271 args
.file
.data
.data_len
= fh
->data
.data_len
;
272 args
.file
.data
.data_val
= fh
->data
.data_val
;
273 args
.offset
= offset
;
275 args
.stable
= stable_how
;;
276 args
.data
.data_len
= count
;
277 args
.data
.data_val
= buf
;
279 if (xdr_WRITE3args(&pdu
->xdr
, &args
) == 0) {
280 rpc_set_error(rpc
, "XDR error: Failed to encode WRITE3args");
281 rpc_free_pdu(rpc
, pdu
);
285 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
286 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nfs/write call");
287 rpc_free_pdu(rpc
, pdu
);
296 int rpc_nfs_commit_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, void *private_data
)
301 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_COMMIT
, cb
, private_data
, (xdrproc_t
)xdr_COMMIT3res
, sizeof(COMMIT3res
));
303 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nfs/commit call");
307 args
.file
.data
.data_len
= fh
->data
.data_len
;
308 args
.file
.data
.data_val
= fh
->data
.data_val
;
312 if (xdr_COMMIT3args(&pdu
->xdr
, &args
) == 0) {
313 rpc_set_error(rpc
, "XDR error: Failed to encode WRITE3args");
314 rpc_free_pdu(rpc
, pdu
);
318 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
319 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nfs/commit call");
320 rpc_free_pdu(rpc
, pdu
);
328 int rpc_nfs_setattr_async(struct rpc_context
*rpc
, rpc_cb cb
, SETATTR3args
*args
, void *private_data
)
332 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_SETATTR
, cb
, private_data
, (xdrproc_t
)xdr_SETATTR3res
, sizeof(SETATTR3res
));
334 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nfs/setattr call");
338 if (xdr_SETATTR3args(&pdu
->xdr
, args
) == 0) {
339 rpc_set_error(rpc
, "XDR error: Failed to encode SETATTR3args");
340 rpc_free_pdu(rpc
, pdu
);
344 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
345 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nfs/setattr call");
346 rpc_free_pdu(rpc
, pdu
);
355 int rpc_nfs_mkdir_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, char *dir
, void *private_data
)
360 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_MKDIR
, cb
, private_data
, (xdrproc_t
)xdr_MKDIR3res
, sizeof(MKDIR3res
));
362 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nfs/setattr call");
366 bzero(&args
, sizeof(MKDIR3args
));
367 args
.where
.dir
.data
.data_len
= fh
->data
.data_len
;
368 args
.where
.dir
.data
.data_val
= fh
->data
.data_val
;
369 args
.where
.name
= dir
;
370 args
.attributes
.mode
.set_it
= 1;
371 args
.attributes
.mode
.set_mode3_u
.mode
= 0755;
373 if (xdr_MKDIR3args(&pdu
->xdr
, &args
) == 0) {
374 rpc_set_error(rpc
, "XDR error: Failed to encode MKDIR3args");
375 rpc_free_pdu(rpc
, pdu
);
379 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
380 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nfs/mkdir call");
381 rpc_free_pdu(rpc
, pdu
);
391 int rpc_nfs_rmdir_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, char *dir
, void *private_data
)
396 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_RMDIR
, cb
, private_data
, (xdrproc_t
)xdr_RMDIR3res
, sizeof(RMDIR3res
));
398 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nfs/rmdir call");
402 bzero(&args
, sizeof(RMDIR3args
));
403 args
.object
.dir
.data
.data_len
= fh
->data
.data_len
;
404 args
.object
.dir
.data
.data_val
= fh
->data
.data_val
;
405 args
.object
.name
= dir
;
407 if (xdr_RMDIR3args(&pdu
->xdr
, &args
) == 0) {
408 rpc_set_error(rpc
, "XDR error: Failed to encode RMDIR3args");
409 rpc_free_pdu(rpc
, pdu
);
413 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
414 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nfs/rmdir call");
415 rpc_free_pdu(rpc
, pdu
);
424 int rpc_nfs_create_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, char *file
, int mode
, void *private_data
)
429 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_CREATE
, cb
, private_data
, (xdrproc_t
)xdr_CREATE3res
, sizeof(CREATE3res
));
431 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nfs/create call");
435 bzero(&args
, sizeof(CREATE3args
));
436 args
.where
.dir
.data
.data_len
= fh
->data
.data_len
;
437 args
.where
.dir
.data
.data_val
= fh
->data
.data_val
;
438 args
.where
.name
= file
;
439 args
.how
.mode
= UNCHECKED
;
440 args
.how
.createhow3_u
.obj_attributes
.mode
.set_it
= 1;
441 args
.how
.createhow3_u
.obj_attributes
.mode
.set_mode3_u
.mode
= mode
;
443 if (xdr_CREATE3args(&pdu
->xdr
, &args
) == 0) {
444 rpc_set_error(rpc
, "XDR error: Failed to encode CREATE3args");
445 rpc_free_pdu(rpc
, pdu
);
449 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
450 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nfs/create call");
451 rpc_free_pdu(rpc
, pdu
);
461 int rpc_nfs_remove_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, char *file
, void *private_data
)
466 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_REMOVE
, cb
, private_data
, (xdrproc_t
)xdr_REMOVE3res
, sizeof(REMOVE3res
));
468 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nfs/remove call");
472 bzero(&args
, sizeof(REMOVE3args
));
473 args
.object
.dir
.data
.data_len
= fh
->data
.data_len
;
474 args
.object
.dir
.data
.data_val
= fh
->data
.data_val
;
475 args
.object
.name
= file
;
477 if (xdr_REMOVE3args(&pdu
->xdr
, &args
) == 0) {
478 rpc_set_error(rpc
, "XDR error: Failed to encode REMOVE3args");
479 rpc_free_pdu(rpc
, pdu
);
483 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
484 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nfs/remove call");
485 rpc_free_pdu(rpc
, pdu
);
493 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
)
498 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_READDIR
, cb
, private_data
, (xdrproc_t
)xdr_READDIR3res
, sizeof(READDIR3res
));
500 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nfs/readdir call");
504 bzero(&args
, sizeof(READDIR3args
));
505 args
.dir
.data
.data_len
= fh
->data
.data_len
;
506 args
.dir
.data
.data_val
= fh
->data
.data_val
;
507 args
.cookie
= cookie
;
508 memcpy(&args
.cookieverf
, cookieverf
, sizeof(cookieverf3
));
511 if (xdr_READDIR3args(&pdu
->xdr
, &args
) == 0) {
512 rpc_set_error(rpc
, "XDR error: Failed to encode READDIR3args");
513 rpc_free_pdu(rpc
, pdu
);
517 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
518 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nfs/readdir call");
519 rpc_free_pdu(rpc
, pdu
);
526 int rpc_nfs_fsstat_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, void *private_data
)
531 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_FSSTAT
, cb
, private_data
, (xdrproc_t
)xdr_FSSTAT3res
, sizeof(FSSTAT3res
));
533 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nfs/fsstat call");
537 args
.fsroot
.data
.data_len
= fh
->data
.data_len
;
538 args
.fsroot
.data
.data_val
= fh
->data
.data_val
;
540 if (xdr_FSSTAT3args(&pdu
->xdr
, &args
) == 0) {
541 rpc_set_error(rpc
, "XDR error: Failed to encode FSSTAT3args");
542 rpc_free_pdu(rpc
, pdu
);
546 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
547 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nfs/fsstat call");
548 rpc_free_pdu(rpc
, pdu
);
555 int rpc_nfs_fsinfo_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, void *private_data
)
560 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_FSINFO
, cb
, private_data
, (xdrproc_t
)xdr_FSINFO3res
, sizeof(FSINFO3res
));
562 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nfs/fsinfo call");
566 args
.fsroot
.data
.data_len
= fh
->data
.data_len
;
567 args
.fsroot
.data
.data_val
= fh
->data
.data_val
;
569 if (xdr_FSINFO3args(&pdu
->xdr
, &args
) == 0) {
570 rpc_set_error(rpc
, "XDR error: Failed to encode FSINFO3args");
571 rpc_free_pdu(rpc
, pdu
);
575 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
576 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nfs/fsinfo call");
577 rpc_free_pdu(rpc
, pdu
);
584 int rpc_nfs_readlink_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, void *private_data
)
589 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_READLINK
, cb
, private_data
, (xdrproc_t
)xdr_READLINK3res
, sizeof(READLINK3res
));
591 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nfs/readlink call");
595 args
.symlink
.data
.data_len
= fh
->data
.data_len
;
596 args
.symlink
.data
.data_val
= fh
->data
.data_val
;
598 if (xdr_READLINK3args(&pdu
->xdr
, &args
) == 0) {
599 rpc_set_error(rpc
, "XDR error: Failed to encode READLINK3args");
600 rpc_free_pdu(rpc
, pdu
);
604 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
605 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nfs/readlink call");
606 rpc_free_pdu(rpc
, pdu
);
614 int rpc_nfs_symlink_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, char *newname
, char *oldpath
, void *private_data
)
619 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_SYMLINK
, cb
, private_data
, (xdrproc_t
)xdr_SYMLINK3res
, sizeof(SYMLINK3res
));
621 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nfs/symlink call");
625 bzero(&args
, sizeof(SYMLINK3args
));
626 args
.where
.dir
.data
.data_len
= fh
->data
.data_len
;
627 args
.where
.dir
.data
.data_val
= fh
->data
.data_val
;
628 args
.where
.name
= newname
;
629 args
.symlink
.symlink_attributes
.mode
.set_it
= 1;
630 args
.symlink
.symlink_attributes
.mode
.set_mode3_u
.mode
= S_IRUSR
|S_IWUSR
|S_IXUSR
|S_IRGRP
|S_IWGRP
|S_IXGRP
|S_IROTH
|S_IWOTH
|S_IXOTH
;
631 args
.symlink
.symlink_data
= oldpath
;
633 if (xdr_SYMLINK3args(&pdu
->xdr
, &args
) == 0) {
634 rpc_set_error(rpc
, "XDR error: Failed to encode SYMLINK3args");
635 rpc_free_pdu(rpc
, pdu
);
639 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
640 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nfs/symlink call");
641 rpc_free_pdu(rpc
, pdu
);
651 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
)
656 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_RENAME
, cb
, private_data
, (xdrproc_t
)xdr_RENAME3res
, sizeof(RENAME3res
));
658 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nfs/rename call");
662 bzero(&args
, sizeof(RENAME3args
));
663 args
.from
.dir
.data
.data_len
= olddir
->data
.data_len
;
664 args
.from
.dir
.data
.data_val
= olddir
->data
.data_val
;
665 args
.from
.name
= oldname
;
666 args
.to
.dir
.data
.data_len
= newdir
->data
.data_len
;
667 args
.to
.dir
.data
.data_val
= newdir
->data
.data_val
;
668 args
.to
.name
= newname
;
670 if (xdr_RENAME3args(&pdu
->xdr
, &args
) == 0) {
671 rpc_set_error(rpc
, "XDR error: Failed to encode RENAME3args");
672 rpc_free_pdu(rpc
, pdu
);
676 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
677 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nfs/rename call");
678 rpc_free_pdu(rpc
, pdu
);
688 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
)
693 pdu
= rpc_allocate_pdu(rpc
, NFS_PROGRAM
, NFS_V3
, NFS3_LINK
, cb
, private_data
, (xdrproc_t
)xdr_LINK3res
, sizeof(LINK3res
));
695 rpc_set_error(rpc
, "Out of memory. Failed to allocate pdu for nfs/link call");
699 bzero(&args
, sizeof(LINK3args
));
700 args
.file
.data
.data_len
= file
->data
.data_len
;
701 args
.file
.data
.data_val
= file
->data
.data_val
;
702 args
.link
.dir
.data
.data_len
= newdir
->data
.data_len
;
703 args
.link
.dir
.data
.data_val
= newdir
->data
.data_val
;
704 args
.link
.name
= newname
;
706 if (xdr_LINK3args(&pdu
->xdr
, &args
) == 0) {
707 rpc_set_error(rpc
, "XDR error: Failed to encode LINK3args");
708 rpc_free_pdu(rpc
, pdu
);
712 if (rpc_queue_pdu(rpc
, pdu
) != 0) {
713 rpc_set_error(rpc
, "Out of memory. Failed to queue pdu for nfs/link call");
714 rpc_free_pdu(rpc
, pdu
);