[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Orphan the mountee.
From: |
Sergiu Ivanov |
Subject: |
Re: [PATCH] Orphan the mountee. |
Date: |
Wed, 8 Jul 2009 19:49:51 +0300 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
>From 726c3ccb12893d4b3dc0afd173669bde43dd92f0 Mon Sep 17 00:00:00 2001
From: Sergiu Ivanov <unlimitedscolobb@gmail.com>
Date: Wed, 8 Jul 2009 13:01:20 +0000
Subject: [PATCH] Orphan the mountee.
* mount.c (unionmount_proxy): Remove variable.
(start_mountee): Remove parameter np. Remove variable
underlying_port. Don't attach the mountee to the proxy node.
(open_port): Don't create the port to the proxy node; return the
port to the underlying node of unionfs.
(setup_unionmount): Don't create the proxy node.
* mount.h (unionmount_proxy): Remove variable.
(start_mountee): Remove parameter np.
---
The previous patch did not actually orphan the mountee, because, at
startup, the mountee was given a port to the proxy node as underlying
node. This patch corrects that: the mountee is given the port to the
(real) underlying node of unionfs and no proxy nodes are created.
---
mount.c | 56 +++++++++++---------------------------------------------
mount.h | 10 +++-------
2 files changed, 14 insertions(+), 52 deletions(-)
diff --git a/mount.c b/mount.c
index f9a5257..40b1c97 100644
--- a/mount.c
+++ b/mount.c
@@ -28,26 +28,22 @@
#include "mount.h"
#include "lib.h"
#include "ulfs.h"
+#include "unionfs.h"
/* The command line for starting the mountee. */
char * mountee_argz;
size_t mountee_argz_len;
-/* The node the mountee is sitting on. */
-node_t * unionmount_proxy;
-
mach_port_t mountee_port;
int mountee_started = 0;
-/* Starts the mountee (given by `argz` and `argz_len`), sets it on
- node `np` and opens a port `port` to with `flags`. */
+/* Starts the mountee (given by `argz` and `argz_len`) and opens a
+ port `port` to it with `flags`. */
error_t
-start_mountee (node_t * np, char * argz, size_t argz_len, int flags,
- mach_port_t * port)
+start_mountee (char * argz, size_t argz_len, int flags, mach_port_t * port)
{
error_t err;
- mach_port_t underlying_port;
/* The intermediate container for the port to the root of the
mountee. */
@@ -108,29 +104,17 @@ start_mountee (node_t * np, char * argz, size_t argz_len,
int flags,
if (err)
return err;
- /* Opens the port on which to set the mountee. */
+ /* Provides the mountee with a port to the unionfs's underlying
+ node. */
error_t
open_port (int flags, mach_port_t * underlying,
mach_msg_type_name_t * underlying_type, task_t task,
void *cookie)
{
- err = 0;
-
- /* Create a port to `np`. */
- newpi = netfs_make_protid
- (netfs_make_peropen (np, flags, NULL), user);
- if (!newpi)
- {
- iohelp_free_iouser (user);
- return errno;
- }
-
- *underlying = underlying_port = ports_get_send_right (newpi);
- *underlying_type = MACH_MSG_TYPE_COPY_SEND;
+ *underlying = underlying_node;
+ *underlying_type = MACH_MSG_TYPE_COPY_SEND;
- ports_port_deref (newpi);
-
- return err;
+ return 0;
} /*open_port */
/* Create a completely unprivileged user. */
@@ -156,14 +140,6 @@ start_mountee (node_t * np, char * argz, size_t argz_len,
int flags,
if (err)
return err;
- /* Attempt to attach the mountee to the port opened in the previous
- call. */
- err = file_set_translator (underlying_port, 0, FS_TRANS_SET, 0, argz,
- argz_len, control, MACH_MSG_TYPE_COPY_SEND);
- port_dealloc (underlying_port);
- if (err)
- return err;
-
/* Obtain the port to the root of the newly-set translator. */
err = fsys_getroot (control, unauth_dir, MACH_MSG_TYPE_COPY_SEND,
uids, nuids, gids, ngids, flags, &retry_port,
@@ -184,23 +160,13 @@ setup_unionmount (void)
{
error_t err = 0;
- /* The proxy node on which the mountee will be sitting must be able
- to forward some of the RPCs coming from the mountee to the
- underlying filesystem. That is why we create this proxy node as
- a clone of the root node: the mountee will feel as if there is no
- unionfs under itself. */
- unionmount_proxy = netfs_make_node (netfs_root_node->nn);
- if (!unionmount_proxy)
- return ENOMEM;
-
- /* Set the mountee on the proxy node.
+ /* Start the mountee.
Note that the O_READ flag does not actually limit access to the
mountee's filesystem considerably. Whenever a client looks up a
node which is not a directory, unionfs will give off a port to
the node itself, withouth proxying it. Proxying happens only for
directory nodes. */
- err = start_mountee (unionmount_proxy, mountee_argz,
- mountee_argz_len, O_READ, &mountee_port);
+ err = start_mountee (mountee_argz, mountee_argz_len, O_READ, &mountee_port);
/* A path equal to "\0" will mean that the current ULFS entry is the
mountee port. */
diff --git a/mount.h b/mount.h
index 181608c..5379f50 100644
--- a/mount.h
+++ b/mount.h
@@ -33,18 +33,14 @@
extern char * mountee_argz;
extern size_t mountee_argz_len;
-/* The node the mountee is sitting on. */
-extern node_t * unionmount_proxy;
-
extern mach_port_t mountee_port;
extern int mountee_started;
-/* Starts the mountee (given by `argz` and `argz_len`), sets it on
- node `np` and opens a port `port` to with `flags`. */
+/* Starts the mountee (given by `argz` and `argz_len`) and opens a
+ port `port` to it with `flags`. */
error_t
-start_mountee (node_t * np, char * argz, size_t argz_len, int flags,
- mach_port_t * port);
+start_mountee (char * argz, size_t argz_len, int flags, mach_port_t * port);
/* Sets up a proxy node, sets the translator on it, and registers the
filesystem published by the translator in the list of merged
--
1.6.3.3