From 2a16fc74fd354484a70efcc5b6dbfcdd73ee5f5a Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Thu, 27 Feb 2014 18:51:28 +0100
Subject: CompositeStorage: add method GetMount()

---
 src/storage/CompositeStorage.cxx | 13 +++++++++++++
 src/storage/CompositeStorage.hxx | 11 +++++++++++
 2 files changed, 24 insertions(+)

(limited to 'src')

diff --git a/src/storage/CompositeStorage.cxx b/src/storage/CompositeStorage.cxx
index 9a27270df..ac6fcecd9 100644
--- a/src/storage/CompositeStorage.cxx
+++ b/src/storage/CompositeStorage.cxx
@@ -210,6 +210,19 @@ CompositeStorage::~CompositeStorage()
 {
 }
 
+Storage *
+CompositeStorage::GetMount(const char *uri)
+{
+	const ScopeLock protect(mutex);
+
+	auto result = FindStorage(uri);
+	if (*result.uri != 0)
+		/* not a mount point */
+		return nullptr;
+
+	return result.directory->storage;
+}
+
 void
 CompositeStorage::Mount(const char *uri, Storage *storage)
 {
diff --git a/src/storage/CompositeStorage.hxx b/src/storage/CompositeStorage.hxx
index 9c10f76f4..3daa45ee3 100644
--- a/src/storage/CompositeStorage.hxx
+++ b/src/storage/CompositeStorage.hxx
@@ -95,6 +95,17 @@ public:
 	CompositeStorage();
 	virtual ~CompositeStorage();
 
+	/**
+	 * Get the #Storage at the specified mount point.  Returns
+	 * nullptr if the given URI is not a mount point.
+	 *
+	 * The returned pointer is unprotected.  No other thread is
+	 * allowed to unmount the given mount point while the return
+	 * value is being used.
+	 */
+	gcc_pure gcc_nonnull_all
+	Storage *GetMount(const char *uri);
+
 	/**
 	 * Call the given function for each mounted storage, including
 	 * the root storage.  Passes mount point URI and the a const
-- 
cgit v1.2.3