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