summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergiu Ivanov <unlimitedscolobb@gmail.com>2009-07-05 22:39:09 +0300
committerSergiu Ivanov <unlimitedscolobb@gmail.com>2009-12-10 21:32:38 +0000
commitf7309c9bf8e75c829da8bb983b28284b9a119340 (patch)
tree03030c3758289fd23cdad2d1f85001d355f20e84
parent64dfa4e12d93c13b676d1cd7d86f4f4004ebfafa (diff)
Add the ``--mount'' command line option.
* Makefile (OBJS): Add mount.o * options.h (OPT_MOUNT, OPT_LONG_MOUNT): Define. * options.c (argp_common_options): Add option ``-mount''. (argp_parse_common_options): Handle the new option. * netfs.c (netfs_append_args): Add the ``--mount'' option to the result. * mount.h: New file. * mount.c: Likewise.
-rw-r--r--Makefile4
-rw-r--r--mount.c29
-rw-r--r--mount.h32
-rw-r--r--netfs.c29
-rw-r--r--options.c19
-rw-r--r--options.h7
6 files changed, 118 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 7ef2100..a6d579b 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,8 @@
# Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc.
#
# Written by Jeroen Dekkers <jeroen@dekkers.cx>.
+#
+# Adapted for unionmount by Sergiu Ivanov <unlimitedscolobb@gmail.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
@@ -27,7 +29,7 @@ CFLAGS += -Wall -g -O2 -D_FILE_OFFSET_BITS=64 -std=gnu99 \
LDFLAGS += -lnetfs -lfshelp -liohelp -lthreads \
-lports -lihash -lshouldbeinlibc -lhurdbugaddr
OBJS = main.o node.o lnode.o ulfs.o ncache.o netfs.o \
- lib.o options.o pattern.o stow.o update.o
+ lib.o options.o pattern.o stow.o update.o mount.o
MIGCOMSFLAGS = -prefix stow_
fs_notify-MIGSFLAGS = -imacros ./stow-mutations.h
diff --git a/mount.c b/mount.c
new file mode 100644
index 0000000..7bc1fb8
--- /dev/null
+++ b/mount.c
@@ -0,0 +1,29 @@
+/* Hurd unionmount
+ The core of unionmount functionality.
+
+ Copyright (C) 2009 Free Software Foundation, Inc.
+
+ Written by Sergiu Ivanov <unlimitedscolobb@gmail.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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#define _GNU_SOURCE
+
+#include "mount.h"
+
+/* The command line for starting the mountee. */
+char * mountee_argz;
+size_t mountee_argz_len;
diff --git a/mount.h b/mount.h
new file mode 100644
index 0000000..a7dd933
--- /dev/null
+++ b/mount.h
@@ -0,0 +1,32 @@
+/* Hurd unionmount
+ General information and properties for unionmount/unionfs.
+
+ Copyright (C) 2009 Free Software Foundation, Inc.
+
+ Written by Sergiu Ivanov <unlimitedscolobb@gmail.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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#ifndef INCLUDED_MOUNT_H
+#define INCLUDED_MOUNT_H
+
+#include <unistd.h>
+
+/* The command line for starting the mountee. */
+extern char * mountee_argz;
+extern size_t mountee_argz_len;
+
+#endif /* not INCLUDED_MOUNT_H */
diff --git a/netfs.c b/netfs.c
index 9d24f06..954222f 100644
--- a/netfs.c
+++ b/netfs.c
@@ -3,6 +3,8 @@
Written by Moritz Schulte <moritz@duesseldorf.ccc.de>.
+ Adapted for unionmount by Sergiu Ivanov <unlimitedscolobb@gmail.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
@@ -37,6 +39,7 @@
#include "lib.h"
#include "ncache.h"
#include "options.h"
+#include "mount.h"
/* Return an argz string describing the current options. Fill *ARGZ
with a pointer to newly malloced storage holding the list and *LEN
@@ -46,6 +49,32 @@ netfs_append_args (char **argz, size_t *argz_len)
{
error_t err = 0;
+ /* Add the --mount option to the result. */
+ if (mountee_argz)
+ {
+ char * buf = NULL;
+
+ /* The mountee command line converted back to a 0-terminated
+ string form. */
+ char * mountee_cl;
+
+ mountee_cl = malloc (mountee_argz_len);
+ if (!mountee_cl)
+ return ENOMEM;
+
+ 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)
+ {
+ err = argz_add (argz, argz_len, buf);
+ free (buf);
+ }
+
+ free (mountee_cl);
+ }
+
ulfs_iterate
{
if (! err)
diff --git a/options.c b/options.c
index 2d3a11f..e2e5dcd 100644
--- a/options.c
+++ b/options.c
@@ -1,7 +1,10 @@
/* Hurd unionfs
Copyright (C) 2001, 2002, 2005, 2009 Free Software Foundation, Inc.
+
Written by Moritz Schulte <moritz@duesseldorf.ccc.de>.
+ Adapted for unionmount by Sergiu Ivanov <unlimitedscolobb@gmail.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
@@ -23,6 +26,7 @@
#include <argp.h>
#include <error.h>
+#include <argz.h>
#include "options.h"
#include "ulfs.h"
@@ -33,6 +37,7 @@
#include "pattern.h"
#include "stow.h"
#include "update.h"
+#include "mount.h"
/* This variable is set to a non-zero value after parsing of the
startup options. Whenever the argument parser is later called to
@@ -51,6 +56,9 @@ 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,
+ "use MOUNTEE as translator command line, start the translator,"
+ "and add its filesystem"},
{ 0, 0, 0, 0, "Runtime options:", 1 },
{ OPT_LONG_STOW, OPT_STOW, "STOWDIR", 0,
"stow given directory", 1},
@@ -124,6 +132,17 @@ argp_parse_common_options (int key, char *arg, struct argp_state *state)
ulfs_match = 0;
break;
+ case OPT_MOUNT:
+ if (mountee_argz)
+ error (EXIT_FAILURE, err, "You can specify only one %s option.",
+ OPT_LONG (OPT_LONG_MOUNT));
+
+ /* TODO: Improve the mountee command line parsing mechanism. */
+ err = argz_create_sep (arg, ' ', &mountee_argz, &mountee_argz_len);
+ if (err)
+ error (EXIT_FAILURE, err, "argz_create_sep");
+ break;
+
case OPT_UNDERLYING: /* --underlying */
case ARGP_KEY_ARG:
diff --git a/options.h b/options.h
index eb74ce6..95a6ddb 100644
--- a/options.h
+++ b/options.h
@@ -1,7 +1,10 @@
/* Hurd unionfs
- Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2009 Free Software Foundation, Inc.
+
Written by Moritz Schulte <moritz@duesseldorf.ccc.de>.
+ Adapted for unionmount by Sergiu Ivanov <unlimitedscolobb@gmail.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
@@ -29,6 +32,7 @@
#define OPT_PATTERN 'm'
#define OPT_PRIORITY 'p'
#define OPT_STOW 's'
+#define OPT_MOUNT 't'
/* The long options. */
#define OPT_LONG_UNDERLYING "underlying"
@@ -40,6 +44,7 @@
#define OPT_LONG_PATTERN "match"
#define OPT_LONG_PRIORITY "priority"
#define OPT_LONG_STOW "stow"
+#define OPT_LONG_MOUNT "mount"
#define OPT_LONG(o) "--" o