using READDIRPLUS3 we get some extra fields for the direentry structure for free...
[deb_libnfs.git] / include / libnfs.h
CommitLineData
84004dbf
RS
1/*
2 Copyright (C) 2010 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>.
16*/
17/*
18 * This is the highlevel interface to access NFS resources using a posix-like interface
19 */
20#include <stdint.h>
21
22struct nfs_context;
7f0242ca 23struct rpc_context;
84004dbf
RS
24
25/*
26 * Used for interfacing the async version of the api into an external eventsystem
27 */
28int nfs_get_fd(struct nfs_context *nfs);
29int nfs_which_events(struct nfs_context *nfs);
30int nfs_service(struct nfs_context *nfs, int revents);
31
32/*
33 * Used if you need different credentials than the default for the current user.
34 */
35struct AUTH;
36void nfs_set_auth(struct nfs_context *nfs, struct AUTH *auth);
37
38
39/*
40 * When an operation failed, this function can extract a detailed error string.
41 */
42char *nfs_get_error(struct nfs_context *nfs);
43
44
45/*
46 * Callback for all ASYNC nfs functions
47 */
48typedef void (*nfs_cb)(int err, struct nfs_context *nfs, void *data, void *private_data);
49
7f0242ca
RS
50/*
51 * Callback for all ASYNC rpc functions
52 */
53typedef void (*rpc_cb)(struct rpc_context *rpc, int status, void *data, void *private_data);
84004dbf
RS
54
55
56
57/*
58 * NFS CONTEXT.
59 */
60/*
61 * Create an NFS c, the context.
62 * Function returns
63 * NULL : Failed to create a context.
64 * *nfs : A pointer to an nfs context.
65 */
66struct nfs_context *nfs_init_context(void);
67/*
68 * Destroy an nfs context.
69 */
70void nfs_destroy_context(struct nfs_context *nfs);
71
72
73struct nfsfh;
74
17ef62fa
RS
75/*
76 * Get the maximum supported READ3 size by the server
77 */
78size_t nfs_get_readmax(struct nfs_context *nfs);
79
80/*
81 * Get the maximum supported WRITE3 size by the server
82 */
83size_t nfs_get_writemax(struct nfs_context *nfs);
84
84004dbf
RS
85
86/*
87 * MOUNT THE EXPORT
88 */
89/*
90 * Async nfs mount.
91 * Function returns
92 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
93 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
94 *
95 * When the callback is invoked, status indicates the result:
96 * 0 : Success.
97 * data is NULL
98 * -errno : An error occured.
99 * data is the error string.
100 */
d6ced294 101int nfs_mount_async(struct nfs_context *nfs, const char *server, const char *exportname, nfs_cb cb, void *private_data);
84004dbf
RS
102/*
103 * Sync nfs mount.
104 * Function returns
105 * 0 : The operation was successfull.
106 * -errno : The command failed.
107 */
e2ba5764 108int nfs_mount(struct nfs_context *nfs, const char *server, const char *exportname);
84004dbf
RS
109
110
111
112
113/*
114 * STAT()
115 */
116/*
117 * Async stat(<filename>)
118 * Function returns
119 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
120 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
121 *
122 * When the callback is invoked, status indicates the result:
123 * 0 : Success.
124 * data is struct stat *
125 * -errno : An error occured.
126 * data is the error string.
127 */
128struct stat;
129int nfs_stat_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
130/*
131 * Sync stat(<filename>)
132 * Function returns
133 * 0 : The operation was successfull.
134 * -errno : The command failed.
135 */
e2ba5764 136int nfs_stat(struct nfs_context *nfs, const char *path, struct stat *st);
84004dbf
RS
137
138
139/*
140 * FSTAT()
141 */
142/*
143 * Async fstat(nfsfh *)
144 * Function returns
145 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
146 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
147 *
148 * When the callback is invoked, status indicates the result:
149 * 0 : Success.
150 * data is struct stat *
151 * -errno : An error occured.
152 * data is the error string.
153 */
154int nfs_fstat_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
155/*
156 * Sync fstat(nfsfh *)
157 * Function returns
158 * 0 : The operation was successfull.
159 * -errno : The command failed.
160 */
e2ba5764 161int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct stat *st);
84004dbf
RS
162
163
164
165/*
166 * OPEN()
167 */
168/*
169 * Async open(<filename>)
170 *
171 * mode is a combination of the flags : O_RDOLNY, O_WRONLY, O_RDWR , O_SYNC
172 *
173 * Function returns
174 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
175 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
176 *
177 * When the callback is invoked, status indicates the result:
178 * 0 : Success.
179 * data is a struct *nfsfh;
180 * The nfsfh is close using nfs_close().
181 * -errno : An error occured.
182 * data is the error string.
183 */
184int nfs_open_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
185/*
186 * Sync stat(<filename>)
187 * Function returns
188 * 0 : The operation was successfull. *nfsfh is filled in.
189 * -errno : The command failed.
190 */
e2ba5764 191int nfs_open(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh);
84004dbf
RS
192
193
194
195
196/*
197 * CLOSE
198 */
199/*
200 * Async close(nfsfh)
201 *
202 * Function returns
203 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
204 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
205 *
206 * When the callback is invoked, status indicates the result:
207 * 0 : Success.
208 * data is NULL.
209 * -errno : An error occured.
210 * data is the error string.
211 */
212int nfs_close_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
213/*
214 * Sync close(nfsfh)
215 * Function returns
216 * 0 : The operation was successfull.
217 * -errno : The command failed.
218 */
e2ba5764 219int nfs_close(struct nfs_context *nfs, struct nfsfh *nfsfh);
84004dbf
RS
220
221
222/*
223 * PREAD()
224 */
225/*
226 * Async pread()
227 *
228 * Function returns
229 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
230 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
231 *
232 * When the callback is invoked, status indicates the result:
233 * >=0 : Success.
234 * status is numer of bytes read.
235 * data is a pointer to the returned data.
236 * -errno : An error occured.
237 * data is the error string.
238 */
239int nfs_pread_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, nfs_cb cb, void *private_data);
240/*
241 * Sync pread()
242 * Function returns
243 * >=0 : numer of bytes read.
244 * -errno : An error occured.
245 */
e2ba5764 246int nfs_pread(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, char *buf);
84004dbf
RS
247
248
249
250/*
251 * READ()
252 */
253/*
254 * Async read()
255 *
256 * Function returns
257 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
258 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
259 *
260 * When the callback is invoked, status indicates the result:
261 * >=0 : Success.
262 * status is numer of bytes read.
263 * data is a pointer to the returned data.
264 * -errno : An error occured.
265 * data is the error string.
266 */
267int nfs_read_async(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, nfs_cb cb, void *private_data);
268/*
269 * Sync read()
270 * Function returns
271 * >=0 : numer of bytes read.
272 * -errno : An error occured.
273 */
e2ba5764 274int nfs_read(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf);
84004dbf
RS
275
276
277
278
279/*
280 * PWRITE()
281 */
282/*
283 * Async pwrite()
284 *
285 * Function returns
286 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
287 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
288 *
289 * When the callback is invoked, status indicates the result:
290 * >=0 : Success.
291 * status is numer of bytes written.
292 * -errno : An error occured.
293 * data is the error string.
294 */
295int nfs_pwrite_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, char *buf, nfs_cb cb, void *private_data);
296/*
297 * Sync pwrite()
298 * Function returns
299 * >=0 : numer of bytes written.
300 * -errno : An error occured.
301 */
e2ba5764 302int nfs_pwrite(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, char *buf);
84004dbf
RS
303
304
305/*
306 * WRITE()
307 */
308/*
309 * Async write()
310 *
311 * Function returns
312 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
313 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
314 *
315 * When the callback is invoked, status indicates the result:
316 * >=0 : Success.
317 * status is numer of bytes written.
318 * -errno : An error occured.
319 * data is the error string.
320 */
321int nfs_write_async(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf, nfs_cb cb, void *private_data);
322/*
323 * Sync write()
324 * Function returns
325 * >=0 : numer of bytes written.
326 * -errno : An error occured.
327 */
e2ba5764 328int nfs_write(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf);
84004dbf
RS
329
330
331/*
332 * LSEEK()
333 */
334/*
335 * Async lseek()
336 *
337 * Function returns
338 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
339 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
340 *
341 * When the callback is invoked, status indicates the result:
342 * >=0 : Success.
343 * data is off_t * for the current position.
344 * -errno : An error occured.
345 * data is the error string.
346 */
347int nfs_lseek_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, int whence, nfs_cb cb, void *private_data);
348/*
349 * Sync lseek()
350 * Function returns
351 * >=0 : numer of bytes read.
352 * -errno : An error occured.
353 */
e2ba5764 354int nfs_lseek(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, int whence, off_t *current_offset);
84004dbf
RS
355
356
357/*
358 * FSYNC()
359 */
360/*
361 * Async fsync()
362 *
363 * Function returns
364 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
365 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
366 *
367 * When the callback is invoked, status indicates the result:
368 * 0 : Success.
369 * -errno : An error occured.
370 * data is the error string.
371 */
372int nfs_fsync_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
373/*
374 * Sync fsync()
375 * Function returns
376 * 0 : Success
377 * -errno : An error occured.
378 */
e2ba5764 379int nfs_fsync(struct nfs_context *nfs, struct nfsfh *nfsfh);
84004dbf
RS
380
381
382
383/*
384 * TRUNCATE()
385 */
386/*
387 * Async truncate()
388 *
389 * Function returns
390 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
391 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
392 *
393 * When the callback is invoked, status indicates the result:
394 * 0 : Success.
395 * -errno : An error occured.
396 * data is the error string.
397 */
398int nfs_truncate_async(struct nfs_context *nfs, const char *path, off_t length, nfs_cb cb, void *private_data);
399/*
400 * Sync truncate()
401 * Function returns
402 * 0 : Success
403 * -errno : An error occured.
404 */
e2ba5764 405int nfs_truncate(struct nfs_context *nfs, const char *path, off_t length);
84004dbf
RS
406
407
408
409/*
410 * FTRUNCATE()
411 */
412/*
413 * Async ftruncate()
414 *
415 * Function returns
416 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
417 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
418 *
419 * When the callback is invoked, status indicates the result:
420 * 0 : Success.
421 * -errno : An error occured.
422 * data is the error string.
423 */
424int nfs_ftruncate_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t length, nfs_cb cb, void *private_data);
425/*
426 * Sync ftruncate()
427 * Function returns
428 * 0 : Success
429 * -errno : An error occured.
430 */
e2ba5764 431int nfs_ftruncate(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t length);
84004dbf
RS
432
433
434
435
436
437
438/*
439 * MKDIR()
440 */
441/*
442 * Async mkdir()
443 *
444 * Function returns
445 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
446 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
447 *
448 * When the callback is invoked, status indicates the result:
449 * 0 : Success.
450 * -errno : An error occured.
451 * data is the error string.
452 */
453int nfs_mkdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
454/*
455 * Sync mkdir()
456 * Function returns
457 * 0 : Success
458 * -errno : An error occured.
459 */
e2ba5764 460int nfs_mkdir(struct nfs_context *nfs, const char *path);
84004dbf
RS
461
462
463
464/*
465 * RMDIR()
466 */
467/*
468 * Async rmdir()
469 *
470 * Function returns
471 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
472 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
473 *
474 * When the callback is invoked, status indicates the result:
475 * 0 : Success.
476 * -errno : An error occured.
477 * data is the error string.
478 */
479int nfs_rmdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
480/*
481 * Sync rmdir()
482 * Function returns
483 * 0 : Success
484 * -errno : An error occured.
485 */
e2ba5764 486int nfs_rmdir(struct nfs_context *nfs, const char *path);
84004dbf
RS
487
488
489
490
491/*
492 * CREAT()
493 */
494/*
495 * Async creat()
496 *
497 * Function returns
498 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
499 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
500 *
501 * When the callback is invoked, status indicates the result:
502 * 0 : Success.
503 * data is a struct *nfsfh;
504 * -errno : An error occured.
505 * data is the error string.
506 */
507int nfs_creat_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
508/*
509 * Sync creat()
510 * Function returns
511 * 0 : Success
512 * -errno : An error occured.
513 */
e2ba5764 514int nfs_creat(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh);
84004dbf
RS
515
516
517
518
519
520/*
521 * UNLINK()
522 */
523/*
524 * Async unlink()
525 *
526 * Function returns
527 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
528 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
529 *
530 * When the callback is invoked, status indicates the result:
531 * 0 : Success.
532 * data is NULL
533 * -errno : An error occured.
534 * data is the error string.
535 */
536int nfs_unlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
537/*
538 * Sync unlink()
539 * Function returns
540 * 0 : Success
541 * -errno : An error occured.
542 */
e2ba5764 543int nfs_unlink(struct nfs_context *nfs, const char *path);
84004dbf
RS
544
545
546
547
548/*
549 * OPENDIR()
550 */
551struct nfsdir;
552/*
553 * Async opendir()
554 *
555 * Function returns
556 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
557 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
558 *
559 * When struct nfsdir * is returned, this resource is closed/freed by calling nfs_closedir()
560 *
561 * When the callback is invoked, status indicates the result:
562 * 0 : Success.
563 * data is struct nfsdir *
564 * -errno : An error occured.
565 * data is the error string.
566 */
567int nfs_opendir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
568/*
569 * Sync opendir()
570 * Function returns
571 * 0 : Success
572 * -errno : An error occured.
573 */
e2ba5764 574int nfs_opendir(struct nfs_context *nfs, const char *path, struct nfsdir **nfsdir);
84004dbf
RS
575
576
577
578/*
579 * READDIR()
580 */
581struct nfsdirent {
582 struct nfsdirent *next;
583 char *name;
584 uint64_t inode;
0804e67d
RS
585
586 /* some extra fields we get for free through the READDIRPLUS3 call. You need libnfs-raw-nfs.h for these */
587 uint32_t type; /* NF3REG, NF3DIR, NF3BLK, ... */
588 uint32_t mode;
589 uint64_t size;
590 struct timeval atime;
591 struct timeval mtime;
592 struct timeval ctime;
84004dbf
RS
593};
594/*
595 * nfs_readdir() never blocks, so no special sync/async versions are available
596 */
597struct nfsdirent *nfs_readdir(struct nfs_context *nfs, struct nfsdir *nfsdir);
598
599
600
601/*
602 * READDIR()
603 */
604/*
605 * nfs_closedir() never blocks, so no special sync/async versions are available
606 */
607void nfs_closedir(struct nfs_context *nfs, struct nfsdir *nfsdir);
608
609
610
611/*
612 * STATVFS()
613 */
614/*
615 * Async statvfs(<dirname>)
616 * Function returns
617 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
618 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
619 *
620 * When the callback is invoked, status indicates the result:
621 * 0 : Success.
622 * data is struct statvfs *
623 * -errno : An error occured.
624 * data is the error string.
625 */
626struct statvfs;
627int nfs_statvfs_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
628/*
629 * Sync statvfs(<dirname>)
630 * Function returns
631 * 0 : The operation was successfull.
632 * -errno : The command failed.
633 */
e2ba5764 634int nfs_statvfs(struct nfs_context *nfs, const char *path, struct statvfs *svfs);
84004dbf
RS
635
636
637/*
638 * READLINK()
639 */
640/*
641 * Async readlink(<name>)
642 * Function returns
643 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
644 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
645 *
646 * When the callback is invoked, status indicates the result:
647 * 0 : Success.
648 * data is a char *
649 * data is only valid during the callback and is automatically freed when the callback returns.
650 * -errno : An error occured.
651 * data is the error string.
652 */
653struct statvfs;
654int nfs_readlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
655/*
656 * Sync readlink(<name>)
657 * Function returns
658 * 0 : The operation was successfull.
659 * -errno : The command failed.
660 */
e2ba5764 661int nfs_readlink(struct nfs_context *nfs, const char *path, char *buf, int bufsize);
84004dbf
RS
662
663
664
665/*
666 * CHMOD()
667 */
668/*
669 * Async chmod(<name>)
670 * Function returns
671 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
672 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
673 *
674 * When the callback is invoked, status indicates the result:
675 * 0 : Success.
676 * data is NULL
677 * -errno : An error occured.
678 * data is the error string.
679 */
680int nfs_chmod_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
681/*
682 * Sync chmod(<name>)
683 * Function returns
684 * 0 : The operation was successfull.
685 * -errno : The command failed.
686 */
e2ba5764 687int nfs_chmod(struct nfs_context *nfs, const char *path, int mode);
84004dbf
RS
688
689
690
691/*
692 * FCHMOD()
693 */
694/*
695 * Async fchmod(<handle>)
696 * Function returns
697 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
698 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
699 *
700 * When the callback is invoked, status indicates the result:
701 * 0 : Success.
702 * data is NULL
703 * -errno : An error occured.
704 * data is the error string.
705 */
706int nfs_fchmod_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode, nfs_cb cb, void *private_data);
707/*
708 * Sync fchmod(<handle>)
709 * Function returns
710 * 0 : The operation was successfull.
711 * -errno : The command failed.
712 */
e2ba5764 713int nfs_fchmod(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode);
84004dbf
RS
714
715
716
717/*
718 * CHOWN()
719 */
720/*
721 * Async chown(<name>)
722 * Function returns
723 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
724 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
725 *
726 * When the callback is invoked, status indicates the result:
727 * 0 : Success.
728 * data is NULL
729 * -errno : An error occured.
730 * data is the error string.
731 */
732int nfs_chown_async(struct nfs_context *nfs, const char *path, int uid, int gid, nfs_cb cb, void *private_data);
733/*
734 * Sync chown(<name>)
735 * Function returns
736 * 0 : The operation was successfull.
737 * -errno : The command failed.
738 */
e2ba5764 739int nfs_chown(struct nfs_context *nfs, const char *path, int uid, int gid);
84004dbf
RS
740
741
742
743/*
744 * FCHOWN()
745 */
746/*
747 * Async fchown(<handle>)
748 * Function returns
749 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
750 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
751 *
752 * When the callback is invoked, status indicates the result:
753 * 0 : Success.
754 * data is NULL
755 * -errno : An error occured.
756 * data is the error string.
757 */
758int nfs_fchown_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid, nfs_cb cb, void *private_data);
759/*
760 * Sync fchown(<handle>)
761 * Function returns
762 * 0 : The operation was successfull.
763 * -errno : The command failed.
764 */
e2ba5764 765int nfs_fchown(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid);
84004dbf
RS
766
767
768
769
770/*
771 * UTIMES()
772 */
773/*
774 * Async utimes(<path>)
775 * Function returns
776 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
777 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
778 *
779 * When the callback is invoked, status indicates the result:
780 * 0 : Success.
781 * data is NULL
782 * -errno : An error occured.
783 * data is the error string.
784 */
785int nfs_utimes_async(struct nfs_context *nfs, const char *path, struct timeval *times, nfs_cb cb, void *private_data);
786/*
787 * Sync utimes(<path>)
788 * Function returns
789 * 0 : The operation was successfull.
790 * -errno : The command failed.
791 */
e2ba5764 792int nfs_utimes(struct nfs_context *nfs, const char *path, struct timeval *times);
84004dbf
RS
793
794
795/*
796 * UTIME()
797 */
798/*
799 * Async utime(<path>)
800 * Function returns
801 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
802 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
803 *
804 * When the callback is invoked, status indicates the result:
805 * 0 : Success.
806 * data is NULL
807 * -errno : An error occured.
808 * data is the error string.
809 */
810struct utimbuf;
811int nfs_utime_async(struct nfs_context *nfs, const char *path, struct utimbuf *times, nfs_cb cb, void *private_data);
812/*
813 * Sync utime(<path>)
814 * Function returns
815 * 0 : The operation was successfull.
816 * -errno : The command failed.
817 */
e2ba5764 818int nfs_utime(struct nfs_context *nfs, const char *path, struct utimbuf *times);
84004dbf
RS
819
820
821
822
823/*
824 * ACCESS()
825 */
826/*
827 * Async access(<path>)
828 * Function returns
829 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
830 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
831 *
832 * When the callback is invoked, status indicates the result:
833 * 0 : Success.
834 * data is NULL
835 * -errno : An error occured.
836 * data is the error string.
837 */
838int nfs_access_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
839/*
840 * Sync access(<path>)
841 * Function returns
842 * 0 : The operation was successfull.
843 * -errno : The command failed.
844 */
e2ba5764 845int nfs_access(struct nfs_context *nfs, const char *path, int mode);
84004dbf
RS
846
847
848
849
850/*
851 * SYMLINK()
852 */
853/*
854 * Async symlink(<path>)
855 * Function returns
856 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
857 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
858 *
859 * When the callback is invoked, status indicates the result:
860 * 0 : Success.
861 * data is NULL
862 * -errno : An error occured.
863 * data is the error string.
864 */
865int nfs_symlink_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data);
866/*
867 * Sync symlink(<path>)
868 * Function returns
869 * 0 : The operation was successfull.
870 * -errno : The command failed.
871 */
e2ba5764 872int nfs_symlink(struct nfs_context *nfs, const char *oldpath, const char *newpath);
84004dbf
RS
873
874
875/*
876 * RENAME()
877 */
878/*
879 * Async rename(<oldpath>, <newpath>)
880 * Function returns
881 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
882 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
883 *
884 * When the callback is invoked, status indicates the result:
885 * 0 : Success.
886 * data is NULL
887 * -errno : An error occured.
888 * data is the error string.
889 */
890int nfs_rename_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data);
891/*
892 * Sync rename(<oldpath>, <newpath>)
893 * Function returns
894 * 0 : The operation was successfull.
895 * -errno : The command failed.
896 */
e2ba5764 897int nfs_rename(struct nfs_context *nfs, const char *oldpath, const char *newpath);
84004dbf
RS
898
899
900
901/*
902 * LINK()
903 */
904/*
905 * Async link(<oldpath>, <newpath>)
906 * Function returns
907 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
908 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
909 *
910 * When the callback is invoked, status indicates the result:
911 * 0 : Success.
912 * data is NULL
913 * -errno : An error occured.
914 * data is the error string.
915 */
916int nfs_link_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data);
917/*
918 * Sync link(<oldpath>, <newpath>)
919 * Function returns
920 * 0 : The operation was successfull.
921 * -errno : The command failed.
922 */
e2ba5764 923int nfs_link(struct nfs_context *nfs, const char *oldpath, const char *newpath);
84004dbf
RS
924
925
7f0242ca
RS
926/*
927 * GETEXPORTS()
928 */
929/*
930 * Async getexports()
931 * NOTE: You must include 'libnfs-raw-mount.h' to get the definitions of the
932 * returned structures.
933 *
934 * This function will return the list of exports from an NFS server.
935 *
936 * Function returns
937 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
938 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
939 *
940 * When the callback is invoked, status indicates the result:
941 * 0 : Success.
942 * data is a pointer to an exports pointer:
943 * exports export = *(exports *)data;
944 * -errno : An error occured.
945 * data is the error string.
946 */
947int mount_getexports_async(struct rpc_context *rpc, const char *server, rpc_cb cb, void *private_data);
df5af25f
RS
948/*
949 * Sync getexports(<server>)
950 * Function returns
951 * NULL : something failed
952 * exports export : a linked list of exported directories
953 *
954 * returned data must be freed by calling mount_free_export_list(exportnode);
955 */
e210bd2a 956struct exportnode *mount_getexports(const char *server);
7f0242ca 957
df5af25f 958void mount_free_export_list(struct exportnode *exports);
7f0242ca 959
84004dbf
RS
960
961//qqq replace later with lseek(cur, 0)
962off_t nfs_get_current_offset(struct nfsfh *nfsfh);
552c7665
RS
963
964
965
9c4212bf
RS
966
967
552c7665
RS
968struct nfs_server_list {
969 struct nfs_server_list *next;
970 char *addr;
971};
972
9c4212bf
RS
973/*
974 * Sync find_local_servers(<server>)
975 * This function will probe all local networks for NFS server. This function will
976 * block for one second while awaiting for all nfs servers to respond.
977 *
978 * Function returns
979 * NULL : something failed
980 *
981 * struct nfs_server_list : a linked list of all discovered servers
982 *
983 * returned data must be freed by nfs_free_srvr_list(srv);
984 */
552c7665
RS
985struct nfs_server_list *nfs_find_local_servers(void);
986void free_nfs_srvr_list(struct nfs_server_list *srv);