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;
95 extern int linux_version_code();
97 static inline enum clnt_stat
98 nfs3_mount(CLIENT *clnt, mnt3arg_t *mnt3arg, mnt3res_t *mnt3res)
100 return clnt_call(clnt, MOUNTPROC3_MNT,
101 (xdrproc_t) xdr_dirpath, (caddr_t) mnt3arg,
102 (xdrproc_t) xdr_mountres3, (caddr_t) mnt3res,
106 static inline enum clnt_stat
107 nfs2_mount(CLIENT *clnt, mnt2arg_t *mnt2arg, mnt2res_t *mnt2res)
109 return clnt_call(clnt, MOUNTPROC_MNT,
110 (xdrproc_t) xdr_dirpath, (caddr_t) mnt2arg,
111 (xdrproc_t) xdr_fhstatus, (caddr_t) mnt2res,
116 nfs_call_mount(clnt_addr_t *mnt_server, clnt_addr_t *nfs_server,
117 mntarg_t *mntarg, mntres_t *mntres)
123 if (!probe_bothports(mnt_server, nfs_server))
126 clnt = mnt_openclnt(mnt_server, &msock);
129 /* make pointers in xdr_mountres3 NULL so
130 * that xdr_array allocates memory for us
132 memset(mntres, 0, sizeof(*mntres));
133 switch (mnt_server->pmap.pm_vers) {
135 stat = nfs3_mount(clnt, mntarg, &mntres->nfsv3);
139 stat = nfs2_mount(clnt, mntarg, &mntres->nfsv2);
144 if (stat != RPC_SUCCESS) {
145 clnt_geterr(clnt, &rpc_createerr.cf_error);
146 rpc_createerr.cf_stat = stat;
148 mnt_closeclnt(clnt, msock);
149 if (stat == RPC_SUCCESS)
156 parse_options(char *old_opts, struct nfs_mount_data *data,
157 int *bg, int *retry, clnt_addr_t *mnt_server,
158 clnt_addr_t *nfs_server, char *new_opts, const int opt_size)
160 struct sockaddr_in *mnt_saddr = &mnt_server->saddr;
161 struct pmap *mnt_pmap = &mnt_server->pmap;
162 struct pmap *nfs_pmap = &nfs_server->pmap;
164 char *opt, *opteq, *p, *opt_b;
165 char *mounthost = NULL;
172 len = strlen(new_opts);
173 for (p=old_opts, opt_b=NULL; p && *p; p++) {
175 opt_b = p; /* begin of the option item */
177 open_quote ^= 1; /* reverse the status */
179 continue; /* still in a quoted block */
181 *p = '\0'; /* terminate the option item */
182 if (*p == '\0' || *(p+1) == '\0') {
183 opt = opt_b; /* opt is useful now */
187 continue; /* still somewhere in the option item */
189 if (strlen(opt) >= sizeof(cbuf))
191 if ((opteq = strchr(opt, '=')) && isdigit(opteq[1])) {
192 int val = atoi(opteq + 1);
194 /* printf("opt=%s\n", opt); */
195 if (!strcmp(opt, "rsize"))
197 else if (!strcmp(opt, "wsize"))
199 else if (!strcmp(opt, "timeo"))
201 else if (!strcmp(opt, "retrans"))
203 else if (!strcmp(opt, "acregmin"))
204 data->acregmin = val;
205 else if (!strcmp(opt, "acregmax"))
206 data->acregmax = val;
207 else if (!strcmp(opt, "acdirmin"))
208 data->acdirmin = val;
209 else if (!strcmp(opt, "acdirmax"))
210 data->acdirmax = val;
211 else if (!strcmp(opt, "actimeo")) {
212 data->acregmin = val;
213 data->acregmax = val;
214 data->acdirmin = val;
215 data->acdirmax = val;
217 else if (!strcmp(opt, "retry"))
219 else if (!strcmp(opt, "port"))
220 nfs_pmap->pm_port = val;
221 else if (!strcmp(opt, "mountport"))
222 mnt_pmap->pm_port = val;
223 else if (!strcmp(opt, "mountprog"))
224 mnt_pmap->pm_prog = val;
225 else if (!strcmp(opt, "mountvers"))
226 mnt_pmap->pm_vers = val;
227 else if (!strcmp(opt, "mounthost"))
228 mounthost=xstrndup(opteq+1, strcspn(opteq+1," \t\n\r,"));
229 else if (!strcmp(opt, "nfsprog"))
230 nfs_pmap->pm_prog = val;
231 else if (!strcmp(opt, "nfsvers") ||
232 !strcmp(opt, "vers")) {
233 nfs_pmap->pm_vers = val;
235 #if NFS_MOUNT_VERSION >= 2
236 } else if (!strcmp(opt, "namlen")) {
237 if (nfs_mount_data_version >= 2)
244 } else if (!strcmp(opt, "addr")) {
251 sprintf(cbuf, "%s=%s,", opt, opteq+1);
254 if (!strcmp(opt, "proto")) {
255 if (!strcmp(opteq+1, "udp")) {
256 nfs_pmap->pm_prot = IPPROTO_UDP;
257 mnt_pmap->pm_prot = IPPROTO_UDP;
258 #if NFS_MOUNT_VERSION >= 2
259 data->flags &= ~NFS_MOUNT_TCP;
260 } else if (!strcmp(opteq+1, "tcp") &&
261 nfs_mount_data_version > 2) {
262 nfs_pmap->pm_prot = IPPROTO_TCP;
263 mnt_pmap->pm_prot = IPPROTO_TCP;
264 data->flags |= NFS_MOUNT_TCP;
270 #if NFS_MOUNT_VERSION >= 5
271 } else if (!strcmp(opt, "sec")) {
272 char *secflavor = opteq+1;
274 if (nfs_mount_data_version < 5) {
275 printf(_("Warning: ignoring sec=%s option\n"), secflavor);
277 } else if (!strcmp(secflavor, "none"))
278 data->pseudoflavor = AUTH_NONE;
279 else if (!strcmp(secflavor, "sys"))
280 data->pseudoflavor = AUTH_SYS;
281 else if (!strcmp(secflavor, "krb5"))
282 data->pseudoflavor = AUTH_GSS_KRB5;
283 else if (!strcmp(secflavor, "krb5i"))
284 data->pseudoflavor = AUTH_GSS_KRB5I;
285 else if (!strcmp(secflavor, "krb5p"))
286 data->pseudoflavor = AUTH_GSS_KRB5P;
287 else if (!strcmp(secflavor, "lipkey"))
288 data->pseudoflavor = AUTH_GSS_LKEY;
289 else if (!strcmp(secflavor, "lipkey-i"))
290 data->pseudoflavor = AUTH_GSS_LKEYI;
291 else if (!strcmp(secflavor, "lipkey-p"))
292 data->pseudoflavor = AUTH_GSS_LKEYP;
293 else if (!strcmp(secflavor, "spkm3"))
294 data->pseudoflavor = AUTH_GSS_SPKM;
295 else if (!strcmp(secflavor, "spkm3i"))
296 data->pseudoflavor = AUTH_GSS_SPKMI;
297 else if (!strcmp(secflavor, "spkm3p"))
298 data->pseudoflavor = AUTH_GSS_SPKMP;
302 printf(_("Warning: Unrecognized security flavor %s.\n"),
306 data->flags |= NFS_MOUNT_SECFLAVOUR;
308 } else if (!strcmp(opt, "mounthost"))
309 mounthost=xstrndup(opteq+1,
310 strcspn(opteq+1," \t\n\r,"));
311 else if (!strcmp(opt, "context")) {
312 char *context = opteq + 1;
313 int ctxlen = strlen(context);
315 if (ctxlen > NFS_MAX_CONTEXT_LEN) {
316 printf(_("context parameter exceeds limit of %d\n"),
317 NFS_MAX_CONTEXT_LEN);
320 /* The context string is in the format of
321 * "system_u:object_r:...". We only want
322 * the context str between the quotes.
325 strncpy(data->context, context+1,
328 strncpy(data->context, context,
329 NFS_MAX_CONTEXT_LEN);
334 sprintf(cbuf, "%s=%s,", opt, opteq+1);
337 if (!strncmp(opt, "no", 2)) {
341 if (!strcmp(opt, "bg"))
343 else if (!strcmp(opt, "fg"))
345 else if (!strcmp(opt, "soft")) {
346 data->flags &= ~NFS_MOUNT_SOFT;
348 data->flags |= NFS_MOUNT_SOFT;
349 } else if (!strcmp(opt, "hard")) {
350 data->flags &= ~NFS_MOUNT_SOFT;
352 data->flags |= NFS_MOUNT_SOFT;
353 } else if (!strcmp(opt, "intr")) {
354 data->flags &= ~NFS_MOUNT_INTR;
356 data->flags |= NFS_MOUNT_INTR;
357 } else if (!strcmp(opt, "posix")) {
358 data->flags &= ~NFS_MOUNT_POSIX;
360 data->flags |= NFS_MOUNT_POSIX;
361 } else if (!strcmp(opt, "cto")) {
362 data->flags &= ~NFS_MOUNT_NOCTO;
364 data->flags |= NFS_MOUNT_NOCTO;
365 } else if (!strcmp(opt, "ac")) {
366 data->flags &= ~NFS_MOUNT_NOAC;
368 data->flags |= NFS_MOUNT_NOAC;
369 #if NFS_MOUNT_VERSION >= 2
370 } else if (!strcmp(opt, "tcp")) {
371 data->flags &= ~NFS_MOUNT_TCP;
373 if (nfs_mount_data_version < 2)
375 nfs_pmap->pm_prot = IPPROTO_TCP;
376 mnt_pmap->pm_prot = IPPROTO_TCP;
377 data->flags |= NFS_MOUNT_TCP;
379 mnt_pmap->pm_prot = IPPROTO_UDP;
380 nfs_pmap->pm_prot = IPPROTO_UDP;
382 } else if (!strcmp(opt, "udp")) {
383 data->flags &= ~NFS_MOUNT_TCP;
385 if (nfs_mount_data_version < 2)
387 nfs_pmap->pm_prot = IPPROTO_TCP;
388 mnt_pmap->pm_prot = IPPROTO_TCP;
389 data->flags |= NFS_MOUNT_TCP;
391 nfs_pmap->pm_prot = IPPROTO_UDP;
392 mnt_pmap->pm_prot = IPPROTO_UDP;
395 #if NFS_MOUNT_VERSION >= 3
396 } else if (!strcmp(opt, "lock")) {
397 data->flags &= ~NFS_MOUNT_NONLM;
399 if (nfs_mount_data_version < 3)
401 data->flags |= NFS_MOUNT_NONLM;
404 #if NFS_MOUNT_VERSION >= 4
405 } else if (!strcmp(opt, "broken_suid")) {
406 data->flags &= ~NFS_MOUNT_BROKEN_SUID;
408 if (nfs_mount_data_version < 4)
410 data->flags |= NFS_MOUNT_BROKEN_SUID;
412 } else if (!strcmp(opt, "acl")) {
413 data->flags &= ~NFS_MOUNT_NOACL;
415 data->flags |= NFS_MOUNT_NOACL;
416 } else if (!strcmp(opt, "rdirplus")) {
417 data->flags &= ~NFS_MOUNT_NORDIRPLUS;
419 data->flags |= NFS_MOUNT_NORDIRPLUS;
420 } else if (!strcmp(opt, "sharecache")) {
421 data->flags &= ~NFS_MOUNT_UNSHARED;
423 data->flags |= NFS_MOUNT_UNSHARED;
429 printf(_("Unsupported nfs mount option: "
430 "%s%s\n"), val ? "" : "no", opt);
433 sprintf(cbuf, val ? "%s,":"no%s,", opt);
436 if (len >= opt_size) {
437 printf(_("mount: excessively long option argument\n"));
440 strcat(new_opts, cbuf);
442 /* See if the nfs host = mount host. */
444 if (!nfs_gethostbyname(mounthost, mnt_saddr))
446 *mnt_server->hostname = mounthost;
450 printf(_("Bad nfs mount parameter: %s\n"), opt);
455 static int nfsmnt_check_compat(const struct pmap *nfs_pmap,
456 const struct pmap *mnt_pmap)
458 unsigned int max_nfs_vers = (nfs_mount_data_version >= 4) ? 3 : 2;
459 unsigned int max_mnt_vers = (nfs_mount_data_version >= 4) ? 3 : 2;
461 if (nfs_pmap->pm_vers == 4) {
462 fprintf(stderr, _("Please use '-t nfs4' "
463 "instead of '-o vers=4'.\n"));
467 if (nfs_pmap->pm_vers) {
468 if (nfs_pmap->pm_vers > max_nfs_vers || nfs_pmap->pm_vers < 2) {
469 fprintf(stderr, _("NFS version %ld is not supported.\n"),
475 if (mnt_pmap->pm_vers > max_mnt_vers) {
476 fprintf(stderr, _("NFS mount version %ld s not supported.\n"),
488 nfsmount(const char *spec, const char *node, int *flags,
489 char **extra_opts, char **mount_opts,
490 int running_bg, int *need_statd)
492 static char *prev_bg_host;
494 char *hostname, *dirname, *old_opts, *mounthost = NULL;
495 char new_opts[1024], cbuf[1024];
496 static struct nfs_mount_data data;
498 static int doonce = 0;
500 clnt_addr_t mnt_server = { &mounthost, };
501 clnt_addr_t nfs_server = { &hostname, };
502 struct sockaddr_in *nfs_saddr = &nfs_server.saddr;
503 struct pmap *mnt_pmap = &mnt_server.pmap,
504 *nfs_pmap = &nfs_server.pmap;
505 struct pmap save_mnt, save_nfs;
514 int retval = EX_FAIL;
519 if (strlen(spec) >= sizeof(hostdir)) {
520 fprintf(stderr, _("mount: "
521 "excessively long host:dir argument\n"));
524 strcpy(hostdir, spec);
525 if ((s = strchr(hostdir, ':'))) {
529 /* Ignore all but first hostname in replicated mounts
530 until they can be fully supported. (mack@sgi.com) */
531 if ((s = strchr(hostdir, ','))) {
535 "multiple hostnames not supported\n"));
540 "directory to mount not in host:dir format\n"));
544 if (!nfs_gethostbyname(hostname, nfs_saddr))
546 mounthost = hostname;
547 memcpy (&mnt_server.saddr, nfs_saddr, sizeof (mnt_server.saddr));
549 /* add IP address to mtab options for use when unmounting */
551 s = inet_ntoa(nfs_saddr->sin_addr);
552 old_opts = *extra_opts;
556 /* Set default options.
557 * rsize/wsize (and bsize, for ver >= 3) are left 0 in order to
558 * let the kernel decide.
559 * timeo is filled in after we know whether it'll be TCP or UDP. */
560 memset(&data, 0, sizeof(data));
565 #if NFS_MOUNT_VERSION >= 2
566 data.namlen = NAME_MAX;
570 retry = 10000; /* 10000 minutes ~ 1 week */
572 memset(mnt_pmap, 0, sizeof(*mnt_pmap));
573 mnt_pmap->pm_prog = MOUNTPROG;
574 memset(nfs_pmap, 0, sizeof(*nfs_pmap));
575 nfs_pmap->pm_prog = NFS_PROGRAM;
579 if (!parse_options(old_opts, &data, &bg, &retry, &mnt_server, &nfs_server,
580 new_opts, sizeof(new_opts)))
582 if (!nfsmnt_check_compat(nfs_pmap, mnt_pmap))
585 if (retry == 10000 && !bg)
586 retry = 2; /* reset for fg mounts */
589 #ifdef NFS_MOUNT_DEBUG
590 printf("rsize = %d, wsize = %d, timeo = %d, retrans = %d\n",
591 data.rsize, data.wsize, data.timeo, data.retrans);
592 printf("acreg (min, max) = (%d, %d), acdir (min, max) = (%d, %d)\n",
593 data.acregmin, data.acregmax, data.acdirmin, data.acdirmax);
594 printf("port = %d, bg = %d, retry = %d, flags = %.8x\n",
595 nfs_pmap->pm_port, bg, retry, data.flags);
596 printf("mountprog = %d, mountvers = %d, nfsprog = %d, nfsvers = %d\n",
597 mnt_pmap->pm_prog, mnt_pmap->pm_vers,
598 nfs_pmap->pm_prog, nfs_pmap->pm_vers);
599 printf("soft = %d, intr = %d, posix = %d, nocto = %d, noac = %d ",
600 (data.flags & NFS_MOUNT_SOFT) != 0,
601 (data.flags & NFS_MOUNT_INTR) != 0,
602 (data.flags & NFS_MOUNT_POSIX) != 0,
603 (data.flags & NFS_MOUNT_NOCTO) != 0,
604 (data.flags & NFS_MOUNT_NOAC) != 0);
605 #if NFS_MOUNT_VERSION >= 2
607 (data.flags & NFS_MOUNT_TCP) != 0);
609 #if NFS_MOUNT_VERSION >= 4
610 printf("noacl = %d ", (data.flags & NFS_MOUNT_NOACL) != 0);
612 #if NFS_MOUNT_VERSION >= 5
613 printf("sec = %u ", data.pseudoflavor);
614 printf("readdirplus = %d ", (data.flags & NFS_MOUNT_NORDIRPLUS) != 0);
619 data.version = nfs_mount_data_version;
620 *mount_opts = (char *) &data;
622 if (*flags & MS_REMOUNT)
626 * If the previous mount operation on the same host was
627 * backgrounded, and the "bg" for this mount is also set,
628 * give up immediately, to avoid the initial timeout.
630 if (bg && !running_bg &&
631 prev_bg_host && strcmp(hostname, prev_bg_host) == 0) {
637 /* create mount deamon client */
640 * The following loop implements the mount retries. On the first
641 * call, "running_bg" is 0. When the mount times out, and the
642 * "bg" option is set, the exit status EX_BG will be returned.
643 * For a backgrounded mount, there will be a second call by the
644 * child process with "running_bg" set to 1.
646 * The case where the mount point is not present and the "bg"
647 * option is set, is treated as a timeout. This is done to
648 * support nested mounts.
650 * The "retry" count specified by the user is the number of
651 * minutes to retry before giving up.
653 * Only the first error message will be displayed.
655 timeout = time(NULL) + 60 * retry;
660 memcpy(&save_nfs, nfs_pmap, sizeof(save_nfs));
661 memcpy(&save_mnt, mnt_pmap, sizeof(save_mnt));
663 if (bg && stat(node, &statbuf) == -1) {
664 /* no mount point yet - sleep */
666 sleep(val); /* 1, 2, 4, 8, 16, 30, ... */
673 /* be careful not to use too many CPU cycles */
677 stat = nfs_call_mount(&mnt_server, &nfs_server,
681 memcpy(nfs_pmap, &save_nfs, sizeof(*nfs_pmap));
682 memcpy(mnt_pmap, &save_mnt, sizeof(*mnt_pmap));
686 switch(rpc_createerr.cf_stat){
689 case RPC_SYSTEMERROR:
690 if (errno == ETIMEDOUT)
693 mount_errors(*nfs_server.hostname, 0, bg);
698 mount_errors(*nfs_server.hostname, 0, bg);
701 mount_errors(*nfs_server.hostname, 1, bg);
705 prev_bg_host = xstrdup(hostname);
712 mount_errors(*nfs_server.hostname, 0, bg);
716 mount_errors(*nfs_server.hostname, 1, bg);
719 if (nfs_pmap->pm_vers == 2) {
720 if (mntres.nfsv2.fhs_status != 0) {
722 _("mount: %s:%s failed, reason given by server: %s\n"),
724 nfs_strerror(mntres.nfsv2.fhs_status));
727 memcpy(data.root.data,
728 (char *) mntres.nfsv2.fhstatus_u.fhs_fhandle,
730 #if NFS_MOUNT_VERSION >= 4
731 data.root.size = NFS_FHSIZE;
732 memcpy(data.old_root.data,
733 (char *) mntres.nfsv2.fhstatus_u.fhs_fhandle,
737 #if NFS_MOUNT_VERSION >= 4
738 mountres3_ok *mountres;
740 int i, *flavor, yum = 0;
741 if (mntres.nfsv3.fhs_status != 0) {
743 _("mount: %s:%s failed, reason given by server: %s\n"),
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",
774 "mount: %s:%s failed, "
775 "security flavor not supported\n",
777 /* server has registered us in rmtab, send umount */
778 nfs_call_umount(&mnt_server, &dirname);
783 fhandle = &mntres.nfsv3.mountres3_u.mountinfo.fhandle;
784 memset(data.old_root.data, 0, NFS_FHSIZE);
785 memset(&data.root, 0, sizeof(data.root));
786 data.root.size = fhandle->fhandle3_len;
787 memcpy(data.root.data,
788 (char *) fhandle->fhandle3_val,
789 fhandle->fhandle3_len);
791 data.flags |= NFS_MOUNT_VER3;
795 if (nfs_mount_data_version == 1) {
796 /* create nfs socket for kernel */
797 if (nfs_pmap->pm_prot == IPPROTO_TCP)
798 fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
800 fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
802 perror(_("nfs socket"));
805 if (bindresvport(fsock, 0) < 0) {
806 perror(_("nfs bindresvport"));
811 #ifdef NFS_MOUNT_DEBUG
812 printf(_("using port %d for nfs deamon\n"), nfs_pmap->pm_port);
814 nfs_saddr->sin_port = htons(nfs_pmap->pm_port);
816 * connect() the socket for kernels 1.3.10 and below only,
817 * to avoid problems with multihomed hosts.
820 if (linux_version_code() <= 0x01030a && fsock != -1
821 && connect(fsock, (struct sockaddr *) nfs_saddr,
822 sizeof (*nfs_saddr)) < 0) {
823 perror(_("nfs connect"));
827 #if NFS_MOUNT_VERSION >= 2
828 if (nfs_pmap->pm_prot == IPPROTO_TCP)
829 data.flags |= NFS_MOUNT_TCP;
831 data.flags &= ~NFS_MOUNT_TCP;
834 /* prepare data structure for kernel */
837 memcpy((char *) &data.addr, (char *) nfs_saddr, sizeof(data.addr));
838 strncpy(data.hostname, hostname, sizeof(data.hostname));
841 /* Ensure we have enough padding for the following strcat()s */
842 if (strlen(new_opts) + strlen(s) + 30 >= sizeof(new_opts)) {
843 fprintf(stderr, _("mount: "
844 "excessively long option argument\n"));
848 snprintf(cbuf, sizeof(cbuf)-1, "addr=%s", s);
849 strcat(new_opts, cbuf);
851 *extra_opts = xstrdup(new_opts);
852 *need_statd = ! (data.flags & NFS_MOUNT_NONLM);