[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120221180055.25235.61001.stgit@warthog.procyon.org.uk>
Date: Tue, 21 Feb 2012 18:00:55 +0000
From: David Howells <dhowells@...hat.com>
To: linux-fsdevel@...r.kernel.org, viro@...IV.linux.org.uk,
valerie.aurora@...il.com
Cc: linux-kernel@...r.kernel.org, David Howells <dhowells@...hat.com>
Subject: [PATCH 27/73] union-mount: Create union_add_dir() [ver #2]
From: Valerie Aurora <vaurora@...hat.com>
union_add_dir() fills out the union stack for the topmost dentry with
the path of the directory in this layer of the union.
Original-author: Valerie Aurora <vaurora@...hat.com>
Signed-off-by: David Howells <dhowells@...hat.com>
---
fs/union.c | 28 ++++++++++++++++++++++++++++
fs/union.h | 8 ++++++++
2 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/fs/union.c b/fs/union.c
index 77d6a74..1e459b0 100644
--- a/fs/union.c
+++ b/fs/union.c
@@ -60,3 +60,31 @@ void d_free_unions(struct dentry *topmost)
kfree(topmost->d_union_stack);
topmost->d_union_stack = NULL;
}
+
+/**
+ * union_add_dir - Add another layer to a unioned directory
+ * @topmost: topmost directory
+ * @lower: directory in the current layer
+ * @layer: index of layer to add this at
+ *
+ * @layer counts starting at 0 for the dir below the topmost dir.
+ *
+ * This transfers the caller's references to the constituents of *lower to the
+ * union stack.
+ */
+int union_add_dir(struct path *topmost, struct path *lower, unsigned layer)
+{
+ struct dentry *dentry = topmost->dentry;
+ struct path *path;
+
+ BUG_ON(layer >= dentry->d_sb->s_union_count);
+
+ if (!dentry->d_union_stack)
+ dentry->d_union_stack = union_alloc(topmost);
+ if (!dentry->d_union_stack)
+ return -ENOMEM;
+
+ path = union_find_dir(dentry, layer);
+ *path = *lower;
+ return 0;
+}
diff --git a/fs/union.h b/fs/union.h
index 04a02ec..f39c88d 100644
--- a/fs/union.h
+++ b/fs/union.h
@@ -57,6 +57,7 @@ static inline bool IS_DIR_UNIONED(struct dentry *dentry)
}
extern void d_free_unions(struct dentry *);
+extern int union_add_dir(struct path *, struct path *, unsigned int);
static inline
struct path *union_find_dir(struct dentry *dentry, unsigned int layer)
@@ -77,4 +78,11 @@ struct path *union_find_dir(struct dentry *dentry, unsigned int layer)
static inline bool IS_DIR_UNIONED(struct dentry *dentry) { return false; }
static inline void d_free_unions(struct dentry *dentry) {}
+static inline
+int union_add_dir(struct path *topmost, struct path *lower, unsigned layer)
+{
+ BUG();
+ return 0;
+}
+
#endif /* CONFIG_UNION_MOUNT */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists