summaryrefslogtreecommitdiffstats
path: root/utils/mount/parse_opt.h
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2007-09-28 16:36:35 -0400
committerNeil Brown <neilb@suse.de>2007-09-29 07:58:57 +1000
commit2ab6ed792a773751d1f5d60d13a06161559c0e54 (patch)
treebc35f4978046e6dfcaadc3379624e1d71a7b6940 /utils/mount/parse_opt.h
parentaf5939d15a41b337cc499a04fe4001a5cd51fdce (diff)
downloadnfs-utils-2ab6ed792a773751d1f5d60d13a06161559c0e54.tar.gz
nfs-utils-2ab6ed792a773751d1f5d60d13a06161559c0e54.tar.xz
nfs-utils-2ab6ed792a773751d1f5d60d13a06161559c0e54.zip
text-based mount.nfs: parse option strings into lists
Adapt a parsing trick used by Python. Parse mount option strings into an abstract data type so we don't have to copy and/or tokenize the whole option string multiple times while trying to manipulate the mount options. Then, just before calling the mount(2) system call, convert the object back into a C string. One major advantage of this approach is that we can copy the final version of the mount options into /etc/mtab when we're done, instead of copying in the original mount options that the user specified. Any fallback from NFS v3 to NFS v2 or TCP to UDP that was done by mount.nfs will be reflected in /etc/mtab. This patch adds methods for creating and manipulating mount option data objects. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'utils/mount/parse_opt.h')
-rw-r--r--utils/mount/parse_opt.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/utils/mount/parse_opt.h b/utils/mount/parse_opt.h
new file mode 100644
index 0000000..93430d9
--- /dev/null
+++ b/utils/mount/parse_opt.h
@@ -0,0 +1,46 @@
+/*
+ * parse_opt.h -- mount option string parsing helpers
+ *
+ * Copyright (C) 2007 Oracle. All rights reserved.
+ * Copyright (C) 2007 Chuck Lever <chuck.lever@oracle.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 021110-1307, USA.
+ *
+ */
+
+enum {
+ PO_FAILED = 0,
+ PO_SUCCEEDED = 1,
+};
+
+enum {
+ PO_NOT_FOUND = 0,
+ PO_FOUND = 1,
+};
+
+struct mount_options;
+
+struct mount_options * po_split(char *);
+void po_replace(struct mount_options *,
+ struct mount_options *);
+int po_join(struct mount_options *, char **);
+
+int po_append(struct mount_options *, char *);
+int po_contains(struct mount_options *, char *);
+char * po_get(struct mount_options *, char *);
+int po_rightmost(struct mount_options *, char *, char *);
+int po_remove_all(struct mount_options *, char *);
+void po_destroy(struct mount_options *);