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