bd23dc11665ac74fb26b3c3f1d60d448a72dba0d
2 Copyright (C) 2010 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>.
18 * This is the lowlevel interface to access NFS resources.
19 * Through this interface you have access to the full gamut of nfs and nfs related
20 * protocol as well as the XDR encoded/decoded structures.
30 struct rpc_context
*rpc_init_context(void);
31 void rpc_destroy_context(struct rpc_context
*rpc
);
34 void rpc_set_auth(struct rpc_context
*rpc
, struct AUTH
*auth
);
36 int rpc_get_fd(struct rpc_context
*rpc
);
37 int rpc_which_events(struct rpc_context
*rpc
);
38 int rpc_service(struct rpc_context
*rpc
, int revents
);
39 char *rpc_get_error(struct rpc_context
*rpc
);
42 #define RPC_STATUS_SUCCESS 0
43 #define RPC_STATUS_ERROR 1
44 #define RPC_STATUS_CANCEL 2
47 * Async connection to the tcp port at server:port.
49 * 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
50 * <0 : An error occured when trying to set up the connection. The callback will not be invoked.
52 * When the callback is invoked, status indicates the result:
53 * RPC_STATUS_SUCCESS : The tcp connection was successfully established.
55 * RPC_STATUS_ERROR : The connection failed to establish.
56 * data is the erro string.
57 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
60 int rpc_connect_async(struct rpc_context
*rpc
, const char *server
, int port
, rpc_cb cb
, void *private_data
);
62 * When disconnecting a connection in flight. All commands in flight will be called with the callback
63 * and status RPC_STATUS_ERROR. Data will be the error string for the disconnection.
65 int rpc_disconnect(struct rpc_context
*rpc
, char *error
);
73 * Call PORTMAPPER/NULL
75 * 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
76 * <0 : An error occured when trying to set up the connection. The callback will not be invoked.
78 * When the callback is invoked, status indicates the result:
79 * RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon.
81 * RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
82 * data is the error string.
83 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
86 int rpc_pmap_null_async(struct rpc_context
*rpc
, rpc_cb cb
, void *private_data
);
90 * Call PORTMAPPER/GETPORT.
92 * 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
93 * <0 : An error occured when trying to set up the connection. The callback will not be invoked.
95 * When the callback is invoked, status indicates the result:
96 * RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon.
97 * data is a (uint32_t *), containing the port returned.
98 * RPC_STATUS_ERROR : An error occured when trying to contact the portmapper.
99 * data is the error string.
100 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
103 int rpc_pmap_getport_async(struct rpc_context
*rpc
, int program
, int version
, rpc_cb cb
, void *private_data
);
110 char *mountstat3_to_str(int stat
);
111 int mountstat3_to_errno(int error
);
116 * 0 : The call was initiated. The callback will be invoked when the call completes.
117 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
119 * When the callback is invoked, status indicates the result:
120 * RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
122 * RPC_STATUS_ERROR : An error occured when trying to contact the mount daemon.
123 * data is the error string.
124 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
127 int rpc_mount_null_async(struct rpc_context
*rpc
, rpc_cb cb
, void *private_data
);
132 * 0 : The call was initiated. The callback will be invoked when the call completes.
133 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
135 * When the callback is invoked, status indicates the result:
136 * RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
137 * data is union mountres3.
138 * RPC_STATUS_ERROR : An error occured when trying to contact the mount daemon.
139 * data is the error string.
140 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
143 int rpc_mount_mnt_async(struct rpc_context
*rpc
, rpc_cb cb
, char *export
, void *private_data
);
148 * 0 : The call was initiated. The callback will be invoked when the call completes.
149 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
151 * When the callback is invoked, status indicates the result:
152 * RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
153 * data is a mountlist.
154 * RPC_STATUS_ERROR : An error occured when trying to contact the mount daemon.
155 * data is the error string.
156 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
159 int rpc_mount_dump_async(struct rpc_context
*rpc
, rpc_cb cb
, void *private_data
);
164 * 0 : The call was initiated. The callback will be invoked when the call completes.
165 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
167 * When the callback is invoked, status indicates the result:
168 * RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
170 * RPC_STATUS_ERROR : An error occured when trying to contact the mount daemon.
171 * data is the error string.
172 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
175 int rpc_mount_umnt_async(struct rpc_context
*rpc
, rpc_cb cb
, char *export
, void *private_data
);
180 * 0 : The call was initiated. The callback will be invoked when the call completes.
181 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
183 * When the callback is invoked, status indicates the result:
184 * RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
186 * RPC_STATUS_ERROR : An error occured when trying to contact the mount daemon.
187 * data is the error string.
188 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
191 int rpc_mount_umntall_async(struct rpc_context
*rpc
, rpc_cb cb
, void *private_data
);
195 * NOTE: You must include 'libnfs-raw-mount.h' to get the definitions of the
196 * returned structures.
199 * 0 : The call was initiated. The callback will be invoked when the call completes.
200 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
202 * When the callback is invoked, status indicates the result:
203 * RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
204 * data is a pointer to an exports pointer:
205 * exports export = *(exports *)data;
206 * RPC_STATUS_ERROR : An error occured when trying to contact the mount daemon.
207 * data is the error string.
208 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
211 int rpc_mount_export_async(struct rpc_context
*rpc
, rpc_cb cb
, void *private_data
);
220 char *nfsstat3_to_str(int error
);
221 int nfsstat3_to_errno(int error
);
226 * 0 : The call was initiated. The callback will be invoked when the call completes.
227 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
229 * When the callback is invoked, status indicates the result:
230 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
232 * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
233 * data is the error string.
234 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
237 int rpc_nfs_null_async(struct rpc_context
*rpc
, rpc_cb cb
, void *private_data
);
242 * 0 : The call was initiated. The callback will be invoked when the call completes.
243 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
245 * When the callback is invoked, status indicates the result:
246 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
247 * data is GETATTR3res
248 * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
249 * data is the error string.
250 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
253 int rpc_nfs_getattr_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, void *private_data
);
258 * 0 : The call was initiated. The callback will be invoked when the call completes.
259 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
261 * When the callback is invoked, status indicates the result:
262 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
264 * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
265 * data is the error string.
266 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
269 int rpc_nfs_lookup_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, char *name
, void *private_data
);
274 * 0 : The call was initiated. The callback will be invoked when the call completes.
275 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
277 * When the callback is invoked, status indicates the result:
278 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
280 * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
281 * data is the error string.
282 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
285 int rpc_nfs_access_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, int access
, void *private_data
);
290 * 0 : The call was initiated. The callback will be invoked when the call completes.
291 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
293 * When the callback is invoked, status indicates the result:
294 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
296 * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
297 * data is the error string.
298 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
301 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
);
306 * 0 : The call was initiated. The callback will be invoked when the call completes.
307 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
309 * When the callback is invoked, status indicates the result:
310 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
311 * data is WRITE3res *
312 * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
313 * data is the error string.
314 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
317 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
);
322 * 0 : The call was initiated. The callback will be invoked when the call completes.
323 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
325 * When the callback is invoked, status indicates the result:
326 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
327 * data is COMMIT3res *
328 * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
329 * data is the error string.
330 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
333 int rpc_nfs_commit_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, void *private_data
);
339 * 0 : The call was initiated. The callback will be invoked when the call completes.
340 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
342 * When the callback is invoked, status indicates the result:
343 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
344 * data is SETATTR3res *
345 * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
346 * data is the error string.
347 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
351 int rpc_nfs_setattr_async(struct rpc_context
*rpc
, rpc_cb cb
, struct SETATTR3args
*args
, void *private_data
);
358 * 0 : The call was initiated. The callback will be invoked when the call completes.
359 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
361 * When the callback is invoked, status indicates the result:
362 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
363 * data is MKDIR3res *
364 * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
365 * data is the error string.
366 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
369 int rpc_nfs_mkdir_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, char *dir
, void *private_data
);
378 * 0 : The call was initiated. The callback will be invoked when the call completes.
379 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
381 * When the callback is invoked, status indicates the result:
382 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
383 * data is RMDIR3res *
384 * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
385 * data is the error string.
386 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
389 int rpc_nfs_rmdir_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, char *dir
, void *private_data
);
397 * 0 : The call was initiated. The callback will be invoked when the call completes.
398 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
400 * When the callback is invoked, status indicates the result:
401 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
402 * data is CREATE3res *
403 * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
404 * data is the error string.
405 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
408 int rpc_nfs_create_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, char *name
, int mode
, void *private_data
);
416 * 0 : The call was initiated. The callback will be invoked when the call completes.
417 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
419 * When the callback is invoked, status indicates the result:
420 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
421 * data is REMOVE3res *
422 * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
423 * data is the error string.
424 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
427 int rpc_nfs_remove_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, char *name
, void *private_data
);
434 * 0 : The call was initiated. The callback will be invoked when the call completes.
435 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
437 * When the callback is invoked, status indicates the result:
438 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
439 * data is READDIR3res *
440 * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
441 * data is the error string.
442 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
445 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
);
450 * 0 : The call was initiated. The callback will be invoked when the call completes.
451 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
453 * When the callback is invoked, status indicates the result:
454 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
456 * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
457 * data is the error string.
458 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
461 int rpc_nfs_fsstat_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, void *private_data
);
468 * 0 : The call was initiated. The callback will be invoked when the call completes.
469 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
471 * When the callback is invoked, status indicates the result:
472 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
474 * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
475 * data is the error string.
476 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
479 int rpc_nfs_fsinfo_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, void *private_data
);
486 * 0 : The call was initiated. The callback will be invoked when the call completes.
487 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
489 * When the callback is invoked, status indicates the result:
490 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
491 * data is READLINK3res *
492 * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
493 * data is the error string.
494 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
497 int rpc_nfs_readlink_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, void *private_data
);
504 * 0 : The call was initiated. The callback will be invoked when the call completes.
505 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
507 * When the callback is invoked, status indicates the result:
508 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
509 * data is SYMLINK3res *
510 * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
511 * data is the error string.
512 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
515 int rpc_nfs_symlink_async(struct rpc_context
*rpc
, rpc_cb cb
, struct nfs_fh3
*fh
, char *newname
, char *oldpath
, void *private_data
);
521 * 0 : The call was initiated. The callback will be invoked when the call completes.
522 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
524 * When the callback is invoked, status indicates the result:
525 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
526 * data is RENAME3res *
527 * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
528 * data is the error string.
529 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
532 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
);
539 * 0 : The call was initiated. The callback will be invoked when the call completes.
540 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
542 * When the callback is invoked, status indicates the result:
543 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
545 * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
546 * data is the error string.
547 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
550 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
);
558 char *rquotastat_to_str(int error
);
559 int rquotastat_to_errno(int error
);
564 * 0 : The call was initiated. The callback will be invoked when the call completes.
565 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
567 * When the callback is invoked, status indicates the result:
568 * RPC_STATUS_SUCCESS : We got a successful response from the rquota daemon.
570 * RPC_STATUS_ERROR : An error occured when trying to contact the rquota daemon.
571 * data is the error string.
572 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
575 int rpc_rquota1_null_async(struct rpc_context
*rpc
, rpc_cb cb
, void *private_data
);
578 * Call RQUOTA1/GETQUOTA
580 * 0 : The call was initiated. The callback will be invoked when the call completes.
581 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
583 * When the callback is invoked, status indicates the result:
584 * RPC_STATUS_SUCCESS : We got a successful response from the rquota daemon.
585 * data is a RQUOTA1res structure.
586 * RPC_STATUS_ERROR : An error occured when trying to contact the rquota daemon.
587 * data is the error string.
588 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
591 int rpc_rquota1_getquota_async(struct rpc_context
*rpc
, rpc_cb cb
, char *export
, int uid
, void *private_data
);
594 * Call RQUOTA1/GETACTIVEQUOTA
596 * 0 : The call was initiated. The callback will be invoked when the call completes.
597 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
599 * When the callback is invoked, status indicates the result:
600 * RPC_STATUS_SUCCESS : We got a successful response from the rquota daemon.
601 * data is a RQUOTA1res structure.
602 * RPC_STATUS_ERROR : An error occured when trying to contact the rquota daemon.
603 * data is the error string.
604 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
607 int rpc_rquota1_getactivequota_async(struct rpc_context
*rpc
, rpc_cb cb
, char *export
, int uid
, void *private_data
);
615 * 0 : The call was initiated. The callback will be invoked when the call completes.
616 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
618 * When the callback is invoked, status indicates the result:
619 * RPC_STATUS_SUCCESS : We got a successful response from the rquota daemon.
621 * RPC_STATUS_ERROR : An error occured when trying to contact the rquota daemon.
622 * data is the error string.
623 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
626 int rpc_rquota2_null_async(struct rpc_context
*rpc
, rpc_cb cb
, void *private_data
);
629 * Call RQUOTA2/GETQUOTA
631 * 0 : The call was initiated. The callback will be invoked when the call completes.
632 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
634 * When the callback is invoked, status indicates the result:
635 * RPC_STATUS_SUCCESS : We got a successful response from the rquota daemon.
636 * data is a RQUOTA1res structure.
637 * RPC_STATUS_ERROR : An error occured when trying to contact the rquota daemon.
638 * data is the error string.
639 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
642 int rpc_rquota2_getquota_async(struct rpc_context
*rpc
, rpc_cb cb
, char *export
, int type
, int uid
, void *private_data
);
645 * Call RQUOTA2/GETACTIVEQUOTA
647 * 0 : The call was initiated. The callback will be invoked when the call completes.
648 * <0 : An error occured when trying to set up the call. The callback will not be invoked.
650 * When the callback is invoked, status indicates the result:
651 * RPC_STATUS_SUCCESS : We got a successful response from the rquota daemon.
652 * data is a RQUOTA1res structure.
653 * RPC_STATUS_ERROR : An error occured when trying to contact the rquota daemon.
654 * data is the error string.
655 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
658 int rpc_rquota2_getactivequota_async(struct rpc_context
*rpc
, rpc_cb cb
, char *export
, int type
, int uid
, void *private_data
);