aboutsummaryrefslogtreecommitdiff
path: root/sbin/mount_ifs
diff options
context:
space:
mode:
authorGarrett Wollman <wollman@FreeBSD.org>1994-11-01 23:51:53 +0000
committerGarrett Wollman <wollman@FreeBSD.org>1994-11-01 23:51:53 +0000
commit3fa88dec7f907cbcfee54e5ebebc001a3279fe30 (patch)
treef614541c69f463075bbc04969273cb64b172d603 /sbin/mount_ifs
parentf23c6e08dfc2a3411b55e1b7a6a916bde7c5862d (diff)
downloadsrc-3fa88dec7f907cbcfee54e5ebebc001a3279fe30.tar.gz
src-3fa88dec7f907cbcfee54e5ebebc001a3279fe30.zip
Add support for filesystem-specific `-o' options, and re-implement the
most common cd9660 and nfs options like God intended them. (It is now possible to say mount -o ro,soft,bg,intr there:/foo/bar /foo/bar again.) This whole getmntopt() business is an incredible botch; it never should have been anything more than a wrapper around getsubopt(3). Because if the way the current hackaround is implemented, options which take arguments (like the old `rsize' and `wsize') are still unavailable, and must be accessed the new, broken way. (It's unimaginable how Berkeley managed to screw up one of the few things about NFS that Sun actually got right to begin with!)
Notes
Notes: svn path=/head/; revision=4065
Diffstat (limited to 'sbin/mount_ifs')
-rw-r--r--sbin/mount_ifs/getmntopts.315
-rw-r--r--sbin/mount_ifs/getmntopts.c14
-rw-r--r--sbin/mount_ifs/mntopts.h30
-rw-r--r--sbin/mount_ifs/mount_ufs.c2
4 files changed, 40 insertions, 21 deletions
diff --git a/sbin/mount_ifs/getmntopts.3 b/sbin/mount_ifs/getmntopts.3
index 642c57aa361d..c1bd25a227da 100644
--- a/sbin/mount_ifs/getmntopts.3
+++ b/sbin/mount_ifs/getmntopts.3
@@ -40,7 +40,7 @@
.Sh SYNOPSIS
.Fd #include <mntopts.h>
.Ft void
-.Fn getmntopts "char *options" "struct mntopt *mopts" "int *flagp"
+.Fn getmntopts "char *options" "struct mntopt *mopts" "int *flagp" "int *altflagp"
.Sh DESCRIPTION
The
.Nm getmntopts
@@ -54,8 +54,13 @@ is broken down into a sequence of comma separated tokens.
Each token is looked up in the table described by
.Dv mopts
and the bits in
-the word referenced by
+the word referenced by either
.Dv flagp
+or
+.Dv altflagp
+(depending on the
+.Dv m_altloc
+field of the option's table entry)
are updated.
The flag word is not initialized by
.Nm getmntopt .
@@ -67,6 +72,7 @@ struct mntopt {
char *m_option; /* option name */
int m_inverse; /* is this a negative option, eg "dev" */
int m_flag; /* bit to set, eg MNT_RDONLY */
+ int m_altloc; /* non-zero to use altflagp rather than flagp */
};
.Ed
.Pp
@@ -100,6 +106,11 @@ by the letters
The
.Dv m_inverse
flag causes these two operations to be reversed.
+.It Fa m_altloc
+the bit should be set or cleared in
+.Dv altflagp
+rather than
+.Dv flagp .
.El
.Pp
Each of the user visible
diff --git a/sbin/mount_ifs/getmntopts.c b/sbin/mount_ifs/getmntopts.c
index 1af5e0f0d460..75c75b202416 100644
--- a/sbin/mount_ifs/getmntopts.c
+++ b/sbin/mount_ifs/getmntopts.c
@@ -46,15 +46,19 @@ static char sccsid[] = "@(#)getmntopts.c 8.1 (Berkeley) 3/27/94";
#include "mntopts.h"
+int getmnt_silent = 0;
+
void
-getmntopts(options, m0, flagp)
+getmntopts(options, m0, flagp, altflagp)
const char *options;
const struct mntopt *m0;
int *flagp;
+ int *altflagp;
{
const struct mntopt *m;
int negative, len;
char *opt, *optbuf;
+ int *thisflagp;
/* Copy option string, since it is about to be torn asunder... */
if ((optbuf = strdup(options)) == NULL)
@@ -80,12 +84,14 @@ getmntopts(options, m0, flagp)
/* Save flag, or fail if option is not recognised. */
if (m->m_option) {
+ thisflagp = m->m_altloc ? altflagp : flagp;
if (negative == m->m_inverse)
- *flagp |= m->m_flag;
+ *thisflagp |= m->m_flag;
else
- *flagp &= ~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_ifs/mntopts.h b/sbin/mount_ifs/mntopts.h
index ec2c6d0ce40f..ba792fa691b8 100644
--- a/sbin/mount_ifs/mntopts.h
+++ b/sbin/mount_ifs/mntopts.h
@@ -37,28 +37,29 @@ 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; /* zero if this is a real mount flag */
};
/* User-visible MNT_ flags. */
-#define MOPT_ASYNC { "async", 0, MNT_ASYNC }
-#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_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 }
/* Skip this options without any action (needed for checkquota/quotaon) */
-#define MOPT_UQUOTA { "userquota", 0, 0 }
-#define MOPT_GQUOTA { "groupquota", 0, 0 }
+#define MOPT_UQUOTA { "userquota", 0, 0, 0 }
+#define MOPT_GQUOTA { "groupquota", 0, 0, 0 }
/* Control flags. */
-#define MOPT_FORCE { "force", 1, MNT_FORCE }
-#define MOPT_UPDATE { "update", 0, MNT_UPDATE }
+#define MOPT_FORCE { "force", 1, MNT_FORCE, 0 }
+#define MOPT_UPDATE { "update", 0, MNT_UPDATE, 0 }
/* 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", 0, MNT_RDONLY, 0 }
+#define MOPT_RW { "rw", 1, MNT_RDONLY, 0 }
#define MOPT_FSTAB_COMPAT \
MOPT_RO, \
@@ -73,4 +74,5 @@ struct mntopt {
MOPT_RDONLY, \
MOPT_UNION
-void getmntopts __P((const char *, const struct mntopt *, int *));
+void getmntopts __P((const char *, const struct mntopt *, int *, int *));
+extern int getmnt_silent;
diff --git a/sbin/mount_ifs/mount_ufs.c b/sbin/mount_ifs/mount_ufs.c
index 37d4756f6857..48be22220d1e 100644
--- a/sbin/mount_ifs/mount_ufs.c
+++ b/sbin/mount_ifs/mount_ufs.c
@@ -81,7 +81,7 @@ mount_ufs(argc, argv)
while ((ch = getopt(argc, argv, "o:")) != EOF)
switch (ch) {
case 'o':
- getmntopts(optarg, mopts, &mntflags);
+ getmntopts(optarg, mopts, &mntflags, 0);
break;
case '?':
default: