summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2009-05-22 12:35:12 +0000
committerrwatson <rwatson@FreeBSD.org>2009-05-22 12:35:12 +0000
commitccb17e335aed123268303ae81de1b71c1340a1e7 (patch)
treed3806d83b9761a1610e63824e4451e9628878f16 /sbin
parenta75d175b4f1d7335efc89a91eac2db17f903ec5e (diff)
downloadFreeBSD-src-ccb17e335aed123268303ae81de1b71c1340a1e7.zip
FreeBSD-src-ccb17e335aed123268303ae81de1b71c1340a1e7.tar.gz
Remove the unmaintained University of Michigan NFSv4 client from 8.x
prior to 8.0-RELEASE. Rick Macklem's new and more feature-rich NFSv234 client and server are replacing it. Discussed with: rmacklem
Diffstat (limited to 'sbin')
-rw-r--r--sbin/Makefile1
-rw-r--r--sbin/idmapd/Makefile11
-rw-r--r--sbin/idmapd/idmapd.863
-rw-r--r--sbin/idmapd/idmapd.c418
-rw-r--r--sbin/mount_nfs/Makefile4
-rw-r--r--sbin/mount_nfs/mount_nfs.87
-rw-r--r--sbin/mount_nfs/mount_nfs.c255
7 files changed, 6 insertions, 753 deletions
diff --git a/sbin/Makefile b/sbin/Makefile
index 649f4a2..8ece390 100644
--- a/sbin/Makefile
+++ b/sbin/Makefile
@@ -36,7 +36,6 @@ SUBDIR= adjkerntz \
ggate \
growfs \
gvinum \
- idmapd \
ifconfig \
init \
${_ipf} \
diff --git a/sbin/idmapd/Makefile b/sbin/idmapd/Makefile
deleted file mode 100644
index 8206e0d..0000000
--- a/sbin/idmapd/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# @(#)Makefile 8.2 (Berkeley) 3/27/94
-#
-# $FreeBSD$
-
-PROG= idmapd
-MAN= idmapd.8
-
-CFLAGS+= -DNFS -I${.CURDIR}/../../sys
-WARNS?= 2
-
-.include <bsd.prog.mk>
diff --git a/sbin/idmapd/idmapd.8 b/sbin/idmapd/idmapd.8
deleted file mode 100644
index 1fb6216..0000000
--- a/sbin/idmapd/idmapd.8
+++ /dev/null
@@ -1,63 +0,0 @@
-.\" copyright (c) 2003
-.\" the regents of the university of michigan
-.\" all rights reserved
-.\"
-.\" permission is granted to use, copy, create derivative works and redistribute
-.\" this software and such derivative works for any purpose, so long as the name
-.\" of the university of michigan is not used in any advertising or publicity
-.\" pertaining to the use or distribution of this software without specific,
-.\" written prior authorization. if the above copyright notice or any other
-.\" identification of the university of michigan is included in any copy of any
-.\" portion of this software, then the disclaimer below must also be included.
-.\"
-.\" this software is provided as is, without representation from the university
-.\" of michigan as to its fitness for any purpose, and without warranty by the
-.\" university of michigan of any kind, either express or implied, including
-.\" without limitation the implied warranties of merchantability and fitness for
-.\" a particular purpose. the regents of the university of michigan shall not be
-.\" liable for any damages, including special, indirect, incidental, or
-.\" consequential damages, with respect to any claim arising out of or in
-.\" connection with the use of the software, even if it has been or is hereafter
-.\" advised of the possibility of such damages.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd October 15, 2006
-.Dt IDMAPD 8
-.Os
-.Sh NAME
-.Nm idmapd
-.Nd name/UID mapper for NFSv4
-.Sh SYNOPSIS
-.Nm
-.Op Fl v
-.Op Fl d Ar domainname
-.Sh DESCRIPTION
-The
-.Nm
-daemon normally runs in the background and services UID/GID-to-name and
-name-to-UID/GID mapping
-requests from the NFSv4 client kernel threads.
-.Pp
-The options are:
-.Bl -tag -width indent
-.It Fl d
-Set the domain part of the name string to the specified string.
-.It Fl v
-Be verbose, and do not run in the background.
-.El
-.Sh FILES
-.Bl -tag -width ".Pa /etc/master.passwd" -compact
-.It Pa /etc/pwd.db
-The insecure password database file.
-.It Pa /etc/spwd.db
-The secure password database file.
-.It Pa /etc/master.passwd
-The current password file.
-.It Pa /etc/passwd
-A Version 7 format password file.
-.El
-.Sh SEE ALSO
-.Xr getpwnam 3 ,
-.Xr getpwuid 3 ,
-.Xr mount_nfs4 8
diff --git a/sbin/idmapd/idmapd.c b/sbin/idmapd/idmapd.c
deleted file mode 100644
index fa3a082..0000000
--- a/sbin/idmapd/idmapd.c
+++ /dev/null
@@ -1,418 +0,0 @@
-/* $FreeBSD$ */
-/* $Id: idmapd.c,v 1.5 2003/11/05 14:58:58 rees Exp $ */
-
-/*
- * copyright (c) 2003
- * the regents of the university of michigan
- * all rights reserved
- *
- * permission is granted to use, copy, create derivative works and redistribute
- * this software and such derivative works for any purpose, so long as the name
- * of the university of michigan is not used in any advertising or publicity
- * pertaining to the use or distribution of this software without specific,
- * written prior authorization. if the above copyright notice or any other
- * identification of the university of michigan is included in any copy of any
- * portion of this software, then the disclaimer below must also be included.
- *
- * this software is provided as is, without representation from the university
- * of michigan as to its fitness for any purpose, and without warranty by the
- * university of michigan of any kind, either express or implied, including
- * without limitation the implied warranties of merchantability and fitness for
- * a particular purpose. the regents of the university of michigan shall not be
- * liable for any damages, including special, indirect, incidental, or
- * consequential damages, with respect to any claim arising out of or in
- * connection with the use of the software, even if it has been or is hereafter
- * advised of the possibility of such damages.
- */
-
-/* XXX ignores the domain of received names. */
-
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/syscall.h>
-#include <sys/errno.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/queue.h>
-
-#include <nfs4client/nfs4_dev.h>
-#include <nfs4client/nfs4_idmap.h>
-
-#include <stdio.h>
-#include <fcntl.h>
-#include <assert.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <pwd.h>
-#include <grp.h>
-
-#define DEV_PATH "/dev/nfs4"
-
-#define DOMAIN "@FreeBSD.org"
-#define BADUSER "nobody"
-#define BADGROUP "nogroup"
-#define BADUID 65534
-#define BADGID 65533
-
-struct idmap_e {
- struct nfs4dev_msg msg;
- TAILQ_ENTRY(idmap_e) next;
-};
-
-int fd, verbose;
-char *domain = DOMAIN;
-
-TAILQ_HEAD(, idmap_e) upcall_q;
-
-#define add_idmap_e(E) do { \
- assert(E != NULL); \
- TAILQ_INSERT_TAIL(&upcall_q, E, next); \
-} while(0)
-
-#define remove_idmap_e(E) do { \
- assert(E != NULL && !TAILQ_EMPTY(&upcall_q)); \
- E = TAILQ_FIRST(&upcall_q); \
- TAILQ_REMOVE(&upcall_q, E, next); \
-} while(0)
-
-#define get_idmap_e(E) do { \
- if ((E = (struct idmap_e *) malloc(sizeof(struct idmap_e))) == NULL) {\
- fprintf(stderr, "get_idmap_e(): error in malloc\n");\
- } } while(0)
-
-#define put_idmap_e(E) free(E)
-
-/* from marius */
-int
-validateascii(char *string, u_int32_t len)
-{
- int i;
-
- for (i = 0; i < len; i++) {
- if (string[i] == '\0')
- break;
- if (string[i] & 0x80)
- return (-1);
- }
-
- if (string[i] != '\0')
- return (-1);
- return (i + 1);
-}
-
-char *
-idmap_prune_domain(struct idmap_msg * m)
-{
- size_t i;
- size_t len;
- char * ret = NULL;
-
- if (m == NULL)
- return NULL;
-
- len = m->id_namelen;
-
- if (validateascii(m->id_name, len) < 0) {
- fprintf(stderr, "msg has invalid ascii\n");
- return NULL;
- }
-
- for (i=0; i < len && m->id_name[i] != '@' ; i++);
-
- ret = (char *)malloc(i+1);
- if (ret == NULL)
- return NULL;
-
- bcopy(m->id_name, ret, i);
- ret[i] = '\0';
-
- return ret;
-}
-
-int
-idmap_add_domain(struct idmap_msg * m, char * name)
-{
- size_t len, nlen;
-
- if (m == NULL || name == NULL)
- return -1;
-
- len = strlen(name);
-
- nlen = len + strlen(domain);
-
- if (nlen > IDMAP_MAXNAMELEN)
- return -1;
-
- bcopy(name, &m->id_name[0], len);
- bcopy(domain, &m->id_name[len], strlen(domain));
-
- m->id_name[nlen] = '\0';
- m->id_namelen = nlen;
-
- return 0;
-}
-
-int
-idmap_name(struct idmap_msg * m, char *name)
-{
- if (m == NULL || name == NULL || m->id_namelen != 0)
- return -1;
-
- if (idmap_add_domain(m, name))
- return -1;
-
- return 0;
-}
-
-int
-idmap_id(struct idmap_msg * m, ident_t id)
-{
- if (m == NULL || m->id_namelen == 0) {
- fprintf(stderr, "idmap_id: bad msg\n");
- return -1;
- }
-
- switch(m->id_type) {
- case IDMAP_TYPE_UID:
- m->id_id.uid = id.uid;
- break;
- case IDMAP_TYPE_GID:
- m->id_id.gid = id.gid;
- break;
- default:
- return -1;
- break;
- };
-
- return 0;
-}
-
-int
-idmap_service(struct idmap_e * e)
-{
- struct idmap_msg * m;
- struct passwd * pwd;
- struct group * grp;
- ident_t id;
- char * name;
-
- if (e == NULL) {
- fprintf(stderr, "bad entry\n");
- return -1;
- }
-
- if (e->msg.msg_vers != NFS4DEV_VERSION) {
- fprintf(stderr, "kernel/userland version mismatch! %d/%d\n",
- e->msg.msg_vers, NFS4DEV_VERSION);
- return -1;
- }
-
- if (e->msg.msg_type != NFS4DEV_TYPE_IDMAP) {
- fprintf(stderr, "bad type!\n");
- return -1;
- }
-
- if (e->msg.msg_len != sizeof(struct idmap_msg)) {
- fprintf(stderr, "bad message length: %zu/%zu\n", e->msg.msg_len,
- sizeof(struct idmap_msg));
- return -1;
- }
-
- if (verbose)
- printf("servicing msg xid: %x\n", e->msg.msg_xid);
-
-
- m = (struct idmap_msg *)e->msg.msg_data;
-
- if (m->id_namelen != 0 && m->id_namelen != strlen(m->id_name)) {
- fprintf(stderr, "bad name length in idmap_msg\n");
- return -1;
- }
-
- switch (m->id_type) {
- case IDMAP_TYPE_UID:
- if (m->id_namelen == 0) {
- /* id to name */
- pwd = getpwuid(m->id_id.uid);
-
- if (pwd == NULL) {
- fprintf(stderr, "unknown uid %d!\n",
- (uint32_t)m->id_id.uid);
- name = BADUSER;
- } else
- name = pwd->pw_name;
-
- if (idmap_name(m, name))
- return -1;
-
- } else {
- /* name to id */
- name = idmap_prune_domain(m);
- if (name == NULL)
- return -1;
-
- pwd = getpwnam(name);
-
- if (pwd == NULL) {
- fprintf(stderr, "unknown username %s!\n", name);
-
- id.uid = (uid_t)BADUID;
- } else
- id.uid = pwd->pw_uid;
-
- free(name);
-
- if (idmap_id(m, id))
- return -1;
- }
- break;
- case IDMAP_TYPE_GID:
- if (m->id_namelen == 0) {
- /* id to name */
- grp = getgrgid(m->id_id.gid);
-
- if (grp == NULL) {
- fprintf(stderr, "unknown gid %d!\n",
- (uint32_t)m->id_id.gid);
- name = BADGROUP;
- } else
- name = grp->gr_name;
-
- if (idmap_name(m, name))
- return -1;
- } else {
- /* name to id */
- name = idmap_prune_domain(m);
- if (name == NULL)
- return -1;
-
- grp = getgrnam(name);
-
- if (grp == NULL) {
- fprintf(stderr, "unknown groupname %s!\n", name);
-
- id.gid = (gid_t)BADGID;
- } else
- id.gid = grp->gr_gid;
-
- free(name);
-
- if (idmap_id(m, id))
- return -1;
- }
- break;
- default:
- fprintf(stderr, "bad idmap type: %d\n", m->id_type);
- return -1;
- break;
- }
-
- return 0;
-}
-
-int
-main(int argc, char ** argv)
-{
- int error = 0;
- struct idmap_e * entry;
- fd_set read_fds, write_fds;
- int maxfd;
- int ret, ch;
-
- while ((ch = getopt(argc, argv, "d:v")) != -1) {
- switch (ch) {
- case 'd':
- domain = optarg;
- break;
- case 'v':
- verbose = 1;
- break;
- default:
- fprintf(stderr, "usage: %s [-v] [-d domain]\n", argv[0]);
- exit(1);
- break;
- }
- }
-
-
- TAILQ_INIT(&upcall_q);
-
- fd = open(DEV_PATH, O_RDWR, S_IRUSR | S_IWUSR);
-
- if (fd < 0) {
- perror(DEV_PATH);
- exit(1);
- }
-
- if (!verbose)
- daemon(0,0);
-
- maxfd = fd;
- for (;;) {
- struct timeval timo = {1, 0};
- do {
- FD_ZERO(&read_fds);
- FD_ZERO(&write_fds);
-
- FD_SET(fd, &read_fds);
- FD_SET(fd, &write_fds);
-
- ret = select(maxfd+1, &read_fds, &write_fds, NULL, &timo);
- } while (ret < 0 && errno == EINTR);
-
- if (ret <= 0) {
- if (ret != 0)
- perror("select");
- continue;
- }
-
-
- if (FD_ISSET(fd, &read_fds)) {
- for (;;) {
- get_idmap_e(entry);
-
- error = ioctl(fd, NFS4DEVIOCGET, &entry->msg);
-
- if (error == -1) {
- if (errno != EAGAIN)
- perror("get ioctl:");
- put_idmap_e(entry);
- break;
- }
-
- switch (entry->msg.msg_type ) {
- case NFS4DEV_TYPE_IDMAP:
- if (idmap_service(entry))
- entry->msg.msg_error = EIO;
- break;
- default:
- fprintf(stderr, "unknown nfs4dev_msg type\n");
- entry->msg.msg_error = EIO;
- break;
- }
-
- add_idmap_e(entry);
- }
- }
-
- if (FD_ISSET(fd, &write_fds)) {
- while (!TAILQ_EMPTY(&upcall_q)) {
- remove_idmap_e(entry);
-
- error = ioctl(fd, NFS4DEVIOCPUT, &entry->msg);
-
- if (error == -1) {
- if (errno != EAGAIN)
- perror("put ioctl");
- break;
- }
- put_idmap_e(entry);
- }
- }
- }
-
- /* never reached */
- exit(1);
-}
diff --git a/sbin/mount_nfs/Makefile b/sbin/mount_nfs/Makefile
index 4f7efea..960f97c 100644
--- a/sbin/mount_nfs/Makefile
+++ b/sbin/mount_nfs/Makefile
@@ -5,15 +5,13 @@
PROG= mount_nfs
SRCS= mount_nfs.c getmntopts.c mounttab.c
MAN= mount_nfs.8
-MLINKS= mount_nfs.8 mount_nfs4.8
+MLINKS= mount_nfs.8
MOUNT= ${.CURDIR}/../mount
UMNTALL= ${.CURDIR}/../../usr.sbin/rpc.umntall
CFLAGS+= -DNFS -I${MOUNT} -I${UMNTALL}
WARNS?= 3
-LINKS= ${BINDIR}/mount_nfs ${BINDIR}/mount_nfs4
-
.PATH: ${MOUNT} ${UMNTALL}
.include <bsd.prog.mk>
diff --git a/sbin/mount_nfs/mount_nfs.8 b/sbin/mount_nfs/mount_nfs.8
index c75a30d..78a3b19 100644
--- a/sbin/mount_nfs/mount_nfs.8
+++ b/sbin/mount_nfs/mount_nfs.8
@@ -36,7 +36,7 @@
.Nd mount NFS file systems
.Sh SYNOPSIS
.Nm
-.Op Fl 234bcdiLlNPsTU
+.Op Fl 23bcdiLlNPsTU
.Op Fl a Ar maxreadahead
.Op Fl D Ar deadthresh
.Op Fl g Ar maxgroups
@@ -157,8 +157,6 @@ then version 2).
Note that NFS version 2 has a file size limit of 2 gigabytes.
.It Cm nfsv3
Use the NFS Version 3 protocol.
-.It Cm nfsv4
-Use the NFS Version 4 protocol.
.It Cm noconn
For UDP mount points, do not do a
.Xr connect 2 .
@@ -303,9 +301,6 @@ Same as
.It Fl 3
Same as
.Fl o Cm nfsv3
-.It Fl 4
-Same as
-.Fl o Cm nfsv4
.It Fl D
Same as
.Fl o Cm deadthresh
diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c
index a2f5e89..102c51d 100644
--- a/sbin/mount_nfs/mount_nfs.c
+++ b/sbin/mount_nfs/mount_nfs.c
@@ -1,28 +1,4 @@
/*
- * copyright (c) 2003
- * the regents of the university of michigan
- * all rights reserved
- *
- * permission is granted to use, copy, create derivative works and redistribute
- * this software and such derivative works for any purpose, so long as the name
- * of the university of michigan is not used in any advertising or publicity
- * pertaining to the use or distribution of this software without specific,
- * written prior authorization. if the above copyright notice or any other
- * identification of the university of michigan is included in any copy of any
- * portion of this software, then the disclaimer below must also be included.
- *
- * this software is provided as is, without representation from the university
- * of michigan as to its fitness for any purpose, and without warranty by the
- * university of michigan of any kind, either express or implied, including
- * without limitation the implied warranties of merchantability and fitness for
- * a particular purpose. the regents of the university of michigan shall not be
- * liable for any damages, including special, indirect, incidental, or
- * consequential damages, with respect to any claim arising out of or in
- * connection with the use of the software, even if it has been or is hereafter
- * advised of the possibility of such damages.
- */
-
-/*
* Copyright (c) 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
@@ -140,7 +116,6 @@ enum mountmode {
ANY,
V2,
V3,
- V4
} mountmode = ANY;
/* Return codes for nfs_tryproto. */
@@ -155,7 +130,6 @@ int fallback_mount(struct iovec *iov, int iovlen, int mntflags);
int sec_name_to_num(char *sec);
char *sec_num_to_name(int num);
int getnfsargs(char *, struct iovec **iov, int *iovlen);
-int getnfs4args(char *, struct iovec **iov, int *iovlen);
/* void set_rpc_maxgrouplist(int); */
struct netconfig *getnetconf_cached(const char *netid);
const char *netidbytype(int af, int sotype);
@@ -164,8 +138,6 @@ int xdr_dir(XDR *, char *);
int xdr_fh(XDR *, struct nfhret *);
enum tryret nfs_tryproto(struct addrinfo *ai, char *hostp, char *spec,
char **errstr, struct iovec **iov, int *iovlen);
-enum tryret nfs4_tryproto(struct addrinfo *ai, char *hostp, char *spec,
- char **errstr);
enum tryret returncode(enum clnt_stat stat, struct rpc_err *rpcerr);
extern int getosreldate(void);
@@ -190,15 +162,8 @@ main(int argc, char *argv[])
++fstype;
- if (strcmp(fstype, "nfs4") == 0) {
- nfsproto = IPPROTO_TCP;
- portspec = "2049";
- build_iovec(&iov, &iovlen, "tcp", NULL, 0);
- mountmode = V4;
- }
-
while ((c = getopt(argc, argv,
- "234a:bcdD:g:I:iLlNo:PR:r:sTt:w:x:U")) != -1)
+ "23a:bcdD:g:I:iLlNo:PR:r:sTt:w:x:U")) != -1)
switch (c) {
case '2':
mountmode = V2;
@@ -206,10 +171,6 @@ main(int argc, char *argv[])
case '3':
mountmode = V3;
break;
- case '4':
- mountmode = V4;
- fstype = "nfs4";
- break;
case 'a':
printf("-a deprecated, use -o readhead=<value>\n");
build_iovec(&iov, &iovlen, "readahead", optarg, (size_t)-1);
@@ -301,10 +262,6 @@ main(int argc, char *argv[])
mountmode = V2;
} else if (strcmp(opt, "nfsv3") == 0) {
mountmode = V3;
- } else if (strcmp(opt, "nfsv4") == 0) {
- pass_flag_to_nmount=0;
- mountmode = V4;
- fstype = "nfs4";
} else if (strcmp(opt, "port") == 0) {
pass_flag_to_nmount=0;
asprintf(&portspec, "%d",
@@ -406,13 +363,8 @@ main(int argc, char *argv[])
/* The default is to keep retrying forever. */
retrycnt = 0;
- if (mountmode == V4) {
- if (!getnfs4args(spec, &iov, &iovlen))
- exit(1);
- } else {
- if (!getnfsargs(spec, &iov, &iovlen))
- exit(1);
- }
+ if (!getnfsargs(spec, &iov, &iovlen))
+ exit(1);
/* resolve the mountpoint with realpath(3) */
(void)checkpath(name, mntpath);
@@ -814,129 +766,6 @@ getnfsargs(char *spec, struct iovec **iov, int *iovlen)
return (1);
}
-
-int
-getnfs4args(char *spec, struct iovec **iov, int *iovlen)
-{
- struct addrinfo hints, *ai_nfs, *ai;
- enum tryret ret;
- int ecode, speclen, remoteerr, sotype;
- char *hostp, *delimp, *errstr;
- size_t len;
- static char nam[MNAMELEN + 1];
-
- if (nfsproto == IPPROTO_TCP)
- sotype = SOCK_STREAM;
- else if (nfsproto == IPPROTO_UDP)
- sotype = SOCK_DGRAM;
-
-
- if ((delimp = strrchr(spec, ':')) != NULL) {
- hostp = spec;
- spec = delimp + 1;
- } else if ((delimp = strrchr(spec, '@')) != NULL) {
- warnx("path@server syntax is deprecated, use server:path");
- hostp = delimp + 1;
- } else {
- warnx("no <host>:<dirpath> nfs-name");
- return (0);
- }
- *delimp = '\0';
-
- /*
- * If there has been a trailing slash at mounttime it seems
- * that some mountd implementations fail to remove the mount
- * entries from their mountlist while unmounting.
- */
- for (speclen = strlen(spec);
- speclen > 1 && spec[speclen - 1] == '/';
- speclen--)
- spec[speclen - 1] = '\0';
- if (strlen(hostp) + strlen(spec) + 1 > MNAMELEN) {
- warnx("%s:%s: %s", hostp, spec, strerror(ENAMETOOLONG));
- return (0);
- }
- /* Make both '@' and ':' notations equal */
- if (*hostp != '\0') {
- len = strlen(hostp);
- memmove(nam, hostp, len);
- nam[len] = ':';
- memmove(nam + len + 1, spec, speclen);
- nam[len + speclen + 1] = '\0';
- }
-
- /*
- * Handle an internet host address.
- */
- memset(&hints, 0, sizeof hints);
- hints.ai_flags = AI_NUMERICHOST;
- hints.ai_socktype = sotype;
- if (getaddrinfo(hostp, portspec, &hints, &ai_nfs) != 0) {
- hints.ai_flags = 0;
- if ((ecode = getaddrinfo(hostp, portspec, &hints, &ai_nfs))
- != 0) {
- if (portspec == NULL)
- errx(1, "%s: %s", hostp, gai_strerror(ecode));
- else
- errx(1, "%s:%s: %s", hostp, portspec,
- gai_strerror(ecode));
- return (0);
- }
- }
-
- ret = TRYRET_LOCALERR;
- for (;;) {
- /*
- * Try each entry returned by getaddrinfo(). Note the
- * occurence of remote errors by setting `remoteerr'.
- */
- remoteerr = 0;
- for (ai = ai_nfs; ai != NULL; ai = ai->ai_next) {
- if ((ai->ai_family == AF_INET6) &&
- (opflags & OF_NOINET6))
- continue;
- if ((ai->ai_family == AF_INET) &&
- (opflags & OF_NOINET4))
- continue;
- ret = nfs4_tryproto(ai, hostp, spec, &errstr);
- if (ret == TRYRET_SUCCESS)
- break;
- if (ret != TRYRET_LOCALERR)
- remoteerr = 1;
- if ((opflags & ISBGRND) == 0)
- fprintf(stderr, "%s\n", errstr);
- }
- if (ret == TRYRET_SUCCESS)
- break;
-
- /* Exit if all errors were local. */
- if (!remoteerr)
- exit(1);
-
- /*
- * If retrycnt == 0, we are to keep retrying forever.
- * Otherwise decrement it, and exit if it hits zero.
- */
- if (retrycnt != 0 && --retrycnt == 0)
- exit(1);
-
- if ((opflags & (BGRND | ISBGRND)) == BGRND) {
- warnx("Cannot immediately mount %s:%s, backgrounding",
- hostp, spec);
- opflags |= ISBGRND;
- if (daemon(0, 0) != 0)
- err(1, "daemon");
- }
- sleep(60);
- }
- freeaddrinfo(ai_nfs);
- build_iovec(iov, iovlen, "hostname", nam, (size_t)-1);
- /* Add mounted file system to PATH_MOUNTTAB */
- if (!add_mtab(hostp, spec))
- warnx("can't update %s for %s:%s", PATH_MOUNTTAB, hostp, spec);
- return (1);
-}
-
/*
* Try to set up the NFS arguments according to the address
* family, protocol (and possibly port) specified in `ai'.
@@ -1142,82 +971,6 @@ tryagain:
return (TRYRET_SUCCESS);
}
-
-/*
- * Try to set up the NFS arguments according to the address
- * family, protocol (and possibly port) specified in `ai'.
- *
- * Returns TRYRET_SUCCESS if successful, or:
- * TRYRET_TIMEOUT The server did not respond.
- * TRYRET_REMOTEERR The server reported an error.
- * TRYRET_LOCALERR Local failure.
- *
- * In all error cases, *errstr will be set to a statically-allocated string
- * describing the error.
- */
-enum tryret
-nfs4_tryproto(struct addrinfo *ai, char *hostp, char *spec, char **errstr)
-{
- static char errbuf[256];
- struct sockaddr_storage nfs_ss;
- struct netbuf nfs_nb;
- struct netconfig *nconf;
- const char *netid;
- int nfsvers, sotype;
-
- errbuf[0] = '\0';
- *errstr = errbuf;
-
- if (nfsproto == IPPROTO_TCP)
- sotype = SOCK_STREAM;
- else if (nfsproto == IPPROTO_UDP)
- sotype = SOCK_DGRAM;
-
- if ((netid = netidbytype(ai->ai_family, sotype)) == NULL) {
- snprintf(errbuf, sizeof errbuf,
- "af %d sotype %d not supported", ai->ai_family, sotype);
- return (TRYRET_LOCALERR);
- }
- if ((nconf = getnetconf_cached(netid)) == NULL) {
- snprintf(errbuf, sizeof errbuf, "%s: %s", netid, nc_sperror());
- return (TRYRET_LOCALERR);
- }
-
- nfsvers = 4;
-
- if (portspec != NULL && atoi(portspec) != 0) {
- /* `ai' contains the complete nfsd sockaddr. */
- nfs_nb.buf = ai->ai_addr;
- nfs_nb.len = nfs_nb.maxlen = ai->ai_addrlen;
- } else {
- /* Ask the remote rpcbind. */
- nfs_nb.buf = &nfs_ss;
- nfs_nb.len = nfs_nb.maxlen = sizeof nfs_ss;
-
- if (!rpcb_getaddr(RPCPROG_NFS, nfsvers, nconf, &nfs_nb,
- hostp)) {
- snprintf(errbuf, sizeof errbuf, "[%s] %s:%s: %s",
- netid, hostp, spec,
- clnt_spcreateerror("RPCPROG_NFS"));
- return (returncode(rpc_createerr.cf_stat,
- &rpc_createerr.cf_error));
- }
- }
-
- /*
- * Store the filehandle and server address in nfsargsp, making
- * sure to copy any locally allocated structures.
- */
- addrlen = nfs_nb.len;
- addr = malloc(addrlen);
-
- if (addr == NULL)
- err(1, "malloc");
- bcopy(nfs_nb.buf, addr, addrlen);
-
- return (TRYRET_SUCCESS);
-}
-
/*
* Catagorise a RPC return status and error into an `enum tryret'
* return code.
@@ -1361,7 +1114,7 @@ void
usage()
{
(void)fprintf(stderr, "%s\n%s\n%s\n%s\n",
-"usage: mount_nfs [-234bcdiLlNPsTU] [-a maxreadahead] [-D deadthresh]",
+"usage: mount_nfs [-23bcdiLlNPsTU] [-a maxreadahead] [-D deadthresh]",
" [-g maxgroups] [-I readdirsize] [-o options] [-R retrycnt]",
" [-r readsize] [-t timeout] [-w writesize] [-x retrans]",
" rhost:path node");
OpenPOWER on IntegriCloud