]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/tools/rbd/action/Lock.cc
import 14.2.4 nautilus point release
[ceph.git] / ceph / src / tools / rbd / action / Lock.cc
index 4ede9245080219536a47523c21819222c30f482e..754cb384c3efc7c72904aff8adfc3ea2cee0b6ba 100644 (file)
@@ -24,11 +24,14 @@ void add_id_option(po::options_description *positional) {
     ("lock-id", "unique lock id");
 }
 
-int get_id(const po::variables_map &vm, std::string *id) {
-  *id = utils::get_positional_argument(vm, 1);
+int get_id(const po::variables_map &vm, size_t *arg_index,
+           std::string *id) {
+  *id = utils::get_positional_argument(vm, *arg_index);
   if (id->empty()) {
     std::cerr << "rbd: lock id was not specified" << std::endl;
     return -EINVAL;
+  } else {
+    ++(*arg_index);
   }
   return 0;
 }
@@ -172,7 +175,7 @@ int execute_add(const po::variables_map &vm,
   }
 
   std::string lock_cookie;
-  r = get_id(vm, &lock_cookie);
+  r = get_id(vm, &arg_index, &lock_cookie);
   if (r < 0) {
     return r;
   }
@@ -233,12 +236,12 @@ int execute_remove(const po::variables_map &vm,
   }
 
   std::string lock_cookie;
-  r = get_id(vm, &lock_cookie);
+  r = get_id(vm, &arg_index, &lock_cookie);
   if (r < 0) {
     return r;
   }
 
-  std::string lock_client = utils::get_positional_argument(vm, 2);
+  std::string lock_client = utils::get_positional_argument(vm, arg_index);
   if (lock_client.empty()) {
     std::cerr << "rbd: locker was not specified" << std::endl;
     return -EINVAL;