| 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 | |
| 21 | #ifndef _LIBNFS_H_ |
| 22 | #define _LIBNFS_H_ |
| 23 | |
| 24 | #include <stdint.h> |
| 25 | #if defined(ANDROID) |
| 26 | #include <sys/time.h> |
| 27 | #endif |
| 28 | #if defined(AROS) |
| 29 | #include <sys/time.h> |
| 30 | #endif |
| 31 | #if defined(__APPLE__) && defined(__MACH__) |
| 32 | #include <sys/time.h> |
| 33 | #endif |
| 34 | |
| 35 | #ifdef __cplusplus |
| 36 | extern "C" { |
| 37 | #endif |
| 38 | |
| 39 | #define LIBNFS_FEATURE_READAHEAD |
| 40 | #define NFS_BLKSIZE 4096 |
| 41 | |
| 42 | struct nfs_context; |
| 43 | struct rpc_context; |
| 44 | |
| 45 | struct nfs_url { |
| 46 | char *server; |
| 47 | char *path; |
| 48 | char *file; |
| 49 | }; |
| 50 | |
| 51 | #if defined(WIN32) |
| 52 | #define EXTERN __declspec( dllexport ) |
| 53 | #else |
| 54 | #define EXTERN |
| 55 | #endif |
| 56 | |
| 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; |
| 67 | uint32_t f_fsid; |
| 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 | |
| 80 | /* |
| 81 | * Used for interfacing the async version of the api into an external eventsystem |
| 82 | */ |
| 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); |
| 86 | EXTERN int nfs_queue_length(struct nfs_context *nfs); |
| 87 | |
| 88 | /* |
| 89 | * Used if you need different credentials than the default for the current user. |
| 90 | */ |
| 91 | struct AUTH; |
| 92 | EXTERN void nfs_set_auth(struct nfs_context *nfs, struct AUTH *auth); |
| 93 | |
| 94 | /* |
| 95 | * When an operation failed, this function can extract a detailed error string. |
| 96 | */ |
| 97 | EXTERN char *nfs_get_error(struct nfs_context *nfs); |
| 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 | |
| 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); |
| 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 | */ |
| 121 | EXTERN struct nfs_context *nfs_init_context(void); |
| 122 | /* |
| 123 | * Destroy an nfs context. |
| 124 | */ |
| 125 | EXTERN void nfs_destroy_context(struct nfs_context *nfs); |
| 126 | |
| 127 | |
| 128 | /* |
| 129 | * URL parsing functions. |
| 130 | * These functions all parse a URL of the form |
| 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 | */ |
| 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 | |
| 171 | struct nfsfh; |
| 172 | |
| 173 | /* |
| 174 | * Get the maximum supported READ3 size by the server |
| 175 | */ |
| 176 | EXTERN uint64_t nfs_get_readmax(struct nfs_context *nfs); |
| 177 | |
| 178 | /* |
| 179 | * Get the maximum supported WRITE3 size by the server |
| 180 | */ |
| 181 | EXTERN uint64_t nfs_get_writemax(struct nfs_context *nfs); |
| 182 | |
| 183 | /* |
| 184 | * MODIFY CONNECT PARAMTERS |
| 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); |
| 190 | EXTERN void nfs_set_readahead(struct nfs_context *nfs, uint32_t v); |
| 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 | */ |
| 207 | EXTERN int nfs_mount_async(struct nfs_context *nfs, const char *server, const char *exportname, nfs_cb cb, void *private_data); |
| 208 | /* |
| 209 | * Sync nfs mount. |
| 210 | * Function returns |
| 211 | * 0 : The operation was successfull. |
| 212 | * -errno : The command failed. |
| 213 | */ |
| 214 | EXTERN int nfs_mount(struct nfs_context *nfs, const char *server, const char *exportname); |
| 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 | */ |
| 234 | /* This function is deprecated. Use nfs_stat64_async() instead */ |
| 235 | struct stat; |
| 236 | EXTERN int nfs_stat_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); |
| 237 | /* |
| 238 | * Sync stat(<filename>) |
| 239 | * Function returns |
| 240 | * 0 : The operation was successfull. |
| 241 | * -errno : The command failed. |
| 242 | */ |
| 243 | /* This function is deprecated. Use nfs_stat64() instead */ |
| 244 | #ifdef WIN32 |
| 245 | EXTERN int nfs_stat(struct nfs_context *nfs, const char *path, struct __stat64 *st); |
| 246 | #else |
| 247 | EXTERN int nfs_stat(struct nfs_context *nfs, const char *path, struct stat *st); |
| 248 | #endif |
| 249 | |
| 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; |
| 273 | uint64_t nfs_atime_nsec; |
| 274 | uint64_t nfs_mtime_nsec; |
| 275 | uint64_t nfs_ctime_nsec; |
| 276 | uint64_t nfs_used; |
| 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 | |
| 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 | |
| 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 | */ |
| 344 | /* This function is deprecated. Use nfs_fstat64_async() instead */ |
| 345 | EXTERN int nfs_fstat_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data); |
| 346 | /* |
| 347 | * Sync fstat(nfsfh *) |
| 348 | * Function returns |
| 349 | * 0 : The operation was successfull. |
| 350 | * -errno : The command failed. |
| 351 | */ |
| 352 | #ifdef WIN32 |
| 353 | EXTERN int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct __stat64 *st); |
| 354 | #else |
| 355 | EXTERN int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct stat *st); |
| 356 | #endif |
| 357 | |
| 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 | |
| 387 | |
| 388 | |
| 389 | /* |
| 390 | * OPEN() |
| 391 | */ |
| 392 | /* |
| 393 | * Async open(<filename>) |
| 394 | * |
| 395 | * mode is a combination of the flags : |
| 396 | * O_RDOLNY, O_WRONLY, O_RDWR , O_SYNC, O_APPEND, O_TRUNC |
| 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 | * |
| 402 | * Supported flags are |
| 403 | * O_APPEND |
| 404 | * O_RDONLY |
| 405 | * O_WRONLY |
| 406 | * O_RDWR |
| 407 | * O_SYNC |
| 408 | * O_TRUNC (Only valid with O_RDWR or O_WRONLY. Ignored otherwise.) |
| 409 | * |
| 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 | */ |
| 417 | EXTERN int nfs_open_async(struct nfs_context *nfs, const char *path, int flags, nfs_cb cb, void *private_data); |
| 418 | /* |
| 419 | * Sync open(<filename>) |
| 420 | * Function returns |
| 421 | * 0 : The operation was successfull. *nfsfh is filled in. |
| 422 | * -errno : The command failed. |
| 423 | */ |
| 424 | EXTERN int nfs_open(struct nfs_context *nfs, const char *path, int flags, struct nfsfh **nfsfh); |
| 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 | */ |
| 445 | EXTERN int nfs_close_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data); |
| 446 | /* |
| 447 | * Sync close(nfsfh) |
| 448 | * Function returns |
| 449 | * 0 : The operation was successfull. |
| 450 | * -errno : The command failed. |
| 451 | */ |
| 452 | EXTERN int nfs_close(struct nfs_context *nfs, struct nfsfh *nfsfh); |
| 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 | */ |
| 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); |
| 473 | /* |
| 474 | * Sync pread() |
| 475 | * Function returns |
| 476 | * >=0 : numer of bytes read. |
| 477 | * -errno : An error occured. |
| 478 | */ |
| 479 | EXTERN int nfs_pread(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, uint64_t count, char *buf); |
| 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 | */ |
| 500 | EXTERN int nfs_read_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, nfs_cb cb, void *private_data); |
| 501 | /* |
| 502 | * Sync read() |
| 503 | * Function returns |
| 504 | * >=0 : numer of bytes read. |
| 505 | * -errno : An error occured. |
| 506 | */ |
| 507 | EXTERN int nfs_read(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, char *buf); |
| 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 | */ |
| 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); |
| 529 | /* |
| 530 | * Sync pwrite() |
| 531 | * Function returns |
| 532 | * >=0 : numer of bytes written. |
| 533 | * -errno : An error occured. |
| 534 | */ |
| 535 | EXTERN int nfs_pwrite(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, uint64_t count, char *buf); |
| 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 | */ |
| 554 | EXTERN int nfs_write_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, char *buf, nfs_cb cb, void *private_data); |
| 555 | /* |
| 556 | * Sync write() |
| 557 | * Function returns |
| 558 | * >=0 : numer of bytes written. |
| 559 | * -errno : An error occured. |
| 560 | */ |
| 561 | EXTERN int nfs_write(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, char *buf); |
| 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. |
| 576 | * data is uint64_t * for the current position. |
| 577 | * -errno : An error occured. |
| 578 | * data is the error string. |
| 579 | */ |
| 580 | EXTERN int nfs_lseek_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int64_t offset, int whence, nfs_cb cb, void *private_data); |
| 581 | /* |
| 582 | * Sync lseek() |
| 583 | * Function returns |
| 584 | * >=0 : numer of bytes read. |
| 585 | * -errno : An error occured. |
| 586 | */ |
| 587 | EXTERN int nfs_lseek(struct nfs_context *nfs, struct nfsfh *nfsfh, int64_t offset, int whence, uint64_t *current_offset); |
| 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 | */ |
| 605 | EXTERN int nfs_fsync_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data); |
| 606 | /* |
| 607 | * Sync fsync() |
| 608 | * Function returns |
| 609 | * 0 : Success |
| 610 | * -errno : An error occured. |
| 611 | */ |
| 612 | EXTERN int nfs_fsync(struct nfs_context *nfs, struct nfsfh *nfsfh); |
| 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 | */ |
| 631 | EXTERN int nfs_truncate_async(struct nfs_context *nfs, const char *path, uint64_t length, nfs_cb cb, void *private_data); |
| 632 | /* |
| 633 | * Sync truncate() |
| 634 | * Function returns |
| 635 | * 0 : Success |
| 636 | * -errno : An error occured. |
| 637 | */ |
| 638 | EXTERN int nfs_truncate(struct nfs_context *nfs, const char *path, uint64_t length); |
| 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 | */ |
| 657 | EXTERN int nfs_ftruncate_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t length, nfs_cb cb, void *private_data); |
| 658 | /* |
| 659 | * Sync ftruncate() |
| 660 | * Function returns |
| 661 | * 0 : Success |
| 662 | * -errno : An error occured. |
| 663 | */ |
| 664 | EXTERN int nfs_ftruncate(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t length); |
| 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 | */ |
| 686 | EXTERN int nfs_mkdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); |
| 687 | /* |
| 688 | * Sync mkdir() |
| 689 | * Function returns |
| 690 | * 0 : Success |
| 691 | * -errno : An error occured. |
| 692 | */ |
| 693 | EXTERN int nfs_mkdir(struct nfs_context *nfs, const char *path); |
| 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 | */ |
| 712 | EXTERN int nfs_rmdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); |
| 713 | /* |
| 714 | * Sync rmdir() |
| 715 | * Function returns |
| 716 | * 0 : Success |
| 717 | * -errno : An error occured. |
| 718 | */ |
| 719 | EXTERN int nfs_rmdir(struct nfs_context *nfs, const char *path); |
| 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 | */ |
| 740 | EXTERN int nfs_creat_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data); |
| 741 | /* |
| 742 | * Sync creat() |
| 743 | * Function returns |
| 744 | * 0 : Success |
| 745 | * -errno : An error occured. |
| 746 | */ |
| 747 | EXTERN int nfs_creat(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh); |
| 748 | |
| 749 | /* |
| 750 | * Async create() |
| 751 | * |
| 752 | * Same as nfs_creat_async but allows passing flags: |
| 753 | * O_APPEND |
| 754 | * O_SYNC |
| 755 | * O_EXCL |
| 756 | * O_TRUNC |
| 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 | |
| 777 | |
| 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); |
| 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 | */ |
| 820 | EXTERN int nfs_unlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); |
| 821 | /* |
| 822 | * Sync unlink() |
| 823 | * Function returns |
| 824 | * 0 : Success |
| 825 | * -errno : An error occured. |
| 826 | */ |
| 827 | EXTERN int nfs_unlink(struct nfs_context *nfs, const char *path); |
| 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 | */ |
| 851 | EXTERN int nfs_opendir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); |
| 852 | /* |
| 853 | * Sync opendir() |
| 854 | * Function returns |
| 855 | * 0 : Success |
| 856 | * -errno : An error occured. |
| 857 | */ |
| 858 | EXTERN int nfs_opendir(struct nfs_context *nfs, const char *path, struct nfsdir **nfsdir); |
| 859 | |
| 860 | |
| 861 | |
| 862 | /* |
| 863 | * READDIR() |
| 864 | */ |
| 865 | struct nfsdirent { |
| 866 | struct nfsdirent *next; |
| 867 | char *name; |
| 868 | uint64_t inode; |
| 869 | |
| 870 | /* Some extra fields we get for free through the READDIRPLUS3 call. |
| 871 | You need libnfs-raw-nfs.h for type/mode constants */ |
| 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; |
| 878 | uint32_t uid; |
| 879 | uint32_t gid; |
| 880 | uint32_t nlink; |
| 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; |
| 889 | }; |
| 890 | /* |
| 891 | * nfs_readdir() never blocks, so no special sync/async versions are available |
| 892 | */ |
| 893 | EXTERN struct nfsdirent *nfs_readdir(struct nfs_context *nfs, struct nfsdir *nfsdir); |
| 894 | |
| 895 | |
| 896 | |
| 897 | /* |
| 898 | * CLOSEDIR() |
| 899 | */ |
| 900 | /* |
| 901 | * nfs_closedir() never blocks, so no special sync/async versions are available |
| 902 | */ |
| 903 | EXTERN void nfs_closedir(struct nfs_context *nfs, struct nfsdir *nfsdir); |
| 904 | |
| 905 | |
| 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 | |
| 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; |
| 966 | EXTERN int nfs_statvfs_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); |
| 967 | /* |
| 968 | * Sync statvfs(<dirname>) |
| 969 | * Function returns |
| 970 | * 0 : The operation was successfull. |
| 971 | * -errno : The command failed. |
| 972 | */ |
| 973 | EXTERN int nfs_statvfs(struct nfs_context *nfs, const char *path, struct statvfs *svfs); |
| 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; |
| 993 | EXTERN int nfs_readlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); |
| 994 | /* |
| 995 | * Sync readlink(<name>) |
| 996 | * Function returns |
| 997 | * 0 : The operation was successfull. |
| 998 | * -errno : The command failed. |
| 999 | */ |
| 1000 | EXTERN int nfs_readlink(struct nfs_context *nfs, const char *path, char *buf, int bufsize); |
| 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 | */ |
| 1019 | EXTERN int nfs_chmod_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data); |
| 1020 | /* |
| 1021 | * Sync chmod(<name>) |
| 1022 | * Function returns |
| 1023 | * 0 : The operation was successfull. |
| 1024 | * -errno : The command failed. |
| 1025 | */ |
| 1026 | EXTERN int nfs_chmod(struct nfs_context *nfs, const char *path, int mode); |
| 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); |
| 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 | */ |
| 1073 | EXTERN int nfs_fchmod_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode, nfs_cb cb, void *private_data); |
| 1074 | /* |
| 1075 | * Sync fchmod(<handle>) |
| 1076 | * Function returns |
| 1077 | * 0 : The operation was successfull. |
| 1078 | * -errno : The command failed. |
| 1079 | */ |
| 1080 | EXTERN int nfs_fchmod(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode); |
| 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 | */ |
| 1099 | EXTERN int nfs_chown_async(struct nfs_context *nfs, const char *path, int uid, int gid, nfs_cb cb, void *private_data); |
| 1100 | /* |
| 1101 | * Sync chown(<name>) |
| 1102 | * Function returns |
| 1103 | * 0 : The operation was successfull. |
| 1104 | * -errno : The command failed. |
| 1105 | */ |
| 1106 | EXTERN int nfs_chown(struct nfs_context *nfs, const char *path, int uid, int gid); |
| 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); |
| 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 | */ |
| 1153 | EXTERN int nfs_fchown_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid, nfs_cb cb, void *private_data); |
| 1154 | /* |
| 1155 | * Sync fchown(<handle>) |
| 1156 | * Function returns |
| 1157 | * 0 : The operation was successfull. |
| 1158 | * -errno : The command failed. |
| 1159 | */ |
| 1160 | EXTERN int nfs_fchown(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid); |
| 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 | */ |
| 1180 | EXTERN int nfs_utimes_async(struct nfs_context *nfs, const char *path, struct timeval *times, nfs_cb cb, void *private_data); |
| 1181 | /* |
| 1182 | * Sync utimes(<path>) |
| 1183 | * Function returns |
| 1184 | * 0 : The operation was successfull. |
| 1185 | * -errno : The command failed. |
| 1186 | */ |
| 1187 | EXTERN int nfs_utimes(struct nfs_context *nfs, const char *path, struct timeval *times); |
| 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); |
| 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; |
| 1234 | EXTERN int nfs_utime_async(struct nfs_context *nfs, const char *path, struct utimbuf *times, nfs_cb cb, void *private_data); |
| 1235 | /* |
| 1236 | * Sync utime(<path>) |
| 1237 | * Function returns |
| 1238 | * 0 : The operation was successfull. |
| 1239 | * -errno : The command failed. |
| 1240 | */ |
| 1241 | EXTERN int nfs_utime(struct nfs_context *nfs, const char *path, struct utimbuf *times); |
| 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 | */ |
| 1261 | EXTERN int nfs_access_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data); |
| 1262 | /* |
| 1263 | * Sync access(<path>) |
| 1264 | * Function returns |
| 1265 | * 0 : The operation was successfull. |
| 1266 | * -errno : The command failed. |
| 1267 | */ |
| 1268 | EXTERN int nfs_access(struct nfs_context *nfs, const char *path, int mode); |
| 1269 | |
| 1270 | |
| 1271 | |
| 1272 | |
| 1273 | |
| 1274 | /* |
| 1275 | * ACCESS2() |
| 1276 | */ |
| 1277 | /* |
| 1278 | * Async access2(<path>) |
| 1279 | * Function returns |
| 1280 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. |
| 1281 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. |
| 1282 | * |
| 1283 | * When the callback is invoked, status indicates the result: |
| 1284 | * >= 0 : A mask of R_OK, W_OK and X_OK indicating which permissions are |
| 1285 | * available. |
| 1286 | * data is NULL |
| 1287 | * -errno : An error occured. |
| 1288 | * data is the error string. |
| 1289 | */ |
| 1290 | EXTERN int nfs_access2_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); |
| 1291 | /* |
| 1292 | * Sync access(<path>) |
| 1293 | * Function returns |
| 1294 | * >= 0 : A mask of R_OK, W_OK and X_OK indicating which permissions are |
| 1295 | * available. |
| 1296 | * -errno : The command failed. |
| 1297 | */ |
| 1298 | EXTERN int nfs_access2(struct nfs_context *nfs, const char *path); |
| 1299 | |
| 1300 | |
| 1301 | |
| 1302 | |
| 1303 | /* |
| 1304 | * SYMLINK() |
| 1305 | */ |
| 1306 | /* |
| 1307 | * Async symlink(<path>) |
| 1308 | * Function returns |
| 1309 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. |
| 1310 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. |
| 1311 | * |
| 1312 | * When the callback is invoked, status indicates the result: |
| 1313 | * 0 : Success. |
| 1314 | * data is NULL |
| 1315 | * -errno : An error occured. |
| 1316 | * data is the error string. |
| 1317 | */ |
| 1318 | EXTERN int nfs_symlink_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data); |
| 1319 | /* |
| 1320 | * Sync symlink(<path>) |
| 1321 | * Function returns |
| 1322 | * 0 : The operation was successfull. |
| 1323 | * -errno : The command failed. |
| 1324 | */ |
| 1325 | EXTERN int nfs_symlink(struct nfs_context *nfs, const char *oldpath, const char *newpath); |
| 1326 | |
| 1327 | |
| 1328 | /* |
| 1329 | * RENAME() |
| 1330 | */ |
| 1331 | /* |
| 1332 | * Async rename(<oldpath>, <newpath>) |
| 1333 | * Function returns |
| 1334 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. |
| 1335 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. |
| 1336 | * |
| 1337 | * When the callback is invoked, status indicates the result: |
| 1338 | * 0 : Success. |
| 1339 | * data is NULL |
| 1340 | * -errno : An error occured. |
| 1341 | * data is the error string. |
| 1342 | */ |
| 1343 | EXTERN int nfs_rename_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data); |
| 1344 | /* |
| 1345 | * Sync rename(<oldpath>, <newpath>) |
| 1346 | * Function returns |
| 1347 | * 0 : The operation was successfull. |
| 1348 | * -errno : The command failed. |
| 1349 | */ |
| 1350 | EXTERN int nfs_rename(struct nfs_context *nfs, const char *oldpath, const char *newpath); |
| 1351 | |
| 1352 | |
| 1353 | |
| 1354 | /* |
| 1355 | * LINK() |
| 1356 | */ |
| 1357 | /* |
| 1358 | * Async link(<oldpath>, <newpath>) |
| 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 NULL |
| 1366 | * -errno : An error occured. |
| 1367 | * data is the error string. |
| 1368 | */ |
| 1369 | EXTERN int nfs_link_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data); |
| 1370 | /* |
| 1371 | * Sync link(<oldpath>, <newpath>) |
| 1372 | * Function returns |
| 1373 | * 0 : The operation was successfull. |
| 1374 | * -errno : The command failed. |
| 1375 | */ |
| 1376 | EXTERN int nfs_link(struct nfs_context *nfs, const char *oldpath, const char *newpath); |
| 1377 | |
| 1378 | |
| 1379 | /* |
| 1380 | * GETEXPORTS() |
| 1381 | */ |
| 1382 | /* |
| 1383 | * Async getexports() |
| 1384 | * NOTE: You must include 'libnfs-raw-mount.h' to get the definitions of the |
| 1385 | * returned structures. |
| 1386 | * |
| 1387 | * This function will return the list of exports from an NFS server. |
| 1388 | * |
| 1389 | * Function returns |
| 1390 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. |
| 1391 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. |
| 1392 | * |
| 1393 | * When the callback is invoked, status indicates the result: |
| 1394 | * 0 : Success. |
| 1395 | * data is a pointer to an exports pointer: |
| 1396 | * exports export = *(exports *)data; |
| 1397 | * -errno : An error occured. |
| 1398 | * data is the error string. |
| 1399 | */ |
| 1400 | EXTERN int mount_getexports_async(struct rpc_context *rpc, const char *server, rpc_cb cb, void *private_data); |
| 1401 | /* |
| 1402 | * Sync getexports(<server>) |
| 1403 | * Function returns |
| 1404 | * NULL : something failed |
| 1405 | * exports export : a linked list of exported directories |
| 1406 | * |
| 1407 | * returned data must be freed by calling mount_free_export_list(exportnode); |
| 1408 | */ |
| 1409 | EXTERN struct exportnode *mount_getexports(const char *server); |
| 1410 | |
| 1411 | EXTERN void mount_free_export_list(struct exportnode *exports); |
| 1412 | |
| 1413 | |
| 1414 | //qqq replace later with lseek(cur, 0) |
| 1415 | uint64_t nfs_get_current_offset(struct nfsfh *nfsfh); |
| 1416 | |
| 1417 | |
| 1418 | |
| 1419 | |
| 1420 | |
| 1421 | struct nfs_server_list { |
| 1422 | struct nfs_server_list *next; |
| 1423 | char *addr; |
| 1424 | }; |
| 1425 | |
| 1426 | /* |
| 1427 | * Sync find_local_servers(<server>) |
| 1428 | * This function will probe all local networks for NFS server. This function will |
| 1429 | * block for one second while awaiting for all nfs servers to respond. |
| 1430 | * |
| 1431 | * Function returns |
| 1432 | * NULL : something failed |
| 1433 | * |
| 1434 | * struct nfs_server_list : a linked list of all discovered servers |
| 1435 | * |
| 1436 | * returned data must be freed by nfs_free_srvr_list(srv); |
| 1437 | */ |
| 1438 | struct nfs_server_list *nfs_find_local_servers(void); |
| 1439 | void free_nfs_srvr_list(struct nfs_server_list *srv); |
| 1440 | |
| 1441 | #ifdef __cplusplus |
| 1442 | } |
| 1443 | #endif |
| 1444 | |
| 1445 | #endif /* !_LIBNFS_H_ */ |