changeset 136:0687dc17a0f5

objstore: getroot wrapper should operate on a vg Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Sun, 18 Oct 2015 10:29:59 -0400
parents 2b39a5cf338b
children de10dd0ec2a7
files src/objstore/CMakeLists.txt src/objstore/include/nomad/objstore.h src/objstore/objstore.c src/objstore/vol.c
diffstat 4 files changed, 52 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/objstore/CMakeLists.txt	Sun Oct 18 10:29:36 2015 -0400
+++ b/src/objstore/CMakeLists.txt	Sun Oct 18 10:29:59 2015 -0400
@@ -23,6 +23,7 @@
 add_library(nomad_objstore SHARED
 	objstore.c
 	vg.c
+	vol.c
 )
 
 target_link_libraries(nomad_objstore
--- a/src/objstore/include/nomad/objstore.h	Sun Oct 18 10:29:36 2015 -0400
+++ b/src/objstore/include/nomad/objstore.h	Sun Oct 18 10:29:59 2015 -0400
@@ -71,7 +71,7 @@
 					      const char *path);
 
 /* volume operations */
-extern int objstore_getroot(struct objstore_vol *store, struct nobjhndl *hndl);
+extern int objstore_getroot(struct objstore *vg, struct nobjhndl *hndl);
 
 /* object operations */
 extern int objstore_obj_getattr(struct objstore_vol *store,
--- a/src/objstore/objstore.c	Sun Oct 18 10:29:36 2015 -0400
+++ b/src/objstore/objstore.c	Sun Oct 18 10:29:59 2015 -0400
@@ -121,17 +121,6 @@
 	return ERR_PTR(ENOTSUP);
 }
 
-int objstore_getroot(struct objstore_vol *store, struct nobjhndl *hndl)
-{
-	if (!hndl)
-		return EINVAL;
-
-	if (!store || !store->def->vol_ops || !store->def->vol_ops->getroot)
-		return EINVAL;
-
-	return store->def->vol_ops->getroot(store, hndl);
-}
-
 int objstore_obj_getattr(struct objstore_vol *store, const struct nobjhndl *hndl,
 			 struct nattr *attr)
 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/objstore/vol.c	Sun Oct 18 10:29:59 2015 -0400
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2015 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <nomad/error.h>
+#include <nomad/objstore.h>
+#include <nomad/objstore_impl.h>
+
+int objstore_getroot(struct objstore *vg, struct nobjhndl *hndl)
+{
+	struct objstore_vol *vol;
+	int ret;
+
+	if (!vg || !hndl)
+		return EINVAL;
+
+	mxlock(&vg->lock);
+
+	/*
+	 * FIXME: we only inspect the first volume
+	 */
+	vol = list_head(&vg->vols);
+
+	if (vol && vol->def->vol_ops && vol->def->vol_ops->getroot)
+		ret = vol->def->vol_ops->getroot(vol, hndl);
+	else
+		ret = ENOTSUP;
+
+	mxunlock(&vg->lock);
+
+	return ret;
+}