]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Extracted RadosXattrIter from librados.cc into independent .h anc .cc files.
authorSebastien Ponce <Sebastien.Ponce@cern.ch>
Thu, 23 Jan 2014 10:08:51 +0000 (11:08 +0100)
committerJosh Durgin <josh.durgin@inktank.com>
Thu, 5 Jun 2014 17:07:15 +0000 (10:07 -0700)
This makes this interface usable by clients of librados.

Signed-off-by: Sebastien Ponce <sebastien.ponce@cern.ch>
src/librados/Makefile.am
src/librados/RadosXattrIter.cc [new file with mode: 0644]
src/librados/RadosXattrIter.h [new file with mode: 0644]
src/librados/librados.cc

index 23e9167fe4c7a236a9a485575f1e2997a56ab7e0..a7d02ad853c8991f87fb2780f97f427a37c8f393 100644 (file)
@@ -2,7 +2,8 @@ librados_la_SOURCES = \
        librados/librados.cc \
        librados/RadosClient.cc \
        librados/IoCtxImpl.cc \
-       librados/snap_set_diff.cc
+       librados/snap_set_diff.cc \
+       librados/RadosXattrIter.cc
 
 # We need this to avoid basename conflicts with the librados build tests in test/Makefile.am
 librados_la_CXXFLAGS = ${AM_CXXFLAGS}
@@ -20,4 +21,5 @@ noinst_HEADERS += \
        librados/AioCompletionImpl.h \
        librados/IoCtxImpl.h \
        librados/PoolAsyncCompletionImpl.h \
-       librados/RadosClient.h
+       librados/RadosClient.h \
+       librados/RadosXattrIter.h
diff --git a/src/librados/RadosXattrIter.cc b/src/librados/RadosXattrIter.cc
new file mode 100644 (file)
index 0000000..c0f23f6
--- /dev/null
@@ -0,0 +1,27 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2014 Sebastien Ponce <sebastien.ponce@cern.ch>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+#include "RadosXattrIter.h"
+
+librados::RadosXattrsIter::RadosXattrsIter()
+  : val(NULL)
+{
+  i = attrset.end();
+}
+
+librados::RadosXattrsIter::~RadosXattrsIter()
+{
+  free(val);
+  val = NULL;
+}
diff --git a/src/librados/RadosXattrIter.h b/src/librados/RadosXattrIter.h
new file mode 100644 (file)
index 0000000..35c8704
--- /dev/null
@@ -0,0 +1,38 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2014 Sebastien Ponce <sebastien.ponce@cern.ch>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+#ifndef CEPH_LIBRADOS_XATTRITER_H
+#define CEPH_LIBRADOS_XATTRITER_H
+
+#include <string>
+#include <map>
+
+#include "include/buffer.h"
+
+namespace librados {
+
+  /**
+   * iterator object used in implementation of the extrenal
+   * attributes part of the C interface of librados
+   */
+  struct RadosXattrsIter {
+    RadosXattrsIter();
+    ~RadosXattrsIter();
+    std::map<std::string, bufferlist> attrset;
+    std::map<std::string, bufferlist>::iterator i;
+    char *val;
+  };
+};
+
+#endif
index 2358fb406e8c5abe0c949dc89811cc9f857bdce5..130ecc44746137d6be0570f91ab53c61166b1f3d 100644 (file)
@@ -27,6 +27,7 @@
 #include "librados/IoCtxImpl.h"
 #include "librados/PoolAsyncCompletionImpl.h"
 #include "librados/RadosClient.h"
+#include "librados/RadosXattrIter.h"
 #include <cls/lock/cls_lock_client.h>
 
 #include <string>
@@ -2602,27 +2603,10 @@ extern "C" int rados_getxattr(rados_ioctx_t io, const char *o, const char *name,
   return ret;
 }
 
-class RadosXattrsIter {
-public:
-  RadosXattrsIter()
-    : val(NULL)
-  {
-    i = attrset.end();
-  }
-  ~RadosXattrsIter()
-  {
-    free(val);
-    val = NULL;
-  }
-  std::map<std::string, bufferlist> attrset;
-  std::map<std::string, bufferlist>::iterator i;
-  char *val;
-};
-
 extern "C" int rados_getxattrs(rados_ioctx_t io, const char *oid,
                               rados_xattrs_iter_t *iter)
 {
-  RadosXattrsIter *it = new RadosXattrsIter();
+  librados::RadosXattrsIter *it = new librados::RadosXattrsIter();
   if (!it)
     return -ENOMEM;
   librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
@@ -2634,7 +2618,7 @@ extern "C" int rados_getxattrs(rados_ioctx_t io, const char *oid,
   }
   it->i = it->attrset.begin();
 
-  RadosXattrsIter **iret = (RadosXattrsIter**)iter;
+  librados::RadosXattrsIter **iret = (librados::RadosXattrsIter**)iter;
   *iret = it;
   *iter = it;
   return 0;
@@ -2643,7 +2627,7 @@ extern "C" int rados_getxattrs(rados_ioctx_t io, const char *oid,
 extern "C" int rados_getxattrs_next(rados_xattrs_iter_t iter,
                                    const char **name, const char **val, size_t *len)
 {
-  RadosXattrsIter *it = static_cast<RadosXattrsIter*>(iter);
+  librados::RadosXattrsIter *it = static_cast<librados::RadosXattrsIter*>(iter);
   if (it->i == it->attrset.end()) {
     *name = NULL;
     *val = NULL;
@@ -2667,7 +2651,7 @@ extern "C" int rados_getxattrs_next(rados_xattrs_iter_t iter,
 
 extern "C" void rados_getxattrs_end(rados_xattrs_iter_t iter)
 {
-  RadosXattrsIter *it = static_cast<RadosXattrsIter*>(iter);
+  librados::RadosXattrsIter *it = static_cast<librados::RadosXattrsIter*>(iter);
   delete it;
 }
 
@@ -3480,9 +3464,9 @@ public:
 };
 
 class C_XattrsIter : public Context {
-  RadosXattrsIter *iter;
+  librados::RadosXattrsIter *iter;
 public:
-  C_XattrsIter(RadosXattrsIter *iter) : iter(iter) {}
+  C_XattrsIter(librados::RadosXattrsIter *iter) : iter(iter) {}
   void finish(int r) {
     iter->i = iter->attrset.begin();
   }
@@ -3492,7 +3476,7 @@ extern "C" void rados_read_op_getxattrs(rados_read_op_t read_op,
                                        rados_xattrs_iter_t *iter,
                                        int *prval)
 {
-  RadosXattrsIter *xattrs_iter = new RadosXattrsIter;
+  librados::RadosXattrsIter *xattrs_iter = new librados::RadosXattrsIter;
   ((::ObjectOperation *)read_op)->getxattrs(&xattrs_iter->attrset, prval);
   ((::ObjectOperation *)read_op)->add_handler(new C_XattrsIter(xattrs_iter));
   *iter = xattrs_iter;