1 #ifndef CCAN_NFS_LIBNFS_RAW_H
2 #define CCAN_NFS_LIBNFS_RAW_H
4 Copyright (C) by Ronnie Sahlberg <ronniesahlberg@gmail.com> 2010
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
20 * This is the lowlevel interface to access NFS resources.
21 * Through this interface you have access to the full gamut of nfs and nfs related
22 * protocol as well as the XDR encoded/decoded structures.
32 struct rpc_context *rpc_init_context(void);
33 void rpc_destroy_context(struct rpc_context *rpc);
36 void rpc_set_auth(struct rpc_context *rpc, struct AUTH *auth);
38 int rpc_get_fd(struct rpc_context *rpc);
39 int rpc_which_events(struct rpc_context *rpc);
40 int rpc_service(struct rpc_context *rpc, int revents);
41 char *rpc_get_error(struct rpc_context *rpc);
44 #define RPC_STATUS_SUCCESS 0
45 #define RPC_STATUS_ERROR 1
46 #define RPC_STATUS_CANCEL 2
48 typedef void (*rpc_cb)(struct rpc_context *rpc, int status, void *data, void *private_data);
51 * Async connection to the tcp port at server:port.
53 * 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
54 * <0 : An error occurred when trying to set up the connection. The callback will not be invoked.
56 * When the callback is invoked, status indicates the result:
57 * RPC_STATUS_SUCCESS : The tcp connection was successfully established.
59 * RPC_STATUS_ERROR : The connection failed to establish.
60 * data is the erro string.
61 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
64 int rpc_connect_async(struct rpc_context *rpc, const char *server, int port, int use_privileged_port, rpc_cb cb, void *private_data);
66 * When disconnecting a connection in flight. All commands in flight will be called with the callback
67 * and status RPC_STATUS_ERROR. Data will be the error string for the disconnection.
69 int rpc_disconnect(struct rpc_context *rpc, char *error);
71 void rpc_set_error(struct rpc_context *rpc, char *error_string, ...);
79 * Call PORTMAPPER/NULL
81 * 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
82 * <0 : An error occurred when trying to set up the connection. The callback will not be invoked.
84 * When the callback is invoked, status indicates the result:
85 * RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon.
87 * RPC_STATUS_ERROR : An error occurred when trying to contact the portmapper.
88 * data is the error string.
89 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
92 int rpc_pmap_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
96 * Call PORTMAPPER/GETPORT.
98 * 0 : The connection was initiated. Once the connection establish finishes, the callback will be invoked.
99 * <0 : An error occurred when trying to set up the connection. The callback will not be invoked.
101 * When the callback is invoked, status indicates the result:
102 * RPC_STATUS_SUCCESS : We got a successful response from the portmapper daemon.
103 * data is a (uint32_t *), containing the port returned.
104 * RPC_STATUS_ERROR : An error occurred when trying to contact the portmapper.
105 * data is the error string.
106 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
109 int rpc_pmap_getport_async(struct rpc_context *rpc, int program, int version, rpc_cb cb, void *private_data);
116 char *mountstat3_to_str(int stat);
117 int mountstat3_to_errno(int error);
122 * 0 : The call was initiated. The callback will be invoked when the call completes.
123 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
125 * When the callback is invoked, status indicates the result:
126 * RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
128 * RPC_STATUS_ERROR : An error occurred when trying to contact the mount daemon.
129 * data is the error string.
130 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
133 int rpc_mount_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
138 * 0 : The call was initiated. The callback will be invoked when the call completes.
139 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
141 * When the callback is invoked, status indicates the result:
142 * RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
143 * data is mountres3 *.
144 * RPC_STATUS_ERROR : An error occurred when trying to contact the mount daemon.
145 * data is the error string.
146 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
149 int rpc_mount_mnt_async(struct rpc_context *rpc, rpc_cb cb, char *export, void *private_data);
154 * 0 : The call was initiated. The callback will be invoked when the call completes.
155 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
157 * When the callback is invoked, status indicates the result:
158 * RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
159 * data is a mountlist.
160 * RPC_STATUS_ERROR : An error occurred when trying to contact the mount daemon.
161 * data is the error string.
162 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
165 int rpc_mount_dump_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
170 * 0 : The call was initiated. The callback will be invoked when the call completes.
171 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
173 * When the callback is invoked, status indicates the result:
174 * RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
176 * RPC_STATUS_ERROR : An error occurred when trying to contact the mount daemon.
177 * data is the error string.
178 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
181 int rpc_mount_umnt_async(struct rpc_context *rpc, rpc_cb cb, char *export, void *private_data);
186 * 0 : The call was initiated. The callback will be invoked when the call completes.
187 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
189 * When the callback is invoked, status indicates the result:
190 * RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
192 * RPC_STATUS_ERROR : An error occurred when trying to contact the mount daemon.
193 * data is the error string.
194 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
197 int rpc_mount_umntall_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
202 * 0 : The call was initiated. The callback will be invoked when the call completes.
203 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
205 * When the callback is invoked, status indicates the result:
206 * RPC_STATUS_SUCCESS : We got a successful response from the mount daemon.
207 * data is an exports.
208 * RPC_STATUS_ERROR : An error occurred when trying to contact the mount daemon.
209 * data is the error string.
210 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
213 int rpc_mount_export_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
222 char *nfsstat3_to_str(int error);
223 int nfsstat3_to_errno(int error);
228 * 0 : The call was initiated. The callback will be invoked when the call completes.
229 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
231 * When the callback is invoked, status indicates the result:
232 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
234 * RPC_STATUS_ERROR : An error occurred when trying to contact the nfs daemon.
235 * data is the error string.
236 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
239 int rpc_nfs_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
244 * 0 : The call was initiated. The callback will be invoked when the call completes.
245 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
247 * When the callback is invoked, status indicates the result:
248 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
249 * data is GETATTR3res
250 * RPC_STATUS_ERROR : An error occurred when trying to contact the nfs daemon.
251 * data is the error string.
252 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
255 int rpc_nfs_getattr_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data);
260 * 0 : The call was initiated. The callback will be invoked when the call completes.
261 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
263 * When the callback is invoked, status indicates the result:
264 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
266 * RPC_STATUS_ERROR : An error occurred when trying to contact the nfs daemon.
267 * data is the error string.
268 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
271 int rpc_nfs_lookup_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *name, void *private_data);
276 * 0 : The call was initiated. The callback will be invoked when the call completes.
277 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
279 * When the callback is invoked, status indicates the result:
280 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
282 * RPC_STATUS_ERROR : An error occurred when trying to contact the nfs daemon.
283 * data is the error string.
284 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
287 int rpc_nfs_access_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, int access, void *private_data);
292 * 0 : The call was initiated. The callback will be invoked when the call completes.
293 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
295 * When the callback is invoked, status indicates the result:
296 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
298 * RPC_STATUS_ERROR : An error occurred when trying to contact the nfs daemon.
299 * data is the error string.
300 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
303 int rpc_nfs_read_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, nfs_off_t offset, size_t count, void *private_data);
308 * 0 : The call was initiated. The callback will be invoked when the call completes.
309 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
311 * When the callback is invoked, status indicates the result:
312 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
313 * data is WRITE3res *
314 * RPC_STATUS_ERROR : An error occurred when trying to contact the nfs daemon.
315 * data is the error string.
316 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
319 int rpc_nfs_write_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *buf, nfs_off_t offset, size_t count, int stable_how, void *private_data);
324 * 0 : The call was initiated. The callback will be invoked when the call completes.
325 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
327 * When the callback is invoked, status indicates the result:
328 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
329 * data is COMMIT3res *
330 * RPC_STATUS_ERROR : An error occurred when trying to contact the nfs daemon.
331 * data is the error string.
332 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
335 int rpc_nfs_commit_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data);
341 * 0 : The call was initiated. The callback will be invoked when the call completes.
342 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
344 * When the callback is invoked, status indicates the result:
345 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
346 * data is SETATTR3res *
347 * RPC_STATUS_ERROR : An error occurred when trying to contact the nfs daemon.
348 * data is the error string.
349 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
353 int rpc_nfs_setattr_async(struct rpc_context *rpc, rpc_cb cb, struct SETATTR3args *args, void *private_data);
360 * 0 : The call was initiated. The callback will be invoked when the call completes.
361 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
363 * When the callback is invoked, status indicates the result:
364 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
365 * data is MKDIR3res *
366 * RPC_STATUS_ERROR : An error occurred when trying to contact the nfs daemon.
367 * data is the error string.
368 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
371 int rpc_nfs_mkdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *dir, void *private_data);
380 * 0 : The call was initiated. The callback will be invoked when the call completes.
381 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
383 * When the callback is invoked, status indicates the result:
384 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
385 * data is RMDIR3res *
386 * RPC_STATUS_ERROR : An error occurred when trying to contact the nfs daemon.
387 * data is the error string.
388 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
391 int rpc_nfs_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *dir, void *private_data);
399 * 0 : The call was initiated. The callback will be invoked when the call completes.
400 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
402 * When the callback is invoked, status indicates the result:
403 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
404 * data is CREATE3res *
405 * RPC_STATUS_ERROR : An error occurred when trying to contact the nfs daemon.
406 * data is the error string.
407 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
410 int rpc_nfs_create_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *name, int mode, void *private_data);
418 * 0 : The call was initiated. The callback will be invoked when the call completes.
419 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
421 * When the callback is invoked, status indicates the result:
422 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
423 * data is REMOVE3res *
424 * RPC_STATUS_ERROR : An error occurred when trying to contact the nfs daemon.
425 * data is the error string.
426 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
429 int rpc_nfs_remove_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *name, void *private_data);
436 * 0 : The call was initiated. The callback will be invoked when the call completes.
437 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
439 * When the callback is invoked, status indicates the result:
440 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
441 * data is READDIR3res *
442 * RPC_STATUS_ERROR : An error occurred when trying to contact the nfs daemon.
443 * data is the error string.
444 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
447 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);
452 * 0 : The call was initiated. The callback will be invoked when the call completes.
453 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
455 * When the callback is invoked, status indicates the result:
456 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
458 * RPC_STATUS_ERROR : An error occurred when trying to contact the nfs daemon.
459 * data is the error string.
460 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
463 int rpc_nfs_fsstat_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data);
471 * 0 : The call was initiated. The callback will be invoked when the call completes.
472 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
474 * When the callback is invoked, status indicates the result:
475 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
476 * data is READLINK3res *
477 * RPC_STATUS_ERROR : An error occurred when trying to contact the nfs daemon.
478 * data is the error string.
479 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
482 int rpc_nfs_readlink_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data);
489 * 0 : The call was initiated. The callback will be invoked when the call completes.
490 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
492 * When the callback is invoked, status indicates the result:
493 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
494 * data is SYMLINK3res *
495 * RPC_STATUS_ERROR : An error occurred when trying to contact the nfs daemon.
496 * data is the error string.
497 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
500 int rpc_nfs_symlink_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *newname, char *oldpath, void *private_data);
506 * 0 : The call was initiated. The callback will be invoked when the call completes.
507 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
509 * When the callback is invoked, status indicates the result:
510 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
511 * data is RENAME3res *
512 * RPC_STATUS_ERROR : An error occurred when trying to contact the nfs daemon.
513 * data is the error string.
514 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
517 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);
524 * 0 : The call was initiated. The callback will be invoked when the call completes.
525 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
527 * When the callback is invoked, status indicates the result:
528 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
530 * RPC_STATUS_ERROR : An error occurred when trying to contact the nfs daemon.
531 * data is the error string.
532 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
535 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);
549 * 0 : The call was initiated. The callback will be invoked when the call completes.
550 * <0 : An error occurred when trying to set up the call. The callback will not be invoked.
552 * When the callback is invoked, status indicates the result:
553 * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
555 * RPC_STATUS_ERROR : An error occurred when trying to contact the nfs daemon.
556 * data is the error string.
557 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
560 int rpc_nfsacl_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
562 #endif /* CCAN_NFS_LIBNFS_RAW_H */