2 * nfsmount.c -- Linux NFS mount
3 * Copyright (C) 1993 Rick Sladkey <jrs@world.std.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * Wed Feb 8 12:51:48 1995, biro@yggdrasil.com (Ross Biro): allow all port
16 * numbers to be specified on the command line.
18 * Fri, 8 Mar 1996 18:01:39, Swen Thuemmler <swen@uni-paderborn.de>:
19 * Omit the call to connect() for Linux version 1.3.11 or later.
21 * Wed Oct 1 23:55:28 1997: Dick Streefland <dick_streefland@tasking.com>
22 * Implemented the "bg", "fg" and "retry" mount options for NFS.
24 * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
25 * - added Native Language Support
27 * Modified by Olaf Kirch and Trond Myklebust for new NFS code,
30 * 2006-06-06 Amit Gud <agud@redhat.com>
31 * - Moved with modifcations to nfs-utils/utils/mount from util-linux/mount.
35 * nfsmount.c,v 1.1.1.1 1993/11/18 08:40:51 jrs Exp
47 #include <rpc/pmap_prot.h>
48 #include <rpc/pmap_clnt.h>
49 #include <sys/socket.h>
52 #include <netinet/in.h>
53 #include <arpa/inet.h>
55 #include <sys/mount.h>
62 #include "nfsumount.h"
63 #include "nfs_mount.h"
64 #include "mount_constants.h"
76 #ifndef HAVE_INET_ATON
77 #define inet_aton(a,b) (0)
80 typedef dirpath mnt2arg_t;
81 typedef dirpath mnt3arg_t;
82 typedef dirpath mntarg_t;
84 typedef struct fhstatus mnt2res_t;
85 typedef struct mountres3 mnt3res_t;
91 extern int nfs_mount_data_version;
92 extern char *progname;
96 extern int linux_version_code(void);
98 static inline enum clnt_stat
99 nfs3_mount(CLIENT *clnt, mnt3arg_t *mnt3arg, mnt3res_t *mnt3res)
101 return clnt_call(clnt, MOUNTPROC3_MNT,
102 (xdrproc_t) xdr_dirpath, (caddr_t) mnt3arg,
103 (xdrproc_t) xdr_mountres3, (caddr_t) mnt3res,
107 static inline enum clnt_stat
108 nfs2_mount(CLIENT *clnt, mnt2arg_t *mnt2arg, mnt2res_t *mnt2res)
110 return clnt_call(clnt, MOUNTPROC_MNT,
111 (xdrproc_t) xdr_dirpath, (caddr_t) mnt2arg,
112 (xdrproc_t) xdr_fhstatus, (caddr_t) mnt2res,
117 nfs_call_mount(clnt_addr_t *mnt_server, clnt_addr_t *nfs_server,
118 mntarg_t *mntarg, mntres_t *mntres)
124 if (!probe_bothports(mnt_server, nfs_server))
127 clnt = mnt_openclnt(mnt_server, &msock);
130 /* make pointers in xdr_mountres3 NULL so
131 * that xdr_array allocates memory for us
133 memset(mntres, 0, sizeof(*mntres));
134 switch (mnt_server->pmap.pm_vers) {
136 stat = nfs3_mount(clnt, mntarg, &mntres->nfsv3);
140 stat = nfs2_mount(clnt, mntarg, &mntres->nfsv2);
145 if (stat != RPC_SUCCESS) {
146 clnt_geterr(clnt, &rpc_createerr.cf_error);
147 rpc_createerr.cf_stat = stat;
149 mnt_closeclnt(clnt, msock);
150 if (stat == RPC_SUCCESS)
157 parse_options(char *old_opts, struct nfs_mount_data *data,
158 int *bg, int *retry, clnt_addr_t *mnt_server,
159 clnt_addr_t *nfs_server, char *new_opts, const int opt_size)
161 struct sockaddr_in *mnt_saddr = &mnt_server->saddr;
162 struct pmap *mnt_pmap = &mnt_server->pmap;
163 struct pmap *nfs_pmap = &nfs_server->pmap;
165 char *opt, *opteq, *p, *opt_b;
166 char *mounthost = NULL;
173 len = strlen(new_opts);
174 for (p=old_opts, opt_b=NULL; p && *p; p++) {
176 opt_b = p; /* begin of the option item */
178 open_quote ^= 1; /* reverse the status */
180 continue; /* still in a quoted block */
182 *p = '\0'; /* terminate the option item */
183 if (*p == '\0' || *(p+1) == '\0') {
184 opt = opt_b; /* opt is useful now */
188 continue; /* still somewhere in the option item */
190 if (strlen(opt) >= sizeof(cbuf))
192 if ((opteq = strchr(opt, '=')) && isdigit(opteq[1])) {
193 int val = atoi(opteq + 1);
195 /* printf("opt=%s\n", opt); */
196 if (!strcmp(opt, "rsize"))
198 else if (!strcmp(opt, "wsize"))
200 else if (!strcmp(opt, "timeo"))
202 else if (!strcmp(opt, "retrans"))
204 else if (!strcmp(opt, "acregmin"))
205 data->acregmin = val;
206 else if (!strcmp(opt, "acregmax"))
207 data->acregmax = val;
208 else if (!strcmp(opt, "acdirmin"))
209 data->acdirmin = val;
210 else if (!strcmp(opt, "acdirmax"))
211 data->acdirmax = val;
212 else if (!strcmp(opt, "actimeo")) {
213 data->acregmin = val;
214 data->acregmax = val;
215 data->acdirmin = val;
216 data->acdirmax = val;
218 else if (!strcmp(opt, "retry"))
220 else if (!strcmp(opt, "port"))
221 nfs_pmap->pm_port = val;
222 else if (!strcmp(opt, "mountport"))
223 mnt_pmap->pm_port = val;
224 else if (!strcmp(opt, "mountprog"))
225 mnt_pmap->pm_prog = val;
226 else if (!strcmp(opt, "mountvers"))
227 mnt_pmap->pm_vers = val;
228 else if (!strcmp(opt, "mounthost"))
229 mounthost=xstrndup(opteq+1, strcspn(opteq+1," \t\n\r,"));
230 else if (!strcmp(opt, "nfsprog"))
231 nfs_pmap->pm_prog = val;
232 else if (!strcmp(opt, "nfsvers") ||
233 !strcmp(opt, "vers")) {
234 nfs_pmap->pm_vers = val;
236 #if NFS_MOUNT_VERSION >= 2
237 } else if (!strcmp(opt, "namlen")) {
238 if (nfs_mount_data_version >= 2)
245 } else if (!strcmp(opt, "addr")) {
252 sprintf(cbuf, "%s=%s,", opt, opteq+1);
255 if (!strcmp(opt, "proto")) {
256 if (!strcmp(opteq+1, "udp")) {
257 nfs_pmap->pm_prot = IPPROTO_UDP;
258 mnt_pmap->pm_prot = IPPROTO_UDP;
259 #if NFS_MOUNT_VERSION >= 2
260 data->flags &= ~NFS_MOUNT_TCP;
261 } else if (!strcmp(opteq+1, "tcp") &&
262 nfs_mount_data_version > 2) {
263 nfs_pmap->pm_prot = IPPROTO_TCP;
264 mnt_pmap->pm_prot = IPPROTO_TCP;
265 data->flags |= NFS_MOUNT_TCP;
271 #if NFS_MOUNT_VERSION >= 5
272 } else if (!strcmp(opt, "sec")) {
273 char *secflavor = opteq+1;
275 if (nfs_mount_data_version < 5) {
276 printf(_("Warning: ignoring sec=%s option\n"),
279 } else if (!strcmp(secflavor, "none"))
280 data->pseudoflavor = AUTH_NONE;
281 else if (!strcmp(secflavor, "sys"))
282 data->pseudoflavor = AUTH_SYS;
283 else if (!strcmp(secflavor, "krb5"))
284 data->pseudoflavor = AUTH_GSS_KRB5;
285 else if (!strcmp(secflavor, "krb5i"))
286 data->pseudoflavor = AUTH_GSS_KRB5I;
287 else if (!strcmp(secflavor, "krb5p"))
288 data->pseudoflavor = AUTH_GSS_KRB5P;
289 else if (!strcmp(secflavor, "lipkey"))
290 data->pseudoflavor = AUTH_GSS_LKEY;
291 else if (!strcmp(secflavor, "lipkey-i"))
292 data->pseudoflavor = AUTH_GSS_LKEYI;
293 else if (!strcmp(secflavor, "lipkey-p"))
294 data->pseudoflavor = AUTH_GSS_LKEYP;
295 else if (!strcmp(secflavor, "spkm3"))
296 data->pseudoflavor = AUTH_GSS_SPKM;
297 else if (!strcmp(secflavor, "spkm3i"))
298 data->pseudoflavor = AUTH_GSS_SPKMI;
299 else if (!strcmp(secflavor, "spkm3p"))
300 data->pseudoflavor = AUTH_GSS_SPKMP;
304 printf(_("Warning: Unrecognized security flavor %s.\n"),
308 data->flags |= NFS_MOUNT_SECFLAVOUR;
310 } else if (!strcmp(opt, "mounthost"))
311 mounthost=xstrndup(opteq+1,
312 strcspn(opteq+1," \t\n\r,"));
313 else if (!strcmp(opt, "context")) {
314 char *context = opteq + 1;
315 int ctxlen = strlen(context);
317 if (ctxlen > NFS_MAX_CONTEXT_LEN) {
318 nfs_error(_("context parameter exceeds"
320 NFS_MAX_CONTEXT_LEN);
323 /* The context string is in the format of
324 * "system_u:object_r:...". We only want
325 * the context str between the quotes.
328 strncpy(data->context, context+1,
331 strncpy(data->context, context,
332 NFS_MAX_CONTEXT_LEN);
337 sprintf(cbuf, "%s=%s,", opt, opteq+1);
340 if (!strncmp(opt, "no", 2)) {
344 if (!strcmp(opt, "bg"))
346 else if (!strcmp(opt, "fg"))
348 else if (!strcmp(opt, "soft")) {
349 data->flags &= ~NFS_MOUNT_SOFT;
351 data->flags |= NFS_MOUNT_SOFT;
352 } else if (!strcmp(opt, "hard")) {
353 data->flags &= ~NFS_MOUNT_SOFT;
355 data->flags |= NFS_MOUNT_SOFT;
356 } else if (!strcmp(opt, "intr")) {
357 data->flags &= ~NFS_MOUNT_INTR;
359 data->flags |= NFS_MOUNT_INTR;
360 } else if (!strcmp(opt, "posix")) {
361 data->flags &= ~NFS_MOUNT_POSIX;
363 data->flags |= NFS_MOUNT_POSIX;
364 } else if (!strcmp(opt, "cto")) {
365 data->flags &= ~NFS_MOUNT_NOCTO;
367 data->flags |= NFS_MOUNT_NOCTO;
368 } else if (!strcmp(opt, "ac")) {
369 data->flags &= ~NFS_MOUNT_NOAC;
371 data->flags |= NFS_MOUNT_NOAC;
372 #if NFS_MOUNT_VERSION >= 2
373 } else if (!strcmp(opt, "tcp")) {
374 data->flags &= ~NFS_MOUNT_TCP;
376 if (nfs_mount_data_version < 2)
378 nfs_pmap->pm_prot = IPPROTO_TCP;
379 mnt_pmap->pm_prot = IPPROTO_TCP;
380 data->flags |= NFS_MOUNT_TCP;
382 mnt_pmap->pm_prot = IPPROTO_UDP;
383 nfs_pmap->pm_prot = IPPROTO_UDP;
385 } else if (!strcmp(opt, "udp")) {
386 data->flags &= ~NFS_MOUNT_TCP;
388 if (nfs_mount_data_version < 2)
390 nfs_pmap->pm_prot = IPPROTO_TCP;
391 mnt_pmap->pm_prot = IPPROTO_TCP;
392 data->flags |= NFS_MOUNT_TCP;
394 nfs_pmap->pm_prot = IPPROTO_UDP;
395 mnt_pmap->pm_prot = IPPROTO_UDP;
398 #if NFS_MOUNT_VERSION >= 3
399 } else if (!strcmp(opt, "lock")) {
400 data->flags &= ~NFS_MOUNT_NONLM;
402 if (nfs_mount_data_version < 3)
404 data->flags |= NFS_MOUNT_NONLM;
407 #if NFS_MOUNT_VERSION >= 4
408 } else if (!strcmp(opt, "broken_suid")) {
409 data->flags &= ~NFS_MOUNT_BROKEN_SUID;
411 if (nfs_mount_data_version < 4)
413 data->flags |= NFS_MOUNT_BROKEN_SUID;
415 } else if (!strcmp(opt, "acl")) {
416 data->flags &= ~NFS_MOUNT_NOACL;
418 data->flags |= NFS_MOUNT_NOACL;
419 } else if (!strcmp(opt, "rdirplus")) {
420 data->flags &= ~NFS_MOUNT_NORDIRPLUS;
422 data->flags |= NFS_MOUNT_NORDIRPLUS;
423 } else if (!strcmp(opt, "sharecache")) {
424 data->flags &= ~NFS_MOUNT_UNSHARED;
426 data->flags |= NFS_MOUNT_UNSHARED;
432 nfs_error(_("%s: Unsupported nfs mount option:"
434 val ? "" : "no", opt);
437 sprintf(cbuf, val ? "%s,":"no%s,", opt);
440 if (len >= opt_size) {
441 nfs_error(_("%s: excessively long option argument"),
445 strcat(new_opts, cbuf);
447 /* See if the nfs host = mount host. */
449 if (!nfs_gethostbyname(mounthost, mnt_saddr))
451 *mnt_server->hostname = mounthost;
455 nfs_error(_("%s: Bad nfs mount parameter: %s\n"), progname, opt);
460 static int nfsmnt_check_compat(const struct pmap *nfs_pmap,
461 const struct pmap *mnt_pmap)
463 unsigned int max_nfs_vers = (nfs_mount_data_version >= 4) ? 3 : 2;
464 unsigned int max_mnt_vers = (nfs_mount_data_version >= 4) ? 3 : 2;
466 if (nfs_pmap->pm_vers == 4) {
467 nfs_error(_("%s: Please use '-t nfs4' "
468 "instead of '-o vers=4'"), progname);
472 if (nfs_pmap->pm_vers) {
473 if (nfs_pmap->pm_vers > max_nfs_vers || nfs_pmap->pm_vers < 2) {
474 nfs_error(_("%s: NFS version %ld is not supported"),
475 progname, nfs_pmap->pm_vers);
480 if (mnt_pmap->pm_vers > max_mnt_vers) {
481 nfs_error(_("%s: NFS mount version %ld s not supported"),
482 progname, mnt_pmap->pm_vers);
493 nfsmount(const char *spec, const char *node, int flags,
494 char **extra_opts, int fake)
496 static char *prev_bg_host;
498 char *hostname, *dirname, *old_opts, *mounthost = NULL;
499 char new_opts[1024], cbuf[1024];
500 static struct nfs_mount_data data;
501 int val, running_bg = 0;
502 static int doonce = 0;
504 clnt_addr_t mnt_server = { &mounthost, };
505 clnt_addr_t nfs_server = { &hostname, };
506 struct sockaddr_in *nfs_saddr = &nfs_server.saddr;
507 struct pmap *mnt_pmap = &mnt_server.pmap,
508 *nfs_pmap = &nfs_server.pmap;
509 struct pmap save_mnt, save_nfs;
518 int retval = EX_FAIL;
523 if (strlen(spec) >= sizeof(hostdir)) {
524 nfs_error(_("%s: excessively long host:dir argument"),
528 strcpy(hostdir, spec);
529 if ((s = strchr(hostdir, ':'))) {
533 /* Ignore all but first hostname in replicated mounts
534 until they can be fully supported. (mack@sgi.com) */
535 if ((s = strchr(hostdir, ','))) {
537 nfs_error(_("%s: warning: "
538 "multiple hostnames not supported"),
542 nfs_error(_("%s: directory to mount not in host:dir format"),
547 if (!nfs_gethostbyname(hostname, nfs_saddr))
549 mounthost = hostname;
550 memcpy (&mnt_server.saddr, nfs_saddr, sizeof (mnt_server.saddr));
552 /* add IP address to mtab options for use when unmounting */
554 s = inet_ntoa(nfs_saddr->sin_addr);
555 old_opts = *extra_opts;
559 /* Set default options.
560 * rsize/wsize (and bsize, for ver >= 3) are left 0 in order to
561 * let the kernel decide.
562 * timeo is filled in after we know whether it'll be TCP or UDP. */
563 memset(&data, 0, sizeof(data));
568 #if NFS_MOUNT_VERSION >= 2
569 data.namlen = NAME_MAX;
573 retry = 10000; /* 10000 minutes ~ 1 week */
575 memset(mnt_pmap, 0, sizeof(*mnt_pmap));
576 mnt_pmap->pm_prog = MOUNTPROG;
577 memset(nfs_pmap, 0, sizeof(*nfs_pmap));
578 nfs_pmap->pm_prog = NFS_PROGRAM;
582 if (!parse_options(old_opts, &data, &bg, &retry, &mnt_server, &nfs_server,
583 new_opts, sizeof(new_opts)))
585 if (!nfsmnt_check_compat(nfs_pmap, mnt_pmap))
588 if (retry == 10000 && !bg)
589 retry = 2; /* reset for fg mounts */
592 #ifdef NFS_MOUNT_DEBUG
593 printf("rsize = %d, wsize = %d, timeo = %d, retrans = %d\n",
594 data.rsize, data.wsize, data.timeo, data.retrans);
595 printf("acreg (min, max) = (%d, %d), acdir (min, max) = (%d, %d)\n",
596 data.acregmin, data.acregmax, data.acdirmin, data.acdirmax);
597 printf("port = %d, bg = %d, retry = %d, flags = %.8x\n",
598 nfs_pmap->pm_port, bg, retry, data.flags);
599 printf("mountprog = %d, mountvers = %d, nfsprog = %d, nfsvers = %d\n",
600 mnt_pmap->pm_prog, mnt_pmap->pm_vers,
601 nfs_pmap->pm_prog, nfs_pmap->pm_vers);
602 printf("soft = %d, intr = %d, posix = %d, nocto = %d, noac = %d ",
603 (data.flags & NFS_MOUNT_SOFT) != 0,
604 (data.flags & NFS_MOUNT_INTR) != 0,
605 (data.flags & NFS_MOUNT_POSIX) != 0,
606 (data.flags & NFS_MOUNT_NOCTO) != 0,
607 (data.flags & NFS_MOUNT_NOAC) != 0);
608 #if NFS_MOUNT_VERSION >= 2
610 (data.flags & NFS_MOUNT_TCP) != 0);
612 #if NFS_MOUNT_VERSION >= 4
613 printf("noacl = %d ", (data.flags & NFS_MOUNT_NOACL) != 0);
615 #if NFS_MOUNT_VERSION >= 5
616 printf("sec = %u ", data.pseudoflavor);
617 printf("readdirplus = %d ", (data.flags & NFS_MOUNT_NORDIRPLUS) != 0);
622 data.version = nfs_mount_data_version;
624 if (flags & MS_REMOUNT)
628 * If the previous mount operation on the same host was
629 * backgrounded, and the "bg" for this mount is also set,
630 * give up immediately, to avoid the initial timeout.
632 if (bg && !running_bg &&
633 prev_bg_host && strcmp(hostname, prev_bg_host) == 0) {
639 /* create mount deamon client */
642 * The following loop implements the mount retries. On the first
643 * call, "running_bg" is 0. When the mount times out, and the
644 * "bg" option is set, the exit status EX_BG will be returned.
645 * For a backgrounded mount, there will be a second call by the
646 * child process with "running_bg" set to 1.
648 * The case where the mount point is not present and the "bg"
649 * option is set, is treated as a timeout. This is done to
650 * support nested mounts.
652 * The "retry" count specified by the user is the number of
653 * minutes to retry before giving up.
655 * Only the first error message will be displayed.
657 timeout = time(NULL) + 60 * retry;
662 memcpy(&save_nfs, nfs_pmap, sizeof(save_nfs));
663 memcpy(&save_mnt, mnt_pmap, sizeof(save_mnt));
665 if (bg && stat(node, &statbuf) == -1) {
666 /* no mount point yet - sleep */
668 sleep(val); /* 1, 2, 4, 8, 16, 30, ... */
675 /* be careful not to use too many CPU cycles */
679 stat = nfs_call_mount(&mnt_server, &nfs_server,
683 memcpy(nfs_pmap, &save_nfs, sizeof(*nfs_pmap));
684 memcpy(mnt_pmap, &save_mnt, sizeof(*mnt_pmap));
688 switch(rpc_createerr.cf_stat){
691 case RPC_SYSTEMERROR:
692 if (errno == ETIMEDOUT)
695 mount_errors(*nfs_server.hostname, 0, bg);
700 mount_errors(*nfs_server.hostname, 0, bg);
703 mount_errors(*nfs_server.hostname, 1, bg);
707 prev_bg_host = xstrdup(hostname);
714 mount_errors(*nfs_server.hostname, 0, bg);
718 mount_errors(*nfs_server.hostname, 1, bg);
721 if (nfs_pmap->pm_vers == 2) {
722 if (mntres.nfsv2.fhs_status != 0) {
723 nfs_error(_("%s: %s:%s failed, reason given by server: %s"),
724 progname, hostname, dirname,
725 nfs_strerror(mntres.nfsv2.fhs_status));
728 memcpy(data.root.data,
729 (char *) mntres.nfsv2.fhstatus_u.fhs_fhandle,
731 #if NFS_MOUNT_VERSION >= 4
732 data.root.size = NFS_FHSIZE;
733 memcpy(data.old_root.data,
734 (char *) mntres.nfsv2.fhstatus_u.fhs_fhandle,
738 #if NFS_MOUNT_VERSION >= 4
739 mountres3_ok *mountres;
741 int i, *flavor, yum = 0;
742 if (mntres.nfsv3.fhs_status != 0) {
743 nfs_error(_("%s: %s:%s failed, reason given by server: %s"),
744 progname, hostname, dirname,
745 nfs_strerror(mntres.nfsv3.fhs_status));
748 #if NFS_MOUNT_VERSION >= 5
749 mountres = &mntres.nfsv3.mountres3_u.mountinfo;
750 i = mountres->auth_flavors.auth_flavors_len;
754 flavor = mountres->auth_flavors.auth_flavors_val;
756 /* If no flavour requested, use first simple
757 * flavour that is offered.
759 if (! (data.flags & NFS_MOUNT_SECFLAVOUR) &&
760 (flavor[i] == AUTH_SYS ||
761 flavor[i] == AUTH_NONE)) {
762 data.pseudoflavor = flavor[i];
763 data.flags |= NFS_MOUNT_SECFLAVOUR;
765 if (flavor[i] == data.pseudoflavor)
767 #ifdef NFS_MOUNT_DEBUG
768 printf("auth flavor %d: %d\n",
773 nfs_error(_("%s: %s:%s failed, security flavor "
775 progname, hostname, dirname);
776 /* server has registered us in rmtab, send umount */
777 nfs_call_umount(&mnt_server, &dirname);
782 fhandle = &mntres.nfsv3.mountres3_u.mountinfo.fhandle;
783 memset(data.old_root.data, 0, NFS_FHSIZE);
784 memset(&data.root, 0, sizeof(data.root));
785 data.root.size = fhandle->fhandle3_len;
786 memcpy(data.root.data,
787 (char *) fhandle->fhandle3_val,
788 fhandle->fhandle3_len);
790 data.flags |= NFS_MOUNT_VER3;
794 if (nfs_mount_data_version == 1) {
795 /* create nfs socket for kernel */
796 if (nfs_pmap->pm_prot == IPPROTO_TCP)
797 fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
799 fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
801 perror(_("nfs socket"));
804 if (bindresvport(fsock, 0) < 0) {
805 perror(_("nfs bindresvport"));
810 #ifdef NFS_MOUNT_DEBUG
811 printf(_("using port %d for nfs deamon\n"), nfs_pmap->pm_port);
813 nfs_saddr->sin_port = htons(nfs_pmap->pm_port);
815 * connect() the socket for kernels 1.3.10 and below only,
816 * to avoid problems with multihomed hosts.
819 if (linux_version_code() <= 0x01030a && fsock != -1
820 && connect(fsock, (struct sockaddr *) nfs_saddr,
821 sizeof (*nfs_saddr)) < 0) {
822 perror(_("nfs connect"));
826 #if NFS_MOUNT_VERSION >= 2
827 if (nfs_pmap->pm_prot == IPPROTO_TCP)
828 data.flags |= NFS_MOUNT_TCP;
830 data.flags &= ~NFS_MOUNT_TCP;
833 /* prepare data structure for kernel */
836 memcpy((char *) &data.addr, (char *) nfs_saddr, sizeof(data.addr));
837 strncpy(data.hostname, hostname, sizeof(data.hostname));
840 /* Ensure we have enough padding for the following strcat()s */
841 if (strlen(new_opts) + strlen(s) + 30 >= sizeof(new_opts)) {
842 nfs_error(_("%s: excessively long option argument"),
847 snprintf(cbuf, sizeof(cbuf)-1, "addr=%s", s);
848 strcat(new_opts, cbuf);
850 *extra_opts = xstrdup(new_opts);
852 if (!fake && !(data.flags & NFS_MOUNT_NONLM)) {
853 if (!start_statd()) {
854 nfs_error(_("%s: rpc.statd is not running but is "
855 "required for remote locking.\n"
856 " Either use '-o nolocks' to keep "
857 "locks local, or start statd."),
864 if (mount(spec, node, "nfs",
865 flags & ~(MS_USER|MS_USERS), &data)) {
866 mount_error(spec, node, errno);