]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
tool: convert str to num using strtoull
authorSimon Gao <simon29rock@gmail.com>
Sat, 27 Jun 2020 14:28:17 +0000 (22:28 +0800)
committerSimon Gao <simon29rock@gmail.com>
Thu, 2 Jul 2020 08:22:25 +0000 (16:22 +0800)
Signed-off-by: Simon Gao <simon29rock@gmail.com>
src/tools/cephfs/MetaTool.cc
src/tools/cephfs/MetaTool.h
src/tools/cephfs/cephfs-meta-injection.cc

index bde23f75990157191be0bdd4000a9ce9295ee2a3..128cfcad5a0bf1c423a44fd005468374b10bf6aa 100644 (file)
@@ -207,7 +207,7 @@ int MetaTool::process(string& mode, string& ino, string out, string in, bool con
 int MetaTool::show_fnode(string& ino, string& out)
 {
   if (ino != "0") {
-    inodeno_t i_ino = conv2hexino(ino.c_str());
+    inodeno_t i_ino = std::stoull(ino.c_str(), nullptr, 0);
     meta_op op(_debug, out);
     meta_op::sub_op* nsop = new meta_op::sub_op(&op);
     nsop->sub_op_t = meta_op::OP_SHOW_FN;
@@ -233,7 +233,7 @@ int MetaTool::amend_fnode(string& in, bool confirm)
 int MetaTool::amend_meta_info(string& ino, string& in, bool confirm)
 {
   if (ino != "0" && in != "") {
-    inodeno_t i_ino = conv2hexino(ino.c_str());
+    inodeno_t i_ino = std::stoull(ino.c_str(), nullptr, 0);
     meta_op op(_debug, "", in, confirm);
     meta_op::sub_op* nsop = new meta_op::sub_op(&op);
     nsop->sub_op_t = meta_op::OP_AMEND;
@@ -249,7 +249,7 @@ int MetaTool::amend_meta_info(string& ino, string& in, bool confirm)
 int MetaTool::list_meta_info(string& ino, string& out)
 {
   if (ino != "0") {
-    inodeno_t i_ino = conv2hexino(ino.c_str());
+    inodeno_t i_ino = std::stoull(ino.c_str(), nullptr, 0);
     meta_op op(_debug, out);
     meta_op::sub_op* nsop = new meta_op::sub_op(&op);
     nsop->sub_op_t = meta_op::OP_LIST;
@@ -265,7 +265,7 @@ int MetaTool::list_meta_info(string& ino, string& out)
 int MetaTool::show_meta_info(string& ino, string& out)
 {
   if (ino != "0") {
-    inodeno_t i_ino = conv2hexino(ino.c_str());
+    inodeno_t i_ino = std::stoull(ino.c_str(), nullptr, 0);
     meta_op op(_debug, out);
 
     meta_op::sub_op* nsop = new meta_op::sub_op(&op);
@@ -771,15 +771,6 @@ int MetaTool::list_meta(meta_op &op)
   }
   return 0;
 }
-unsigned long long MetaTool::conv2hexino(const char* ino)
-{
-  unsigned long long iino = 0;
-  std::stringstream conv;
-  conv << ino;
-  conv >> iino;
-  printf("convert to hexadecimal ino  %s => %llx \n", ino, iino);
-  return iino;
-}
 
 int MetaTool::file_meta(meta_op &op)
 {
index 809c8d9b6cf80a35cb66e617d614195266136ecb..041e223b7de15c903db856409fe07aa07111fb7a 100644 (file)
@@ -255,7 +255,6 @@ private:
   int _amend_meta(string &k, inode_meta_t& i, const string& fn, meta_op& op);
   int _show_fn(inode_meta_t& i, const string& fn);
   int _amend_fn(const string& fn, bool confirm);
-  static unsigned long long conv2hexino(const char* ino);
   void usage();
   MetaTool(bool debug=false):
       _debug(debug) {}
index 79ffbaea31cb411d1c6f33e7d06fbb381984e28f..5768d38693c4f68c8fd63a22b8e38ad2c646e6bf 100644 (file)
@@ -33,7 +33,7 @@ int main(int argc, const char **argv)
       ("debug", "show debug info")
       ("rank,r", po::value<string>(&rank_str), "the rank of cephfs, default(0) (e.g. -r cephfs_a:0)")
       ("minfo", po::value<string>(&minfo), "specify metapool, datapools and rank (e.g. cephfs_metadata_a:cephfs_data_a:0)")
-      ("ino,i", po::value<string>(&ino), "specify inode. e.g. 1099511627776, you can find it with cmd, 'ls -i'")
+      ("ino,i", po::value<string>(&ino), "specify inode. e.g. 1099511627776 or 0x10000000000, you can find it with cmd, 'ls -i'")
       ("out,o", po::value<string>(&out), "output file")
       ("in", po::value<string>(&in), "input file")
       ("yes-i-really-really-mean-it", "need by amend info")
@@ -43,7 +43,6 @@ int main(int argc, const char **argv)
   po::options_description modeoptions("mode options");
   modeoptions.add_options()
       ("mode", po::value<string>(&mode),
-       "\tconv : convert decimal ino to hex\n"  \
        "\tlistc : list all obj of dir\n"        \
        "\tshowm : show the info of ino\n"          \
        "\tshowfn : show the fnode of dir\n"        \
@@ -71,7 +70,7 @@ int main(int argc, const char **argv)
   if (vm.count("help")) {
     std::cout << version << std::endl;
     std::cout << "usage : \n"
-              << "  cephfs-meta-injection <conv|listc|showm|showfn|amend|amendfn> -r <fsname:rank> -i <ino>"
+              << "  cephfs-meta-injection <listc|showm|showfn|amend|amendfn> -r <fsname:rank> -i <ino>"
               << std::endl;
     std::cout << "example : \n"
               << "  amend info of inode(1099531628828)\n"
@@ -83,11 +82,6 @@ int main(int argc, const char **argv)
     return 0;
   }
 
-  if (mode == "conv") {
-    MetaTool::conv2hexino(ino.c_str());
-    return 0;
-  }
-
   MetaTool mt(vm.count("debug"));
   int rc = mt.init();
   if (rc != 0) {