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