]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: improve conditional compilation specific checks
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Mon, 17 May 2021 09:40:45 +0000 (15:10 +0530)
committerPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Wed, 26 May 2021 04:47:49 +0000 (10:17 +0530)
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
src/tools/rbd/action/Ggate.cc
src/tools/rbd/action/Kernel.cc
src/tools/rbd/action/Nbd.cc
src/tools/rbd/action/Wnbd.cc

index 4ff02d48748191e7ebb84259fb8b418306a86b65..24699b43ff8d7b7f523a4e590d1ad62196617c52 100644 (file)
@@ -25,6 +25,7 @@ namespace ggate {
 namespace at = argument_types;
 namespace po = boost::program_options;
 
+#if defined(__FreeBSD__)
 static int call_ggate_cmd(const po::variables_map &vm,
                           const std::vector<std::string> &args,
                           const std::vector<std::string> &ceph_global_args) {
@@ -103,13 +104,14 @@ int parse_options(const std::vector<std::string> &options,
 
   return 0;
 }
+#endif
 
 int execute_list(const po::variables_map &vm,
                  const std::vector<std::string> &ceph_global_init_args) {
 #if !defined(__FreeBSD__)
   std::cerr << "rbd: ggate is only supported on FreeBSD" << std::endl;
   return -EOPNOTSUPP;
-#endif
+#else
   std::vector<std::string> args;
 
   args.push_back("list");
@@ -123,6 +125,7 @@ int execute_list(const po::variables_map &vm,
   }
 
   return call_ggate_cmd(vm, args, ceph_global_init_args);
+#endif
 }
 
 int execute_map(const po::variables_map &vm,
@@ -130,7 +133,7 @@ int execute_map(const po::variables_map &vm,
 #if !defined(__FreeBSD__)
   std::cerr << "rbd: ggate is only supported on FreeBSD" << std::endl;
   return -EOPNOTSUPP;
-#endif
+#else
   std::vector<std::string> args;
 
   args.push_back("map");
@@ -165,6 +168,7 @@ int execute_map(const po::variables_map &vm,
   }
 
   return call_ggate_cmd(vm, args, ceph_global_init_args);
+#endif
 }
 
 int execute_unmap(const po::variables_map &vm,
@@ -172,7 +176,7 @@ int execute_unmap(const po::variables_map &vm,
 #if !defined(__FreeBSD__)
   std::cerr << "rbd: ggate is only supported on FreeBSD" << std::endl;
   return -EOPNOTSUPP;
-#endif
+#else
   std::string device_name = utils::get_positional_argument(vm, 0);
   if (!boost::starts_with(device_name, "/dev/")) {
     device_name.clear();
@@ -205,15 +209,26 @@ int execute_unmap(const po::variables_map &vm,
   }
 
   return call_ggate_cmd(vm, args, ceph_global_init_args);
+#endif
 }
 
 int execute_attach(const po::variables_map &vm,
                    const std::vector<std::string> &ceph_global_init_args) {
+#if !defined(__FreeBSD__)
+  std::cerr << "rbd: ggate is only supported on FreeBSD" << std::endl;
+#else
+  std::cerr << "rbd: ggate attach command not supported" << std::endl;
+#endif
   return -EOPNOTSUPP;
 }
 
 int execute_detach(const po::variables_map &vm,
                    const std::vector<std::string> &ceph_global_init_args) {
+#if !defined(__FreeBSD__)
+  std::cerr << "rbd: ggate is only supported on FreeBSD" << std::endl;
+#else
+  std::cerr << "rbd: ggate detach command not supported" << std::endl;
+#endif
   return -EOPNOTSUPP;
 }
 
index c1167a88ae348323344071165e31b35c62a068e9..51e9975867e8d1e5e8067e3bcc71bb58d649b172 100644 (file)
@@ -635,11 +635,21 @@ int execute_unmap(const po::variables_map &vm,
 
 int execute_attach(const po::variables_map &vm,
                    const std::vector<std::string> &ceph_global_init_args) {
+#if defined(WITH_KRBD)
+  std::cerr << "rbd: krbd does not support attach" << std::endl;
+#else
+  std::cerr << "rbd: kernel device is not supported" << std::endl;
+#endif
   return -EOPNOTSUPP;
 }
 
 int execute_detach(const po::variables_map &vm,
                    const std::vector<std::string> &ceph_global_init_args) {
+#if defined(WITH_KRBD)
+  std::cerr << "rbd: krbd does not support detach" << std::endl;
+#else
+  std::cerr << "rbd: kernel device is not supported" << std::endl;
+#endif
   return -EOPNOTSUPP;
 }
 
index 557842e8477f8a95ff43992fea6bf250e58cfddc..117a2592dd1e86aac073bec8a21bce63c4acefd7 100644 (file)
@@ -21,7 +21,7 @@ namespace po = boost::program_options;
 static int call_nbd_cmd(const po::variables_map &vm,
                         const std::vector<std::string> &args,
                         const std::vector<std::string> &ceph_global_init_args) {
-  #ifdef _WIN32
+  #if defined(__FreeBSD__) || defined(_WIN32)
   std::cerr << "rbd: nbd device is not supported" << std::endl;
   return -EOPNOTSUPP;
   #else
@@ -60,6 +60,7 @@ static int call_nbd_cmd(const po::variables_map &vm,
   #endif
 }
 
+#if !defined(__FreeBSD__) && !defined(_WIN32)
 int get_image_or_snap_spec(const po::variables_map &vm, std::string *spec) {
   size_t arg_index = 0;
   std::string pool_name;
@@ -112,13 +113,14 @@ int parse_options(const std::vector<std::string> &options,
 
   return 0;
 }
+#endif
 
 int execute_list(const po::variables_map &vm,
                  const std::vector<std::string> &ceph_global_init_args) {
 #if defined(__FreeBSD__) || defined(_WIN32)
   std::cerr << "rbd: nbd device is not supported" << std::endl;
   return -EOPNOTSUPP;
-#endif
+#else
   std::vector<std::string> args;
 
   args.push_back("list-mapped");
@@ -132,6 +134,7 @@ int execute_list(const po::variables_map &vm,
   }
 
   return call_nbd_cmd(vm, args, ceph_global_init_args);
+#endif
 }
 
 int execute_attach(const po::variables_map &vm,
@@ -139,7 +142,7 @@ int execute_attach(const po::variables_map &vm,
 #if defined(__FreeBSD__) || defined(_WIN32)
   std::cerr << "rbd: nbd device is not supported" << std::endl;
   return -EOPNOTSUPP;
-#endif
+#else
   std::vector<std::string> args;
   std::string device_path;
 
@@ -192,6 +195,7 @@ int execute_attach(const po::variables_map &vm,
   }
 
   return call_nbd_cmd(vm, args, ceph_global_init_args);
+#endif
 }
 
 int execute_detach(const po::variables_map &vm,
@@ -199,7 +203,7 @@ int execute_detach(const po::variables_map &vm,
 #if defined(__FreeBSD__) || defined(_WIN32)
   std::cerr << "rbd: nbd device is not supported" << std::endl;
   return -EOPNOTSUPP;
-#endif
+#else
   std::string device_name = utils::get_positional_argument(vm, 0);
   if (!boost::starts_with(device_name, "/dev/")) {
     device_name.clear();
@@ -232,6 +236,7 @@ int execute_detach(const po::variables_map &vm,
   }
 
   return call_nbd_cmd(vm, args, ceph_global_init_args);
+#endif
 }
 
 int execute_map(const po::variables_map &vm,
@@ -239,7 +244,7 @@ int execute_map(const po::variables_map &vm,
 #if defined(__FreeBSD__) || defined(_WIN32)
   std::cerr << "rbd: nbd device is not supported" << std::endl;
   return -EOPNOTSUPP;
-#endif
+#else
   std::vector<std::string> args;
 
   args.push_back("map");
@@ -275,6 +280,7 @@ int execute_map(const po::variables_map &vm,
   }
 
   return call_nbd_cmd(vm, args, ceph_global_init_args);
+#endif
 }
 
 int execute_unmap(const po::variables_map &vm,
@@ -282,7 +288,7 @@ int execute_unmap(const po::variables_map &vm,
 #if defined(__FreeBSD__) || defined(_WIN32)
   std::cerr << "rbd: nbd device is not supported" << std::endl;
   return -EOPNOTSUPP;
-#endif
+#else
   std::string device_name = utils::get_positional_argument(vm, 0);
   if (!boost::starts_with(device_name, "/dev/")) {
     device_name.clear();
@@ -315,6 +321,7 @@ int execute_unmap(const po::variables_map &vm,
   }
 
   return call_nbd_cmd(vm, args, ceph_global_init_args);
+#endif
 }
 
 void get_list_arguments_deprecated(po::options_description *positional,
index 5c524045224469cfd19722117791c2a3ef9e74b0..4da6be33b5d5465a45d70c991b5ce8d672a6eb09 100644 (file)
@@ -18,6 +18,7 @@ namespace wnbd {
 namespace at = argument_types;
 namespace po = boost::program_options;
 
+#if defined(_WIN32)
 static int call_wnbd_cmd(const po::variables_map &vm,
                         const std::vector<std::string> &args,
                         const std::vector<std::string> &ceph_global_init_args) {
@@ -106,9 +107,14 @@ int parse_options(const std::vector<std::string> &options,
 
   return 0;
 }
+#endif
 
 int execute_list(const po::variables_map &vm,
                  const std::vector<std::string> &ceph_global_init_args) {
+#if !defined(_WIN32)
+  std::cerr << "rbd: wnbd is only supported on Windows" << std::endl;
+  return -EOPNOTSUPP;
+#else
   std::vector<std::string> args;
 
   args.push_back("list");
@@ -122,10 +128,15 @@ int execute_list(const po::variables_map &vm,
   }
 
   return call_wnbd_cmd(vm, args, ceph_global_init_args);
+#endif
 }
 
 int execute_map(const po::variables_map &vm,
                 const std::vector<std::string> &ceph_global_init_args) {
+#if !defined(_WIN32)
+  std::cerr << "rbd: wnbd is only supported on Windows" << std::endl;
+  return -EOPNOTSUPP;
+#else
   std::vector<std::string> args;
 
   args.push_back("map");
@@ -152,10 +163,15 @@ int execute_map(const po::variables_map &vm,
   }
 
   return call_wnbd_cmd(vm, args, ceph_global_init_args);
+#endif
 }
 
 int execute_unmap(const po::variables_map &vm,
                   const std::vector<std::string> &ceph_global_init_args) {
+#if !defined(_WIN32)
+  std::cerr << "rbd: wnbd is only supported on Windows" << std::endl;
+  return -EOPNOTSUPP;
+#else
   std::string device_name = utils::get_positional_argument(vm, 0);
 
   std::string image_name;
@@ -185,15 +201,26 @@ int execute_unmap(const po::variables_map &vm,
   }
 
   return call_wnbd_cmd(vm, args, ceph_global_init_args);
+#endif
 }
 
 int execute_attach(const po::variables_map &vm,
                    const std::vector<std::string> &ceph_global_init_args) {
+#if !defined(_WIN32)
+  std::cerr << "rbd: wnbd is only supported on Windows" << std::endl;
+#else
+  std::cerr << "rbd: wnbd attach command not supported" << std::endl;
+#endif
   return -EOPNOTSUPP;
 }
 
 int execute_detach(const po::variables_map &vm,
                    const std::vector<std::string> &ceph_global_init_args) {
+#if !defined(_WIN32)
+  std::cerr << "rbd: wnbd is only supported on Windows" << std::endl;
+#else
+  std::cerr << "rbd: wnbd detach command not supported" << std::endl;
+#endif
   return -EOPNOTSUPP;
 }