]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
FileStore: convert dev, jdev to std::string
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Tue, 29 Mar 2011 18:34:54 +0000 (11:34 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Tue, 29 Mar 2011 19:05:04 +0000 (12:05 -0700)
Convert dev, jdev to std::string in preparation for adding std::string
to g_conf.

Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/cosd.cc
src/os/FileStore.cc
src/os/FileStore.h
src/osd/OSD.cc
src/osd/OSD.h

index c1624115b6ccfa1b0c2d524e85a56ad4ec224287..f61e2ae879a3499723af4f24f4d3b2159b9e3fb0 100644 (file)
@@ -260,7 +260,9 @@ int main(int argc, const char **argv)
 
 
 
-  OSD *osd = new OSD(whoami, cluster_messenger, client_messenger, messenger_hb, &mc, g_conf.osd_data, g_conf.osd_journal);
+  OSD *osd = new OSD(whoami, cluster_messenger, client_messenger, messenger_hb, &mc,
+                    (g_conf.osd_data ? g_conf.osd_data : ""),
+                    (g_conf.osd_journal ? g_conf.osd_journal : ""));
 
   int err = osd->pre_init();
   if (err < 0) {
index ac6e60fdedceaa33c18d3bd9f85c0f826c5efd44..42a6bfa38acc8fe8e5ff8d28cc9f6bb774ea70cf 100644 (file)
@@ -363,8 +363,8 @@ done:
   return r;
 }
 
-FileStore::FileStore(const char *base, const char *jdev) :
-  basedir(base), journalpath(jdev ? jdev:""),
+FileStore::FileStore(const std::string &base, const std::string &jdev) :
+  basedir(base), journalpath(jdev),
   fsid(0),
   btrfs(false), btrfs_trans_start_end(false), btrfs_clone_range(false),
   btrfs_snap_create(false),
index 4c961fa6f7b37929060b53ad75370392403f2e6c..bfe1bc35975e5270abc7df566ef59e7712d803a8 100644 (file)
@@ -240,7 +240,7 @@ public:
   void stop_logger();
 
  public:
-  FileStore(const char *base, const char *jdev);
+  FileStore(const std::string &base, const std::string &jdev);
 
   int _detect_fs();
   int _sanity_check_fs();
index c9b18263226618b8eeb2f159c993f4ccce541d60..a5fd9eb61b86289dac8a30898a42aabcadc5bb26 100644 (file)
@@ -130,10 +130,11 @@ const struct CompatSet::Feature ceph_osd_feature_ro_compat[] = {
 
 
 
-ObjectStore *OSD::create_object_store(const char *dev, const char *jdev)
+ObjectStore *OSD::
+create_object_store(const std::string &dev, const std::string &jdev)
 {
   struct stat st;
-  if (::stat(dev, &st) != 0)
+  if (::stat(dev.c_str(), &st) != 0)
     return 0;
 
   //if (g_conf.ebofs) 
@@ -151,7 +152,7 @@ ObjectStore *OSD::create_object_store(const char *dev, const char *jdev)
 #undef dout_prefix
 #define dout_prefix *_dout
 
-int OSD::mkfs(const char *dev, const char *jdev, ceph_fsid_t fsid, int whoami)
+int OSD::mkfs(const std::string &dev, const std::string &jdev, ceph_fsid_t fsid, int whoami)
 {
   int ret;
   ObjectStore *store = NULL;
@@ -280,13 +281,14 @@ int OSD::flushjournal(const char *dev, const char *jdev)
   return err;
 }
 
-int OSD::write_meta(const char *base, const char *file, const char *val, size_t vallen)
+int OSD::write_meta(const std::string &base, const std::string &file,
+                   const char *val, size_t vallen)
 {
   int ret;
   char fn[PATH_MAX];
   int fd;
 
-  snprintf(fn, sizeof(fn), "%s/%s", base, file);
+  snprintf(fn, sizeof(fn), "%s/%s", base.c_str(), file.c_str());
   fd = ::open(fn, O_WRONLY|O_CREAT|O_TRUNC, 0644);
   if (fd < 0) {
     ret = errno;
@@ -310,12 +312,13 @@ int OSD::write_meta(const char *base, const char *file, const char *val, size_t
   return 0;
 }
 
-int OSD::read_meta(const char *base, const char *file, char *val, size_t vallen)
+int OSD::read_meta(const  std::string &base, const std::string &file,
+                  char *val, size_t vallen)
 {
   char fn[PATH_MAX];
   int fd, len;
 
-  snprintf(fn, sizeof(fn), "%s/%s", base, file);
+  snprintf(fn, sizeof(fn), "%s/%s", base.c_str(), file.c_str());
   fd = ::open(fn, O_RDONLY);
   if (fd < 0) {
     int err = errno;
@@ -340,7 +343,7 @@ int OSD::read_meta(const char *base, const char *file, char *val, size_t vallen)
                (f)->fsid[8], (f)->fsid[9], (f)->fsid[10], (f)->fsid[11],  \
                (f)->fsid[12], (f)->fsid[13], (f)->fsid[14], (f)->fsid[15]
 
-int OSD::write_meta(const char *base, ceph_fsid_t& fsid, int whoami)
+int OSD::write_meta(const std::string &base, ceph_fsid_t& fsid, int whoami)
 {
   char val[80];
   
@@ -356,7 +359,8 @@ int OSD::write_meta(const char *base, ceph_fsid_t& fsid, int whoami)
   return 0;
 }
 
-int OSD::peek_meta(const char *dev, string& magic, ceph_fsid_t& fsid, int& whoami)
+int OSD::peek_meta(const std::string &dev, std::string& magic,
+                  ceph_fsid_t& fsid, int& whoami)
 {
   char val[80] = { 0 };
 
@@ -401,7 +405,9 @@ int OSD::peek_meta(const char *dev, string& magic, ceph_fsid_t& fsid, int& whoam
 
 // cons/des
 
-OSD::OSD(int id, Messenger *internal_messenger, Messenger *external_messenger, Messenger *hbm, MonClient *mc, const char *dev, const char *jdev) :
+OSD::OSD(int id, Messenger *internal_messenger, Messenger *external_messenger,
+        Messenger *hbm, MonClient *mc,
+        const std::string &dev, const std::string &jdev) :
   osd_lock("OSD::osd_lock"),
   timer(osd_lock),
   cluster_messenger(internal_messenger),
@@ -528,7 +534,8 @@ int OSD::init()
   watch = new Watch();
 
   // mount.
-  dout(2) << "mounting " << dev_path << " " << (journal_path ? journal_path : "(no journal)") << dendl;
+  dout(2) << "mounting " << dev_path << " "
+         << (journal_path.empty() ? "(no journal)" : journal_path) << dendl;
   assert(store);  // call pre_init() first!
 
   int r = store->mount();
index 1dea3dd4337187b4e936febfcd7f7d34f72f801e..cf64c03f636f0b880f6b693d0e64e95c605db6cd 100644 (file)
@@ -124,7 +124,7 @@ protected:
   LogClient clog;
 
   int whoami;
-  const char *dev_path, *journal_path;
+  std::string dev_path, journal_path;
 
   class C_Tick : public Context {
     OSD *osd;
@@ -1054,13 +1054,14 @@ protected:
   /* internal and external can point to the same messenger, they will still
    * be cleaned up properly*/
   OSD(int id, Messenger *internal, Messenger *external, Messenger *hbm, MonClient *mc,
-      const char *dev = 0, const char *jdev = 0);
+      const std::string &dev, const std::string &jdev);
   ~OSD();
 
   // static bits
   static int find_osd_dev(char *result, int whoami);
-  static ObjectStore *create_object_store(const char *dev, const char *jdev);
-  static int mkfs(const char *dev, const char *jdev, ceph_fsid_t fsid, int whoami);
+  static ObjectStore *create_object_store(const std::string &dev, const std::string &jdev);
+  static int mkfs(const std::string &dev, const std::string &jdev,
+                 ceph_fsid_t fsid, int whoami);
   static int mkjournal(const char *dev, const char *jdev);
   static int flushjournal(const char *dev, const char *jdev);
   /* remove any non-user xattrs from a map of them */
@@ -1075,11 +1076,13 @@ protected:
   }
 
 private:
-  static int write_meta(const char *base, const char *file, const char *val, size_t vallen);
-  static int read_meta(const char *base, const char *file, char *val, size_t vallen);
-  static int write_meta(const char *base, ceph_fsid_t& fsid, int whoami);
+  static int write_meta(const std::string &base, const std::string &file,
+                       const char *val, size_t vallen);
+  static int read_meta(const std::string &base, const std::string &file,
+                      char *val, size_t vallen);
+  static int write_meta(const std::string &base, ceph_fsid_t& fsid, int whoami);
 public:
-  static int peek_meta(const char *dev, string& magic, ceph_fsid_t& fsid, int& whoami);
+  static int peek_meta(const std::string &dev, string& magic, ceph_fsid_t& fsid, int& whoami);
   
 
   // startup/shutdown