+ nfs = nfs_init_context();
+ if (nfs == NULL) {
+ printf("failed to init context\n");
+ goto finished;
+ }
+
+ if (discovery) {
+ url = nfs_parse_url_incomplete(nfs, argv[argc - 1]);
+ if (url == NULL) {
+ fprintf(stderr, "%s\n", nfs_get_error(nfs));
+ goto finished;
+ }
+ if (!url->server) {
+ struct nfs_server_list *srvrs;
+ struct nfs_server_list *srv;
+
+ srvrs = nfs_find_local_servers();
+ if (srvrs == NULL) {
+ fprintf(stderr, "Failed to find local servers.\n");
+ goto finished;
+ }
+ for (srv=srvrs; srv; srv = srv->next) {
+ if (recursive) {
+ process_server(srv->addr);
+ } else {
+ printf("nfs://%s\n", srv->addr);
+ }
+ }
+ free_nfs_srvr_list(srvrs);
+ ret = 0;
+ goto finished;
+ }
+ if (url->server && !url->path) {
+ ret = process_server(url->server);
+ goto finished;
+ }
+ nfs_destroy_url(url);
+ }
+
+ url = nfs_parse_url_dir(nfs, argv[argc - 1]);
+ if (url == NULL) {
+ fprintf(stderr, "%s\n", nfs_get_error(nfs));
+ goto finished;
+ }
+
+ client.server = url->server;
+ client.export = url->path;
+ client.is_finished = 0;
+
+ if ((ret = nfs_mount(nfs, client.server, client.export)) != 0) {
+ fprintf(stderr, "Failed to mount nfs share : %s\n", nfs_get_error(nfs));
+ goto finished;
+ }
+
+ process_dir(nfs, "", 16);