Commit | Line | Data |
---|---|---|
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 | */ | |
52014ebf AR |
20 | |
21 | #ifndef _LIBNFS_H_ | |
22 | #define _LIBNFS_H_ | |
23 | ||
84004dbf | 24 | #include <stdint.h> |
252aa90d CF |
25 | #if defined(ANDROID) |
26 | #include <sys/time.h> | |
27 | #endif | |
d7c6e9aa RS |
28 | #if defined(AROS) |
29 | #include <sys/time.h> | |
30 | #endif | |
bd2f43c8 M |
31 | #if defined(__APPLE__) && defined(__MACH__) |
32 | #include <sys/time.h> | |
33 | #endif | |
84004dbf | 34 | |
d48be00c AR |
35 | #ifdef __cplusplus |
36 | extern "C" { | |
37 | #endif | |
38 | ||
3ca2aac9 PL |
39 | #define LIBNFS_FEATURE_READAHEAD |
40 | #define NFS_BLKSIZE 4096 | |
41 | ||
84004dbf | 42 | struct nfs_context; |
7f0242ca | 43 | struct rpc_context; |
84004dbf | 44 | |
d2ec73c7 PL |
45 | struct nfs_url { |
46 | char *server; | |
47 | char *path; | |
48 | char *file; | |
49 | }; | |
50 | ||
66ad6d84 RS |
51 | #if defined(WIN32) |
52 | #define EXTERN __declspec( dllexport ) | |
53 | #else | |
52014ebf | 54 | #define EXTERN |
66ad6d84 RS |
55 | #endif |
56 | ||
eecdc4f3 RS |
57 | #if defined(WIN32) |
58 | struct statvfs { | |
59 | uint32_t f_bsize; | |
60 | uint32_t f_frsize; | |
61 | uint64_t f_blocks; | |
62 | uint64_t f_bfree; | |
63 | uint64_t f_bavail; | |
64 | uint32_t f_files; | |
65 | uint32_t f_ffree; | |
66 | uint32_t f_favail; | |
52014ebf | 67 | uint32_t f_fsid; |
eecdc4f3 RS |
68 | uint32_t f_flag; |
69 | uint32_t f_namemax; | |
70 | }; | |
71 | struct utimbuf { | |
72 | time_t actime; | |
73 | time_t modtime; | |
74 | }; | |
75 | #define R_OK 4 | |
76 | #define W_OK 2 | |
77 | #define X_OK 1 | |
78 | #endif | |
79 | ||
84004dbf RS |
80 | /* |
81 | * Used for interfacing the async version of the api into an external eventsystem | |
82 | */ | |
66ad6d84 RS |
83 | EXTERN int nfs_get_fd(struct nfs_context *nfs); |
84 | EXTERN int nfs_which_events(struct nfs_context *nfs); | |
85 | EXTERN int nfs_service(struct nfs_context *nfs, int revents); | |
83aa785d | 86 | EXTERN int nfs_queue_length(struct nfs_context *nfs); |
84004dbf RS |
87 | |
88 | /* | |
89 | * Used if you need different credentials than the default for the current user. | |
90 | */ | |
67ba2239 RS |
91 | struct AUTH; |
92 | EXTERN void nfs_set_auth(struct nfs_context *nfs, struct AUTH *auth); | |
84004dbf | 93 | |
84004dbf RS |
94 | /* |
95 | * When an operation failed, this function can extract a detailed error string. | |
96 | */ | |
66ad6d84 | 97 | EXTERN char *nfs_get_error(struct nfs_context *nfs); |
84004dbf RS |
98 | |
99 | ||
100 | /* | |
101 | * Callback for all ASYNC nfs functions | |
102 | */ | |
103 | typedef void (*nfs_cb)(int err, struct nfs_context *nfs, void *data, void *private_data); | |
104 | ||
7f0242ca RS |
105 | /* |
106 | * Callback for all ASYNC rpc functions | |
107 | */ | |
108 | typedef void (*rpc_cb)(struct rpc_context *rpc, int status, void *data, void *private_data); | |
84004dbf RS |
109 | |
110 | ||
111 | ||
112 | /* | |
113 | * NFS CONTEXT. | |
114 | */ | |
115 | /* | |
116 | * Create an NFS c, the context. | |
117 | * Function returns | |
118 | * NULL : Failed to create a context. | |
119 | * *nfs : A pointer to an nfs context. | |
120 | */ | |
66ad6d84 | 121 | EXTERN struct nfs_context *nfs_init_context(void); |
84004dbf RS |
122 | /* |
123 | * Destroy an nfs context. | |
124 | */ | |
66ad6d84 | 125 | EXTERN void nfs_destroy_context(struct nfs_context *nfs); |
84004dbf RS |
126 | |
127 | ||
0961765a RS |
128 | /* |
129 | * URL parsing functions. | |
52014ebf | 130 | * These functions all parse a URL of the form |
0961765a RS |
131 | * nfs://server/path/file?argv=val[&arg=val]* |
132 | * and returns a nfs_url. | |
133 | * | |
134 | * Apart from parsing the URL the functions will also update | |
135 | * the nfs context to reflect settings controlled via url arguments. | |
136 | * | |
137 | * Current URL arguments are : | |
138 | * tcp-syncnt=<int> : Number of SYNs to send during the seccion establish | |
139 | * before failing settin up the tcp connection to the | |
140 | * server. | |
141 | * uid=<int> : UID value to use when talking to the server. | |
142 | * default it 65534 on Windows and getuid() on unixen. | |
143 | * gid=<int> : GID value to use when talking to the server. | |
144 | * default it 65534 on Windows and getgid() on unixen. | |
145 | */ | |
d2ec73c7 PL |
146 | /* |
147 | * Parse a complete NFS URL including, server, path and | |
148 | * filename. Fail if any component is missing. | |
149 | */ | |
150 | EXTERN struct nfs_url *nfs_parse_url_full(struct nfs_context *nfs, const char *url); | |
151 | ||
152 | /* | |
153 | * Parse an NFS URL, but do not split path and file. File | |
154 | * in the resulting struct remains NULL. | |
155 | */ | |
156 | EXTERN struct nfs_url *nfs_parse_url_dir(struct nfs_context *nfs, const char *url); | |
157 | ||
158 | /* | |
159 | * Parse an NFS URL, but do not fail if file, path or even server is missing. | |
160 | * Check elements of the resulting struct for NULL. | |
161 | */ | |
162 | EXTERN struct nfs_url *nfs_parse_url_incomplete(struct nfs_context *nfs, const char *url); | |
163 | ||
164 | ||
165 | /* | |
166 | * Free the URL struct returned by the nfs_parse_url_* functions. | |
167 | */ | |
168 | EXTERN void nfs_destroy_url(struct nfs_url *url); | |
169 | ||
170 | ||
84004dbf RS |
171 | struct nfsfh; |
172 | ||
17ef62fa RS |
173 | /* |
174 | * Get the maximum supported READ3 size by the server | |
175 | */ | |
183451cf | 176 | EXTERN uint64_t nfs_get_readmax(struct nfs_context *nfs); |
17ef62fa RS |
177 | |
178 | /* | |
179 | * Get the maximum supported WRITE3 size by the server | |
180 | */ | |
183451cf | 181 | EXTERN uint64_t nfs_get_writemax(struct nfs_context *nfs); |
17ef62fa | 182 | |
d43a8953 | 183 | /* |
52014ebf | 184 | * MODIFY CONNECT PARAMTERS |
d43a8953 PL |
185 | */ |
186 | ||
187 | EXTERN void nfs_set_tcp_syncnt(struct nfs_context *nfs, int v); | |
188 | EXTERN void nfs_set_uid(struct nfs_context *nfs, int uid); | |
189 | EXTERN void nfs_set_gid(struct nfs_context *nfs, int gid); | |
3ca2aac9 | 190 | EXTERN void nfs_set_readahead(struct nfs_context *nfs, uint32_t v); |
84004dbf RS |
191 | |
192 | /* | |
193 | * MOUNT THE EXPORT | |
194 | */ | |
195 | /* | |
196 | * Async nfs mount. | |
197 | * Function returns | |
198 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
199 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
200 | * | |
201 | * When the callback is invoked, status indicates the result: | |
202 | * 0 : Success. | |
203 | * data is NULL | |
204 | * -errno : An error occured. | |
205 | * data is the error string. | |
206 | */ | |
66ad6d84 | 207 | EXTERN int nfs_mount_async(struct nfs_context *nfs, const char *server, const char *exportname, nfs_cb cb, void *private_data); |
84004dbf RS |
208 | /* |
209 | * Sync nfs mount. | |
210 | * Function returns | |
211 | * 0 : The operation was successfull. | |
212 | * -errno : The command failed. | |
213 | */ | |
66ad6d84 | 214 | EXTERN int nfs_mount(struct nfs_context *nfs, const char *server, const char *exportname); |
84004dbf RS |
215 | |
216 | ||
217 | ||
218 | ||
219 | /* | |
220 | * STAT() | |
221 | */ | |
222 | /* | |
223 | * Async stat(<filename>) | |
224 | * Function returns | |
225 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
226 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
227 | * | |
228 | * When the callback is invoked, status indicates the result: | |
229 | * 0 : Success. | |
230 | * data is struct stat * | |
231 | * -errno : An error occured. | |
232 | * data is the error string. | |
233 | */ | |
479302f7 | 234 | /* This function is deprecated. Use nfs_stat64_async() instead */ |
84004dbf | 235 | struct stat; |
66ad6d84 | 236 | EXTERN int nfs_stat_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); |
84004dbf RS |
237 | /* |
238 | * Sync stat(<filename>) | |
239 | * Function returns | |
240 | * 0 : The operation was successfull. | |
241 | * -errno : The command failed. | |
242 | */ | |
479302f7 | 243 | /* This function is deprecated. Use nfs_stat64() instead */ |
be184101 M |
244 | #ifdef WIN32 |
245 | EXTERN int nfs_stat(struct nfs_context *nfs, const char *path, struct __stat64 *st); | |
246 | #else | |
66ad6d84 | 247 | EXTERN int nfs_stat(struct nfs_context *nfs, const char *path, struct stat *st); |
be184101 | 248 | #endif |
84004dbf | 249 | |
479302f7 RS |
250 | |
251 | /* nfs_stat64 | |
252 | * 64 bit version if stat. All fields are always 64bit. | |
253 | * Use these functions instead of nfs_stat[_async](), especially if you | |
254 | * have weird stat structures. | |
255 | */ | |
256 | /* | |
257 | * STAT() | |
258 | */ | |
259 | struct nfs_stat_64 { | |
260 | uint64_t nfs_dev; | |
261 | uint64_t nfs_ino; | |
262 | uint64_t nfs_mode; | |
263 | uint64_t nfs_nlink; | |
264 | uint64_t nfs_uid; | |
265 | uint64_t nfs_gid; | |
266 | uint64_t nfs_rdev; | |
267 | uint64_t nfs_size; | |
268 | uint64_t nfs_blksize; | |
269 | uint64_t nfs_blocks; | |
270 | uint64_t nfs_atime; | |
271 | uint64_t nfs_mtime; | |
272 | uint64_t nfs_ctime; | |
fc08ac45 RL |
273 | uint64_t nfs_atime_nsec; |
274 | uint64_t nfs_mtime_nsec; | |
275 | uint64_t nfs_ctime_nsec; | |
276 | uint64_t nfs_used; | |
479302f7 RS |
277 | }; |
278 | ||
279 | /* | |
280 | * Async stat(<filename>) | |
281 | * Function returns | |
282 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
283 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
284 | * | |
285 | * When the callback is invoked, status indicates the result: | |
286 | * 0 : Success. | |
287 | * data is struct nfs_stat_64 * | |
288 | * -errno : An error occured. | |
289 | * data is the error string. | |
290 | */ | |
291 | EXTERN int nfs_stat64_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); | |
292 | /* | |
293 | * Sync stat(<filename>) | |
294 | * Function returns | |
295 | * 0 : The operation was successfull. | |
296 | * -errno : The command failed. | |
297 | */ | |
298 | EXTERN int nfs_stat64(struct nfs_context *nfs, const char *path, struct nfs_stat_64 *st); | |
299 | ||
bf769f96 RL |
300 | /* |
301 | * Async stat(<filename>) | |
302 | * | |
303 | * Like stat except if the destination is a symbolic link, it acts on the | |
304 | * symbolic link itself. | |
305 | * | |
306 | * Function returns | |
307 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
308 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
309 | * | |
310 | * When the callback is invoked, status indicates the result: | |
311 | * 0 : Success. | |
312 | * data is struct nfs_stat_64 * | |
313 | * -errno : An error occured. | |
314 | * data is the error string. | |
315 | */ | |
316 | EXTERN int nfs_lstat64_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); | |
317 | /* | |
318 | * Sync stat(<filename>) | |
319 | * | |
320 | * Like stat except if the destination is a symbolic link, it acts on the | |
321 | * symbolic link itself. | |
322 | * | |
323 | * Function returns | |
324 | * 0 : The operation was successfull. | |
325 | * -errno : The command failed. | |
326 | */ | |
327 | EXTERN int nfs_lstat64(struct nfs_context *nfs, const char *path, struct nfs_stat_64 *st); | |
328 | ||
84004dbf RS |
329 | /* |
330 | * FSTAT() | |
331 | */ | |
332 | /* | |
333 | * Async fstat(nfsfh *) | |
334 | * Function returns | |
335 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
336 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
337 | * | |
338 | * When the callback is invoked, status indicates the result: | |
339 | * 0 : Success. | |
340 | * data is struct stat * | |
341 | * -errno : An error occured. | |
342 | * data is the error string. | |
343 | */ | |
3e020c15 | 344 | /* This function is deprecated. Use nfs_fstat64_async() instead */ |
66ad6d84 | 345 | EXTERN int nfs_fstat_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data); |
84004dbf RS |
346 | /* |
347 | * Sync fstat(nfsfh *) | |
348 | * Function returns | |
349 | * 0 : The operation was successfull. | |
350 | * -errno : The command failed. | |
351 | */ | |
be184101 M |
352 | #ifdef WIN32 |
353 | EXTERN int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct __stat64 *st); | |
354 | #else | |
66ad6d84 | 355 | EXTERN int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct stat *st); |
be184101 | 356 | #endif |
84004dbf | 357 | |
3e020c15 RL |
358 | /* nfs_fstat64 |
359 | * 64 bit version of fstat. All fields are always 64bit. | |
360 | * Use these functions instead of nfs_fstat[_async](), especially if you | |
361 | * have weird stat structures. | |
362 | */ | |
363 | /* | |
364 | * FSTAT() | |
365 | */ | |
366 | /* | |
367 | * Async fstat(nfsfh *) | |
368 | * Function returns | |
369 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
370 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
371 | * | |
372 | * When the callback is invoked, status indicates the result: | |
373 | * 0 : Success. | |
374 | * data is struct stat * | |
375 | * -errno : An error occured. | |
376 | * data is the error string. | |
377 | */ | |
378 | EXTERN int nfs_fstat64_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data); | |
379 | /* | |
380 | * Sync fstat(nfsfh *) | |
381 | * Function returns | |
382 | * 0 : The operation was successfull. | |
383 | * -errno : The command failed. | |
384 | */ | |
385 | EXTERN int nfs_fstat64(struct nfs_context *nfs, struct nfsfh *nfsfh, struct nfs_stat_64 *st); | |
386 | ||
84004dbf RS |
387 | |
388 | ||
389 | /* | |
390 | * OPEN() | |
391 | */ | |
392 | /* | |
393 | * Async open(<filename>) | |
394 | * | |
548e2bea | 395 | * mode is a combination of the flags : |
00b29d10 | 396 | * O_RDOLNY, O_WRONLY, O_RDWR , O_SYNC, O_APPEND, O_TRUNC |
84004dbf RS |
397 | * |
398 | * Function returns | |
399 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
400 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
401 | * | |
3cea44dc | 402 | * Supported flags are |
548e2bea | 403 | * O_APPEND |
3cea44dc RS |
404 | * O_RDONLY |
405 | * O_WRONLY | |
406 | * O_RDWR | |
00b29d10 | 407 | * O_SYNC |
22a0f15b | 408 | * O_TRUNC (Only valid with O_RDWR or O_WRONLY. Ignored otherwise.) |
3cea44dc | 409 | * |
84004dbf RS |
410 | * When the callback is invoked, status indicates the result: |
411 | * 0 : Success. | |
412 | * data is a struct *nfsfh; | |
413 | * The nfsfh is close using nfs_close(). | |
414 | * -errno : An error occured. | |
415 | * data is the error string. | |
416 | */ | |
3cea44dc | 417 | EXTERN int nfs_open_async(struct nfs_context *nfs, const char *path, int flags, nfs_cb cb, void *private_data); |
84004dbf | 418 | /* |
f893b680 | 419 | * Sync open(<filename>) |
84004dbf RS |
420 | * Function returns |
421 | * 0 : The operation was successfull. *nfsfh is filled in. | |
422 | * -errno : The command failed. | |
423 | */ | |
3cea44dc | 424 | EXTERN int nfs_open(struct nfs_context *nfs, const char *path, int flags, struct nfsfh **nfsfh); |
84004dbf RS |
425 | |
426 | ||
427 | ||
428 | ||
429 | /* | |
430 | * CLOSE | |
431 | */ | |
432 | /* | |
433 | * Async close(nfsfh) | |
434 | * | |
435 | * Function returns | |
436 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
437 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
438 | * | |
439 | * When the callback is invoked, status indicates the result: | |
440 | * 0 : Success. | |
441 | * data is NULL. | |
442 | * -errno : An error occured. | |
443 | * data is the error string. | |
444 | */ | |
66ad6d84 | 445 | EXTERN int nfs_close_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data); |
84004dbf RS |
446 | /* |
447 | * Sync close(nfsfh) | |
448 | * Function returns | |
449 | * 0 : The operation was successfull. | |
450 | * -errno : The command failed. | |
451 | */ | |
66ad6d84 | 452 | EXTERN int nfs_close(struct nfs_context *nfs, struct nfsfh *nfsfh); |
84004dbf RS |
453 | |
454 | ||
455 | /* | |
456 | * PREAD() | |
457 | */ | |
458 | /* | |
459 | * Async pread() | |
460 | * | |
461 | * Function returns | |
462 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
463 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
464 | * | |
465 | * When the callback is invoked, status indicates the result: | |
466 | * >=0 : Success. | |
467 | * status is numer of bytes read. | |
468 | * data is a pointer to the returned data. | |
469 | * -errno : An error occured. | |
470 | * data is the error string. | |
471 | */ | |
183451cf | 472 | EXTERN int nfs_pread_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, uint64_t count, nfs_cb cb, void *private_data); |
84004dbf RS |
473 | /* |
474 | * Sync pread() | |
475 | * Function returns | |
476 | * >=0 : numer of bytes read. | |
477 | * -errno : An error occured. | |
478 | */ | |
183451cf | 479 | EXTERN int nfs_pread(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, uint64_t count, char *buf); |
84004dbf RS |
480 | |
481 | ||
482 | ||
483 | /* | |
484 | * READ() | |
485 | */ | |
486 | /* | |
487 | * Async read() | |
488 | * | |
489 | * Function returns | |
490 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
491 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
492 | * | |
493 | * When the callback is invoked, status indicates the result: | |
494 | * >=0 : Success. | |
495 | * status is numer of bytes read. | |
496 | * data is a pointer to the returned data. | |
497 | * -errno : An error occured. | |
498 | * data is the error string. | |
499 | */ | |
183451cf | 500 | EXTERN int nfs_read_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, nfs_cb cb, void *private_data); |
84004dbf RS |
501 | /* |
502 | * Sync read() | |
503 | * Function returns | |
504 | * >=0 : numer of bytes read. | |
505 | * -errno : An error occured. | |
506 | */ | |
183451cf | 507 | EXTERN int nfs_read(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, char *buf); |
84004dbf RS |
508 | |
509 | ||
510 | ||
511 | ||
512 | /* | |
513 | * PWRITE() | |
514 | */ | |
515 | /* | |
516 | * Async pwrite() | |
517 | * | |
518 | * Function returns | |
519 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
520 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
521 | * | |
522 | * When the callback is invoked, status indicates the result: | |
523 | * >=0 : Success. | |
524 | * status is numer of bytes written. | |
525 | * -errno : An error occured. | |
526 | * data is the error string. | |
527 | */ | |
183451cf | 528 | EXTERN int nfs_pwrite_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, uint64_t count, char *buf, nfs_cb cb, void *private_data); |
84004dbf RS |
529 | /* |
530 | * Sync pwrite() | |
531 | * Function returns | |
532 | * >=0 : numer of bytes written. | |
533 | * -errno : An error occured. | |
534 | */ | |
183451cf | 535 | EXTERN int nfs_pwrite(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, uint64_t count, char *buf); |
84004dbf RS |
536 | |
537 | ||
538 | /* | |
539 | * WRITE() | |
540 | */ | |
541 | /* | |
542 | * Async write() | |
543 | * | |
544 | * Function returns | |
545 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
546 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
547 | * | |
548 | * When the callback is invoked, status indicates the result: | |
549 | * >=0 : Success. | |
550 | * status is numer of bytes written. | |
551 | * -errno : An error occured. | |
552 | * data is the error string. | |
553 | */ | |
183451cf | 554 | EXTERN int nfs_write_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, char *buf, nfs_cb cb, void *private_data); |
84004dbf RS |
555 | /* |
556 | * Sync write() | |
557 | * Function returns | |
558 | * >=0 : numer of bytes written. | |
559 | * -errno : An error occured. | |
560 | */ | |
183451cf | 561 | EXTERN int nfs_write(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, char *buf); |
84004dbf RS |
562 | |
563 | ||
564 | /* | |
565 | * LSEEK() | |
566 | */ | |
567 | /* | |
568 | * Async lseek() | |
569 | * | |
570 | * Function returns | |
571 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
572 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
573 | * | |
574 | * When the callback is invoked, status indicates the result: | |
575 | * >=0 : Success. | |
183451cf | 576 | * data is uint64_t * for the current position. |
84004dbf RS |
577 | * -errno : An error occured. |
578 | * data is the error string. | |
579 | */ | |
1f1b6cb0 | 580 | EXTERN int nfs_lseek_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int64_t offset, int whence, nfs_cb cb, void *private_data); |
84004dbf RS |
581 | /* |
582 | * Sync lseek() | |
583 | * Function returns | |
584 | * >=0 : numer of bytes read. | |
585 | * -errno : An error occured. | |
586 | */ | |
1f1b6cb0 | 587 | EXTERN int nfs_lseek(struct nfs_context *nfs, struct nfsfh *nfsfh, int64_t offset, int whence, uint64_t *current_offset); |
84004dbf RS |
588 | |
589 | ||
590 | /* | |
591 | * FSYNC() | |
592 | */ | |
593 | /* | |
594 | * Async fsync() | |
595 | * | |
596 | * Function returns | |
597 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
598 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
599 | * | |
600 | * When the callback is invoked, status indicates the result: | |
601 | * 0 : Success. | |
602 | * -errno : An error occured. | |
603 | * data is the error string. | |
604 | */ | |
66ad6d84 | 605 | EXTERN int nfs_fsync_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data); |
84004dbf RS |
606 | /* |
607 | * Sync fsync() | |
608 | * Function returns | |
609 | * 0 : Success | |
610 | * -errno : An error occured. | |
611 | */ | |
66ad6d84 | 612 | EXTERN int nfs_fsync(struct nfs_context *nfs, struct nfsfh *nfsfh); |
84004dbf RS |
613 | |
614 | ||
615 | ||
616 | /* | |
617 | * TRUNCATE() | |
618 | */ | |
619 | /* | |
620 | * Async truncate() | |
621 | * | |
622 | * Function returns | |
623 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
624 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
625 | * | |
626 | * When the callback is invoked, status indicates the result: | |
627 | * 0 : Success. | |
628 | * -errno : An error occured. | |
629 | * data is the error string. | |
630 | */ | |
183451cf | 631 | EXTERN int nfs_truncate_async(struct nfs_context *nfs, const char *path, uint64_t length, nfs_cb cb, void *private_data); |
84004dbf RS |
632 | /* |
633 | * Sync truncate() | |
634 | * Function returns | |
635 | * 0 : Success | |
636 | * -errno : An error occured. | |
637 | */ | |
183451cf | 638 | EXTERN int nfs_truncate(struct nfs_context *nfs, const char *path, uint64_t length); |
84004dbf RS |
639 | |
640 | ||
641 | ||
642 | /* | |
643 | * FTRUNCATE() | |
644 | */ | |
645 | /* | |
646 | * Async ftruncate() | |
647 | * | |
648 | * Function returns | |
649 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
650 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
651 | * | |
652 | * When the callback is invoked, status indicates the result: | |
653 | * 0 : Success. | |
654 | * -errno : An error occured. | |
655 | * data is the error string. | |
656 | */ | |
183451cf | 657 | EXTERN int nfs_ftruncate_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t length, nfs_cb cb, void *private_data); |
84004dbf RS |
658 | /* |
659 | * Sync ftruncate() | |
660 | * Function returns | |
661 | * 0 : Success | |
662 | * -errno : An error occured. | |
663 | */ | |
183451cf | 664 | EXTERN int nfs_ftruncate(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t length); |
84004dbf RS |
665 | |
666 | ||
667 | ||
668 | ||
669 | ||
670 | ||
671 | /* | |
672 | * MKDIR() | |
673 | */ | |
674 | /* | |
675 | * Async mkdir() | |
676 | * | |
677 | * Function returns | |
678 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
679 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
680 | * | |
681 | * When the callback is invoked, status indicates the result: | |
682 | * 0 : Success. | |
683 | * -errno : An error occured. | |
684 | * data is the error string. | |
685 | */ | |
66ad6d84 | 686 | EXTERN int nfs_mkdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); |
84004dbf RS |
687 | /* |
688 | * Sync mkdir() | |
689 | * Function returns | |
690 | * 0 : Success | |
691 | * -errno : An error occured. | |
692 | */ | |
66ad6d84 | 693 | EXTERN int nfs_mkdir(struct nfs_context *nfs, const char *path); |
84004dbf RS |
694 | |
695 | ||
696 | ||
697 | /* | |
698 | * RMDIR() | |
699 | */ | |
700 | /* | |
701 | * Async rmdir() | |
702 | * | |
703 | * Function returns | |
704 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
705 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
706 | * | |
707 | * When the callback is invoked, status indicates the result: | |
708 | * 0 : Success. | |
709 | * -errno : An error occured. | |
710 | * data is the error string. | |
711 | */ | |
66ad6d84 | 712 | EXTERN int nfs_rmdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); |
84004dbf RS |
713 | /* |
714 | * Sync rmdir() | |
715 | * Function returns | |
716 | * 0 : Success | |
717 | * -errno : An error occured. | |
718 | */ | |
66ad6d84 | 719 | EXTERN int nfs_rmdir(struct nfs_context *nfs, const char *path); |
84004dbf RS |
720 | |
721 | ||
722 | ||
723 | ||
724 | /* | |
725 | * CREAT() | |
726 | */ | |
727 | /* | |
728 | * Async creat() | |
729 | * | |
730 | * Function returns | |
731 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
732 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
733 | * | |
734 | * When the callback is invoked, status indicates the result: | |
735 | * 0 : Success. | |
736 | * data is a struct *nfsfh; | |
737 | * -errno : An error occured. | |
738 | * data is the error string. | |
739 | */ | |
66ad6d84 | 740 | EXTERN int nfs_creat_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data); |
84004dbf RS |
741 | /* |
742 | * Sync creat() | |
743 | * Function returns | |
744 | * 0 : Success | |
745 | * -errno : An error occured. | |
746 | */ | |
66ad6d84 | 747 | EXTERN int nfs_creat(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh); |
84004dbf | 748 | |
037a1061 RL |
749 | /* |
750 | * Async create() | |
751 | * | |
752 | * Same as nfs_creat_async but allows passing flags: | |
753 | * O_APPEND | |
754 | * O_SYNC | |
755 | * O_EXCL | |
370c59e3 | 756 | * O_TRUNC |
037a1061 RL |
757 | * |
758 | * Function returns | |
759 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
760 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
761 | * | |
762 | * When the callback is invoked, status indicates the result: | |
763 | * 0 : Success. | |
764 | * data is a struct *nfsfh; | |
765 | * -errno : An error occured. | |
766 | * data is the error string. | |
767 | */ | |
768 | EXTERN int nfs_create_async(struct nfs_context *nfs, const char *path, int flags, int mode, nfs_cb cb, void *private_data); | |
769 | /* | |
770 | * Sync create() | |
771 | * Function returns | |
772 | * 0 : Success | |
773 | * -errno : An error occured. | |
774 | */ | |
775 | EXTERN int nfs_create(struct nfs_context *nfs, const char *path, int flags, int mode, struct nfsfh **nfsfh); | |
776 | ||
84004dbf | 777 | |
1ec6b50a RS |
778 | /* |
779 | * MKNOD() | |
780 | */ | |
781 | /* | |
782 | * Async mknod() | |
783 | * | |
784 | * Function returns | |
785 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
786 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
787 | * | |
788 | * When the callback is invoked, status indicates the result: | |
789 | * 0 : Success. | |
790 | * -errno : An error occured. | |
791 | * data is the error string. | |
792 | */ | |
793 | EXTERN int nfs_mknod_async(struct nfs_context *nfs, const char *path, int mode, int dev, nfs_cb cb, void *private_data); | |
794 | /* | |
795 | * Sync mknod() | |
796 | * Function returns | |
797 | * 0 : Success | |
798 | * -errno : An error occured. | |
799 | */ | |
800 | EXTERN int nfs_mknod(struct nfs_context *nfs, const char *path, int mode, int dev); | |
84004dbf RS |
801 | |
802 | ||
803 | ||
804 | /* | |
805 | * UNLINK() | |
806 | */ | |
807 | /* | |
808 | * Async unlink() | |
809 | * | |
810 | * Function returns | |
811 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
812 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
813 | * | |
814 | * When the callback is invoked, status indicates the result: | |
815 | * 0 : Success. | |
816 | * data is NULL | |
817 | * -errno : An error occured. | |
818 | * data is the error string. | |
819 | */ | |
66ad6d84 | 820 | EXTERN int nfs_unlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); |
84004dbf RS |
821 | /* |
822 | * Sync unlink() | |
823 | * Function returns | |
824 | * 0 : Success | |
825 | * -errno : An error occured. | |
826 | */ | |
66ad6d84 | 827 | EXTERN int nfs_unlink(struct nfs_context *nfs, const char *path); |
84004dbf RS |
828 | |
829 | ||
830 | ||
831 | ||
832 | /* | |
833 | * OPENDIR() | |
834 | */ | |
835 | struct nfsdir; | |
836 | /* | |
837 | * Async opendir() | |
838 | * | |
839 | * Function returns | |
840 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
841 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
842 | * | |
843 | * When struct nfsdir * is returned, this resource is closed/freed by calling nfs_closedir() | |
844 | * | |
845 | * When the callback is invoked, status indicates the result: | |
846 | * 0 : Success. | |
847 | * data is struct nfsdir * | |
848 | * -errno : An error occured. | |
849 | * data is the error string. | |
850 | */ | |
66ad6d84 | 851 | EXTERN int nfs_opendir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); |
84004dbf RS |
852 | /* |
853 | * Sync opendir() | |
854 | * Function returns | |
855 | * 0 : Success | |
856 | * -errno : An error occured. | |
857 | */ | |
66ad6d84 | 858 | EXTERN int nfs_opendir(struct nfs_context *nfs, const char *path, struct nfsdir **nfsdir); |
84004dbf RS |
859 | |
860 | ||
861 | ||
862 | /* | |
863 | * READDIR() | |
864 | */ | |
865 | struct nfsdirent { | |
866 | struct nfsdirent *next; | |
867 | char *name; | |
868 | uint64_t inode; | |
0804e67d | 869 | |
7bda8bad RS |
870 | /* Some extra fields we get for free through the READDIRPLUS3 call. |
871 | You need libnfs-raw-nfs.h for type/mode constants */ | |
0804e67d RS |
872 | uint32_t type; /* NF3REG, NF3DIR, NF3BLK, ... */ |
873 | uint32_t mode; | |
874 | uint64_t size; | |
875 | struct timeval atime; | |
876 | struct timeval mtime; | |
877 | struct timeval ctime; | |
7bda8bad RS |
878 | uint32_t uid; |
879 | uint32_t gid; | |
390ff38a | 880 | uint32_t nlink; |
fc08ac45 RL |
881 | uint64_t dev; |
882 | uint64_t rdev; | |
883 | uint64_t blksize; | |
884 | uint64_t blocks; | |
885 | uint64_t used; | |
886 | uint32_t atime_nsec; | |
887 | uint32_t mtime_nsec; | |
888 | uint32_t ctime_nsec; | |
84004dbf RS |
889 | }; |
890 | /* | |
891 | * nfs_readdir() never blocks, so no special sync/async versions are available | |
892 | */ | |
66ad6d84 | 893 | EXTERN struct nfsdirent *nfs_readdir(struct nfs_context *nfs, struct nfsdir *nfsdir); |
84004dbf RS |
894 | |
895 | ||
896 | ||
897 | /* | |
f893b680 | 898 | * CLOSEDIR() |
84004dbf RS |
899 | */ |
900 | /* | |
901 | * nfs_closedir() never blocks, so no special sync/async versions are available | |
902 | */ | |
66ad6d84 | 903 | EXTERN void nfs_closedir(struct nfs_context *nfs, struct nfsdir *nfsdir); |
84004dbf RS |
904 | |
905 | ||
f893b680 RS |
906 | /* |
907 | * CHDIR() | |
908 | */ | |
909 | /* | |
910 | * Async chdir(<path>) | |
911 | * | |
912 | * Function returns | |
913 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
914 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
915 | * | |
916 | * When the callback is invoked, status indicates the result: | |
917 | * 0 : Success. | |
918 | * data is NULL; | |
919 | * -errno : An error occured. | |
920 | * data is the error string. | |
921 | */ | |
922 | EXTERN int nfs_chdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); | |
923 | /* | |
924 | * Sync chdir(<path>) | |
925 | * Function returns | |
926 | * 0 : The operation was successfull. | |
927 | * -errno : The command failed. | |
928 | */ | |
929 | EXTERN int nfs_chdir(struct nfs_context *nfs, const char *path); | |
930 | ||
931 | /* | |
932 | * GETCWD() | |
933 | */ | |
934 | /* | |
935 | * nfs_getcwd() never blocks, so no special sync/async versions are available | |
936 | */ | |
937 | /* | |
938 | * Sync getcwd() | |
939 | * This function returns a pointer to the current working directory. | |
940 | * This pointer is only stable until the next [f]chdir or when the | |
941 | * context is destroyed. | |
942 | * | |
943 | * Function returns | |
944 | * 0 : The operation was successfull and *cwd is filled in. | |
945 | * -errno : The command failed. | |
946 | */ | |
947 | EXTERN void nfs_getcwd(struct nfs_context *nfs, const char **cwd); | |
948 | ||
84004dbf RS |
949 | |
950 | /* | |
951 | * STATVFS() | |
952 | */ | |
953 | /* | |
954 | * Async statvfs(<dirname>) | |
955 | * Function returns | |
956 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
957 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
958 | * | |
959 | * When the callback is invoked, status indicates the result: | |
960 | * 0 : Success. | |
961 | * data is struct statvfs * | |
962 | * -errno : An error occured. | |
963 | * data is the error string. | |
964 | */ | |
965 | struct statvfs; | |
66ad6d84 | 966 | EXTERN int nfs_statvfs_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); |
84004dbf RS |
967 | /* |
968 | * Sync statvfs(<dirname>) | |
969 | * Function returns | |
970 | * 0 : The operation was successfull. | |
971 | * -errno : The command failed. | |
972 | */ | |
66ad6d84 | 973 | EXTERN int nfs_statvfs(struct nfs_context *nfs, const char *path, struct statvfs *svfs); |
84004dbf RS |
974 | |
975 | ||
976 | /* | |
977 | * READLINK() | |
978 | */ | |
979 | /* | |
980 | * Async readlink(<name>) | |
981 | * Function returns | |
982 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
983 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
984 | * | |
985 | * When the callback is invoked, status indicates the result: | |
986 | * 0 : Success. | |
987 | * data is a char * | |
988 | * data is only valid during the callback and is automatically freed when the callback returns. | |
989 | * -errno : An error occured. | |
990 | * data is the error string. | |
991 | */ | |
992 | struct statvfs; | |
66ad6d84 | 993 | EXTERN int nfs_readlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); |
84004dbf RS |
994 | /* |
995 | * Sync readlink(<name>) | |
996 | * Function returns | |
997 | * 0 : The operation was successfull. | |
998 | * -errno : The command failed. | |
999 | */ | |
66ad6d84 | 1000 | EXTERN int nfs_readlink(struct nfs_context *nfs, const char *path, char *buf, int bufsize); |
84004dbf RS |
1001 | |
1002 | ||
1003 | ||
1004 | /* | |
1005 | * CHMOD() | |
1006 | */ | |
1007 | /* | |
1008 | * Async chmod(<name>) | |
1009 | * Function returns | |
1010 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
1011 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
1012 | * | |
1013 | * When the callback is invoked, status indicates the result: | |
1014 | * 0 : Success. | |
1015 | * data is NULL | |
1016 | * -errno : An error occured. | |
1017 | * data is the error string. | |
1018 | */ | |
66ad6d84 | 1019 | EXTERN int nfs_chmod_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data); |
84004dbf RS |
1020 | /* |
1021 | * Sync chmod(<name>) | |
1022 | * Function returns | |
1023 | * 0 : The operation was successfull. | |
1024 | * -errno : The command failed. | |
1025 | */ | |
66ad6d84 | 1026 | EXTERN int nfs_chmod(struct nfs_context *nfs, const char *path, int mode); |
8d590667 RL |
1027 | /* |
1028 | * Async chmod(<name>) | |
1029 | * | |
1030 | * Like chmod except if the destination is a symbolic link, it acts on the | |
1031 | * symbolic link itself. | |
1032 | * | |
1033 | * Function returns | |
1034 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
1035 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
1036 | * | |
1037 | * When the callback is invoked, status indicates the result: | |
1038 | * 0 : Success. | |
1039 | * data is NULL | |
1040 | * -errno : An error occured. | |
1041 | * data is the error string. | |
1042 | */ | |
1043 | EXTERN int nfs_lchmod_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data); | |
1044 | /* | |
1045 | * Sync chmod(<name>) | |
1046 | * | |
1047 | * Like chmod except if the destination is a symbolic link, it acts on the | |
1048 | * symbolic link itself. | |
1049 | * | |
1050 | * Function returns | |
1051 | * 0 : The operation was successfull. | |
1052 | * -errno : The command failed. | |
1053 | */ | |
1054 | EXTERN int nfs_lchmod(struct nfs_context *nfs, const char *path, int mode); | |
84004dbf RS |
1055 | |
1056 | ||
1057 | ||
1058 | /* | |
1059 | * FCHMOD() | |
1060 | */ | |
1061 | /* | |
1062 | * Async fchmod(<handle>) | |
1063 | * Function returns | |
1064 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
1065 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
1066 | * | |
1067 | * When the callback is invoked, status indicates the result: | |
1068 | * 0 : Success. | |
1069 | * data is NULL | |
1070 | * -errno : An error occured. | |
1071 | * data is the error string. | |
1072 | */ | |
66ad6d84 | 1073 | EXTERN int nfs_fchmod_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode, nfs_cb cb, void *private_data); |
84004dbf RS |
1074 | /* |
1075 | * Sync fchmod(<handle>) | |
1076 | * Function returns | |
1077 | * 0 : The operation was successfull. | |
1078 | * -errno : The command failed. | |
1079 | */ | |
66ad6d84 | 1080 | EXTERN int nfs_fchmod(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode); |
84004dbf RS |
1081 | |
1082 | ||
1083 | ||
1084 | /* | |
1085 | * CHOWN() | |
1086 | */ | |
1087 | /* | |
1088 | * Async chown(<name>) | |
1089 | * Function returns | |
1090 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
1091 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
1092 | * | |
1093 | * When the callback is invoked, status indicates the result: | |
1094 | * 0 : Success. | |
1095 | * data is NULL | |
1096 | * -errno : An error occured. | |
1097 | * data is the error string. | |
1098 | */ | |
66ad6d84 | 1099 | EXTERN int nfs_chown_async(struct nfs_context *nfs, const char *path, int uid, int gid, nfs_cb cb, void *private_data); |
84004dbf RS |
1100 | /* |
1101 | * Sync chown(<name>) | |
1102 | * Function returns | |
1103 | * 0 : The operation was successfull. | |
1104 | * -errno : The command failed. | |
1105 | */ | |
66ad6d84 | 1106 | EXTERN int nfs_chown(struct nfs_context *nfs, const char *path, int uid, int gid); |
5935a28a RL |
1107 | /* |
1108 | * Async chown(<name>) | |
1109 | * | |
1110 | * Like chown except if the destination is a symbolic link, it acts on the | |
1111 | * symbolic link itself. | |
1112 | * | |
1113 | * Function returns | |
1114 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
1115 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
1116 | * | |
1117 | * When the callback is invoked, status indicates the result: | |
1118 | * 0 : Success. | |
1119 | * data is NULL | |
1120 | * -errno : An error occured. | |
1121 | * data is the error string. | |
1122 | */ | |
1123 | EXTERN int nfs_lchown_async(struct nfs_context *nfs, const char *path, int uid, int gid, nfs_cb cb, void *private_data); | |
1124 | /* | |
1125 | * Sync chown(<name>) | |
1126 | * | |
1127 | * Like chown except if the destination is a symbolic link, it acts on the | |
1128 | * symbolic link itself. | |
1129 | * | |
1130 | * Function returns | |
1131 | * 0 : The operation was successfull. | |
1132 | * -errno : The command failed. | |
1133 | */ | |
1134 | EXTERN int nfs_lchown(struct nfs_context *nfs, const char *path, int uid, int gid); | |
84004dbf RS |
1135 | |
1136 | ||
1137 | ||
1138 | /* | |
1139 | * FCHOWN() | |
1140 | */ | |
1141 | /* | |
1142 | * Async fchown(<handle>) | |
1143 | * Function returns | |
1144 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
1145 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
1146 | * | |
1147 | * When the callback is invoked, status indicates the result: | |
1148 | * 0 : Success. | |
1149 | * data is NULL | |
1150 | * -errno : An error occured. | |
1151 | * data is the error string. | |
1152 | */ | |
66ad6d84 | 1153 | EXTERN int nfs_fchown_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid, nfs_cb cb, void *private_data); |
84004dbf RS |
1154 | /* |
1155 | * Sync fchown(<handle>) | |
1156 | * Function returns | |
1157 | * 0 : The operation was successfull. | |
1158 | * -errno : The command failed. | |
1159 | */ | |
66ad6d84 | 1160 | EXTERN int nfs_fchown(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid); |
84004dbf RS |
1161 | |
1162 | ||
1163 | ||
1164 | ||
1165 | /* | |
1166 | * UTIMES() | |
1167 | */ | |
1168 | /* | |
1169 | * Async utimes(<path>) | |
1170 | * Function returns | |
1171 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
1172 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
1173 | * | |
1174 | * When the callback is invoked, status indicates the result: | |
1175 | * 0 : Success. | |
1176 | * data is NULL | |
1177 | * -errno : An error occured. | |
1178 | * data is the error string. | |
1179 | */ | |
66ad6d84 | 1180 | EXTERN int nfs_utimes_async(struct nfs_context *nfs, const char *path, struct timeval *times, nfs_cb cb, void *private_data); |
84004dbf RS |
1181 | /* |
1182 | * Sync utimes(<path>) | |
1183 | * Function returns | |
1184 | * 0 : The operation was successfull. | |
1185 | * -errno : The command failed. | |
1186 | */ | |
66ad6d84 | 1187 | EXTERN int nfs_utimes(struct nfs_context *nfs, const char *path, struct timeval *times); |
6505b539 RL |
1188 | /* |
1189 | * Async utimes(<path>) | |
1190 | * | |
1191 | * Like utimes except if the destination is a symbolic link, it acts on the | |
1192 | * symbolic link itself. | |
1193 | * | |
1194 | * Function returns | |
1195 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
1196 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
1197 | * | |
1198 | * When the callback is invoked, status indicates the result: | |
1199 | * 0 : Success. | |
1200 | * data is NULL | |
1201 | * -errno : An error occured. | |
1202 | * data is the error string. | |
1203 | */ | |
1204 | EXTERN int nfs_lutimes_async(struct nfs_context *nfs, const char *path, struct timeval *times, nfs_cb cb, void *private_data); | |
1205 | /* | |
1206 | * Sync utimes(<path>) | |
1207 | * | |
1208 | * Like utimes except if the destination is a symbolic link, it acts on the | |
1209 | * symbolic link itself. | |
1210 | * | |
1211 | * Function returns | |
1212 | * 0 : The operation was successfull. | |
1213 | * -errno : The command failed. | |
1214 | */ | |
1215 | EXTERN int nfs_lutimes(struct nfs_context *nfs, const char *path, struct timeval *times); | |
84004dbf RS |
1216 | |
1217 | ||
1218 | /* | |
1219 | * UTIME() | |
1220 | */ | |
1221 | /* | |
1222 | * Async utime(<path>) | |
1223 | * Function returns | |
1224 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
1225 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
1226 | * | |
1227 | * When the callback is invoked, status indicates the result: | |
1228 | * 0 : Success. | |
1229 | * data is NULL | |
1230 | * -errno : An error occured. | |
1231 | * data is the error string. | |
1232 | */ | |
1233 | struct utimbuf; | |
66ad6d84 | 1234 | EXTERN int nfs_utime_async(struct nfs_context *nfs, const char *path, struct utimbuf *times, nfs_cb cb, void *private_data); |
84004dbf RS |
1235 | /* |
1236 | * Sync utime(<path>) | |
1237 | * Function returns | |
1238 | * 0 : The operation was successfull. | |
1239 | * -errno : The command failed. | |
1240 | */ | |
66ad6d84 | 1241 | EXTERN int nfs_utime(struct nfs_context *nfs, const char *path, struct utimbuf *times); |
84004dbf RS |
1242 | |
1243 | ||
1244 | ||
1245 | ||
1246 | /* | |
1247 | * ACCESS() | |
1248 | */ | |
1249 | /* | |
1250 | * Async access(<path>) | |
1251 | * Function returns | |
1252 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
1253 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
1254 | * | |
1255 | * When the callback is invoked, status indicates the result: | |
1256 | * 0 : Success. | |
1257 | * data is NULL | |
1258 | * -errno : An error occured. | |
1259 | * data is the error string. | |
1260 | */ | |
66ad6d84 | 1261 | EXTERN int nfs_access_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data); |
84004dbf RS |
1262 | /* |
1263 | * Sync access(<path>) | |
1264 | * Function returns | |
1265 | * 0 : The operation was successfull. | |
1266 | * -errno : The command failed. | |
1267 | */ | |
66ad6d84 | 1268 | EXTERN int nfs_access(struct nfs_context *nfs, const char *path, int mode); |
84004dbf RS |
1269 | |
1270 | ||
1271 | ||
1272 | ||
1273 | /* | |
1274 | * SYMLINK() | |
1275 | */ | |
1276 | /* | |
1277 | * Async symlink(<path>) | |
1278 | * Function returns | |
1279 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
1280 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
1281 | * | |
1282 | * When the callback is invoked, status indicates the result: | |
1283 | * 0 : Success. | |
1284 | * data is NULL | |
1285 | * -errno : An error occured. | |
1286 | * data is the error string. | |
1287 | */ | |
66ad6d84 | 1288 | EXTERN int nfs_symlink_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data); |
84004dbf RS |
1289 | /* |
1290 | * Sync symlink(<path>) | |
1291 | * Function returns | |
1292 | * 0 : The operation was successfull. | |
1293 | * -errno : The command failed. | |
1294 | */ | |
66ad6d84 | 1295 | EXTERN int nfs_symlink(struct nfs_context *nfs, const char *oldpath, const char *newpath); |
84004dbf RS |
1296 | |
1297 | ||
1298 | /* | |
1299 | * RENAME() | |
1300 | */ | |
1301 | /* | |
1302 | * Async rename(<oldpath>, <newpath>) | |
1303 | * Function returns | |
1304 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
1305 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
1306 | * | |
1307 | * When the callback is invoked, status indicates the result: | |
1308 | * 0 : Success. | |
1309 | * data is NULL | |
1310 | * -errno : An error occured. | |
1311 | * data is the error string. | |
1312 | */ | |
66ad6d84 | 1313 | EXTERN int nfs_rename_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data); |
84004dbf RS |
1314 | /* |
1315 | * Sync rename(<oldpath>, <newpath>) | |
1316 | * Function returns | |
1317 | * 0 : The operation was successfull. | |
1318 | * -errno : The command failed. | |
1319 | */ | |
66ad6d84 | 1320 | EXTERN int nfs_rename(struct nfs_context *nfs, const char *oldpath, const char *newpath); |
84004dbf RS |
1321 | |
1322 | ||
1323 | ||
1324 | /* | |
1325 | * LINK() | |
1326 | */ | |
1327 | /* | |
1328 | * Async link(<oldpath>, <newpath>) | |
1329 | * Function returns | |
1330 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
1331 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
1332 | * | |
1333 | * When the callback is invoked, status indicates the result: | |
1334 | * 0 : Success. | |
1335 | * data is NULL | |
1336 | * -errno : An error occured. | |
1337 | * data is the error string. | |
1338 | */ | |
66ad6d84 | 1339 | EXTERN int nfs_link_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data); |
84004dbf RS |
1340 | /* |
1341 | * Sync link(<oldpath>, <newpath>) | |
1342 | * Function returns | |
1343 | * 0 : The operation was successfull. | |
1344 | * -errno : The command failed. | |
1345 | */ | |
66ad6d84 | 1346 | EXTERN int nfs_link(struct nfs_context *nfs, const char *oldpath, const char *newpath); |
84004dbf RS |
1347 | |
1348 | ||
7f0242ca RS |
1349 | /* |
1350 | * GETEXPORTS() | |
1351 | */ | |
1352 | /* | |
1353 | * Async getexports() | |
1354 | * NOTE: You must include 'libnfs-raw-mount.h' to get the definitions of the | |
1355 | * returned structures. | |
1356 | * | |
1357 | * This function will return the list of exports from an NFS server. | |
1358 | * | |
1359 | * Function returns | |
1360 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
1361 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
1362 | * | |
1363 | * When the callback is invoked, status indicates the result: | |
1364 | * 0 : Success. | |
1365 | * data is a pointer to an exports pointer: | |
1366 | * exports export = *(exports *)data; | |
1367 | * -errno : An error occured. | |
1368 | * data is the error string. | |
1369 | */ | |
66ad6d84 | 1370 | EXTERN int mount_getexports_async(struct rpc_context *rpc, const char *server, rpc_cb cb, void *private_data); |
df5af25f RS |
1371 | /* |
1372 | * Sync getexports(<server>) | |
1373 | * Function returns | |
1374 | * NULL : something failed | |
1375 | * exports export : a linked list of exported directories | |
52014ebf | 1376 | * |
df5af25f RS |
1377 | * returned data must be freed by calling mount_free_export_list(exportnode); |
1378 | */ | |
66ad6d84 | 1379 | EXTERN struct exportnode *mount_getexports(const char *server); |
7f0242ca | 1380 | |
66ad6d84 | 1381 | EXTERN void mount_free_export_list(struct exportnode *exports); |
7f0242ca | 1382 | |
84004dbf RS |
1383 | |
1384 | //qqq replace later with lseek(cur, 0) | |
183451cf | 1385 | uint64_t nfs_get_current_offset(struct nfsfh *nfsfh); |
552c7665 RS |
1386 | |
1387 | ||
1388 | ||
9c4212bf RS |
1389 | |
1390 | ||
552c7665 RS |
1391 | struct nfs_server_list { |
1392 | struct nfs_server_list *next; | |
1393 | char *addr; | |
1394 | }; | |
1395 | ||
9c4212bf RS |
1396 | /* |
1397 | * Sync find_local_servers(<server>) | |
1398 | * This function will probe all local networks for NFS server. This function will | |
1399 | * block for one second while awaiting for all nfs servers to respond. | |
1400 | * | |
1401 | * Function returns | |
1402 | * NULL : something failed | |
1403 | * | |
1404 | * struct nfs_server_list : a linked list of all discovered servers | |
52014ebf | 1405 | * |
9c4212bf RS |
1406 | * returned data must be freed by nfs_free_srvr_list(srv); |
1407 | */ | |
552c7665 RS |
1408 | struct nfs_server_list *nfs_find_local_servers(void); |
1409 | void free_nfs_srvr_list(struct nfs_server_list *srv); | |
52014ebf | 1410 | |
d48be00c AR |
1411 | #ifdef __cplusplus |
1412 | } | |
1413 | #endif | |
1414 | ||
52014ebf | 1415 | #endif /* !_LIBNFS_H_ */ |