summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2004-06-22 21:12:00 +0000
committerotto <otto@openbsd.org>2004-06-22 21:12:00 +0000
commitbea7d8bfef2fdf698be1ae208ab4b0b7cdffae5b (patch)
tree51df2db381aa7b70e59ff08774f4563737c7c446
parentRecent glue_strings change reversed a few checks; fix up conditionals (diff)
downloadwireguard-openbsd-bea7d8bfef2fdf698be1ae208ab4b0b7cdffae5b.tar.xz
wireguard-openbsd-bea7d8bfef2fdf698be1ae208ab4b0b7cdffae5b.zip
Rewrite of getmntopts(), making it more robust and getting rid of
the mount_nfs alternative implementation of the same function. Joint work with millert@. Fixes PR 3642. ok pedro@ millert@
-rw-r--r--sbin/mount/getmntopts.c106
-rw-r--r--sbin/mount/mntopts.h55
-rw-r--r--sbin/mount_nfs/Makefile11
-rw-r--r--sbin/mount_nfs/getmntopts.c96
-rw-r--r--sbin/mount_nfs/mntopts.h78
-rw-r--r--sbin/mount_nfs/mount_nfs.c193
-rw-r--r--sbin/mount_procfs/Makefile4
-rw-r--r--sbin/mount_procfs/mount_procfs.c8
8 files changed, 219 insertions, 332 deletions
diff --git a/sbin/mount/getmntopts.c b/sbin/mount/getmntopts.c
index 2712fa29c17..cd51786a87b 100644
--- a/sbin/mount/getmntopts.c
+++ b/sbin/mount/getmntopts.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getmntopts.c,v 1.7 2004/05/18 11:07:53 otto Exp $ */
+/* $OpenBSD: getmntopts.c,v 1.8 2004/06/22 21:12:00 otto Exp $ */
/* $NetBSD: getmntopts.c,v 1.3 1995/03/18 14:56:58 cgd Exp $ */
/*-
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)getmntopts.c 8.1 (Berkeley) 3/27/94";
#else
-static char rcsid[] = "$OpenBSD: getmntopts.c,v 1.7 2004/05/18 11:07:53 otto Exp $";
+static char rcsid[] = "$OpenBSD: getmntopts.c,v 1.8 2004/06/22 21:12:00 otto Exp $";
#endif
#endif /* not lint */
@@ -49,47 +49,85 @@ static char rcsid[] = "$OpenBSD: getmntopts.c,v 1.7 2004/05/18 11:07:53 otto Exp
#include "mntopts.h"
-void
-getmntopts(const char *options, const struct mntopt *m0, int *flagp)
+int
+getmntopts(const char *optionp, const struct mntopt *m0, int *flagp)
{
- const struct mntopt *m;
- int negative;
- char *opt, *optbuf, *p;
+ char *p, *q;
+ union mntval val;
+ int ret = 0;
- /* Copy option string, since it is about to be torn asunder... */
- if ((optbuf = strdup(options)) == NULL)
+ p = q = strdup(optionp);
+ if (p == NULL)
err(1, NULL);
+ while (p != NULL) {
+ ret |= getmntopt(&p, &val, m0, flagp);
+ }
+ free(q);
+ return (ret);
+}
- for (opt = optbuf; (opt = strtok(opt, ",")) != NULL; opt = NULL) {
- /* Check for "no" prefix. */
- if (opt[0] == 'n' && opt[1] == 'o') {
- negative = 1;
- opt += 2;
- } else
- negative = 0;
+int
+getmntopt(char **optionp, union mntval *valuep, const struct mntopt *m0,
+ int *flagp)
+{
+ const struct mntopt *m;
+ char *opt, *value, *endp;
+ long l;
+ int inverse, negative, needval, ret = 0;
- /*
- * for options with assignments in them (ie. quotas)
- * ignore the assignment as it's handled elsewhere
- */
- p = strchr(opt, '=');
- if (p != NULL)
- *p = '\0';
+ /* Pull out the next option. */
+ do {
+ if (*optionp == NULL)
+ return (0);
+ opt = strsep(optionp, ",");
+ } while (opt == NULL || *opt == '\0');
- /* Scan option table. */
- for (m = m0; m->m_option != NULL; ++m)
- if (strcasecmp(opt, m->m_option) == 0)
- break;
+ /* Check for "no" prefix. */
+ if (opt[0] == 'n' && opt[1] == 'o') {
+ negative = 1;
+ opt += 2;
+ } else
+ negative = 0;
- /* Save flag, or fail if option is not recognised. */
- if (m->m_option) {
- if (negative == m->m_inverse)
+ /* Stash the value for options with assignments in them. */
+ if ((value = strchr(opt, '=')) != NULL)
+ *value++ = '\0';
+
+ /* Scan option table. */
+ for (m = m0; m->m_option != NULL; ++m)
+ if (strcasecmp(opt, m->m_option) == 0)
+ break;
+
+ /* Save flag, or fail if option is not recognised. */
+ if (m->m_option) {
+ needval = (m->m_oflags & (MFLAG_INTVAL|MFLAG_STRVAL)) != 0;
+ if (needval != (value != NULL))
+ errx(1, "-o %s: option %s a value", opt,
+ needval ? "needs" : "does not need");
+ inverse = (m->m_oflags & MFLAG_INVERSE) ? 1 : 0;
+ if (m->m_oflags & MFLAG_SET) {
+ if (negative == inverse)
*flagp |= m->m_flag;
else
*flagp &= ~m->m_flag;
- } else
- errx(1, "-o %s: option not supported", opt);
- }
+ }
+ else if (negative == inverse)
+ ret = m->m_flag;
+ } else
+ errx(1, "-o %s: option not supported", opt);
- free(optbuf);
+ /* Store the value for options with assignments in them. */
+ if (value != NULL) {
+ if (m->m_oflags & MFLAG_INTVAL) {
+ l = strtol(value, &endp, 10);
+ if (endp == value || l < 0 || l > INT_MAX ||
+ (l == LONG_MAX && errno == ERANGE))
+ errx(1, "%s: illegal value '%s'",
+ opt, value);
+ valuep->ival = (int)l;
+ } else
+ valuep->strval = value;
+ } else
+ memset(valuep, 0, sizeof(*valuep));
+ return (ret);
}
diff --git a/sbin/mount/mntopts.h b/sbin/mount/mntopts.h
index 094580ec1ca..8551b1cd86f 100644
--- a/sbin/mount/mntopts.h
+++ b/sbin/mount/mntopts.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mntopts.h,v 1.12 2004/05/18 11:07:53 otto Exp $ */
+/* $OpenBSD: mntopts.h,v 1.13 2004/06/22 21:12:00 otto Exp $ */
/* $NetBSD: mntopts.h,v 1.3 1995/03/18 14:56:59 cgd Exp $ */
/*-
@@ -32,37 +32,49 @@
* @(#)mntopts.h 8.3 (Berkeley) 3/27/94
*/
+#define MFLAG_INVERSE 0x01 /* if a negative option, eg "dev" */
+#define MFLAG_SET 0x02 /* 1 => set bit in mntflags,
+ 0 => return flag */
+#define MFLAG_STRVAL 0x04 /* option needs a string value */
+#define MFLAG_INTVAL 0x08 /* option needs an int value */
+
struct mntopt {
const char *m_option; /* option name */
- int m_inverse; /* if a negative option, eg "dev" */
int m_flag; /* bit to set, eg. MNT_RDONLY */
+ int m_oflags;
+};
+
+union mntval {
+ char *strval;
+ int ival;
};
/* User-visible MNT_ flags. */
-#define MOPT_ASYNC { "async", 0, MNT_ASYNC }
-#define MOPT_NOACCESSTIME { "accesstime", 1, MNT_NOATIME }
-#define MOPT_NOATIME { "atime", 1, MNT_NOATIME }
-#define MOPT_NODEV { "dev", 1, MNT_NODEV }
-#define MOPT_NOEXEC { "exec", 1, MNT_NOEXEC }
-#define MOPT_NOSUID { "suid", 1, MNT_NOSUID }
-#define MOPT_RDONLY { "rdonly", 0, MNT_RDONLY }
-#define MOPT_SYNC { "sync", 0, MNT_SYNCHRONOUS }
-#define MOPT_UNION { "union", 0, MNT_UNION }
-#define MOPT_USERQUOTA { "userquota", 0, 0 }
-#define MOPT_GROUPQUOTA { "groupquota", 0, 0 }
-#define MOPT_SOFTDEP { "softdep", 0, MNT_SOFTDEP }
+#define MOPT_ASYNC { "async", MNT_ASYNC, MFLAG_SET }
+#define MOPT_NOACCESSTIME { "accesstime", MNT_NOATIME, \
+ MFLAG_INVERSE | MFLAG_SET }
+#define MOPT_NOATIME { "atime", MNT_NOATIME, MFLAG_INVERSE | MFLAG_SET }
+#define MOPT_NODEV { "dev", MNT_NODEV, MFLAG_INVERSE | MFLAG_SET }
+#define MOPT_NOEXEC { "exec", MNT_NOEXEC, MFLAG_INVERSE | MFLAG_SET }
+#define MOPT_NOSUID { "suid", MNT_NOSUID, MFLAG_INVERSE | MFLAG_SET }
+#define MOPT_RDONLY { "rdonly", MNT_RDONLY, MFLAG_SET }
+#define MOPT_SYNC { "sync", MNT_SYNCHRONOUS, MFLAG_SET }
+#define MOPT_UNION { "union", MNT_UNION, MFLAG_SET }
+#define MOPT_USERQUOTA { "userquota", 0, MFLAG_SET }
+#define MOPT_GROUPQUOTA { "groupquota", 0, MFLAG_SET }
+#define MOPT_SOFTDEP { "softdep", MNT_SOFTDEP, MFLAG_SET }
/* Control flags. */
-#define MOPT_FORCE { "force", 0, MNT_FORCE }
-#define MOPT_UPDATE { "update", 0, MNT_UPDATE }
-#define MOPT_RELOAD { "reload", 0, MNT_RELOAD }
+#define MOPT_FORCE { "force", MNT_FORCE, MFLAG_SET }
+#define MOPT_UPDATE { "update", MNT_UPDATE, MFLAG_SET }
+#define MOPT_RELOAD { "reload", MNT_RELOAD, MFLAG_SET }
/* Support for old-style "ro", "rw" flags. */
-#define MOPT_RO { "ro", 0, MNT_RDONLY }
-#define MOPT_RW { "rw", 1, MNT_RDONLY }
+#define MOPT_RO { "ro", MNT_RDONLY, MFLAG_SET }
+#define MOPT_RW { "rw", MNT_RDONLY, MFLAG_INVERSE | MFLAG_SET }
/* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */
-#define MOPT_AUTO { "auto", 0, 0 }
+#define MOPT_AUTO { "auto", 0, MFLAG_SET }
#define MOPT_FSTAB_COMPAT \
MOPT_RO, \
@@ -82,4 +94,5 @@ struct mntopt {
MOPT_RDONLY, \
MOPT_UNION
-void getmntopts(const char *, const struct mntopt *, int *);
+int getmntopts(const char *, const struct mntopt *, int *);
+int getmntopt(char **, union mntval *, const struct mntopt *, int *);
diff --git a/sbin/mount_nfs/Makefile b/sbin/mount_nfs/Makefile
index 0b96e9898ea..a8ec76fb9b0 100644
--- a/sbin/mount_nfs/Makefile
+++ b/sbin/mount_nfs/Makefile
@@ -1,14 +1,11 @@
-# $OpenBSD: Makefile,v 1.10 2004/05/18 11:07:53 otto Exp $
+# $OpenBSD: Makefile,v 1.11 2004/06/22 21:12:00 otto Exp $
PROG= mount_nfs
SRCS= mount_nfs.c getmntopts.c
MAN= mount_nfs.8
-# Temporarily removed to use own getmntops.c - fvdl
-#
-#MOUNT= ${.CURDIR}/../mount
-#CFLAGS+= -DNFS -I${MOUNT}
-#.PATH: ${MOUNT}
-CFLAGS+=-DNFS
+MOUNT= ${.CURDIR}/../mount
+CFLAGS+= -DNFS -I${MOUNT}
+.PATH: ${MOUNT}
.include <bsd.prog.mk>
diff --git a/sbin/mount_nfs/getmntopts.c b/sbin/mount_nfs/getmntopts.c
deleted file mode 100644
index ec04fe1007c..00000000000
--- a/sbin/mount_nfs/getmntopts.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/* $OpenBSD: getmntopts.c,v 1.5 2004/05/18 11:07:53 otto Exp $ */
-
-/*-
- * Copyright (c) 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)getmntopts.c 8.3 (Berkeley) 3/29/95";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/mount.h>
-
-#include <err.h>
-#include <errno.h>
-#include <fstab.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "mntopts.h"
-
-int getmnt_silent = 0;
-
-void
-getmntopts(const char *options, const struct mntopt *m0, int *flagp,
- int *altflagp)
-{
- const struct mntopt *m;
- int negative;
- char *opt, *optbuf, *p;
- int *thisflagp;
-
- /* Copy option string, since it is about to be torn asunder... */
- if ((optbuf = strdup(options)) == NULL)
- err(1, NULL);
-
- for (opt = optbuf; (opt = strtok(opt, ",")) != NULL; opt = NULL) {
- /* Check for "no" prefix. */
- if (opt[0] == 'n' && opt[1] == 'o') {
- negative = 1;
- opt += 2;
- } else
- negative = 0;
-
- /*
- * for options with assignments in them (ie. quotas)
- * ignore the assignment as it's handled elsewhere
- */
- p = strchr(opt, '=');
- if (p)
- *p = '\0';
-
- /* Scan option table. */
- for (m = m0; m->m_option != NULL; ++m)
- if (strcasecmp(opt, m->m_option) == 0)
- break;
-
- /* Save flag, or fail if option is not recognised. */
- if (m->m_option) {
- thisflagp = m->m_altloc ? altflagp : flagp;
- if (negative == m->m_inverse)
- *thisflagp |= m->m_flag;
- else
- *thisflagp &= ~m->m_flag;
- } else if (!getmnt_silent) {
- errx(1, "-o %s: option not supported", opt);
- }
- }
-
- free(optbuf);
-}
diff --git a/sbin/mount_nfs/mntopts.h b/sbin/mount_nfs/mntopts.h
deleted file mode 100644
index f4d0b5eb12c..00000000000
--- a/sbin/mount_nfs/mntopts.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* $OpenBSD: mntopts.h,v 1.5 2004/05/18 11:07:53 otto Exp $ */
-
-/*-
- * Copyright (c) 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)mntopts.h 8.7 (Berkeley) 3/29/95
- */
-
-struct mntopt {
- const char *m_option; /* option name */
- int m_inverse; /* if a negative option, eg "dev" */
- int m_flag; /* bit to set, eg. MNT_RDONLY */
- int m_altloc; /* 1 => set bit in altflags */
-};
-
-/* User-visible MNT_ flags. */
-#define MOPT_ASYNC { "async", 0, MNT_ASYNC, 0 }
-#define MOPT_NODEV { "dev", 1, MNT_NODEV, 0 }
-#define MOPT_NOEXEC { "exec", 1, MNT_NOEXEC, 0 }
-#define MOPT_NOSUID { "suid", 1, MNT_NOSUID, 0 }
-#define MOPT_RDONLY { "rdonly", 0, MNT_RDONLY, 0 }
-#define MOPT_SYNC { "sync", 0, MNT_SYNCHRONOUS, 0 }
-#define MOPT_UNION { "union", 0, MNT_UNION, 0 }
-#define MOPT_USERQUOTA { "userquota", 0, 0, 0 }
-#define MOPT_GROUPQUOTA { "groupquota", 0, 0, 0 }
-
-/* Control flags. */
-#define MOPT_FORCE { "force", 0, MNT_FORCE, 0 }
-#define MOPT_UPDATE { "update", 0, MNT_UPDATE, 0 }
-#define MOPT_RO { "ro", 0, MNT_RDONLY, 0 }
-#define MOPT_RW { "rw", 1, MNT_RDONLY, 0 }
-
-/* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */
-#define MOPT_AUTO { "auto", 0, 0, 0 }
-
-#define MOPT_FSTAB_COMPAT \
- MOPT_RO, \
- MOPT_RW, \
- MOPT_AUTO
-
-/* Standard options which all mounts can understand. */
-#define MOPT_STDOPTS \
- MOPT_USERQUOTA, \
- MOPT_GROUPQUOTA, \
- MOPT_FSTAB_COMPAT, \
- MOPT_NODEV, \
- MOPT_NOEXEC, \
- MOPT_NOSUID, \
- MOPT_RDONLY, \
- MOPT_UNION
-
-void getmntopts(const char *, const struct mntopt *, int *, int *);
-extern int getmnt_silent;
diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c
index 3aca9f5b556..a0a59827d4e 100644
--- a/sbin/mount_nfs/mount_nfs.c
+++ b/sbin/mount_nfs/mount_nfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_nfs.c,v 1.38 2004/05/18 11:07:53 otto Exp $ */
+/* $OpenBSD: mount_nfs.c,v 1.39 2004/06/22 21:12:00 otto Exp $ */
/* $NetBSD: mount_nfs.c,v 1.12.4.1 1996/05/25 22:48:05 fvdl Exp $ */
/*
@@ -106,26 +106,26 @@ const struct mntopt mopts[] = {
MOPT_STDOPTS,
MOPT_FORCE,
MOPT_UPDATE,
- { "bg", 0, ALTF_BG, 1 },
- { "conn", 1, ALTF_NOCONN, 1 },
- { "dumbtimer", 0, ALTF_DUMBTIMR, 1 },
- { "intr", 0, ALTF_INTR, 1 },
- { "nfsv3", 0, ALTF_NFSV3, 1 },
- { "rdirplus", 0, ALTF_RDIRPLUS, 1 },
- { "mntudp", 0, ALTF_MNTUDP, 1 },
- { "resvport", 0, ALTF_RESVPORT, 1 },
+ { "bg", ALTF_BG, 0 },
+ { "conn", ALTF_NOCONN, MFLAG_INVERSE },
+ { "dumbtimer", ALTF_DUMBTIMR, 0 },
+ { "intr", ALTF_INTR, 0 },
+ { "nfsv3", ALTF_NFSV3, 0 },
+ { "rdirplus", ALTF_RDIRPLUS, 0 },
+ { "mntudp", ALTF_MNTUDP, 0 },
+ { "resvport", ALTF_RESVPORT, 0 },
#ifdef ISO
- { "seqpacket", 0, ALTF_SEQPACKET, 1 },
+ { "seqpacket", ALTF_SEQPACKET, 0 },
#endif
- { "soft", 0, ALTF_SOFT, 1 },
- { "tcp", 0, ALTF_TCP, 1 },
- { "port", 0, ALTF_PORT, 1 },
- { "nfsv2", 0, ALTF_NFSV2, 1 },
- { "ac", 1, ALTF_NOAC, 1 },
- { "acregmin", 0, ALTF_ACREGMIN, 1},
- { "acregmax", 0, ALTF_ACREGMAX, 1},
- { "acdirmin", 0, ALTF_ACDIRMIN, 1},
- { "acdirmax", 0, ALTF_ACDIRMAX, 1},
+ { "soft", ALTF_SOFT, 0 },
+ { "tcp", ALTF_TCP, 0 },
+ { "port", ALTF_PORT, MFLAG_INTVAL },
+ { "nfsv2", ALTF_NFSV2, 0 },
+ { "ac", ALTF_NOAC, 0 },
+ { "acregmin", ALTF_ACREGMIN, MFLAG_INTVAL },
+ { "acregmax", ALTF_ACREGMAX, MFLAG_INTVAL },
+ { "acdirmin", ALTF_ACDIRMIN, MFLAG_INTVAL },
+ { "acdirmax", ALTF_ACDIRMAX, MFLAG_INTVAL },
{ NULL }
};
@@ -187,13 +187,13 @@ main(int argc, char *argv[])
int c;
struct nfs_args *nfsargsp;
struct nfs_args nfsargs;
- int mntflags, altflags, num;
- char name[MAXPATHLEN], *p, *spec;
+ int mntflags, num;
+ char name[MAXPATHLEN], *options = NULL, *p, *spec;
+ union mntval value;
retrycnt = DEF_RETRY;
mntflags = 0;
- altflags = 0;
nfsargs = nfsdefargs;
nfsargsp = &nfsargs;
while ((c = getopt(argc, argv,
@@ -264,74 +264,7 @@ main(int argc, char *argv[])
nfsargsp->flags |= NFSMNT_RDIRPLUS;
break;
case 'o':
- getmntopts(optarg, mopts, &mntflags, &altflags);
- if (altflags & ALTF_BG)
- opflags |= BGRND;
- if (altflags & ALTF_NOCONN)
- nfsargsp->flags |= NFSMNT_NOCONN;
- if (altflags & ALTF_DUMBTIMR)
- nfsargsp->flags |= NFSMNT_DUMBTIMR;
- if (altflags & ALTF_INTR)
- nfsargsp->flags |= NFSMNT_INT;
- if (altflags & ALTF_NFSV3) {
- if (force2)
- errx(1,"conflicting version options");
- force3 = 1;
- }
- if (altflags & ALTF_NFSV2) {
- if (force3)
- errx(1,"conflicting version options");
- force2 = 1;
- nfsargsp->flags &= ~NFSMNT_NFSV3;
- }
- if (altflags & ALTF_RDIRPLUS)
- nfsargsp->flags |= NFSMNT_RDIRPLUS;
- if (altflags & ALTF_MNTUDP)
- mnttcp_ok = 0;
- if (altflags & ALTF_RESVPORT)
- nfsargsp->flags |= NFSMNT_RESVPORT;
-#ifdef ISO
- if (altflags & ALTF_SEQPACKET)
- nfsargsp->sotype = SOCK_SEQPACKET;
-#endif
- if (altflags & ALTF_SOFT)
- nfsargsp->flags |= NFSMNT_SOFT;
- if (altflags & ALTF_TCP) {
- nfsargsp->sotype = SOCK_STREAM;
- nfsproto = IPPROTO_TCP;
- }
- if (altflags & ALTF_PORT)
- port_no = atoi(strstr(optarg, "port=") + 5);
- if (altflags & ALTF_NOAC) {
- nfsargsp->flags
- |= (NFSMNT_ACREGMIN | NFSMNT_ACREGMAX |
- NFSMNT_ACDIRMIN | NFSMNT_ACDIRMAX);
- nfsargsp->acregmin = 0;
- nfsargsp->acregmax = 0;
- nfsargsp->acdirmin = 0;
- nfsargsp->acdirmax = 0;
- }
- if (altflags & ALTF_ACREGMIN) {
- nfsargsp->flags |= NFSMNT_ACREGMIN;
- nfsargsp->acregmin =
- atoi(strstr(optarg, "acregmin=") + 9);
- }
- if (altflags & ALTF_ACREGMAX) {
- nfsargsp->flags |= NFSMNT_ACREGMAX;
- nfsargsp->acregmax =
- atoi(strstr(optarg, "acregmax=") + 9);
- }
- if (altflags & ALTF_ACDIRMIN) {
- nfsargsp->flags |= NFSMNT_ACDIRMIN;
- nfsargsp->acdirmin =
- atoi(strstr(optarg, "acdirmin=") + 9);
- }
- if (altflags & ALTF_ACDIRMAX) {
- nfsargsp->flags |= NFSMNT_ACDIRMAX;
- nfsargsp->acdirmax =
- atoi(strstr(optarg, "acdirmax=") + 9);
- }
- altflags = 0;
+ options = optarg;
break;
case 'P':
nfsargsp->flags |= NFSMNT_RESVPORT;
@@ -395,6 +328,86 @@ main(int argc, char *argv[])
if (argc != 2)
usage();
+ /* parse -o options */
+ while (options != NULL) {
+ switch (getmntopt(&options, &value, mopts, &mntflags)) {
+ case ALTF_BG:
+ opflags |= BGRND;
+ break;
+ case ALTF_NOCONN:
+ nfsargsp->flags |= NFSMNT_NOCONN;
+ break;
+ case ALTF_DUMBTIMR:
+ nfsargsp->flags |= NFSMNT_DUMBTIMR;
+ break;
+ case ALTF_INTR:
+ nfsargsp->flags |= NFSMNT_INT;
+ break;
+ case ALTF_NFSV3:
+ if (force2)
+ errx(1,
+ "conflicting version options");
+ force3 = 1;
+ break;
+ case ALTF_NFSV2:
+ if (force3)
+ errx(1,
+ "conflicting version options");
+ force2 = 1;
+ nfsargsp->flags &= ~NFSMNT_NFSV3;
+ break;
+ case ALTF_RDIRPLUS:
+ nfsargsp->flags |= NFSMNT_RDIRPLUS;
+ break;
+ case ALTF_MNTUDP:
+ mnttcp_ok = 0;
+ break;
+ case ALTF_RESVPORT:
+ nfsargsp->flags |= NFSMNT_RESVPORT;
+ break;
+#ifdef ISO
+ case ALTF_SEQPACKET:
+ nfsargsp->sotype = SOCK_SEQPACKET;
+ break;
+#endif
+ case ALTF_SOFT:
+ nfsargsp->flags |= NFSMNT_SOFT;
+ break;
+ case ALTF_TCP:
+ nfsargsp->sotype = SOCK_STREAM;
+ nfsproto = IPPROTO_TCP;
+ break;
+ case ALTF_PORT:
+ port_no = value.ival;
+ break;
+ case ALTF_NOAC:
+ nfsargsp->flags |= (NFSMNT_ACREGMIN |
+ NFSMNT_ACREGMAX | NFSMNT_ACDIRMIN |
+ NFSMNT_ACDIRMAX);
+ nfsargsp->acregmin = 0;
+ nfsargsp->acregmax = 0;
+ nfsargsp->acdirmin = 0;
+ nfsargsp->acdirmax = 0;
+ break;
+ case ALTF_ACREGMIN:
+ nfsargsp->flags |= NFSMNT_ACREGMIN;
+ nfsargsp->acregmin = value.ival;
+ break;
+ case ALTF_ACREGMAX:
+ nfsargsp->flags |= NFSMNT_ACREGMAX;
+ nfsargsp->acregmax = value.ival;
+ break;
+ case ALTF_ACDIRMIN:
+ nfsargsp->flags |= NFSMNT_ACDIRMIN;
+ nfsargsp->acdirmin = value.ival;
+ break;
+ case ALTF_ACDIRMAX:
+ nfsargsp->flags |= NFSMNT_ACDIRMAX;
+ nfsargsp->acdirmax = value.ival;
+ break;
+ }
+ }
+
spec = *argv++;
if (realpath(*argv, name) == NULL)
err(1, "realpath %s", name);
diff --git a/sbin/mount_procfs/Makefile b/sbin/mount_procfs/Makefile
index 31cc3697c5a..8fce908e85c 100644
--- a/sbin/mount_procfs/Makefile
+++ b/sbin/mount_procfs/Makefile
@@ -1,10 +1,10 @@
-# $OpenBSD: Makefile,v 1.6 2004/05/18 11:07:54 otto Exp $
+# $OpenBSD: Makefile,v 1.7 2004/06/22 21:12:00 otto Exp $
PROG= mount_procfs
SRCS= mount_procfs.c getmntopts.c
MAN= mount_procfs.8
-MOUNT= ${.CURDIR}/../mount_nfs
+MOUNT= ${.CURDIR}/../mount
CFLAGS+= -I${MOUNT}
.PATH: ${MOUNT}
diff --git a/sbin/mount_procfs/mount_procfs.c b/sbin/mount_procfs/mount_procfs.c
index 97360a76266..4f860dca0f6 100644
--- a/sbin/mount_procfs/mount_procfs.c
+++ b/sbin/mount_procfs/mount_procfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_procfs.c,v 1.13 2004/05/18 11:07:54 otto Exp $ */
+/* $OpenBSD: mount_procfs.c,v 1.14 2004/06/22 21:12:00 otto Exp $ */
/* $NetBSD: mount_procfs.c,v 1.7 1996/04/13 01:31:59 jtc Exp $ */
/*
@@ -44,7 +44,7 @@ char copyright[] =
#if 0
static char sccsid[] = "@(#)mount_procfs.c 8.3 (Berkeley) 3/27/94";
#else
-static char rcsid[] = "$OpenBSD: mount_procfs.c,v 1.13 2004/05/18 11:07:54 otto Exp $";
+static char rcsid[] = "$OpenBSD: mount_procfs.c,v 1.14 2004/06/22 21:12:00 otto Exp $";
#endif
#endif /* not lint */
@@ -64,7 +64,7 @@ static char rcsid[] = "$OpenBSD: mount_procfs.c,v 1.13 2004/05/18 11:07:54 otto
const struct mntopt mopts[] = {
MOPT_STDOPTS,
- { "linux", 0, PROCFSMNT_LINUXCOMPAT, 1 },
+ { "linux", PROCFSMNT_LINUXCOMPAT, 0 },
{ NULL }
};
@@ -81,7 +81,7 @@ main(int argc, char *argv[])
while ((ch = getopt(argc, argv, "o:")) != -1)
switch (ch) {
case 'o':
- getmntopts(optarg, mopts, &mntflags, &altflags);
+ altflags |= getmntopts(optarg, mopts, &mntflags);
break;
case '?':
default: