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