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