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