summaryrefslogtreecommitdiff
path: root/sbin/mount/mntopts.h
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2004-06-22 21:12:01 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2004-06-22 21:12:01 +0000
commit8f82eb3c9226e55fa05cde787c8a8124f3e44165 (patch)
tree9f489ffba1ea0d8bbbc98dcac119049aaab2e533 /sbin/mount/mntopts.h
parent582fea99f4e2f9dc8816573bd7cb2db443b9e705 (diff)
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@
Diffstat (limited to 'sbin/mount/mntopts.h')
-rw-r--r--sbin/mount/mntopts.h55
1 files changed, 34 insertions, 21 deletions
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 *);