You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nfs_open.c 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. /*
  2. * Copyright (C) 2013 Marin Hannache <ipxe@mareo.fr>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA.
  18. */
  19. #include <stdint.h>
  20. #include <stdlib.h>
  21. #include <stdio.h>
  22. #include <string.h>
  23. #include <assert.h>
  24. #include <errno.h>
  25. #include <libgen.h>
  26. #include <byteswap.h>
  27. #include <ipxe/time.h>
  28. #include <ipxe/socket.h>
  29. #include <ipxe/tcpip.h>
  30. #include <ipxe/in.h>
  31. #include <ipxe/iobuf.h>
  32. #include <ipxe/xfer.h>
  33. #include <ipxe/open.h>
  34. #include <ipxe/uri.h>
  35. #include <ipxe/features.h>
  36. #include <ipxe/nfs.h>
  37. #include <ipxe/nfs_open.h>
  38. #include <ipxe/oncrpc.h>
  39. #include <ipxe/oncrpc_iob.h>
  40. #include <ipxe/portmap.h>
  41. #include <ipxe/mount.h>
  42. #include <ipxe/nfs_uri.h>
  43. /** @file
  44. *
  45. * Network File System protocol
  46. *
  47. */
  48. FEATURE ( FEATURE_PROTOCOL, "NFS", DHCP_EB_FEATURE_NFS, 1 );
  49. #define NFS_RSIZE 100000
  50. enum nfs_pm_state {
  51. NFS_PORTMAP_NONE = 0,
  52. NFS_PORTMAP_MOUNTPORT,
  53. NFS_PORTMAP_NFSPORT,
  54. MFS_PORTMAP_CLOSED,
  55. };
  56. enum nfs_mount_state {
  57. NFS_MOUNT_NONE = 0,
  58. NFS_MOUNT_MNT,
  59. NFS_MOUNT_UMNT,
  60. NFS_MOUNT_CLOSED,
  61. };
  62. enum nfs_state {
  63. NFS_NONE = 0,
  64. NFS_LOOKUP,
  65. NFS_LOOKUP_SENT,
  66. NFS_READLINK,
  67. NFS_READLINK_SENT,
  68. NFS_READ,
  69. NFS_READ_SENT,
  70. NFS_CLOSED,
  71. };
  72. /**
  73. * A NFS request
  74. *
  75. */
  76. struct nfs_request {
  77. /** Reference counter */
  78. struct refcnt refcnt;
  79. /** Data transfer interface */
  80. struct interface xfer;
  81. struct interface pm_intf;
  82. struct interface mount_intf;
  83. struct interface nfs_intf;
  84. enum nfs_pm_state pm_state;
  85. enum nfs_mount_state mount_state;
  86. enum nfs_state nfs_state;
  87. struct oncrpc_session pm_session;
  88. struct oncrpc_session mount_session;
  89. struct oncrpc_session nfs_session;
  90. struct oncrpc_cred_sys auth_sys;
  91. char * hostname;
  92. struct nfs_uri uri;
  93. struct nfs_fh readlink_fh;
  94. struct nfs_fh current_fh;
  95. uint64_t file_offset;
  96. size_t remaining;
  97. int eof;
  98. };
  99. static void nfs_step ( struct nfs_request *nfs );
  100. /**
  101. * Free NFS request
  102. *
  103. * @v refcnt Reference counter
  104. */
  105. static void nfs_free ( struct refcnt *refcnt ) {
  106. struct nfs_request *nfs;
  107. nfs = container_of ( refcnt, struct nfs_request, refcnt );
  108. DBGC ( nfs, "NFS_OPEN %p freed\n", nfs );
  109. nfs_uri_free ( &nfs->uri );
  110. free ( nfs->hostname );
  111. free ( nfs->auth_sys.hostname );
  112. free ( nfs );
  113. }
  114. /**
  115. * Mark NFS operation as complete
  116. *
  117. * @v nfs NFS request
  118. * @v rc Return status code
  119. */
  120. static void nfs_done ( struct nfs_request *nfs, int rc ) {
  121. if ( rc == 0 && nfs->nfs_state != NFS_CLOSED )
  122. rc = -ECONNRESET;
  123. DBGC ( nfs, "NFS_OPEN %p completed (%s)\n", nfs, strerror ( rc ) );
  124. intf_shutdown ( &nfs->xfer, rc );
  125. intf_shutdown ( &nfs->pm_intf, rc );
  126. intf_shutdown ( &nfs->mount_intf, rc );
  127. intf_shutdown ( &nfs->nfs_intf, rc );
  128. }
  129. static int nfs_connect ( struct interface *intf, uint16_t port,
  130. const char *hostname ) {
  131. struct sockaddr_tcpip peer;
  132. struct sockaddr_tcpip local;
  133. if ( ! intf || ! hostname || ! port )
  134. return -EINVAL;
  135. memset ( &peer, 0, sizeof ( peer ) );
  136. memset ( &local, 0, sizeof ( local ) );
  137. peer.st_port = htons ( port );
  138. /* Use a local port < 1024 to avoid using the 'insecure' option in
  139. * /etc/exports file. */
  140. local.st_flags = TCPIP_BIND_PRIVILEGED;
  141. return xfer_open_named_socket ( intf, SOCK_STREAM,
  142. ( struct sockaddr * ) &peer, hostname,
  143. ( struct sockaddr * ) &local );
  144. }
  145. static void nfs_pm_step ( struct nfs_request *nfs ) {
  146. int rc;
  147. if ( ! xfer_window ( &nfs->pm_intf ) )
  148. return;
  149. if ( nfs->pm_state == NFS_PORTMAP_NONE ) {
  150. DBGC ( nfs, "NFS_OPEN %p GETPORT call (mount)\n", nfs );
  151. rc = portmap_getport ( &nfs->pm_intf, &nfs->pm_session,
  152. ONCRPC_MOUNT, MOUNT_VERS,
  153. PORTMAP_PROTO_TCP );
  154. if ( rc != 0 )
  155. goto err;
  156. nfs->pm_state++;
  157. return;
  158. }
  159. if ( nfs->pm_state == NFS_PORTMAP_NFSPORT ) {
  160. DBGC ( nfs, "NFS_OPEN %p GETPORT call (nfs)\n", nfs );
  161. rc = portmap_getport ( &nfs->pm_intf, &nfs->pm_session,
  162. ONCRPC_NFS, NFS_VERS,
  163. PORTMAP_PROTO_TCP );
  164. if ( rc != 0 )
  165. goto err;
  166. return;
  167. }
  168. return;
  169. err:
  170. nfs_done ( nfs, rc );
  171. }
  172. static int nfs_pm_deliver ( struct nfs_request *nfs,
  173. struct io_buffer *io_buf,
  174. struct xfer_metadata *meta __unused ) {
  175. int rc;
  176. struct oncrpc_reply reply;
  177. struct portmap_getport_reply getport_reply;
  178. oncrpc_get_reply ( &nfs->pm_session, &reply, io_buf );
  179. if ( reply.accept_state != 0 )
  180. {
  181. rc = -EPROTO;
  182. goto err;
  183. }
  184. if ( nfs->pm_state == NFS_PORTMAP_MOUNTPORT ) {
  185. DBGC ( nfs, "NFS_OPEN %p got GETPORT reply (mount)\n", nfs );
  186. rc = portmap_get_getport_reply ( &getport_reply, &reply );
  187. if ( rc != 0 )
  188. goto err;
  189. rc = nfs_connect ( &nfs->mount_intf, getport_reply.port,
  190. nfs->hostname );
  191. if ( rc != 0 )
  192. goto err;
  193. nfs->pm_state++;
  194. nfs_pm_step ( nfs );
  195. goto done;
  196. }
  197. if ( nfs->pm_state == NFS_PORTMAP_NFSPORT ) {
  198. DBGC ( nfs, "NFS_OPEN %p got GETPORT reply (nfs)\n", nfs );
  199. rc = portmap_get_getport_reply ( &getport_reply, &reply );
  200. if ( rc != 0 )
  201. goto err;
  202. rc = nfs_connect ( &nfs->nfs_intf, getport_reply.port,
  203. nfs->hostname );
  204. if ( rc != 0 )
  205. goto err;
  206. intf_shutdown ( &nfs->pm_intf, 0 );
  207. nfs->pm_state++;
  208. goto done;
  209. }
  210. rc = -EPROTO;
  211. err:
  212. nfs_done ( nfs, rc );
  213. done:
  214. free_iob ( io_buf );
  215. return 0;
  216. }
  217. static void nfs_mount_step ( struct nfs_request *nfs ) {
  218. int rc;
  219. if ( ! xfer_window ( &nfs->mount_intf ) )
  220. return;
  221. if ( nfs->mount_state == NFS_MOUNT_NONE ) {
  222. DBGC ( nfs, "NFS_OPEN %p MNT call (%s)\n", nfs,
  223. nfs_uri_mountpoint ( &nfs->uri ) );
  224. rc = mount_mnt ( &nfs->mount_intf, &nfs->mount_session,
  225. nfs_uri_mountpoint ( &nfs->uri ) );
  226. if ( rc != 0 )
  227. goto err;
  228. nfs->mount_state++;
  229. return;
  230. }
  231. if ( nfs->mount_state == NFS_MOUNT_UMNT ) {
  232. DBGC ( nfs, "NFS_OPEN %p UMNT call\n", nfs );
  233. rc = mount_umnt ( &nfs->mount_intf, &nfs->mount_session,
  234. nfs_uri_mountpoint ( &nfs->uri ) );
  235. if ( rc != 0 )
  236. goto err;
  237. }
  238. return;
  239. err:
  240. nfs_done ( nfs, rc );
  241. }
  242. static int nfs_mount_deliver ( struct nfs_request *nfs,
  243. struct io_buffer *io_buf,
  244. struct xfer_metadata *meta __unused ) {
  245. int rc;
  246. struct oncrpc_reply reply;
  247. struct mount_mnt_reply mnt_reply;
  248. oncrpc_get_reply ( &nfs->mount_session, &reply, io_buf );
  249. if ( reply.accept_state != 0 )
  250. {
  251. rc = -EPROTO;
  252. goto err;
  253. }
  254. if ( nfs->mount_state == NFS_MOUNT_MNT ) {
  255. DBGC ( nfs, "NFS_OPEN %p got MNT reply\n", nfs );
  256. rc = mount_get_mnt_reply ( &mnt_reply, &reply );
  257. if ( rc != 0 ) {
  258. switch ( mnt_reply.status ) {
  259. case MNT3ERR_NOTDIR:
  260. case MNT3ERR_NOENT:
  261. case MNT3ERR_ACCES:
  262. break;
  263. default:
  264. goto err;
  265. }
  266. if ( ! strcmp ( nfs_uri_mountpoint ( &nfs->uri ),
  267. "/" ) )
  268. goto err;
  269. if ( ( rc = nfs_uri_next_mountpoint ( &nfs->uri ) ) )
  270. goto err;
  271. DBGC ( nfs, "NFS_OPEN %p MNT failed retrying with " \
  272. "%s\n", nfs, nfs_uri_mountpoint ( &nfs->uri ) );
  273. nfs->mount_state--;
  274. nfs_mount_step ( nfs );
  275. goto done;
  276. }
  277. nfs->current_fh = mnt_reply.fh;
  278. nfs->nfs_state = NFS_LOOKUP;
  279. nfs_step ( nfs );
  280. goto done;
  281. }
  282. if ( nfs->mount_state == NFS_MOUNT_UMNT ) {
  283. DBGC ( nfs, "NFS_OPEN %p got UMNT reply\n", nfs );
  284. nfs_done ( nfs, 0 );
  285. goto done;
  286. }
  287. rc = -EPROTO;
  288. err:
  289. nfs_done ( nfs, rc );
  290. done:
  291. free_iob ( io_buf );
  292. return 0;
  293. }
  294. static void nfs_step ( struct nfs_request *nfs ) {
  295. int rc;
  296. char *path_component;
  297. if ( ! xfer_window ( &nfs->nfs_intf ) )
  298. return;
  299. if ( nfs->nfs_state == NFS_LOOKUP ) {
  300. path_component = nfs_uri_next_path_component ( &nfs->uri );
  301. DBGC ( nfs, "NFS_OPEN %p LOOKUP call (%s)\n", nfs,
  302. path_component );
  303. rc = nfs_lookup ( &nfs->nfs_intf, &nfs->nfs_session,
  304. &nfs->current_fh, path_component );
  305. if ( rc != 0 )
  306. goto err;
  307. nfs->nfs_state++;
  308. return;
  309. }
  310. if ( nfs->nfs_state == NFS_READLINK ) {
  311. DBGC ( nfs, "NFS_OPEN %p READLINK call\n", nfs );
  312. rc = nfs_readlink ( &nfs->nfs_intf, &nfs->nfs_session,
  313. &nfs->readlink_fh );
  314. if ( rc != 0 )
  315. goto err;
  316. nfs->nfs_state++;
  317. return;
  318. }
  319. if ( nfs->nfs_state == NFS_READ ) {
  320. DBGC ( nfs, "NFS_OPEN %p READ call\n", nfs );
  321. rc = nfs_read ( &nfs->nfs_intf, &nfs->nfs_session,
  322. &nfs->current_fh, nfs->file_offset,
  323. NFS_RSIZE );
  324. if ( rc != 0 )
  325. goto err;
  326. nfs->nfs_state++;
  327. return;
  328. }
  329. return;
  330. err:
  331. nfs_done ( nfs, rc );
  332. }
  333. static int nfs_deliver ( struct nfs_request *nfs,
  334. struct io_buffer *io_buf,
  335. struct xfer_metadata *meta __unused ) {
  336. int rc;
  337. struct oncrpc_reply reply;
  338. if ( nfs->remaining == 0 ) {
  339. oncrpc_get_reply ( &nfs->nfs_session, &reply, io_buf );
  340. if ( reply.accept_state != 0 ) {
  341. rc = -EPROTO;
  342. goto err;
  343. }
  344. }
  345. if ( nfs->nfs_state == NFS_LOOKUP_SENT ) {
  346. struct nfs_lookup_reply lookup_reply;
  347. DBGC ( nfs, "NFS_OPEN %p got LOOKUP reply\n", nfs );
  348. rc = nfs_get_lookup_reply ( &lookup_reply, &reply );
  349. if ( rc != 0 )
  350. goto err;
  351. if ( lookup_reply.ent_type == NFS_ATTR_SYMLINK ) {
  352. nfs->readlink_fh = lookup_reply.fh;
  353. nfs->nfs_state = NFS_READLINK;
  354. } else {
  355. nfs->current_fh = lookup_reply.fh;
  356. if ( nfs->uri.lookup_pos[0] == '\0' )
  357. nfs->nfs_state = NFS_READ;
  358. else
  359. nfs->nfs_state--;
  360. }
  361. nfs_step ( nfs );
  362. goto done;
  363. }
  364. if ( nfs->nfs_state == NFS_READLINK_SENT ) {
  365. char *path;
  366. struct nfs_readlink_reply readlink_reply;
  367. DBGC ( nfs, "NFS_OPEN %p got READLINK reply\n", nfs );
  368. rc = nfs_get_readlink_reply ( &readlink_reply, &reply );
  369. if ( rc != 0 )
  370. goto err;
  371. if ( readlink_reply.path_len == 0 )
  372. {
  373. rc = -EINVAL;
  374. goto err;
  375. }
  376. if ( ! ( path = strndup ( readlink_reply.path,
  377. readlink_reply.path_len ) ) )
  378. {
  379. rc = -ENOMEM;
  380. goto err;
  381. }
  382. nfs_uri_symlink ( &nfs->uri, path );
  383. free ( path );
  384. DBGC ( nfs, "NFS_OPEN %p new path: %s\n", nfs,
  385. nfs->uri.path );
  386. nfs->nfs_state = NFS_LOOKUP;
  387. nfs_step ( nfs );
  388. goto done;
  389. }
  390. if ( nfs->nfs_state == NFS_READ_SENT ) {
  391. if ( nfs->remaining == 0 ) {
  392. DBGC ( nfs, "NFS_OPEN %p got READ reply\n", nfs );
  393. struct nfs_read_reply read_reply;
  394. rc = nfs_get_read_reply ( &read_reply, &reply );
  395. if ( rc != 0 )
  396. goto err;
  397. if ( nfs->file_offset == 0 ) {
  398. DBGC2 ( nfs, "NFS_OPEN %p size: %llu bytes\n",
  399. nfs, read_reply.filesize );
  400. xfer_seek ( &nfs->xfer, read_reply.filesize );
  401. xfer_seek ( &nfs->xfer, 0 );
  402. }
  403. nfs->file_offset += read_reply.count;
  404. nfs->remaining = read_reply.count;
  405. nfs->eof = read_reply.eof;
  406. }
  407. size_t len = iob_len ( io_buf );
  408. if ( len > nfs->remaining )
  409. iob_unput ( io_buf, len - nfs->remaining );
  410. nfs->remaining -= iob_len ( io_buf );
  411. DBGC ( nfs, "NFS_OPEN %p got %zd bytes\n", nfs,
  412. iob_len ( io_buf ) );
  413. rc = xfer_deliver_iob ( &nfs->xfer, iob_disown ( io_buf ) );
  414. if ( rc != 0 )
  415. goto err;
  416. if ( nfs->remaining == 0 ) {
  417. if ( ! nfs->eof ) {
  418. nfs->nfs_state--;
  419. nfs_step ( nfs );
  420. } else {
  421. intf_shutdown ( &nfs->nfs_intf, 0 );
  422. nfs->nfs_state++;
  423. nfs->mount_state++;
  424. nfs_mount_step ( nfs );
  425. }
  426. }
  427. return 0;
  428. }
  429. rc = -EPROTO;
  430. err:
  431. nfs_done ( nfs, rc );
  432. done:
  433. free_iob ( io_buf );
  434. return 0;
  435. }
  436. /*****************************************************************************
  437. * Interfaces
  438. *
  439. */
  440. static struct interface_operation nfs_xfer_operations[] = {
  441. INTF_OP ( intf_close, struct nfs_request *, nfs_done ),
  442. };
  443. /** NFS data transfer interface descriptor */
  444. static struct interface_descriptor nfs_xfer_desc =
  445. INTF_DESC ( struct nfs_request, xfer, nfs_xfer_operations );
  446. static struct interface_operation nfs_pm_operations[] = {
  447. INTF_OP ( intf_close, struct nfs_request *, nfs_done ),
  448. INTF_OP ( xfer_deliver, struct nfs_request *, nfs_pm_deliver ),
  449. INTF_OP ( xfer_window_changed, struct nfs_request *, nfs_pm_step ),
  450. };
  451. static struct interface_descriptor nfs_pm_desc =
  452. INTF_DESC ( struct nfs_request, pm_intf, nfs_pm_operations );
  453. static struct interface_operation nfs_mount_operations[] = {
  454. INTF_OP ( intf_close, struct nfs_request *, nfs_done ),
  455. INTF_OP ( xfer_deliver, struct nfs_request *, nfs_mount_deliver ),
  456. INTF_OP ( xfer_window_changed, struct nfs_request *, nfs_mount_step ),
  457. };
  458. static struct interface_descriptor nfs_mount_desc =
  459. INTF_DESC ( struct nfs_request, mount_intf, nfs_mount_operations );
  460. static struct interface_operation nfs_operations[] = {
  461. INTF_OP ( intf_close, struct nfs_request *, nfs_done ),
  462. INTF_OP ( xfer_deliver, struct nfs_request *, nfs_deliver ),
  463. INTF_OP ( xfer_window_changed, struct nfs_request *, nfs_step ),
  464. };
  465. static struct interface_descriptor nfs_desc =
  466. INTF_DESC_PASSTHRU ( struct nfs_request, nfs_intf, nfs_operations,
  467. xfer );
  468. /*****************************************************************************
  469. *
  470. * URI opener
  471. *
  472. */
  473. static int nfs_parse_uri ( struct nfs_request *nfs, const struct uri *uri ) {
  474. int rc;
  475. if ( ! uri || ! uri->host || ! uri->path )
  476. return -EINVAL;
  477. if ( ( rc = nfs_uri_init ( &nfs->uri, uri ) ) != 0 )
  478. return rc;
  479. if ( ! ( nfs->hostname = strdup ( uri->host ) ) ) {
  480. rc = -ENOMEM;
  481. goto err_hostname;
  482. }
  483. DBGC ( nfs, "NFS_OPEN %p URI parsed: (mountpoint=%s, path=%s)\n",
  484. nfs, nfs_uri_mountpoint ( &nfs->uri), nfs->uri.path );
  485. return 0;
  486. err_hostname:
  487. nfs_uri_free ( &nfs->uri );
  488. return rc;
  489. }
  490. /**
  491. * Initiate a NFS connection
  492. *
  493. * @v xfer Data transfer interface
  494. * @v uri Uniform Resource Identifier
  495. * @ret rc Return status code
  496. */
  497. static int nfs_open ( struct interface *xfer, struct uri *uri ) {
  498. int rc;
  499. struct nfs_request *nfs;
  500. nfs = zalloc ( sizeof ( *nfs ) );
  501. if ( ! nfs )
  502. return -ENOMEM;
  503. rc = nfs_parse_uri( nfs, uri );
  504. if ( rc != 0 )
  505. goto err_uri;
  506. rc = oncrpc_init_cred_sys ( &nfs->auth_sys );
  507. if ( rc != 0 )
  508. goto err_cred;
  509. ref_init ( &nfs->refcnt, nfs_free );
  510. intf_init ( &nfs->xfer, &nfs_xfer_desc, &nfs->refcnt );
  511. intf_init ( &nfs->pm_intf, &nfs_pm_desc, &nfs->refcnt );
  512. intf_init ( &nfs->mount_intf, &nfs_mount_desc, &nfs->refcnt );
  513. intf_init ( &nfs->nfs_intf, &nfs_desc, &nfs->refcnt );
  514. portmap_init_session ( &nfs->pm_session, &nfs->auth_sys.credential );
  515. mount_init_session ( &nfs->mount_session, &nfs->auth_sys.credential );
  516. nfs_init_session ( &nfs->nfs_session, &nfs->auth_sys.credential );
  517. DBGC ( nfs, "NFS_OPEN %p connecting to port mapper (%s:%d)...\n", nfs,
  518. nfs->hostname, PORTMAP_PORT );
  519. rc = nfs_connect ( &nfs->pm_intf, PORTMAP_PORT, nfs->hostname );
  520. if ( rc != 0 )
  521. goto err_connect;
  522. /* Attach to parent interface, mortalise self, and return */
  523. intf_plug_plug ( &nfs->xfer, xfer );
  524. ref_put ( &nfs->refcnt );
  525. return 0;
  526. err_connect:
  527. free ( nfs->auth_sys.hostname );
  528. err_cred:
  529. nfs_uri_free ( &nfs->uri );
  530. free ( nfs->hostname );
  531. err_uri:
  532. free ( nfs );
  533. return rc;
  534. }
  535. /** NFS URI opener */
  536. struct uri_opener nfs_uri_opener __uri_opener = {
  537. .scheme = "nfs",
  538. .open = nfs_open,
  539. };