summaryrefslogtreecommitdiff
path: root/utils/mount.c
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2013-07-05 17:13:28 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2013-08-28 23:11:29 +0200
commit61c5d308d97dec46f856085b0cd07dfbd5c76a16 (patch)
tree54e20c8af832f543d3811f6985f462cacf33f775 /utils/mount.c
parent178b15f2de2c1d147ae212a56663bdc5c8b8d548 (diff)
mount: implement -O, --test-opts
--test-opts in combination with --all mounts only those filesystems with options matching the given set of options. Note that the semantic of the inverting "no" prefix differs from --types: While --types=nonfs,ufs means neither nfs nor ufs, --test-opts=nofoo,bar means not foo, but bar. * utils/match-options.h: New file. * utils/match-options.c: Likewise. (test_opts): New variable. (test_opts_len): Likewise. (match_options): New function. * utils/mount.c (parse_opt): Handle -O, --test-opts. (main): Use match_options as filter.
Diffstat (limited to 'utils/mount.c')
-rw-r--r--utils/mount.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/utils/mount.c b/utils/mount.c
index f8928f1c..73a75391 100644
--- a/utils/mount.c
+++ b/utils/mount.c
@@ -29,6 +29,8 @@
#include <hurd/fshelp.h>
#include <hurd/paths.h>
+#include "match-options.h"
+
#define SEARCH_FMTS _HURD "%sfs\0" _HURD "%s"
#define DEFAULT_FSTYPE "ext2"
@@ -57,6 +59,8 @@ static const struct argp_option argp_opts[] =
{"remount", 0, 0, OPTION_ALIAS},
{"verbose", 'v', 0, 0, "Give more detailed information"},
{"no-mtab", 'n', 0, 0, "Do not update /etc/mtab"},
+ {"test-opts", 'O', "OPTIONS", 0,
+ "Only mount fstab entries matching the given set of options"},
{"fake", 'f', 0, 0, "Do not actually mount, just pretend"},
{0, 0}
};
@@ -122,6 +126,12 @@ parse_opt (int key, char *arg, struct argp_state *state)
fake = 1;
break;
+ case 'O':
+ err = argz_create_sep (arg, ',', &test_opts, &test_opts_len);
+ if (err)
+ argp_failure (state, 100, ENOMEM, "%s", arg);
+ break;
+
case ARGP_KEY_ARG:
if (mountpoint == 0) /* One arg: mountpoint */
mountpoint = arg;
@@ -615,8 +625,13 @@ main (int argc, char **argv)
case mount:
for (fs = fstab->entries; fs; fs = fs->next)
{
- if (fstab_params.do_all && hasmntopt (&fs->mntent, MNTOPT_NOAUTO))
- continue;
+ if (fstab_params.do_all) {
+ if (hasmntopt (&fs->mntent, MNTOPT_NOAUTO))
+ continue;
+
+ if (! match_options (&fs->mntent))
+ continue;
+ }
err |= do_mount (fs, remount);
}
break;