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 Miskiewicz <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
51 #include <rpc/pmap_prot.h>
52 #include <rpc/pmap_clnt.h>
53 #include <sys/socket.h>
56 #include <netinet/in.h>
57 #include <arpa/inet.h>
59 #include <sys/mount.h>
65 #include "nfs_mount.h"
66 #include "mount_constants.h"
72 #ifdef HAVE_RPCSVC_NFS_PROT_H
73 #include <rpcsvc/nfs_prot.h>
75 #include <linux/nfs.h>
76 #define nfsstat nfs_stat
86 #ifndef HAVE_INET_ATON
87 #define inet_aton(a,b) (0)
90 typedef dirpath mnt2arg_t;
91 typedef dirpath mnt3arg_t;
92 typedef dirpath mntarg_t;
94 typedef struct fhstatus mnt2res_t;
95 typedef struct mountres3 mnt3res_t;
101 extern int nfs_mount_data_version;
102 extern char *progname;
106 static inline enum clnt_stat
107 nfs3_mount(CLIENT *clnt, mnt3arg_t *mnt3arg, mnt3res_t *mnt3res)
109 return clnt_call(clnt, MOUNTPROC3_MNT,
110 (xdrproc_t) xdr_dirpath, (caddr_t) mnt3arg,
111 (xdrproc_t) xdr_mountres3, (caddr_t) mnt3res,
115 static inline enum clnt_stat
116 nfs2_mount(CLIENT *clnt, mnt2arg_t *mnt2arg, mnt2res_t *mnt2res)
118 return clnt_call(clnt, MOUNTPROC_MNT,
119 (xdrproc_t) xdr_dirpath, (caddr_t) mnt2arg,
120 (xdrproc_t) xdr_fhstatus, (caddr_t) mnt2res,
125 nfs_call_mount(clnt_addr_t *mnt_server, clnt_addr_t *nfs_server,
126 mntarg_t *mntarg, mntres_t *mntres)
132 if (!probe_bothports(mnt_server, nfs_server))
135 clnt = mnt_openclnt(mnt_server, &msock);
138 /* make pointers in xdr_mountres3 NULL so
139 * that xdr_array allocates memory for us
141 memset(mntres, 0, sizeof(*mntres));
142 switch (mnt_server->pmap.pm_vers) {
144 stat = nfs3_mount(clnt, mntarg, &mntres->nfsv3);
148 stat = nfs2_mount(clnt, mntarg, &mntres->nfsv2);
153 if (stat != RPC_SUCCESS) {
154 clnt_geterr(clnt, &rpc_createerr.cf_error);
155 rpc_createerr.cf_stat = stat;
157 mnt_closeclnt(clnt, msock);
158 if (stat == RPC_SUCCESS)
165 parse_options(char *old_opts, struct nfs_mount_data *data,
166 int *bg, int *retry, clnt_addr_t *mnt_server,
167 clnt_addr_t *nfs_server, char *new_opts, const int opt_size)
169 struct sockaddr_in *mnt_saddr = &mnt_server->saddr;
170 struct pmap *mnt_pmap = &mnt_server->pmap;
171 struct pmap *nfs_pmap = &nfs_server->pmap;
173 char *opt, *opteq, *p, *opt_b, *tmp_opts;
174 char *mounthost = NULL;
181 len = strlen(new_opts);
182 tmp_opts = xstrdup(old_opts);
183 for (p=tmp_opts, opt_b=NULL; p && *p; p++) {
185 opt_b = p; /* begin of the option item */
187 open_quote ^= 1; /* reverse the status */
189 continue; /* still in a quoted block */
191 *p = '\0'; /* terminate the option item */
192 if (*p == '\0' || *(p+1) == '\0') {
193 opt = opt_b; /* opt is useful now */
197 continue; /* still somewhere in the option item */
199 if (strlen(opt) >= sizeof(cbuf))
201 if ((opteq = strchr(opt, '=')) && isdigit(opteq[1])) {
202 int val = atoi(opteq + 1);
204 if (!strcmp(opt, "rsize"))
206 else if (!strcmp(opt, "wsize"))
208 else if (!strcmp(opt, "timeo"))
210 else if (!strcmp(opt, "retrans"))
212 else if (!strcmp(opt, "acregmin"))
213 data->acregmin = val;
214 else if (!strcmp(opt, "acregmax"))
215 data->acregmax = val;
216 else if (!strcmp(opt, "acdirmin"))
217 data->acdirmin = val;
218 else if (!strcmp(opt, "acdirmax"))
219 data->acdirmax = val;
220 else if (!strcmp(opt, "actimeo")) {
221 data->acregmin = val;
222 data->acregmax = val;
223 data->acdirmin = val;
224 data->acdirmax = val;
226 else if (!strcmp(opt, "retry"))
228 else if (!strcmp(opt, "port"))
229 nfs_pmap->pm_port = val;
230 else if (!strcmp(opt, "mountport"))
231 mnt_pmap->pm_port = val;
232 else if (!strcmp(opt, "mountprog"))
233 mnt_pmap->pm_prog = val;
234 else if (!strcmp(opt, "mountvers"))
235 mnt_pmap->pm_vers = val;
236 else if (!strcmp(opt, "mounthost"))
237 mounthost=xstrndup(opteq+1, strcspn(opteq+1," \t\n\r,"));
238 else if (!strcmp(opt, "nfsprog"))
239 nfs_pmap->pm_prog = val;
240 else if (!strcmp(opt, "nfsvers") ||
241 !strcmp(opt, "vers")) {
242 nfs_pmap->pm_vers = val;
244 #if NFS_MOUNT_VERSION >= 2
245 } else if (!strcmp(opt, "namlen")) {
246 if (nfs_mount_data_version >= 2)
253 } else if (!strcmp(opt, "addr")) {
260 sprintf(cbuf, "%s=%s,", opt, opteq+1);
263 if (!strcmp(opt, "proto")) {
264 if (!strcmp(opteq+1, "udp")) {
265 nfs_pmap->pm_prot = IPPROTO_UDP;
266 mnt_pmap->pm_prot = IPPROTO_UDP;
267 #if NFS_MOUNT_VERSION >= 2
268 data->flags &= ~NFS_MOUNT_TCP;
269 } else if (!strcmp(opteq+1, "tcp") &&
270 nfs_mount_data_version > 2) {
271 nfs_pmap->pm_prot = IPPROTO_TCP;
272 mnt_pmap->pm_prot = IPPROTO_TCP;
273 data->flags |= NFS_MOUNT_TCP;
279 #if NFS_MOUNT_VERSION >= 5
280 } else if (!strcmp(opt, "sec")) {
281 char *secflavor = opteq+1;
283 if (nfs_mount_data_version < 5) {
284 printf(_("Warning: ignoring sec=%s option\n"),
287 } else if (!strcmp(secflavor, "none"))
288 data->pseudoflavor = AUTH_NONE;
289 else if (!strcmp(secflavor, "sys"))
290 data->pseudoflavor = AUTH_SYS;
291 else if (!strcmp(secflavor, "krb5"))
292 data->pseudoflavor = AUTH_GSS_KRB5;
293 else if (!strcmp(secflavor, "krb5i"))
294 data->pseudoflavor = AUTH_GSS_KRB5I;
295 else if (!strcmp(secflavor, "krb5p"))
296 data->pseudoflavor = AUTH_GSS_KRB5P;
300 printf(_("Warning: Unrecognized security flavor %s.\n"),
304 data->flags |= NFS_MOUNT_SECFLAVOUR;
306 } else if (!strcmp(opt, "mounthost"))
307 mounthost=xstrndup(opteq+1,
308 strcspn(opteq+1," \t\n\r,"));
309 else if (!strcmp(opt, "context")) {
310 char *context = opteq + 1;
311 int ctxlen = strlen(context);
313 if (ctxlen > NFS_MAX_CONTEXT_LEN) {
314 nfs_error(_("context parameter exceeds"
316 NFS_MAX_CONTEXT_LEN);
319 /* The context string is in the format of
320 * "system_u:object_r:...". We only want
321 * the context str between the quotes.
324 strncpy(data->context, context+1,
327 strncpy(data->context, context,
328 NFS_MAX_CONTEXT_LEN);
333 sprintf(cbuf, "%s=%s,", opt, opteq+1);
336 if (!strncmp(opt, "no", 2)) {
340 if (!strcmp(opt, "bg"))
342 else if (!strcmp(opt, "fg"))
344 else if (!strcmp(opt, "soft")) {
345 data->flags &= ~NFS_MOUNT_SOFT;
347 data->flags |= NFS_MOUNT_SOFT;
348 } else if (!strcmp(opt, "hard")) {
349 data->flags &= ~NFS_MOUNT_SOFT;
351 data->flags |= NFS_MOUNT_SOFT;
352 } else if (!strcmp(opt, "intr")) {
353 data->flags &= ~NFS_MOUNT_INTR;
355 data->flags |= NFS_MOUNT_INTR;
356 } else if (!strcmp(opt, "posix")) {
357 data->flags &= ~NFS_MOUNT_POSIX;
359 data->flags |= NFS_MOUNT_POSIX;
360 } else if (!strcmp(opt, "cto")) {
361 data->flags &= ~NFS_MOUNT_NOCTO;
363 data->flags |= NFS_MOUNT_NOCTO;
364 } else if (!strcmp(opt, "ac")) {
365 data->flags &= ~NFS_MOUNT_NOAC;
367 data->flags |= NFS_MOUNT_NOAC;
368 #if NFS_MOUNT_VERSION >= 2
369 } else if (!strcmp(opt, "tcp")) {
370 data->flags &= ~NFS_MOUNT_TCP;
372 if (nfs_mount_data_version < 2)
374 nfs_pmap->pm_prot = IPPROTO_TCP;
375 mnt_pmap->pm_prot = IPPROTO_TCP;
376 data->flags |= NFS_MOUNT_TCP;
378 mnt_pmap->pm_prot = IPPROTO_UDP;
379 nfs_pmap->pm_prot = IPPROTO_UDP;
381 } else if (!strcmp(opt, "udp")) {
382 data->flags &= ~NFS_MOUNT_TCP;
384 if (nfs_mount_data_version < 2)
386 nfs_pmap->pm_prot = IPPROTO_TCP;
387 mnt_pmap->pm_prot = IPPROTO_TCP;
388 data->flags |= NFS_MOUNT_TCP;
390 nfs_pmap->pm_prot = IPPROTO_UDP;
391 mnt_pmap->pm_prot = IPPROTO_UDP;
394 #if NFS_MOUNT_VERSION >= 3
395 } else if (!strcmp(opt, "lock")) {
396 data->flags &= ~NFS_MOUNT_NONLM;
398 if (nfs_mount_data_version < 3)
400 data->flags |= NFS_MOUNT_NONLM;
403 #if NFS_MOUNT_VERSION >= 4
404 } else if (!strcmp(opt, "broken_suid")) {
405 data->flags &= ~NFS_MOUNT_BROKEN_SUID;
407 if (nfs_mount_data_version < 4)
409 data->flags |= NFS_MOUNT_BROKEN_SUID;
411 } else if (!strcmp(opt, "acl")) {
412 data->flags &= ~NFS_MOUNT_NOACL;
414 data->flags |= NFS_MOUNT_NOACL;
415 } else if (!strcmp(opt, "rdirplus")) {
416 data->flags &= ~NFS_MOUNT_NORDIRPLUS;
418 data->flags |= NFS_MOUNT_NORDIRPLUS;
419 } else if (!strcmp(opt, "sharecache")) {
420 data->flags &= ~NFS_MOUNT_UNSHARED;
422 data->flags |= NFS_MOUNT_UNSHARED;
428 nfs_error(_("%s: Unsupported nfs mount option:"
430 val ? "" : "no", opt);
433 sprintf(cbuf, val ? "%s," : "no%s,", opt);
436 if (len >= opt_size) {
437 nfs_error(_("%s: excessively long option argument"),
441 strcat(new_opts, cbuf);
443 /* See if the nfs host = mount host. */
445 if (!nfs_gethostbyname(mounthost, mnt_saddr))
447 *mnt_server->hostname = mounthost;
452 nfs_error(_("%s: Bad nfs mount parameter: %s\n"), progname, opt);
458 static int nfsmnt_check_compat(const struct pmap *nfs_pmap,
459 const struct pmap *mnt_pmap)
461 unsigned int max_nfs_vers = (nfs_mount_data_version >= 4) ? 3 : 2;
462 unsigned int max_mnt_vers = (nfs_mount_data_version >= 4) ? 3 : 2;
464 if (nfs_pmap->pm_vers == 4) {
465 nfs_error(_("%s: Please use '-t nfs4' "
466 "instead of '-o vers=4'"), progname);
470 if (nfs_pmap->pm_vers) {
471 if (nfs_pmap->pm_vers > max_nfs_vers || nfs_pmap->pm_vers < 2) {
472 nfs_error(_("%s: NFS version %ld is not supported"),
473 progname, nfs_pmap->pm_vers);
478 if (mnt_pmap->pm_vers > max_mnt_vers) {
479 nfs_error(_("%s: NFS mount version %ld is not supported"),
480 progname, mnt_pmap->pm_vers);
491 nfsmount(const char *spec, const char *node, int flags,
492 char **extra_opts, int fake, int running_bg)
495 char *hostname, *dirname, *old_opts, *mounthost = NULL;
496 char new_opts[1024], cbuf[1024];
497 static struct nfs_mount_data data;
499 static int doonce = 0;
501 clnt_addr_t mnt_server = {
502 .hostname = &mounthost
504 clnt_addr_t nfs_server = {
505 .hostname = &hostname
507 struct sockaddr_in *nfs_saddr = &nfs_server.saddr;
508 struct pmap *mnt_pmap = &mnt_server.pmap,
509 *nfs_pmap = &nfs_server.pmap;
510 struct pmap save_mnt, save_nfs;
519 int retval = EX_FAIL;
524 if (strlen(spec) >= sizeof(hostdir)) {
525 nfs_error(_("%s: excessively long host:dir argument"),
529 strcpy(hostdir, spec);
530 if ((s = strchr(hostdir, ':'))) {
534 /* Ignore all but first hostname in replicated mounts
535 until they can be fully supported. (mack@sgi.com) */
536 if ((s = strchr(hostdir, ','))) {
538 nfs_error(_("%s: warning: "
539 "multiple hostnames not supported"),
543 nfs_error(_("%s: directory to mount not in host:dir format"),
548 if (!nfs_gethostbyname(hostname, nfs_saddr))
550 mounthost = hostname;
551 memcpy (&mnt_server.saddr, nfs_saddr, sizeof (mnt_server.saddr));
553 /* add IP address to mtab options for use when unmounting */
555 s = inet_ntoa(nfs_saddr->sin_addr);
556 old_opts = *extra_opts;
560 /* Set default options.
561 * rsize/wsize (and bsize, for ver >= 3) are left 0 in order to
562 * let the kernel decide.
563 * timeo is filled in after we know whether it'll be TCP or UDP. */
564 memset(&data, 0, sizeof(data));
569 #if NFS_MOUNT_VERSION >= 2
570 data.namlen = NAME_MAX;
576 memset(mnt_pmap, 0, sizeof(*mnt_pmap));
577 mnt_pmap->pm_prog = MOUNTPROG;
578 memset(nfs_pmap, 0, sizeof(*nfs_pmap));
579 nfs_pmap->pm_prog = NFS_PROGRAM;
583 if (!parse_options(old_opts, &data, &bg, &retry, &mnt_server, &nfs_server,
584 new_opts, sizeof(new_opts)))
586 if (!nfsmnt_check_compat(nfs_pmap, mnt_pmap))
591 retry = 10000; /* 10000 mins == ~1 week*/
593 retry = 2; /* 2 min default on fg mounts */
596 #ifdef NFS_MOUNT_DEBUG
597 printf(_("rsize = %d, wsize = %d, timeo = %d, retrans = %d\n"),
598 data.rsize, data.wsize, data.timeo, data.retrans);
599 printf(_("acreg (min, max) = (%d, %d), acdir (min, max) = (%d, %d)\n"),
600 data.acregmin, data.acregmax, data.acdirmin, data.acdirmax);
601 printf(_("port = %lu, bg = %d, retry = %d, flags = %.8x\n"),
602 nfs_pmap->pm_port, bg, retry, data.flags);
603 printf(_("mountprog = %lu, mountvers = %lu, nfsprog = %lu, nfsvers = %lu\n"),
604 mnt_pmap->pm_prog, mnt_pmap->pm_vers,
605 nfs_pmap->pm_prog, nfs_pmap->pm_vers);
606 printf(_("soft = %d, intr = %d, posix = %d, nocto = %d, noac = %d"),
607 (data.flags & NFS_MOUNT_SOFT) != 0,
608 (data.flags & NFS_MOUNT_INTR) != 0,
609 (data.flags & NFS_MOUNT_POSIX) != 0,
610 (data.flags & NFS_MOUNT_NOCTO) != 0,
611 (data.flags & NFS_MOUNT_NOAC) != 0);
612 #if NFS_MOUNT_VERSION >= 2
613 printf(_(", tcp = %d"),
614 (data.flags & NFS_MOUNT_TCP) != 0);
616 #if NFS_MOUNT_VERSION >= 4
617 printf(_(", noacl = %d"), (data.flags & NFS_MOUNT_NOACL) != 0);
619 #if NFS_MOUNT_VERSION >= 5
620 printf(_(", sec = %u"), data.pseudoflavor);
621 printf(_(", readdirplus = %d"), (data.flags & NFS_MOUNT_NORDIRPLUS) != 0);
626 data.version = nfs_mount_data_version;
628 if (flags & MS_REMOUNT)
631 /* create mount deamon client */
634 * The following loop implements the mount retries. On the first
635 * call, "running_bg" is 0. When the mount times out, and the
636 * "bg" option is set, the exit status EX_BG will be returned.
637 * For a backgrounded mount, there will be a second call by the
638 * child process with "running_bg" set to 1.
640 * The case where the mount point is not present and the "bg"
641 * option is set, is treated as a timeout. This is done to
642 * support nested mounts.
644 * The "retry" count specified by the user is the number of
645 * minutes to retry before giving up.
647 * Only the first error message will be displayed.
649 timeout = time(NULL) + 60 * retry;
654 memcpy(&save_nfs, nfs_pmap, sizeof(save_nfs));
655 memcpy(&save_mnt, mnt_pmap, sizeof(save_mnt));
657 if (bg && stat(node, &statbuf) == -1) {
658 /* no mount point yet - sleep */
660 sleep(val); /* 1, 2, 4, 8, 16, 30, ... */
667 /* be careful not to use too many CPU cycles */
671 stat = nfs_call_mount(&mnt_server, &nfs_server,
675 memcpy(nfs_pmap, &save_nfs, sizeof(*nfs_pmap));
676 memcpy(mnt_pmap, &save_mnt, sizeof(*mnt_pmap));
680 switch(rpc_createerr.cf_stat){
683 case RPC_SYSTEMERROR:
684 if (errno == ETIMEDOUT)
687 rpc_mount_errors(*nfs_server.hostname, 0, bg);
692 rpc_mount_errors(*nfs_server.hostname, 0, bg);
695 rpc_mount_errors(*nfs_server.hostname, 1, bg);
705 rpc_mount_errors(*nfs_server.hostname, 0, bg);
709 rpc_mount_errors(*nfs_server.hostname, 1, bg);
712 if (mnt_pmap->pm_vers <= 2) {
713 if (mntres.nfsv2.fhs_status != 0) {
714 nfs_error(_("%s: %s:%s failed, reason given by server: %s"),
715 progname, hostname, dirname,
716 nfs_strerror(mntres.nfsv2.fhs_status));
719 memcpy(data.root.data,
720 (char *) mntres.nfsv2.fhstatus_u.fhs_fhandle,
722 #if NFS_MOUNT_VERSION >= 4
723 data.root.size = NFS_FHSIZE;
724 memcpy(data.old_root.data,
725 (char *) mntres.nfsv2.fhstatus_u.fhs_fhandle,
729 #if NFS_MOUNT_VERSION >= 4
730 mountres3_ok *mountres;
732 int i, n_flavors, *flavor, yum = 0;
733 if (mntres.nfsv3.fhs_status != 0) {
734 nfs_error(_("%s: %s:%s failed, reason given by server: %s"),
735 progname, hostname, dirname,
736 nfs_strerror(mntres.nfsv3.fhs_status));
739 #if NFS_MOUNT_VERSION >= 5
740 mountres = &mntres.nfsv3.mountres3_u.mountinfo;
741 n_flavors = mountres->auth_flavors.auth_flavors_len;
745 flavor = mountres->auth_flavors.auth_flavors_val;
746 for (i = 0; i < n_flavors; ++i) {
748 * Per RFC2623, section 2.7, we should prefer the
749 * flavour listed first.
750 * If no flavour requested, use the first simple
751 * flavour that is offered.
753 if (! (data.flags & NFS_MOUNT_SECFLAVOUR) &&
754 (flavor[i] == AUTH_SYS ||
755 flavor[i] == AUTH_NONE)) {
756 data.pseudoflavor = flavor[i];
757 data.flags |= NFS_MOUNT_SECFLAVOUR;
759 if (flavor[i] == data.pseudoflavor)
761 #ifdef NFS_MOUNT_DEBUG
762 printf(_("auth flavor %d: %d\n"), i, flavor[i]);
766 nfs_error(_("%s: %s:%s failed, security flavor "
768 progname, hostname, dirname);
769 /* server has registered us in rmtab, send umount */
770 nfs_call_umount(&mnt_server, &dirname);
775 fhandle = &mntres.nfsv3.mountres3_u.mountinfo.fhandle;
776 memset(data.old_root.data, 0, NFS_FHSIZE);
777 memset(&data.root, 0, sizeof(data.root));
778 data.root.size = fhandle->fhandle3_len;
779 memcpy(data.root.data,
780 (char *) fhandle->fhandle3_val,
781 fhandle->fhandle3_len);
783 data.flags |= NFS_MOUNT_VER3;
787 if (nfs_mount_data_version == 1) {
788 /* create nfs socket for kernel */
789 if (nfs_pmap->pm_prot == IPPROTO_TCP)
790 fsock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
792 fsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
794 perror(_("nfs socket"));
797 if (bindresvport(fsock, 0) < 0) {
798 perror(_("nfs bindresvport"));
803 #ifdef NFS_MOUNT_DEBUG
804 printf(_("using port %lu for nfs deamon\n"), nfs_pmap->pm_port);
806 nfs_saddr->sin_port = htons(nfs_pmap->pm_port);
808 * connect() the socket for kernels 1.3.10 and below only,
809 * to avoid problems with multihomed hosts.
812 if (linux_version_code() <= MAKE_VERSION(1, 3, 10) && fsock != -1
813 && connect(fsock, (struct sockaddr *) nfs_saddr,
814 sizeof (*nfs_saddr)) < 0) {
815 perror(_("nfs connect"));
819 #if NFS_MOUNT_VERSION >= 2
820 if (nfs_pmap->pm_prot == IPPROTO_TCP)
821 data.flags |= NFS_MOUNT_TCP;
823 data.flags &= ~NFS_MOUNT_TCP;
826 /* prepare data structure for kernel */
829 memcpy((char *) &data.addr, (char *) nfs_saddr, sizeof(data.addr));
830 strncpy(data.hostname, hostname, sizeof(data.hostname));
833 /* Ensure we have enough padding for the following strcat()s */
834 if (strlen(new_opts) + strlen(s) + 30 >= sizeof(new_opts)) {
835 nfs_error(_("%s: excessively long option argument"),
840 snprintf(cbuf, sizeof(cbuf)-1, "addr=%s", s);
841 strcat(new_opts, cbuf);
843 *extra_opts = xstrdup(new_opts);
845 if (!fake && !(data.flags & NFS_MOUNT_NONLM)) {
846 if (!start_statd()) {
847 nfs_error(_("%s: rpc.statd is not running but is "
848 "required for remote locking.\n"
849 " Either use '-o nolock' to keep "
850 "locks local, or start statd."),
857 if (mount(spec, node, "nfs",
858 flags & ~(MS_USER|MS_USERS), &data)) {
859 mount_error(spec, node, errno);