aboutsummaryrefslogtreecommitdiff
path: root/sbin/mount
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/mount')
-rw-r--r--sbin/mount/getmntopts.315
-rw-r--r--sbin/mount/getmntopts.c14
-rw-r--r--sbin/mount/mntopts.h30
-rw-r--r--sbin/mount/mount_ufs.c2
4 files changed, 40 insertions, 21 deletions
diff --git a/sbin/mount/getmntopts.3 b/sbin/mount/getmntopts.3
index 642c57aa361d..c1bd25a227da 100644
--- a/sbin/mount/getmntopts.3
+++ b/sbin/mount/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/getmntopts.c b/sbin/mount/getmntopts.c
index 1af5e0f0d460..75c75b202416 100644
--- a/sbin/mount/getmntopts.c
+++ b/sbin/mount/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/mntopts.h b/sbin/mount/mntopts.h
index ec2c6d0ce40f..ba792fa691b8 100644
--- a/sbin/mount/mntopts.h
+++ b/sbin/mount/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/mount_ufs.c b/sbin/mount/mount_ufs.c
index 37d4756f6857..48be22220d1e 100644
--- a/sbin/mount/mount_ufs.c
+++ b/sbin/mount/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: