[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/4] Add the ``--no-mount'' option.
From: |
Sergiu Ivanov |
Subject: |
[PATCH 1/4] Add the ``--no-mount'' option. |
Date: |
Fri, 17 Jul 2009 13:56:57 +0300 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
>From da538ce70651fa552f8fce67d34e87c5c66be31c Mon Sep 17 00:00:00 2001
From: Sergiu Ivanov <unlimitedscolobb@gmail.com>
Date: Tue, 14 Jul 2009 16:36:05 +0000
Subject: [PATCH 1/4] Add the ``--no-mount'' option.
* mount.c (transparent_mount): New variable.
* mount.h (transparent_mount): Likewise.
* netfs.c (netfs_append_args): Handle the ``--no-mount'' option.
* option.c (argp_common_option): Add the ``--no-mount'' option.
Change the explanation of the ``--mount'' option.
(argp_parse_common_options): Handle the ``--no-mount'' option.
* option.h (OPT_NOMOUNT): New definition.
(OPT_LONG_NOMOUNT): Likewise.
---
mount.c | 4 ++++
mount.h | 4 ++++
netfs.c | 8 +++++---
options.c | 8 +++++++-
options.h | 2 ++
5 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/mount.c b/mount.c
index 7045423..4d12cd6 100644
--- a/mount.c
+++ b/mount.c
@@ -40,6 +40,10 @@ mach_port_t mountee_port;
int mountee_started = 0;
+/* Shows the mode in which the current instance of unionmount
+ operates (transparent/non-transparent). */
+int transparent_mount = 1;
+
/* Starts the mountee (given by `argz` and `argz_len`), sets it on
node `np` and opens a port `port` to with `flags`. `port` is not
modified when an error occurs. */
diff --git a/mount.h b/mount.h
index 2dd1900..d01b234 100644
--- a/mount.h
+++ b/mount.h
@@ -40,6 +40,10 @@ extern mach_port_t mountee_port;
extern int mountee_started;
+/* Shows the mode in which the current instance of unionmount
+ operates (transparent/non-transparent). */
+extern int transparent_mount;
+
/* Starts the mountee (given by `argz` and `argz_len`), sets it on
node `np` and opens a port `port` to with `flags`. `port` is not
modified when an error occurs. */
diff --git a/netfs.c b/netfs.c
index 5549365..fc2572f 100644
--- a/netfs.c
+++ b/netfs.c
@@ -50,10 +50,10 @@ netfs_append_args (char **argz, size_t *argz_len)
{
error_t err = 0;
- /* Add the --mount option to the result. */
+ /* Add the --mount or --no-mount option to the result. */
if (mountee_argz)
{
- /* The string describing the value of the ``--mount'' option. */
+ /* The string describing the value of the option. */
char * opt = NULL;
/* The mountee command line converted to a 0-terminated string
@@ -65,7 +65,9 @@ netfs_append_args (char **argz, size_t *argz_len)
memcpy (mountee_cl, mountee_argz, mountee_argz_len);
argz_stringify (mountee_cl, mountee_argz_len, ' ');
- if (asprintf (&opt, "%s=\"%s\"", OPT_LONG (OPT_LONG_MOUNT), mountee_cl)
== -1)
+ char * opt_name = (transparent_mount ? OPT_LONG (OPT_LONG_MOUNT)
+ : OPT_LONG (OPT_LONG_NOMOUNT));
+ if (asprintf (&opt, "%s=\"%s\"", opt_name, mountee_cl) == -1)
return ENOMEM;
err = argz_add (argz, argz_len, opt);
diff --git a/options.c b/options.c
index e2e5dcd..49d8701 100644
--- a/options.c
+++ b/options.c
@@ -56,9 +56,12 @@ static const struct argp_option argp_common_options[] =
"send debugging messages to stderr" },
{ OPT_LONG_CACHE_SIZE, OPT_CACHE_SIZE, "SIZE", 0,
"specify the maximum number of nodes in the cache" },
- { OPT_LONG_MOUNT, OPT_MOUNT, "MOUNTEE", 0,
+ { OPT_LONG_NOMOUNT, OPT_NOMOUNT, "MOUNTEE", 0,
"use MOUNTEE as translator command line, start the translator,"
"and add its filesystem"},
+ { OPT_LONG_MOUNT, OPT_MOUNT, "MOUNTEE", 0,
+ "like --no-mount, but make it appear as if MOUNTEE had been mounted "
+ "directly"},
{ 0, 0, 0, 0, "Runtime options:", 1 },
{ OPT_LONG_STOW, OPT_STOW, "STOWDIR", 0,
"stow given directory", 1},
@@ -132,6 +135,9 @@ argp_parse_common_options (int key, char *arg, struct
argp_state *state)
ulfs_match = 0;
break;
+ case OPT_NOMOUNT:
+ transparent_mount = 0;
+
case OPT_MOUNT:
if (mountee_argz)
error (EXIT_FAILURE, err, "You can specify only one %s option.",
diff --git a/options.h b/options.h
index 95a6ddb..2d80ba1 100644
--- a/options.h
+++ b/options.h
@@ -33,6 +33,7 @@
#define OPT_PRIORITY 'p'
#define OPT_STOW 's'
#define OPT_MOUNT 't'
+#define OPT_NOMOUNT 'n'
/* The long options. */
#define OPT_LONG_UNDERLYING "underlying"
@@ -45,6 +46,7 @@
#define OPT_LONG_PRIORITY "priority"
#define OPT_LONG_STOW "stow"
#define OPT_LONG_MOUNT "mount"
+#define OPT_LONG_NOMOUNT "no-mount"
#define OPT_LONG(o) "--" o
--
1.6.3.3