]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-filestore-dump.cc: don't use po::value<string>()->required()
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Thu, 31 Jan 2013 14:41:19 +0000 (15:41 +0100)
committerGary Lowell <glowell@inktank.com>
Fri, 1 Feb 2013 00:52:40 +0000 (16:52 -0800)
Don't use po::value<string>()->required() since this breaks build on
RHEL/CentOs6. Check if the options are set as in the code of other
ceph parts.

Move some checks up in the code to validate options as soon
as possible. Remove printing 'help' twice, and check it first.

Fix type description.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: David Zafman <david.zafman@inktank.com>
src/tools/ceph-filestore-dump.cc

index d470468c7cde949d946a929af535a6c1eedff1d6..224ef32bf0c544824e307bbbc0d058a10c79ed2c 100644 (file)
@@ -53,14 +53,14 @@ int main(int argc, char **argv)
   po::options_description desc("Allowed options");
   desc.add_options()
     ("help", "produce help message")
-    ("filestore-path", po::value<string>(&fspath)->required(),
+    ("filestore-path", po::value<string>(&fspath),
      "path to filestore directory, mandatory")
-    ("journal-path", po::value<string>(&jpath)->required(),
+    ("journal-path", po::value<string>(&jpath),
      "path to journal, mandatory")
-    ("pgid", po::value<string>(&pgid)->required(),
+    ("pgid", po::value<string>(&pgid),
      "PG id, mandatory")
-    ("type", po::value<string>(&type)->required(),
-     "Type which is 'info' or 'log'")
+    ("type", po::value<string>(&type),
+     "Type which is 'info' or 'log', mandatory")
     ("debug", "Enable diagnostic output to stderr")
     ;
 
@@ -72,13 +72,39 @@ int main(int argc, char **argv)
     po::notify(vm);
   }
   catch(...) {
-    cout << desc << "\n";
+    cout << desc << std::endl;
     exit(1);
   }
      
-  //Never get here with required() options
   if (vm.count("help")) {
-    cout << desc << "\n";
+    cout << desc << std::endl;
+    return 1;
+  }
+
+  if (!vm.count("filestore-path")) {
+    cout << "Must provide filestore-path" << std::endl
+        << desc << std::endl;
+    return 1;
+  } 
+  if (!vm.count("journal-path")) {
+    cout << "Must provide journal-path" << std::endl
+        << desc << std::endl;
+    return 1;
+  } 
+  if (!vm.count("pgid")) {
+    cout << "Must provide pgid" << std::endl
+        << desc << std::endl;
+    return 1;
+  } 
+  if (!vm.count("type")) {
+    cout << "Must provide type ('info' or 'log')" << std::endl
+        << desc << std::endl;
+    return 1;
+  } 
+  
+  if (fspath.length() == 0 || jpath.length() == 0 || pgid.length() == 0 ||
+    (type != "info" && type != "log")) {
+    cerr << "Invalid params" << std::endl;
     exit(1);
   }
 
@@ -106,23 +132,6 @@ int main(int argc, char **argv)
   g_ceph_context->_conf->apply_changes(NULL);
   g_conf = g_ceph_context->_conf;
 
-  if (!vm.count("filestore-path") || !vm.count("journal-path")) {
-    cout << "Must provide filestore-path and journal-path" << std::endl
-        << desc << std::endl;
-    return 1;
-  }
-
-  if (vm.count("help")) {
-    cout << desc << std::endl;
-    return 1;
-  }
-
-  if (fspath.length() == 0 || jpath.length() == 0 || pgid.length() == 0 ||
-    (type != "info" && type != "log")) {
-    cerr << "Invalid params" << std::endl;
-    exit(1);
-  }
-
   //Verify that fspath really is an osd store
   struct stat st;
   if (::stat(fspath.c_str(), &st) == -1) {