]> git.decadent.org.uk Git - nfs-utils.git/blob - utils/mount/stropts.c
c8148c42a4ed7b1a6ba42c05aaf1fe0f585b390c
[nfs-utils.git] / utils / mount / stropts.c
1 /*
2  * stropts.c -- NFS mount using C string to pass options to kernel
3  *
4  * Copyright (C) 2007 Oracle.  All rights reserved.
5  * Copyright (C) 2007 Chuck Lever <chuck.lever@oracle.com>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public
18  * License along with this program; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 021110-1307, USA.
21  *
22  */
23
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27
28 #include <ctype.h>
29 #include <unistd.h>
30 #include <stdio.h>
31 #include <string.h>
32 #include <stdlib.h>
33 #include <errno.h>
34 #include <netdb.h>
35 #include <time.h>
36 #include <sys/socket.h>
37 #include <sys/mount.h>
38
39 #include "xcommon.h"
40 #include "mount.h"
41 #include "nls.h"
42 #include "nfs_mount.h"
43 #include "mount_constants.h"
44 #include "stropts.h"
45 #include "error.h"
46 #include "network.h"
47 #include "parse_opt.h"
48
49 #ifdef HAVE_RPCSVC_NFS_PROT_H
50 #include <rpcsvc/nfs_prot.h>
51 #else
52 #include <linux/nfs.h>
53 #define nfsstat nfs_stat
54 #endif
55
56 #ifndef NFS_PORT
57 #define NFS_PORT 2049
58 #endif
59
60 #ifndef NFS_MAXHOSTNAME
61 #define NFS_MAXHOSTNAME         (255)
62 #endif
63
64 #ifndef NFS_MAXPATHNAME
65 #define NFS_MAXPATHNAME         (1024)
66 #endif
67
68 #ifndef NFS_DEF_FG_TIMEOUT_MINUTES
69 #define NFS_DEF_FG_TIMEOUT_MINUTES      (2u)
70 #endif
71
72 #ifndef NFS_DEF_BG_TIMEOUT_MINUTES
73 #define NFS_DEF_BG_TIMEOUT_MINUTES      (10000u)
74 #endif
75
76 extern int nfs_mount_data_version;
77 extern char *progname;
78 extern int verbose;
79
80 struct nfsmount_info {
81         const char              *spec,          /* server:/path */
82                                 *node,          /* mounted-on dir */
83                                 *type;          /* "nfs" or "nfs4" */
84         char                    *hostname;      /* server's hostname */
85
86         struct mount_options    *options;       /* parsed mount options */
87         char                    **extra_opts;   /* string for /etc/mtab */
88
89         int                     flags,          /* MS_ flags */
90                                 fake,           /* actually do the mount? */
91                                 child;          /* forked bg child? */
92 };
93
94 static int nfs_parse_devname(struct nfsmount_info *mi)
95 {
96         int ret = 0;
97         char *dev, *pathname, *s;
98
99         dev = xstrdup(mi->spec);
100
101         if (!(pathname = strchr(dev, ':'))) {
102                 nfs_error(_("%s: remote share not in 'host:dir' format"),
103                                 progname);
104                 goto out;
105         }
106         *pathname = '\0';
107         pathname++;
108
109         /*
110          * We don't need a copy of the pathname, but let's
111          * sanity check it anyway.
112          */
113         if (strlen(pathname) > NFS_MAXPATHNAME) {
114                 nfs_error(_("%s: export pathname is too long"),
115                                 progname);
116                 goto out;
117         }
118
119         /*
120          * Ignore all but first hostname in replicated mounts
121          * until they can be fully supported. (mack@sgi.com)
122          */
123         if ((s = strchr(dev, ','))) {
124                 *s = '\0';
125                 nfs_error(_("%s: warning: multiple hostnames not supported"),
126                                 progname);
127                 nfs_error(_("%s: ignoring hostnames that follow the first one"),
128                                 progname);
129         }
130         mi->hostname = xstrdup(dev);
131         if (strlen(mi->hostname) > NFS_MAXHOSTNAME) {
132                 nfs_error(_("%s: server hostname is too long"),
133                                 progname);
134                 free(mi->hostname);
135                 mi->hostname = NULL;
136                 goto out;
137         }
138
139         ret = 1;
140
141 out:
142         free(dev);
143         return ret;
144 }
145
146 static int fill_ipv4_sockaddr(const char *hostname, struct sockaddr_in *addr)
147 {
148         struct hostent *hp;
149         addr->sin_family = AF_INET;
150
151         if (inet_aton(hostname, &addr->sin_addr))
152                 return 1;
153         if ((hp = gethostbyname(hostname)) == NULL) {
154                 nfs_error(_("%s: can't get address for %s\n"),
155                                 progname, hostname);
156                 return 0;
157         }
158         if (hp->h_length > sizeof(struct in_addr)) {
159                 nfs_error(_("%s: got bad hp->h_length"), progname);
160                 hp->h_length = sizeof(struct in_addr);
161         }
162         memcpy(&addr->sin_addr, hp->h_addr, hp->h_length);
163         return 1;
164 }
165
166 /*
167  * Obtain a retry timeout value based on the value of the "retry=" option.
168  *
169  * Returns a time_t timeout timestamp, in seconds.
170  */
171 static time_t nfs_parse_retry_option(struct mount_options *options,
172                                      unsigned int timeout_minutes)
173 {
174         char *retry_option, *endptr;
175
176         retry_option = po_get(options, "retry");
177         if (retry_option) {
178                 long tmp;
179
180                 errno = 0;
181                 tmp = strtol(retry_option, &endptr, 10);
182                 if (errno == 0 && endptr != retry_option && tmp >= 0)
183                         timeout_minutes = tmp;
184                 else if (verbose)
185                         nfs_error(_("%s: invalid retry timeout was specified; "
186                                         "using default timeout"), progname);
187         }
188
189         return time(NULL) + (time_t)(timeout_minutes * 60);
190 }
191
192 /*
193  * Append the 'addr=' option to the options string to pass a resolved
194  * server address to the kernel.  After a successful mount, this address
195  * is also added to /etc/mtab for use when unmounting.
196  *
197  * If 'addr=' is already present, we strip it out.  This prevents users
198  * from setting a bogus 'addr=' option themselves, and also allows bg
199  * retries to recompute the server's address, in case it has changed.
200  *
201  * Returns 1 if 'addr=' option appended successfully;
202  * otherwise zero.
203  */
204 static int append_addr_option(struct sockaddr_in *saddr,
205                            struct mount_options *options)
206 {
207         char new_option[24];
208
209         po_remove_all(options, "addr");
210
211         snprintf(new_option, sizeof(new_option) - 1,
212                         "addr=%s", inet_ntoa(saddr->sin_addr));
213
214         if (po_append(options, new_option) == PO_SUCCEEDED)
215                 return 1;
216         return 0;
217 }
218
219 /*
220  * Called to discover our address and append an appropriate 'clientaddr='
221  * option to the options string.
222  *
223  * Returns 1 if 'clientaddr=' option created successfully or if
224  * 'clientaddr=' option is already present; otherwise zero.
225  */
226 static int append_clientaddr_option(struct sockaddr_in *saddr,
227                                     struct mount_options *options)
228 {
229         struct sockaddr_in my_addr;
230         char new_option[32];
231
232         if (po_contains(options, "clientaddr") == PO_SUCCEEDED)
233                 return 1;
234
235         if (!get_client_address(saddr, &my_addr))
236                 return 0;
237
238         snprintf(new_option, sizeof(new_option) - 1,
239                         "clientaddr=%s", inet_ntoa(my_addr.sin_addr));
240
241         if (po_append(options, new_option) == PO_SUCCEEDED)
242                 return 1;
243         return 0;
244 }
245
246 /*
247  * Resolve the 'mounthost=' hostname and append a new option using
248  * the resulting IPv4 address.
249  */
250 static int fix_mounthost_option(struct mount_options *options)
251 {
252         struct sockaddr_in maddr;
253         char *mounthost, new_option[32];
254
255         mounthost = po_get(options, "mounthost");
256         if (!mounthost)
257                 return 1;
258
259         if (!fill_ipv4_sockaddr(mounthost, &maddr))
260                 return 0;
261
262         snprintf(new_option, sizeof(new_option) - 1,
263                         "mountaddr=%s", inet_ntoa(maddr.sin_addr));
264
265         if (po_append(options, new_option) == PO_SUCCEEDED)
266                 return 1;
267         return 0;
268 }
269
270 /*
271  * Returns zero if the "lock" option is in effect, but statd
272  * can't be started.  Otherwise, returns 1.
273  */
274 static int verify_lock_option(struct mount_options *options)
275 {
276         if (po_rightmost(options, "nolock", "lock") == PO_KEY1_RIGHTMOST)
277                 return 1;
278
279         if (!start_statd()) {
280                 nfs_error(_("%s: rpc.statd is not running but is "
281                             "required for remote locking."), progname);
282                 nfs_error(_("%s: Either use '-o nolock' to keep "
283                             "locks local, or start statd."), progname);
284                 return 0;
285         }
286
287         return 1;
288 }
289
290 /*
291  * Set up mandatory NFS mount options.
292  *
293  * Returns 1 if successful; otherwise zero.
294  */
295 static int nfs_validate_options(struct nfsmount_info *mi)
296 {
297         struct sockaddr_in saddr;
298
299         if (!fill_ipv4_sockaddr(mi->hostname, &saddr))
300                 return 0;
301
302         if (strncmp(mi->type, "nfs4", 4) == 0) {
303                 if (!append_clientaddr_option(&saddr, mi->options))
304                         return 0;
305         } else {
306                 if (!fix_mounthost_option(mi->options))
307                         return 0;
308                 if (!mi->fake && !verify_lock_option(mi->options))
309                         return 0;
310         }
311
312         if (!append_addr_option(&saddr, mi->options))
313                 return 0;
314
315         return 1;
316 }
317
318 /*
319  * Distinguish between permanent and temporary errors.
320  *
321  * Returns 0 if the passed-in error is temporary, thus the
322  * mount system call should be retried; returns one if the
323  * passed-in error is permanent, thus the mount system call
324  * should not be retried.
325  */
326 static int is_permanent_error(int error)
327 {
328         switch (error) {
329         case ESTALE:
330         case ETIMEDOUT:
331         case ECONNREFUSED:
332                 return 0;       /* temporary */
333         default:
334                 return 1;       /* permanent */
335         }
336 }
337
338 /*
339  * Reconstruct the mount option string based on a portmapper probe
340  * of the server.  Returns one if the server's portmapper returned
341  * something we can use, otherwise zero.
342  *
343  * To handle version and transport protocol fallback properly, we
344  * need to parse some of the mount options in order to set up a
345  * portmap probe.  Mount options that rewrite_mount_options()
346  * doesn't recognize are left alone.
347  *
348  * Returns a new group of mount options if successful; otherwise
349  * NULL is returned if some failure occurred.
350  */
351 static struct mount_options *rewrite_mount_options(char *str)
352 {
353         struct mount_options *options;
354         char *option, new_option[64];
355         clnt_addr_t mnt_server = { };
356         clnt_addr_t nfs_server = { };
357         int p;
358
359         options = po_split(str);
360         if (!options) {
361                 errno = EFAULT;
362                 return NULL;
363         }
364
365         errno = EINVAL;
366         option = po_get(options, "addr");
367         if (option) {
368                 nfs_server.saddr.sin_family = AF_INET;
369                 if (!inet_aton((const char *)option, &nfs_server.saddr.sin_addr))
370                         goto err;
371         } else
372                 goto err;
373
374         option = po_get(options, "mountaddr");
375         if (option) {
376                 mnt_server.saddr.sin_family = AF_INET;
377                 if (!inet_aton((const char *)option, &mnt_server.saddr.sin_addr))
378                         goto err;
379         } else
380                 memcpy(&mnt_server.saddr, &nfs_server.saddr,
381                                 sizeof(mnt_server.saddr));
382
383         option = po_get(options, "mountport");
384         if (option)
385                 mnt_server.pmap.pm_port = atoi(option);
386         mnt_server.pmap.pm_prog = MOUNTPROG;
387         option = po_get(options, "mountvers");
388         if (option)
389                 mnt_server.pmap.pm_vers = atoi(option);
390
391         option = po_get(options, "port");
392         if (option) {
393                 nfs_server.pmap.pm_port = atoi(option);
394                 po_remove_all(options, "port");
395         }
396         nfs_server.pmap.pm_prog = NFS_PROGRAM;
397
398         option = po_get(options, "nfsvers");
399         if (option) {
400                 nfs_server.pmap.pm_vers = atoi(option);
401                 po_remove_all(options, "nfsvers");
402         }
403         option = po_get(options, "vers");
404         if (option) {
405                 nfs_server.pmap.pm_vers = atoi(option);
406                 po_remove_all(options, "vers");
407         }
408         option = po_get(options, "proto");
409         if (option) {
410                 if (strcmp(option, "tcp") == 0) {
411                         nfs_server.pmap.pm_prot = IPPROTO_TCP;
412                         po_remove_all(options, "proto");
413                 }
414                 if (strcmp(option, "udp") == 0) {
415                         nfs_server.pmap.pm_prot = IPPROTO_UDP;
416                         po_remove_all(options, "proto");
417                 }
418         }
419         p = po_rightmost(options, "tcp", "udp");
420         switch (p) {
421         case PO_KEY2_RIGHTMOST:
422                 nfs_server.pmap.pm_prot = IPPROTO_UDP;
423                 break;
424         case PO_KEY1_RIGHTMOST:
425                 nfs_server.pmap.pm_prot = IPPROTO_TCP;
426                 break;
427         }
428         po_remove_all(options, "tcp");
429         po_remove_all(options, "udp");
430
431         if (!probe_bothports(&mnt_server, &nfs_server)) {
432                 errno = ESPIPE;
433                 goto err;
434         }
435
436         snprintf(new_option, sizeof(new_option) - 1,
437                  "nfsvers=%lu", nfs_server.pmap.pm_vers);
438         if (po_append(options, new_option) == PO_FAILED)
439                 goto err;
440
441         if (nfs_server.pmap.pm_prot == IPPROTO_TCP)
442                 snprintf(new_option, sizeof(new_option) - 1,
443                          "proto=tcp");
444         else
445                 snprintf(new_option, sizeof(new_option) - 1,
446                          "proto=udp");
447         if (po_append(options, new_option) == PO_FAILED)
448                 goto err;
449
450         if (nfs_server.pmap.pm_port != NFS_PORT) {
451                 snprintf(new_option, sizeof(new_option) - 1,
452                          "port=%lu", nfs_server.pmap.pm_port);
453                 if (po_append(options, new_option) == PO_FAILED)
454                         goto err;
455
456         }
457
458         errno = 0;
459         return options;
460
461 err:
462         po_destroy(options);
463         return NULL;
464 }
465
466 /*
467  * Do the mount(2) system call.
468  *
469  * Returns 1 if successful, otherwise zero.
470  * "errno" is set to reflect the individual error.
471  */
472 static int nfs_sys_mount(const struct nfsmount_info *mi, const char *type,
473                          const char *options)
474 {
475         int result;
476
477         result = mount(mi->spec, mi->node, type,
478                                 mi->flags & ~(MS_USER|MS_USERS), options);
479         if (verbose && result) {
480                 int save = errno;
481                 nfs_error(_("%s: mount(2): %s"), progname, strerror(save));
482                 errno = save;
483         }
484         return !result;
485 }
486
487 /*
488  * Retry an NFS mount that failed because the requested service isn't
489  * available on the server.
490  *
491  * Returns 1 if successful.  Otherwise, returns zero.
492  * "errno" is set to reflect the individual error.
493  *
494  * Side effect: If the retry is successful, both 'options' and
495  * 'extra_opts' are updated to reflect the mount options that worked.
496  * If the retry fails, 'options' and 'extra_opts' are left unchanged.
497  */
498 static int nfs_retry_nfs23mount(struct nfsmount_info *mi)
499 {
500         struct mount_options *retry_options;
501         char *retry_str = NULL;
502         char **extra_opts = mi->extra_opts;
503
504         retry_options = rewrite_mount_options(*extra_opts);
505         if (!retry_options)
506                 return 0;
507
508         if (po_join(retry_options, &retry_str) == PO_FAILED) {
509                 po_destroy(retry_options);
510                 errno = EIO;
511                 return 0;
512         }
513
514         if (verbose)
515                 printf(_("%s: text-based options (retry): '%s'\n"),
516                         progname, retry_str);
517
518         if (!nfs_sys_mount(mi, "nfs", retry_str)) {
519                 po_destroy(retry_options);
520                 free(retry_str);
521                 return 0;
522         }
523
524         free(*extra_opts);
525         *extra_opts = retry_str;
526         po_replace(mi->options, retry_options);
527         return 1;
528 }
529
530 /*
531  * Attempt an NFSv2/3 mount via a mount(2) system call.  If the kernel
532  * claims the requested service isn't supported on the server, probe
533  * the server to see what's supported, rewrite the mount options,
534  * and retry the request.
535  *
536  * Returns 1 if successful.  Otherwise, returns zero.
537  * "errno" is set to reflect the individual error.
538  *
539  * Side effect: If the retry is successful, both 'options' and
540  * 'extra_opts' are updated to reflect the mount options that worked.
541  * If the retry fails, 'options' and 'extra_opts' are left unchanged.
542  */
543 static int nfs_try_nfs23mount(struct nfsmount_info *mi)
544 {
545         char **extra_opts = mi->extra_opts;
546
547         if (po_join(mi->options, extra_opts) == PO_FAILED) {
548                 errno = EIO;
549                 return 0;
550         }
551
552         if (verbose)
553                 printf(_("%s: text-based options: '%s'\n"),
554                         progname, *extra_opts);
555
556         if (mi->fake)
557                 return 1;
558
559         if (nfs_sys_mount(mi, "nfs", *extra_opts))
560                 return 1;
561
562         /*
563          * The kernel returns EOPNOTSUPP if the RPC bind failed,
564          * and EPROTONOSUPPORT if the version isn't supported.
565          */
566         if (errno != EOPNOTSUPP && errno != EPROTONOSUPPORT)
567                 return 0;
568
569         return nfs_retry_nfs23mount(mi);
570 }
571
572 /*
573  * Attempt an NFS v4 mount via a mount(2) system call.
574  *
575  * Returns 1 if successful.  Otherwise, returns zero.
576  * "errno" is set to reflect the individual error.
577  */
578 static int nfs_try_nfs4mount(struct nfsmount_info *mi)
579 {
580         char **extra_opts = mi->extra_opts;
581
582         if (po_join(mi->options, extra_opts) == PO_FAILED) {
583                 errno = EIO;
584                 return 0;
585         }
586
587         if (verbose)
588                 printf(_("%s: text-based options: '%s'\n"),
589                         progname, *extra_opts);
590
591         if (mi->fake)
592                 return 1;
593
594         return nfs_sys_mount(mi, "nfs4", *extra_opts);
595 }
596
597 /*
598  * Perform either an NFSv2/3 mount, or an NFSv4 mount system call.
599  *
600  * Returns 1 if successful.  Otherwise, returns zero.
601  * "errno" is set to reflect the individual error.
602  */
603 static int nfs_try_mount(struct nfsmount_info *mi)
604 {
605         if (strncmp(mi->type, "nfs4", 4) == 0)
606                 return nfs_try_nfs4mount(mi);
607         else
608                 return nfs_try_nfs23mount(mi);
609 }
610
611 /*
612  * Handle "foreground" NFS mounts.
613  *
614  * Retry the mount request for as long as the 'retry=' option says.
615  *
616  * Returns a valid mount command exit code.
617  */
618 static int nfsmount_fg(struct nfsmount_info *mi)
619 {
620         unsigned int secs = 1;
621         time_t timeout;
622
623         timeout = nfs_parse_retry_option(mi->options,
624                                          NFS_DEF_FG_TIMEOUT_MINUTES);
625         if (verbose)
626                 printf(_("%s: timeout set for %s"),
627                         progname, ctime(&timeout));
628
629         for (;;) {
630                 if (nfs_try_mount(mi))
631                         return EX_SUCCESS;
632
633                 if (is_permanent_error(errno))
634                         break;
635
636                 if (time(NULL) > timeout) {
637                         errno = ETIMEDOUT;
638                         break;
639                 }
640
641                 if (errno != ETIMEDOUT) {
642                         if (sleep(secs))
643                                 break;
644                         secs <<= 1;
645                         if (secs > 10)
646                                 secs = 10;
647                 }
648         };
649
650         mount_error(mi->spec, mi->node, errno);
651         return EX_FAIL;
652 }
653
654 /*
655  * Handle "background" NFS mount [first try]
656  *
657  * Returns a valid mount command exit code.
658  *
659  * EX_BG should cause the caller to fork and invoke nfsmount_child.
660  */
661 static int nfsmount_parent(struct nfsmount_info *mi)
662 {
663         if (nfs_try_mount(mi))
664                 return EX_SUCCESS;
665
666         if (is_permanent_error(errno)) {
667                 mount_error(mi->spec, mi->node, errno);
668                 return EX_FAIL;
669         }
670
671         sys_mount_errors(mi->hostname, errno, 1, 1);
672         return EX_BG;
673 }
674
675 /*
676  * Handle "background" NFS mount [retry daemon]
677  *
678  * Returns a valid mount command exit code: EX_SUCCESS if successful,
679  * EX_FAIL if a failure occurred.  There's nothing to catch the
680  * error return, though, so we use sys_mount_errors to log the
681  * failure.
682  */
683 static int nfsmount_child(struct nfsmount_info *mi)
684 {
685         unsigned int secs = 1;
686         time_t timeout;
687
688         timeout = nfs_parse_retry_option(mi->options,
689                                          NFS_DEF_BG_TIMEOUT_MINUTES);
690
691         for (;;) {
692                 if (sleep(secs))
693                         break;
694                 secs <<= 1;
695                 if (secs > 120)
696                         secs = 120;
697
698                 if (nfs_try_mount(mi))
699                         return EX_SUCCESS;
700
701                 if (is_permanent_error(errno))
702                         break;
703
704                 if (time(NULL) > timeout)
705                         break;
706
707                 sys_mount_errors(mi->hostname, errno, 1, 1);
708         };
709
710         sys_mount_errors(mi->hostname, errno, 1, 0);
711         return EX_FAIL;
712 }
713
714 /*
715  * Handle "background" NFS mount
716  *
717  * Returns a valid mount command exit code.
718  */
719 static int nfsmount_bg(struct nfsmount_info *mi)
720 {
721         if (!mi->child)
722                 return nfsmount_parent(mi);
723         else
724                 return nfsmount_child(mi);
725 }
726
727 /*
728  * Process mount options and try a mount system call.
729  *
730  * Returns a valid mount command exit code.
731  */
732 static int nfsmount_start(struct nfsmount_info *mi)
733 {
734         if (!nfs_validate_options(mi))
735                 return EX_FAIL;
736
737         if (po_rightmost(mi->options, "bg", "fg") == PO_KEY1_RIGHTMOST)
738                 return nfsmount_bg(mi);
739         else
740                 return nfsmount_fg(mi);
741 }
742
743 /**
744  * nfsmount_string - Mount an NFS file system using C string options
745  * @spec: C string specifying remote share to mount ("hostname:path")
746  * @node: C string pathname of local mounted-on directory
747  * @type: C string that represents file system type ("nfs" or "nfs4")
748  * @flags: MS_ style mount flags
749  * @extra_opts: pointer to C string containing fs-specific mount options
750  *              (input and output argument)
751  * @fake: flag indicating whether to carry out the whole operation
752  * @child: one if this is a mount daemon (bg)
753  */
754 int nfsmount_string(const char *spec, const char *node, const char *type,
755                     int flags, char **extra_opts, int fake, int child)
756 {
757         struct nfsmount_info mi = {
758                 .spec           = spec,
759                 .node           = node,
760                 .type           = type,
761                 .extra_opts     = extra_opts,
762                 .flags          = flags,
763                 .fake           = fake,
764                 .child          = child,
765         };
766         int retval = EX_FAIL;
767
768         if (!nfs_parse_devname(&mi))
769                 return retval;
770
771         mi.options = po_split(*extra_opts);
772         if (mi.options) {
773                 retval = nfsmount_start(&mi);
774                 po_destroy(mi.options);
775         } else
776                 nfs_error(_("%s: internal option parsing error"), progname);
777
778         free(mi.hostname);
779         return retval;
780 }