diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2004-05-18 11:07:55 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2004-05-18 11:07:55 +0000 |
commit | 4ac4e54d7aeca8f95a01bdd8c492e789c7000d7c (patch) | |
tree | 63c27ae76e822716f1a41227dc1190679883bab3 /sbin | |
parent | fb3389aa6c32e957b970a221c7bd4db26b90768a (diff) |
Backout changes accidentally committed in prvious commit.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/mount/getmntopts.c | 103 | ||||
-rw-r--r-- | sbin/mount/mntopts.h | 55 | ||||
-rw-r--r-- | sbin/mount_nfs/Makefile | 10 | ||||
-rw-r--r-- | sbin/mount_nfs/getmntopts.c | 96 | ||||
-rw-r--r-- | sbin/mount_nfs/mntopts.h | 78 | ||||
-rw-r--r-- | sbin/mount_nfs/mount_nfs.c | 193 | ||||
-rw-r--r-- | sbin/mount_procfs/Makefile | 4 | ||||
-rw-r--r-- | sbin/mount_procfs/mount_procfs.c | 8 |
8 files changed, 331 insertions, 216 deletions
diff --git a/sbin/mount/getmntopts.c b/sbin/mount/getmntopts.c index 134d5e4d8f9..2712fa29c17 100644 --- a/sbin/mount/getmntopts.c +++ b/sbin/mount/getmntopts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getmntopts.c,v 1.6 2004/05/18 10:54:08 otto Exp $ */ +/* $OpenBSD: getmntopts.c,v 1.7 2004/05/18 11:07:53 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.6 2004/05/18 10:54:08 otto Exp $"; +static char rcsid[] = "$OpenBSD: getmntopts.c,v 1.7 2004/05/18 11:07:53 otto Exp $"; #endif #endif /* not lint */ @@ -49,82 +49,47 @@ static char rcsid[] = "$OpenBSD: getmntopts.c,v 1.6 2004/05/18 10:54:08 otto Exp #include "mntopts.h" -int -getmntopts(const char *optionp, const struct mntopt *m0, int *flagp) -{ - char *p, *q; - union mntval val; - int ret = 0; - - p = q = strdup(optionp); - if (p == NULL) - err(1, NULL); - while (p != NULL) { - ret |= getmntopt(&p, &val, m0, flagp); - } - free(q); - return (ret); -} - -int -getmntopt(char **optionp, union mntval *valuep, const struct mntopt *m0, - int *flagp) +void +getmntopts(const char *options, const struct mntopt *m0, int *flagp) { const struct mntopt *m; - char *opt, *value, *endp; - long l; - int negative, needval; + int negative; + char *opt, *optbuf, *p; - /* Pull out the next option. */ - do { - opt = strsep(optionp, ","); - } while (opt == NULL || *opt == '\0'); - if (opt == NULL) - return (0); + /* Copy option string, since it is about to be torn asunder... */ + if ((optbuf = strdup(options)) == NULL) + err(1, NULL); - /* Check for "no" prefix. */ - if (opt[0] == 'n' && opt[1] == 'o') { - negative = 1; - opt += 2; - } else - negative = 0; + 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; - /* Stash the value for options with assignments in them. */ - if ((value = strchr(opt, '=')) != NULL) - *value++ = '\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'; - /* Scan option table. */ - for (m = m0; m->m_option != NULL; ++m) - if (strcasecmp(opt, m->m_option) == 0) - break; + /* 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"); - if (m->m_oflags & MFLAG_SET) { - if (negative == (m->m_oflags & MFLAG_INVERSE) ? 1 : 0) + /* Save flag, or fail if option is not recognised. */ + if (m->m_option) { + if (negative == m->m_inverse) *flagp |= m->m_flag; else *flagp &= ~m->m_flag; - } - } else - errx(1, "-o %s: option not supported", opt); - - /* 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 ((m->m_oflags & MFLAG_SET) ? 0 : (negative ? 0 : m->m_flag)); + errx(1, "-o %s: option not supported", opt); + } + + free(optbuf); } diff --git a/sbin/mount/mntopts.h b/sbin/mount/mntopts.h index 65de81b0ba9..094580ec1ca 100644 --- a/sbin/mount/mntopts.h +++ b/sbin/mount/mntopts.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mntopts.h,v 1.11 2004/05/18 10:54:08 otto Exp $ */ +/* $OpenBSD: mntopts.h,v 1.12 2004/05/18 11:07:53 otto Exp $ */ /* $NetBSD: mntopts.h,v 1.3 1995/03/18 14:56:59 cgd Exp $ */ /*- @@ -32,49 +32,37 @@ * @(#)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 as 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", 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 } +#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 } /* Control flags. */ -#define MOPT_FORCE { "force", MNT_FORCE, MFLAG_SET } -#define MOPT_UPDATE { "update", MNT_UPDATE, MFLAG_SET } -#define MOPT_RELOAD { "reload", MNT_RELOAD, MFLAG_SET } +#define MOPT_FORCE { "force", 0, MNT_FORCE } +#define MOPT_UPDATE { "update", 0, MNT_UPDATE } +#define MOPT_RELOAD { "reload", 0, MNT_RELOAD } /* Support for old-style "ro", "rw" flags. */ -#define MOPT_RO { "ro", MNT_RDONLY, MFLAG_SET } -#define MOPT_RW { "rw", MNT_RDONLY, MFLAG_INVERSE | MFLAG_SET } +#define MOPT_RO { "ro", 0, MNT_RDONLY } +#define MOPT_RW { "rw", 1, MNT_RDONLY } /* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */ -#define MOPT_AUTO { "auto", 0, MFLAG_SET } +#define MOPT_AUTO { "auto", 0, 0 } #define MOPT_FSTAB_COMPAT \ MOPT_RO, \ @@ -94,5 +82,4 @@ union mntval { MOPT_RDONLY, \ MOPT_UNION -int getmntopts(const char *, const struct mntopt *, int *); -int getmntopt(char **, union mntval *, const struct mntopt *, int *); +void getmntopts(const char *, const struct mntopt *, int *); diff --git a/sbin/mount_nfs/Makefile b/sbin/mount_nfs/Makefile index 213be67c4d8..0b96e9898ea 100644 --- a/sbin/mount_nfs/Makefile +++ b/sbin/mount_nfs/Makefile @@ -1,12 +1,14 @@ -# $OpenBSD: Makefile,v 1.9 2004/05/18 10:54:08 otto Exp $ +# $OpenBSD: Makefile,v 1.10 2004/05/18 11:07:53 otto Exp $ PROG= mount_nfs SRCS= mount_nfs.c getmntopts.c MAN= mount_nfs.8 -MOUNT= ${.CURDIR}/../mount -CFLAGS+= -DNFS -I${MOUNT} -.PATH: ${MOUNT} +# Temporarily removed to use own getmntops.c - fvdl +# +#MOUNT= ${.CURDIR}/../mount +#CFLAGS+= -DNFS -I${MOUNT} +#.PATH: ${MOUNT} CFLAGS+=-DNFS .include <bsd.prog.mk> diff --git a/sbin/mount_nfs/getmntopts.c b/sbin/mount_nfs/getmntopts.c new file mode 100644 index 00000000000..ec04fe1007c --- /dev/null +++ b/sbin/mount_nfs/getmntopts.c @@ -0,0 +1,96 @@ +/* $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 new file mode 100644 index 00000000000..f4d0b5eb12c --- /dev/null +++ b/sbin/mount_nfs/mntopts.h @@ -0,0 +1,78 @@ +/* $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 263c2cd2132..3aca9f5b556 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.37 2004/05/18 10:54:08 otto Exp $ */ +/* $OpenBSD: mount_nfs.c,v 1.38 2004/05/18 11:07:53 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", 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 }, + { "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 }, #ifdef ISO - { "seqpacket", ALTF_SEQPACKET, 0 }, + { "seqpacket", 0, ALTF_SEQPACKET, 1 }, #endif - { "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 }, + { "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}, { NULL } }; @@ -187,13 +187,13 @@ main(int argc, char *argv[]) int c; struct nfs_args *nfsargsp; struct nfs_args nfsargs; - int mntflags, num; - char name[MAXPATHLEN], *options = NULL, *p, *spec; - union mntval value; + int mntflags, altflags, num; + char name[MAXPATHLEN], *p, *spec; retrycnt = DEF_RETRY; mntflags = 0; + altflags = 0; nfsargs = nfsdefargs; nfsargsp = &nfsargs; while ((c = getopt(argc, argv, @@ -264,7 +264,74 @@ main(int argc, char *argv[]) nfsargsp->flags |= NFSMNT_RDIRPLUS; break; case 'o': - options = optarg; + 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; break; case 'P': nfsargsp->flags |= NFSMNT_RESVPORT; @@ -328,86 +395,6 @@ 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 1f63bf93346..31cc3697c5a 100644 --- a/sbin/mount_procfs/Makefile +++ b/sbin/mount_procfs/Makefile @@ -1,10 +1,10 @@ -# $OpenBSD: Makefile,v 1.5 2004/05/18 10:54:08 otto Exp $ +# $OpenBSD: Makefile,v 1.6 2004/05/18 11:07:54 otto Exp $ PROG= mount_procfs SRCS= mount_procfs.c getmntopts.c MAN= mount_procfs.8 -MOUNT= ${.CURDIR}/../mount +MOUNT= ${.CURDIR}/../mount_nfs CFLAGS+= -I${MOUNT} .PATH: ${MOUNT} diff --git a/sbin/mount_procfs/mount_procfs.c b/sbin/mount_procfs/mount_procfs.c index 30747c955f0..97360a76266 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.12 2004/05/18 10:54:08 otto Exp $ */ +/* $OpenBSD: mount_procfs.c,v 1.13 2004/05/18 11:07:54 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.12 2004/05/18 10:54:08 otto Exp $"; +static char rcsid[] = "$OpenBSD: mount_procfs.c,v 1.13 2004/05/18 11:07:54 otto Exp $"; #endif #endif /* not lint */ @@ -64,7 +64,7 @@ static char rcsid[] = "$OpenBSD: mount_procfs.c,v 1.12 2004/05/18 10:54:08 otto const struct mntopt mopts[] = { MOPT_STDOPTS, - { "linux", PROCFSMNT_LINUXCOMPAT, 0 }, + { "linux", 0, PROCFSMNT_LINUXCOMPAT, 1 }, { NULL } }; @@ -81,7 +81,7 @@ main(int argc, char *argv[]) while ((ch = getopt(argc, argv, "o:")) != -1) switch (ch) { case 'o': - altflags |= getmntopts(optarg, mopts, &mntflags); + getmntopts(optarg, mopts, &mntflags, &altflags); break; case '?': default: |