[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/4] Add the ``--no-mount'' option.
From: |
Sergiu Ivanov |
Subject: |
Re: [PATCH 1/4] Add the ``--no-mount'' option. |
Date: |
Tue, 4 Aug 2009 00:14:01 +0300 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
>From 38ee759112cfc93a6e8edbed35d7550e998513e3 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 | 11 ++++++++---
options.c | 8 +++++++-
options.h | 2 ++
5 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/mount.c b/mount.c
index e284fe6..83bd7c3 100644
--- a/mount.c
+++ b/mount.c
@@ -40,6 +40,10 @@ mach_port_t mountee_root;
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`), attaches it to
the node `np` and opens a port `port` to the mountee with
`flags`. */
diff --git a/mount.h b/mount.h
index 53679ad..d51fdeb 100644
--- a/mount.h
+++ b/mount.h
@@ -37,6 +37,10 @@ extern mach_port_t mountee_root;
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`), attaches it to
the node `np` and opens a port `port` to the mountee with
`flags`. */
diff --git a/netfs.c b/netfs.c
index 8d2a4ec..00b12bf 100644
--- a/netfs.c
+++ b/netfs.c
@@ -50,7 +50,7 @@ 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)
{
char * buf = NULL;
@@ -59,6 +59,10 @@ netfs_append_args (char **argz, size_t *argz_len)
string form. */
char * mountee_cl;
+ /* This will be either ``--mount'' or ``--no-mount'' depending
+ on the whether the unionmount is transparent or not. */
+ char * opt_name;
+
mountee_cl = malloc (mountee_argz_len);
if (!mountee_cl)
return ENOMEM;
@@ -66,8 +70,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 ((err = asprintf (&buf, "%s=\"%s\"", OPT_LONG (OPT_LONG_MOUNT),
- mountee_cl)) == -1)
+ opt_name = (transparent_mount ? OPT_LONG (OPT_LONG_MOUNT)
+ : OPT_LONG (OPT_LONG_NOMOUNT));
+ if ((err = asprintf (&buf, "%s=\"%s\"", opt_name, mountee_cl)) == -1)
{
free (mountee_cl);
return ENOMEM;
diff --git a/options.c b/options.c
index e2e5dcd..4b9a594 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 set on the "
+ "underlying node 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
- Re: [PATCH 1/4] Add the ``--no-mount'' option.,
Sergiu Ivanov <=