nfs.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916
  1. #ifndef CCAN_NFS_H
  2. #define CCAN_NFS_H
  3. /*
  4. Copyright (C) by Ronnie Sahlberg <ronniesahlberg@gmail.com> 2010
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  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 General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, see <http://www.gnu.org/licenses/>.
  15. */
  16. /*
  17. * This is the highlevel interface to access NFS resources using a posix-like interface
  18. */
  19. #include <sys/types.h>
  20. #include <stdint.h>
  21. typedef uint64_t nfs_off_t;
  22. struct nfs_context;
  23. /*
  24. * Used for interfacing the async version of the api into an external eventsystem
  25. */
  26. int nfs_get_fd(struct nfs_context *nfs);
  27. int nfs_which_events(struct nfs_context *nfs);
  28. int nfs_service(struct nfs_context *nfs, int revents);
  29. /*
  30. * Used if you need different credentials than the default for the current user.
  31. */
  32. struct AUTH;
  33. void nfs_set_auth(struct nfs_context *nfs, struct AUTH *auth);
  34. /*
  35. * When an operation failed, this function can extract a detailed error string.
  36. */
  37. char *nfs_get_error(struct nfs_context *nfs);
  38. /*
  39. * Callback for all async nfs functions
  40. */
  41. typedef void (*nfs_cb)(int err, struct nfs_context *nfs, void *data, void *private_data);
  42. /*
  43. * NFS CONTEXT.
  44. */
  45. /*
  46. * Create an NFS context.
  47. * Function returns
  48. * NULL : Failed to create a context.
  49. * struct nfs_context * : A pointer to an nfs context.
  50. */
  51. struct nfs_context *nfs_init_context(void);
  52. /*
  53. * Destroy an nfs context.
  54. */
  55. void nfs_destroy_context(struct nfs_context *nfs);
  56. /*
  57. * A libnfs filehandle
  58. */
  59. struct nfsfh;
  60. /*
  61. * MOUNT THE EXPORT
  62. */
  63. /*
  64. * Async nfs mount.
  65. * This function will try to connect to the server and mount the export.
  66. * Function returns
  67. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  68. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  69. *
  70. * When the callback is invoked, status indicates the result:
  71. * 0 : Success.
  72. * data is NULL
  73. * -errno : An error occurred.
  74. * data is the error string.
  75. */
  76. int nfs_mount_async(struct nfs_context *nfs, const char *server, const char *export, nfs_cb cb, void *private_data);
  77. /*
  78. * Sync nfs mount.
  79. * Function returns
  80. * 0 : The operation was successful.
  81. * -errno : The command failed.
  82. */
  83. int nfs_mount_sync(struct nfs_context *nfs, const char *server, const char *export);
  84. /*
  85. * STAT()
  86. */
  87. /*
  88. * Async stat(<filename>)
  89. * Function returns
  90. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  91. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  92. *
  93. * When the callback is invoked, status indicates the result:
  94. * 0 : Success.
  95. * data is struct stat *
  96. * -errno : An error occurred.
  97. * data is the error string.
  98. */
  99. struct stat;
  100. int nfs_stat_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
  101. /*
  102. * Sync stat(<filename>)
  103. * Function returns
  104. * 0 : The operation was successful.
  105. * -errno : The command failed.
  106. */
  107. int nfs_stat_sync(struct nfs_context *nfs, const char *path, struct stat *st);
  108. /*
  109. * FSTAT()
  110. */
  111. /*
  112. * Async fstat(nfsfh *)
  113. * Function returns
  114. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  115. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  116. *
  117. * When the callback is invoked, status indicates the result:
  118. * 0 : Success.
  119. * data is struct stat *
  120. * -errno : An error occurred.
  121. * data is the error string.
  122. */
  123. int nfs_fstat_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
  124. /*
  125. * Sync fstat(nfsfh *)
  126. * Function returns
  127. * 0 : The operation was successful.
  128. * -errno : The command failed.
  129. */
  130. int nfs_fstat_sync(struct nfs_context *nfs, struct nfsfh *nfsfh, struct stat *st);
  131. /*
  132. * OPEN()
  133. */
  134. /*
  135. * Async open(<filename>)
  136. *
  137. * mode is a combination of the flags : O_RDOLNY, O_WRONLY, O_RDWR , O_SYNC
  138. *
  139. * Function returns
  140. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  141. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  142. *
  143. * When the callback is invoked, status indicates the result:
  144. * 0 : Success.
  145. * data is a struct *nfsfh;
  146. * The nfsfh is close using nfs_close().
  147. * -errno : An error occurred.
  148. * data is the error string.
  149. */
  150. int nfs_open_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
  151. /*
  152. * Sync open(<filename>)
  153. * Function returns
  154. * 0 : The operation was successful. *nfsfh is filled in.
  155. * -errno : The command failed.
  156. */
  157. int nfs_open_sync(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh);
  158. /*
  159. * CLOSE
  160. */
  161. /*
  162. * Async close(nfsfh)
  163. *
  164. * Function returns
  165. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  166. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  167. *
  168. * When the callback is invoked, status indicates the result:
  169. * 0 : Success.
  170. * data is NULL.
  171. * -errno : An error occurred.
  172. * data is the error string.
  173. */
  174. int nfs_close_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
  175. /*
  176. * Sync close(nfsfh)
  177. * Function returns
  178. * 0 : The operation was successful.
  179. * -errno : The command failed.
  180. */
  181. int nfs_close_sync(struct nfs_context *nfs, struct nfsfh *nfsfh);
  182. /*
  183. * PREAD()
  184. */
  185. /*
  186. * Async pread()
  187. *
  188. * Function returns
  189. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  190. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  191. *
  192. * When the callback is invoked, status indicates the result:
  193. * >=0 : Success.
  194. * status is numer of bytes read.
  195. * data is a pointer to the returned data.
  196. * -errno : An error occurred.
  197. * data is the error string.
  198. */
  199. int nfs_pread_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_off_t offset, size_t count, nfs_cb cb, void *private_data);
  200. /*
  201. * Sync pread()
  202. * Function returns
  203. * >=0 : numer of bytes read.
  204. * -errno : An error occurred.
  205. */
  206. int nfs_pread_sync(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_off_t offset, size_t count, char *buf);
  207. /*
  208. * READ()
  209. */
  210. /*
  211. * Async read()
  212. *
  213. * Function returns
  214. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  215. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  216. *
  217. * When the callback is invoked, status indicates the result:
  218. * >=0 : Success.
  219. * status is numer of bytes read.
  220. * data is a pointer to the returned data.
  221. * -errno : An error occurred.
  222. * data is the error string.
  223. */
  224. int nfs_read_async(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, nfs_cb cb, void *private_data);
  225. /*
  226. * Sync read()
  227. * Function returns
  228. * >=0 : numer of bytes read.
  229. * -errno : An error occurred.
  230. */
  231. int nfs_read_sync(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf);
  232. /*
  233. * PWRITE()
  234. */
  235. /*
  236. * Async pwrite()
  237. *
  238. * Function returns
  239. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  240. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  241. *
  242. * When the callback is invoked, status indicates the result:
  243. * >=0 : Success.
  244. * status is numer of bytes written.
  245. * -errno : An error occurred.
  246. * data is the error string.
  247. */
  248. int nfs_pwrite_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_off_t offset, size_t count, char *buf, nfs_cb cb, void *private_data);
  249. /*
  250. * Sync pwrite()
  251. * Function returns
  252. * >=0 : numer of bytes written.
  253. * -errno : An error occurred.
  254. */
  255. int nfs_pwrite_sync(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_off_t offset, size_t count, char *buf);
  256. /*
  257. * WRITE()
  258. */
  259. /*
  260. * Async write()
  261. *
  262. * Function returns
  263. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  264. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  265. *
  266. * When the callback is invoked, status indicates the result:
  267. * >=0 : Success.
  268. * status is numer of bytes written.
  269. * -errno : An error occurred.
  270. * data is the error string.
  271. */
  272. int nfs_write_async(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf, nfs_cb cb, void *private_data);
  273. /*
  274. * Sync write()
  275. * Function returns
  276. * >=0 : numer of bytes written.
  277. * -errno : An error occurred.
  278. */
  279. int nfs_write_sync(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf);
  280. /*
  281. * LSEEK()
  282. */
  283. /*
  284. * Async lseek()
  285. *
  286. * Function returns
  287. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  288. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  289. *
  290. * When the callback is invoked, status indicates the result:
  291. * >=0 : Success.
  292. * data is nfs_off_t * for the current position.
  293. * -errno : An error occurred.
  294. * data is the error string.
  295. */
  296. int nfs_lseek_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_off_t offset, int whence, nfs_cb cb, void *private_data);
  297. /*
  298. * Sync lseek()
  299. * Function returns
  300. * >=0 : numer of bytes read.
  301. * -errno : An error occurred.
  302. */
  303. int nfs_lseek_sync(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_off_t offset, int whence, nfs_off_t *current_offset);
  304. /*
  305. * FSYNC()
  306. */
  307. /*
  308. * Async fsync()
  309. *
  310. * Function returns
  311. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  312. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  313. *
  314. * When the callback is invoked, status indicates the result:
  315. * 0 : Success.
  316. * -errno : An error occurred.
  317. * data is the error string.
  318. */
  319. int nfs_fsync_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
  320. /*
  321. * Sync fsync()
  322. * Function returns
  323. * 0 : Success
  324. * -errno : An error occurred.
  325. */
  326. int nfs_fsync_sync(struct nfs_context *nfs, struct nfsfh *nfsfh);
  327. /*
  328. * TRUNCATE()
  329. */
  330. /*
  331. * Async truncate()
  332. *
  333. * Function returns
  334. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  335. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  336. *
  337. * When the callback is invoked, status indicates the result:
  338. * 0 : Success.
  339. * -errno : An error occurred.
  340. * data is the error string.
  341. */
  342. int nfs_truncate_async(struct nfs_context *nfs, const char *path, nfs_off_t length, nfs_cb cb, void *private_data);
  343. /*
  344. * Sync truncate()
  345. * Function returns
  346. * 0 : Success
  347. * -errno : An error occurred.
  348. */
  349. int nfs_truncate_sync(struct nfs_context *nfs, const char *path, nfs_off_t length);
  350. /*
  351. * FTRUNCATE()
  352. */
  353. /*
  354. * Async ftruncate()
  355. *
  356. * Function returns
  357. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  358. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  359. *
  360. * When the callback is invoked, status indicates the result:
  361. * 0 : Success.
  362. * -errno : An error occurred.
  363. * data is the error string.
  364. */
  365. int nfs_ftruncate_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_off_t length, nfs_cb cb, void *private_data);
  366. /*
  367. * Sync ftruncate()
  368. * Function returns
  369. * 0 : Success
  370. * -errno : An error occurred.
  371. */
  372. int nfs_ftruncate_sync(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_off_t length);
  373. /*
  374. * MKDIR()
  375. */
  376. /*
  377. * Async mkdir()
  378. *
  379. * Function returns
  380. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  381. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  382. *
  383. * When the callback is invoked, status indicates the result:
  384. * 0 : Success.
  385. * -errno : An error occurred.
  386. * data is the error string.
  387. */
  388. int nfs_mkdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
  389. /*
  390. * Sync mkdir()
  391. * Function returns
  392. * 0 : Success
  393. * -errno : An error occurred.
  394. */
  395. int nfs_mkdir_sync(struct nfs_context *nfs, const char *path);
  396. /*
  397. * RMDIR()
  398. */
  399. /*
  400. * Async rmdir()
  401. *
  402. * Function returns
  403. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  404. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  405. *
  406. * When the callback is invoked, status indicates the result:
  407. * 0 : Success.
  408. * -errno : An error occurred.
  409. * data is the error string.
  410. */
  411. int nfs_rmdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
  412. /*
  413. * Sync rmdir()
  414. * Function returns
  415. * 0 : Success
  416. * -errno : An error occurred.
  417. */
  418. int nfs_rmdir_sync(struct nfs_context *nfs, const char *path);
  419. /*
  420. * CREAT()
  421. */
  422. /*
  423. * Async creat()
  424. *
  425. * Function returns
  426. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  427. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  428. *
  429. * When the callback is invoked, status indicates the result:
  430. * 0 : Success.
  431. * data is a struct *nfsfh;
  432. * -errno : An error occurred.
  433. * data is the error string.
  434. */
  435. int nfs_creat_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
  436. /*
  437. * Sync creat()
  438. * Function returns
  439. * 0 : Success
  440. * -errno : An error occurred.
  441. */
  442. int nfs_creat_sync(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh);
  443. /*
  444. * UNLINK()
  445. */
  446. /*
  447. * Async unlink()
  448. *
  449. * Function returns
  450. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  451. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  452. *
  453. * When the callback is invoked, status indicates the result:
  454. * 0 : Success.
  455. * data is NULL
  456. * -errno : An error occurred.
  457. * data is the error string.
  458. */
  459. int nfs_unlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
  460. /*
  461. * Sync unlink()
  462. * Function returns
  463. * 0 : Success
  464. * -errno : An error occurred.
  465. */
  466. int nfs_unlink_sync(struct nfs_context *nfs, const char *path);
  467. /*
  468. * OPENDIR()
  469. */
  470. struct nfsdir;
  471. /*
  472. * Async opendir()
  473. *
  474. * Function returns
  475. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  476. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  477. *
  478. * When struct nfsdir * is returned, this resource is closed/freed by calling nfs_closedir()
  479. *
  480. * When the callback is invoked, status indicates the result:
  481. * 0 : Success.
  482. * data is struct nfsdir *
  483. * -errno : An error occurred.
  484. * data is the error string.
  485. */
  486. int nfs_opendir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
  487. /*
  488. * Sync opendir()
  489. * Function returns
  490. * 0 : Success
  491. * -errno : An error occurred.
  492. */
  493. int nfs_opendir_sync(struct nfs_context *nfs, const char *path, struct nfsdir **nfsdir);
  494. /*
  495. * READDIR()
  496. */
  497. struct nfsdirent {
  498. struct nfsdirent *next;
  499. char *name;
  500. uint64_t inode;
  501. };
  502. /*
  503. * nfs_readdir() never blocks, so no special sync/async versions are available
  504. */
  505. struct nfsdirent *nfs_readdir(struct nfs_context *nfs, struct nfsdir *nfsdir);
  506. /*
  507. * READDIR()
  508. */
  509. /*
  510. * nfs_closedir() never blocks, so no special sync/async versions are available
  511. */
  512. void nfs_closedir(struct nfs_context *nfs, struct nfsdir *nfsdir);
  513. /*
  514. * STATVFS()
  515. */
  516. /*
  517. * Async statvfs(<dirname>)
  518. * Function returns
  519. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  520. * <0 : An error occurred 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. * data is struct statvfs *
  525. * -errno : An error occurred.
  526. * data is the error string.
  527. */
  528. struct statvfs;
  529. int nfs_statvfs_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
  530. /*
  531. * Sync statvfs(<dirname>)
  532. * Function returns
  533. * 0 : The operation was successful.
  534. * -errno : The command failed.
  535. */
  536. int nfs_statvfs_sync(struct nfs_context *nfs, const char *path, struct statvfs *svfs);
  537. /*
  538. * READLINK()
  539. */
  540. /*
  541. * Async readlink(<name>)
  542. * Function returns
  543. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  544. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  545. *
  546. * When the callback is invoked, status indicates the result:
  547. * 0 : Success.
  548. * data is a char *
  549. * data is only valid during the callback and is automatically freed when the callback returns.
  550. * -errno : An error occurred.
  551. * data is the error string.
  552. */
  553. struct statvfs;
  554. int nfs_readlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
  555. /*
  556. * Sync readlink(<name>)
  557. * Function returns
  558. * 0 : The operation was successful.
  559. * -errno : The command failed.
  560. */
  561. int nfs_readlink_sync(struct nfs_context *nfs, const char *path, char *buf, int bufsize);
  562. /*
  563. * CHMOD()
  564. */
  565. /*
  566. * Async chmod(<name>)
  567. * Function returns
  568. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  569. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  570. *
  571. * When the callback is invoked, status indicates the result:
  572. * 0 : Success.
  573. * data is NULL
  574. * -errno : An error occurred.
  575. * data is the error string.
  576. */
  577. int nfs_chmod_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
  578. /*
  579. * Sync chmod(<name>)
  580. * Function returns
  581. * 0 : The operation was successful.
  582. * -errno : The command failed.
  583. */
  584. int nfs_chmod_sync(struct nfs_context *nfs, const char *path, int mode);
  585. /*
  586. * FCHMOD()
  587. */
  588. /*
  589. * Async fchmod(<handle>)
  590. * Function returns
  591. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  592. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  593. *
  594. * When the callback is invoked, status indicates the result:
  595. * 0 : Success.
  596. * data is NULL
  597. * -errno : An error occurred.
  598. * data is the error string.
  599. */
  600. int nfs_fchmod_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode, nfs_cb cb, void *private_data);
  601. /*
  602. * Sync fchmod(<handle>)
  603. * Function returns
  604. * 0 : The operation was successful.
  605. * -errno : The command failed.
  606. */
  607. int nfs_fchmod_sync(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode);
  608. /*
  609. * CHOWN()
  610. */
  611. /*
  612. * Async chown(<name>)
  613. * Function returns
  614. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  615. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  616. *
  617. * When the callback is invoked, status indicates the result:
  618. * 0 : Success.
  619. * data is NULL
  620. * -errno : An error occurred.
  621. * data is the error string.
  622. */
  623. int nfs_chown_async(struct nfs_context *nfs, const char *path, int uid, int gid, nfs_cb cb, void *private_data);
  624. /*
  625. * Sync chown(<name>)
  626. * Function returns
  627. * 0 : The operation was successful.
  628. * -errno : The command failed.
  629. */
  630. int nfs_chown_sync(struct nfs_context *nfs, const char *path, int uid, int gid);
  631. /*
  632. * FCHOWN()
  633. */
  634. /*
  635. * Async fchown(<handle>)
  636. * Function returns
  637. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  638. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  639. *
  640. * When the callback is invoked, status indicates the result:
  641. * 0 : Success.
  642. * data is NULL
  643. * -errno : An error occurred.
  644. * data is the error string.
  645. */
  646. int nfs_fchown_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid, nfs_cb cb, void *private_data);
  647. /*
  648. * Sync fchown(<handle>)
  649. * Function returns
  650. * 0 : The operation was successful.
  651. * -errno : The command failed.
  652. */
  653. int nfs_fchown_sync(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid);
  654. /*
  655. * UTIMES()
  656. */
  657. /*
  658. * Async utimes(<path>)
  659. * Function returns
  660. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  661. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  662. *
  663. * When the callback is invoked, status indicates the result:
  664. * 0 : Success.
  665. * data is NULL
  666. * -errno : An error occurred.
  667. * data is the error string.
  668. */
  669. int nfs_utimes_async(struct nfs_context *nfs, const char *path, struct timeval *times, nfs_cb cb, void *private_data);
  670. /*
  671. * Sync utimes(<path>)
  672. * Function returns
  673. * 0 : The operation was successful.
  674. * -errno : The command failed.
  675. */
  676. int nfs_utimes_sync(struct nfs_context *nfs, const char *path, struct timeval *times);
  677. /*
  678. * UTIME()
  679. */
  680. /*
  681. * Async utime(<path>)
  682. * Function returns
  683. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  684. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  685. *
  686. * When the callback is invoked, status indicates the result:
  687. * 0 : Success.
  688. * data is NULL
  689. * -errno : An error occurred.
  690. * data is the error string.
  691. */
  692. struct utimbuf;
  693. int nfs_utime_async(struct nfs_context *nfs, const char *path, struct utimbuf *times, nfs_cb cb, void *private_data);
  694. /*
  695. * Sync utime(<path>)
  696. * Function returns
  697. * 0 : The operation was successful.
  698. * -errno : The command failed.
  699. */
  700. int nfs_utime_sync(struct nfs_context *nfs, const char *path, struct utimbuf *times);
  701. /*
  702. * ACCESS()
  703. */
  704. /*
  705. * Async access(<path>)
  706. * Function returns
  707. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  708. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  709. *
  710. * When the callback is invoked, status indicates the result:
  711. * 0 : Success.
  712. * data is NULL
  713. * -errno : An error occurred.
  714. * data is the error string.
  715. */
  716. int nfs_access_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
  717. /*
  718. * Sync access(<path>)
  719. * Function returns
  720. * 0 : The operation was successful.
  721. * -errno : The command failed.
  722. */
  723. int nfs_access_sync(struct nfs_context *nfs, const char *path, int mode);
  724. /*
  725. * SYMLINK()
  726. */
  727. /*
  728. * Async symlink(<path>)
  729. * Function returns
  730. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  731. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  732. *
  733. * When the callback is invoked, status indicates the result:
  734. * 0 : Success.
  735. * data is NULL
  736. * -errno : An error occurred.
  737. * data is the error string.
  738. */
  739. int nfs_symlink_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data);
  740. /*
  741. * Sync symlink(<path>)
  742. * Function returns
  743. * 0 : The operation was successful.
  744. * -errno : The command failed.
  745. */
  746. int nfs_symlink_sync(struct nfs_context *nfs, const char *oldpath, const char *newpath);
  747. /*
  748. * RENAME()
  749. */
  750. /*
  751. * Async rename(<oldpath>, <newpath>)
  752. * Function returns
  753. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  754. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  755. *
  756. * When the callback is invoked, status indicates the result:
  757. * 0 : Success.
  758. * data is NULL
  759. * -errno : An error occurred.
  760. * data is the error string.
  761. */
  762. int nfs_rename_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data);
  763. /*
  764. * Sync rename(<oldpath>, <newpath>)
  765. * Function returns
  766. * 0 : The operation was successful.
  767. * -errno : The command failed.
  768. */
  769. int nfs_rename_sync(struct nfs_context *nfs, const char *oldpath, const char *newpath);
  770. /*
  771. * LINK()
  772. */
  773. /*
  774. * Async link(<oldpath>, <newpath>)
  775. * Function returns
  776. * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
  777. * <0 : An error occurred when trying to set up the operation. The callback will not be invoked.
  778. *
  779. * When the callback is invoked, status indicates the result:
  780. * 0 : Success.
  781. * data is NULL
  782. * -errno : An error occurred.
  783. * data is the error string.
  784. */
  785. int nfs_link_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data);
  786. /*
  787. * Sync link(<oldpath>, <newpath>)
  788. * Function returns
  789. * 0 : The operation was successful.
  790. * -errno : The command failed.
  791. */
  792. int nfs_link_sync(struct nfs_context *nfs, const char *oldpath, const char *newpath);
  793. //qqq replace later with lseek(cur, 0)
  794. nfs_off_t nfs_get_current_offset(struct nfsfh *nfsfh);
  795. #endif /* CCAN_NFS_H */