]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mkmonfs: use common_init and parse regular args
authorSage Weil <sage@newdream.net>
Fri, 6 Nov 2009 06:24:19 +0000 (22:24 -0800)
committerSage Weil <sage@newdream.net>
Fri, 6 Nov 2009 06:24:19 +0000 (22:24 -0800)
src/mkmonfs.cc

index 2b805471ed26a35d10930cfe95c085a8a60fdfb1..3186f3299e610ee6dcffac0151412c5720423db0 100644 (file)
@@ -20,6 +20,7 @@
 #include "mds/MDSMap.h"
 #include "osd/OSDMap.h"
 #include "mon/PGMap.h"
+#include "common/common_init.h"
 
 void usage() 
 {
@@ -33,11 +34,11 @@ int main(int argc, const char **argv)
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
   DEFINE_CONF_VARS(usage);
+  common_init(args, "mkmonfs", false);
 
   bool clobber = false;
-  const char *fsdir = 0;
   int whoami = -1;
-  const char *monmapfn = 0;
+  const char *monmapfn = g_conf.monmap;
   const char *osdmapfn = 0;
 
   FOR_EACH_ARG(args) {
@@ -49,19 +50,17 @@ int main(int argc, const char **argv)
       CONF_SAFE_SET_ARG_VAL(&monmapfn, OPT_STR);
     } else if (CONF_ARG_EQ("osdmap", '\0')) {
       CONF_SAFE_SET_ARG_VAL(&osdmapfn, OPT_STR);
-    } else if (CONF_ARG_EQ("mon_data", '\0')) {
-      CONF_SAFE_SET_ARG_VAL(&fsdir, OPT_STR);
     } else 
       usage();
   }
-  if (!fsdir || !monmapfn || whoami < 0)
+  if (!g_conf.mon_data || !monmapfn || whoami < 0)
     usage();
 
   if (!clobber) {
     // make sure it doesn't exist
     struct stat st;
-    if (::lstat(fsdir, &st) == 0) {
-      cerr << "monfs dir " << fsdir << " already exists; remove it first" << std::endl;
+    if (::lstat(g_conf.mon_data, &st) == 0) {
+      cerr << "monfs dir " << g_conf.mon_data << " already exists; remove it first" << std::endl;
       usage();
     }
   }
@@ -79,10 +78,10 @@ int main(int argc, const char **argv)
     exit(1);
 
   // go
-  MonitorStore store(fsdir);
+  MonitorStore store(g_conf.mon_data);
   Monitor mon(whoami, &store, 0, &monmap);
   mon.mkfs(osdmapbl);
-  cout << argv[0] << ": created monfs at " << fsdir 
+  cout << argv[0] << ": created monfs at " << g_conf.mon_data 
        << " for mon" << whoami
        << std::endl;
   return 0;