]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: stub certain modules and functions on Windows 32705/head
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Fri, 18 Oct 2019 15:51:30 +0000 (15:51 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Thu, 4 Jun 2020 15:52:16 +0000 (15:52 +0000)
We're going to stub certain modules and functions for Windows builds.
Some of them will be implemented in subsequent commits, some are platform
specific and will be skipped.

Modules:
* module.c
* subprocess.cc
* blkdev.cc
* dns_resolve.cc
* numa.cc
* syslog.h
* statvfs.h
* libblk
* neorados

Functions:
x signal functions
x fork
x chown
* socketpair_cloexec
* dump_open_fds
* run_cmd
* is_symlink
* CInode::d_type
* nbd commands

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
21 files changed:
src/CMakeLists.txt
src/common/CMakeLists.txt
src/common/SubProcess.cc
src/common/SubProcess.h
src/common/Thread.cc
src/common/blkdev_win32.cc [new file with mode: 0644]
src/common/compat.cc
src/common/dns_resolve.h
src/common/dns_resolve_win32.cc [new file with mode: 0644]
src/common/fd.cc
src/common/fork_function.h
src/common/ipaddr.cc
src/common/module.c
src/common/numa.cc
src/common/signal.cc
src/include/compat.h
src/include/win32/sys/statvfs.h [new file with mode: 0644]
src/include/win32/syslog.h [new file with mode: 0644]
src/os/ObjectStore.h
src/tools/CMakeLists.txt
src/tools/rbd/action/Nbd.cc

index 0227d8750f2ffe87a3d603dee5ba5539577cb5fa..801bbe5941f5bfba97a24a397f67ccc57681e048 100644 (file)
@@ -544,7 +544,9 @@ endif()
 
 add_subdirectory(kv)
 add_subdirectory(os)
+if(NOT WIN32)
 add_subdirectory(blk)
+endif()
 
 add_subdirectory(osd)
 
index fbf6915f2c6a7d890e017b0f278922beb88a547c..470ad46234a3a0b29a9fc9242ed023a49dec96e6 100644 (file)
@@ -45,7 +45,6 @@ set(common_srcs
   admin_socket_client.cc
   assert.cc
   bit_str.cc
-  blkdev.cc
   bloom_filter.cc
   ceph_argparse.cc
   ceph_context.cc
@@ -64,7 +63,6 @@ set(common_srcs
   condition_variable_debug.cc
   config.cc
   config_values.cc
-  dns_resolve.cc
   dout.cc
   entity_name.cc
   environment.cc
@@ -76,9 +74,7 @@ set(common_srcs
   histogram.cc
   hobject.cc
   hostname.cc
-  ipaddr.cc
   iso_8601.cc
-  linux_version.c
   lockdep.cc
   mempool.cc
   mime.c
@@ -93,7 +89,6 @@ set(common_srcs
   pick_address.cc
   random_string.cc
   reverse.c
-  run_cmd.cc
   scrub_types.cc
   shared_mutex_debug.cc
   signal.cc
@@ -108,6 +103,19 @@ set(common_srcs
   util.cc
   version.cc)
 
+if(WIN32)
+  list(APPEND common_srcs
+    blkdev_win32.cc
+    dns_resolve_win32.cc)
+else()
+  list(APPEND common_srcs
+    blkdev.cc
+    dns_resolve.cc
+    ipaddr.cc
+    linux_version.c
+    run_cmd.cc)
+endif()
+
 set_source_files_properties(${CMAKE_SOURCE_DIR}/src/common/version.cc
   APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/src/include/ceph_ver.h)
 
index 1faf33e36eeeb45af57068185edeacc2407bd10a..ab4ecd180210afb89b46b8122632025babcd1a4a 100644 (file)
@@ -102,6 +102,7 @@ void SubProcess::close_stderr() {
   close(stderr_pipe_in_fd);
 }
 
+#ifndef _WIN32
 void SubProcess::kill(int signo) const {
   ceph_assert(is_spawned());
 
@@ -273,6 +274,7 @@ int SubProcess::join() {
   errstr << cmd << ": waitpid: unknown status returned\n";
   return EXIT_FAILURE;
 }
+#endif /* _WIN32 */
 
 SubProcessTimed::SubProcessTimed(const char *cmd, std_fd_op stdin_op,
                                 std_fd_op stdout_op, std_fd_op stderr_op,
@@ -288,6 +290,7 @@ void timeout_sighandler(int sig) {
 }
 static void dummy_sighandler(int sig) {}
 
+#ifndef _WIN32
 void SubProcessTimed::exec() {
   ceph_assert(is_child());
 
@@ -392,3 +395,22 @@ void SubProcessTimed::exec() {
 fail_exit:
   _exit(EXIT_FAILURE);
 }
+
+#else
+int SubProcess::join() {
+  return EXIT_FAILURE;
+}
+
+void SubProcess::kill(int signo) const {
+}
+
+int SubProcess::spawn() {
+  return EXIT_FAILURE;
+}
+
+void SubProcess::exec() {
+}
+
+void SubProcessTimed::exec() {
+}
+#endif /* _WIN32 */
index 763822af49051b9dabcb0898054ab52b5cf3c001..829749284fc6b1fbe0e6cd8527d2ddc19575f12b 100644 (file)
@@ -21,7 +21,9 @@
 #include <signal.h>
 #endif
 
+#ifndef _WIN32
 #include <sys/wait.h>
+#endif
 #include <sstream>
 #include <vector>
 
index edbd7d34c8749ac0e929971936167cc6587dc9b5..45451040c4adfa31112dd00d1b88c324a0ca16c9 100644 (file)
@@ -125,6 +125,8 @@ int Thread::try_create(size_t stacksize)
   // the set of signals we want to block.  (It's ok to block signals more
   // signals than usual for a little while-- they will just be delivered to
   // another thread or delieverd to this thread later.)
+
+  #ifndef _WIN32
   sigset_t old_sigset;
   if (g_code_env == CODE_ENVIRONMENT_LIBRARY) {
     block_signals(NULL, &old_sigset);
@@ -135,6 +137,9 @@ int Thread::try_create(size_t stacksize)
   }
   r = pthread_create(&thread_id, thread_attr, _entry_func, (void*)this);
   restore_sigset(&old_sigset);
+  #else
+  r = pthread_create(&thread_id, thread_attr, _entry_func, (void*)this);
+  #endif
 
   if (thread_attr) {
     pthread_attr_destroy(thread_attr); 
diff --git a/src/common/blkdev_win32.cc b/src/common/blkdev_win32.cc
new file mode 100644 (file)
index 0000000..c3e28e3
--- /dev/null
@@ -0,0 +1,137 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2020 SUSE LINUX GmbH
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+#include <errno.h>
+#include "blkdev.h"
+
+int get_device_by_path(const char *path, char* partition, char* device,
+               size_t max)
+{
+  return -EOPNOTSUPP;
+}
+
+
+BlkDev::BlkDev(int f)
+  : fd(f)
+{}
+
+BlkDev::BlkDev(const std::string& devname)
+  : devname(devname)
+{}
+
+int BlkDev::get_devid(dev_t *id) const
+{
+  return -EOPNOTSUPP;
+}
+
+const char *BlkDev::sysfsdir() const {
+  assert(false);  // Should never be called on Windows
+  return "";
+}
+
+int BlkDev::dev(char *dev, size_t max) const
+{
+  return -EOPNOTSUPP;
+}
+
+int BlkDev::get_size(int64_t *psize) const
+{
+  return -EOPNOTSUPP;
+}
+
+bool BlkDev::support_discard() const
+{
+  return false;
+}
+
+int BlkDev::discard(int64_t offset, int64_t len) const
+{
+  return -EOPNOTSUPP;
+}
+
+bool BlkDev::is_rotational() const
+{
+  return false;
+}
+
+int BlkDev::model(char *model, size_t max) const
+{
+  return -EOPNOTSUPP;
+}
+
+int BlkDev::serial(char *serial, size_t max) const
+{
+  return -EOPNOTSUPP;
+}
+
+int BlkDev::partition(char *partition, size_t max) const
+{
+  return -EOPNOTSUPP;
+}
+
+int BlkDev::wholedisk(char *wd, size_t max) const
+{
+  return -EOPNOTSUPP;
+}
+
+void get_dm_parents(const std::string& dev, std::set<std::string> *ls)
+{
+}
+
+void get_raw_devices(const std::string& in,
+             std::set<std::string> *ls)
+{
+}
+
+int get_vdo_stats_handle(const char *devname, std::string *vdo_name)
+{
+  return -1;
+}
+
+int64_t get_vdo_stat(int fd, const char *property)
+{
+  return 0;
+}
+
+bool get_vdo_utilization(int fd, uint64_t *total, uint64_t *avail)
+{
+  return false;
+}
+
+std::string get_device_id(const std::string& devname,
+              std::string *err)
+{
+  if (err) {
+    *err = "not implemented";
+  }
+  return std::string();
+}
+
+int block_device_run_smartctl(const char *device, int timeout,
+                  std::string *result)
+{
+  return -EOPNOTSUPP;
+}
+
+int block_device_get_metrics(const std::string& devname, int timeout,
+                             json_spirit::mValue *result)
+{
+  return -EOPNOTSUPP;
+}
+
+int block_device_run_nvme(const char *device, const char *vendor, int timeout,
+            std::string *result)
+{
+  return -EOPNOTSUPP;
+}
index e38aff4fb1d279ae469b0f692e6282437004f3ba..74e99165572c2ae3d3fea9a7052586bf05c18013 100644 (file)
@@ -148,6 +148,9 @@ int socketpair_cloexec(int domain, int type, int protocol, int sv[2])
 {
 #ifdef SOCK_CLOEXEC
   return socketpair(domain, type|SOCK_CLOEXEC, protocol, sv);
+#elif _WIN32
+  /* TODO */
+  return -ENOTSUP;
 #else
   int rc = socketpair(domain, type, protocol, sv);
   if (rc == -1)
@@ -207,3 +210,21 @@ char *ceph_strerror_r(int errnum, char *buf, size_t buflen)
   return buf;
 #endif
 }
+
+#ifdef _WIN32
+
+// chown is not available on Windows. Plus, changing file owners is not
+// a common practice on Windows.
+int chown(const char *path, uid_t owner, gid_t group) {
+  return 0;
+}
+
+int fchown(int fd, uid_t owner, gid_t group) {
+  return 0;
+}
+
+int lchown(const char *path, uid_t owner, gid_t group) {
+  return 0;
+}
+
+#endif /* _WIN32 */
\ No newline at end of file
index d3bbf103b52da32cdfbacbfbe7e8f7fcc64c46c8..7a32e2a2a62a0bf58d95a9c561c51e2918902a86 100644 (file)
@@ -139,11 +139,13 @@ class DNSResolver {
     void put_state(res_state s);
 #endif
 
+#ifndef _WIN32
     /* this private function allows to reuse the res_state structure used
      * by other function of this class
      */
     int resolve_ip_addr(CephContext *cct, res_state *res,
         const std::string& hostname, entity_addr_t *addr);
+#endif
 
     std::string srv_protocol_to_str(SRV_Protocol proto) {
       switch (proto) {
diff --git a/src/common/dns_resolve_win32.cc b/src/common/dns_resolve_win32.cc
new file mode 100644 (file)
index 0000000..b7a888b
--- /dev/null
@@ -0,0 +1,65 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2019 SUSE LINUX GmbH
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+#include "include/scope_guard.h"
+#include "dns_resolve.h"
+#include "common/debug.h"
+
+#define dout_subsys ceph_subsys_
+
+
+namespace ceph {
+
+int ResolvHWrapper::res_query(const char *hostname, int cls,
+    int type, u_char *buf, int bufsz) {
+  return -1;
+}
+
+int ResolvHWrapper::res_search(const char *hostname, int cls,
+    int type, u_char *buf, int bufsz) {
+  return -1;
+}
+
+DNSResolver::~DNSResolver()
+{
+  delete resolv_h;
+}
+
+int DNSResolver::resolve_cname(CephContext *cct, const string& hostname,
+    string *cname, bool *found)
+{
+  return -ENOTSUP;
+}
+
+int DNSResolver::resolve_ip_addr(CephContext *cct, const string& hostname,
+    entity_addr_t *addr)
+{
+  return -ENOTSUP;
+}
+
+int DNSResolver::resolve_srv_hosts(CephContext *cct, const string& service_name,
+    const SRV_Protocol trans_protocol,
+    map<string, DNSResolver::Record> *srv_hosts)
+{
+  return this->resolve_srv_hosts(cct, service_name, trans_protocol, "", srv_hosts);
+}
+
+int DNSResolver::resolve_srv_hosts(CephContext *cct, const string& service_name,
+    const SRV_Protocol trans_protocol, const string& domain,
+    map<string, DNSResolver::Record> *srv_hosts)
+{
+  return -ENOTSUP;
+}
+
+}
index 931d4353c2b8bb64ee67e4669778eeab1a7518af..89d18940b63ba93c4737d33fe20b4ed48bb27202 100644 (file)
@@ -16,6 +16,7 @@
 #include "debug.h"
 #include "errno.h"
 
+#ifndef _WIN32
 void dump_open_fds(CephContext *cct)
 {
 #ifdef __APPLE__
@@ -51,3 +52,8 @@ void dump_open_fds(CephContext *cct)
 
   closedir(d);
 }
+#else
+void dump_open_fds(CephContext *cct)
+{
+}
+#endif
index 9076cc5a995aec9ee933669164ac023719a4f375..4b223384658195b906c4c54e688cd96fa0c0dffe 100644 (file)
@@ -10,7 +10,9 @@
 #include <ostream>
 
 #include <signal.h>
+#ifndef _WIN32
 #include <sys/wait.h>
+#endif
 #include <sys/types.h>
 
 #include "include/ceph_assert.h"
@@ -22,6 +24,7 @@ static void _fork_function_dummy_sighandler(int sig) {}
 // int8_t only due to unix exit code limitations.  Returns -ETIMEDOUT
 // if timeout is reached.
 
+#ifndef _WIN32
 static inline int fork_function(
   int timeout,
   std::ostream& errstr,
@@ -162,3 +165,13 @@ static inline int fork_function(
 fail_exit:
   _exit(EXIT_FAILURE);
 }
+#else
+static inline int fork_function(
+  int timeout,
+  std::ostream& errstr,
+  std::function<int8_t(void)> f)
+{
+  errstr << "Forking is not available on Windows.\n";
+  return -1;
+}
+#endif
index d166dc8b41205dc8e76ec9fd71b7125eb88428f9..16114093798989f7519da6a7a31b81a2eb4a1158 100644 (file)
@@ -36,7 +36,7 @@ void netmask_ipv4(const struct in_addr *addr,
 
 static bool match_numa_node(const string& if_name, int numa_node)
 {
-#ifdef WITH_SEASTAR
+#if defined(WITH_SEASTAR) || defined(_WIN32)
   return true;
 #else
   int if_node = -1;
index e67b3bf933afe5cd718f32395ae49cf4ccb30d32..e08c49d15c39389df97a919a1763010b90d82354 100644 (file)
@@ -20,6 +20,7 @@
 #include <sys/wait.h>
 #endif 
 
+#ifndef _WIN32
 /*
  * TODO: Switch to libkmod when we abandon older platforms.  The APIs
  * we want are:
@@ -77,3 +78,23 @@ int module_load(const char *module, const char *options)
 
        return run_command(command);
 }
+
+#else
+
+// We're stubbing out those functions, for now.
+static int run_command(const char *command)
+{
+       return -1;
+}
+
+int module_has_param(const char *module, const char *param)
+{
+       return -1;
+}
+
+int module_load(const char *module, const char *options)
+{
+       return -1;
+}
+
+#endif /* _WIN32 */
index 89368bd4005f317c54ee8a8f0e0588e9cdf5f673..87fde6e68af8a68247228b56f1f9c728e2310b93 100644 (file)
@@ -188,8 +188,7 @@ int set_cpu_affinity_all_threads(size_t cpu_set_size, cpu_set_t *cpu_set)
   return 0;
 }
 
-#elif defined(__FreeBSD__)
-
+#else
 int parse_cpu_set_list(const char *s,
                       size_t *cpu_set_size,
                       cpu_set_t *cpu_set)
index edb6aa17aa6db1dbdfa530c4c155d048cb6e81d0..97f13edfafb256c91582dd64159d3e0f939a4231 100644 (file)
@@ -30,6 +30,7 @@
 
 using namespace std::literals;
 
+#ifndef _WIN32
 std::string signal_mask_to_str()
 {
   sigset_t old_sigset;
@@ -83,3 +84,14 @@ void unblock_all_signals(sigset_t *old_sigset)
   int ret = pthread_sigmask(SIG_UNBLOCK, &sigset, old_sigset);
   ceph_assert(ret == 0);
 }
+#else
+std::string signal_mask_to_str()
+{
+  return "(unsupported signal)";
+}
+
+// Windows provides limited signal functionality.
+void block_signals(const int *siglist, sigset_t *old_sigset) {}
+void restore_sigset(const sigset_t *old_sigset) {}
+void unblock_all_signals(sigset_t *old_sigset) {}
+#endif /* _WIN32 */
index a7cf55b42ba409efc056d3686aa5738bc68389f0..9197863e32b0672e6a0220e1f8ab4c24b87107e6 100644 (file)
@@ -219,6 +219,14 @@ typedef long nlink_t;
 
 typedef long long loff_t;
 
+#define CPU_SETSIZE (sizeof(size_t)*8)
+
+typedef union
+{
+  char cpuset[CPU_SETSIZE/8];
+  size_t _align;
+} cpu_set_t;
+
 #define SHUT_RD SD_RECEIVE
 #define SHUT_WR SD_SEND
 #define SHUT_RDWR SD_BOTH
@@ -245,6 +253,18 @@ typedef long long loff_t;
 // flag as a no-op.
 #define O_CLOEXEC 0
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int chown(const char *path, uid_t owner, gid_t group);
+int fchown(int fd, uid_t owner, gid_t group);
+int lchown(const char *path, uid_t owner, gid_t group);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* WIN32 */
 
 #endif /* !CEPH_COMPAT_H */
diff --git a/src/include/win32/sys/statvfs.h b/src/include/win32/sys/statvfs.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/include/win32/syslog.h b/src/include/win32/syslog.h
new file mode 100644 (file)
index 0000000..d59cd3d
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2013, 2015 Cloudbase Solutions Srl
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.You may obtain
+ * a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef SYSLOG_H
+#define SYSLOG_H 1
+
+#define LOG_EMERG       0       /* system is unusable */
+#define LOG_ALERT       1       /* action must be taken immediately */
+#define LOG_CRIT        2       /* critical conditions */
+#define LOG_ERR         3       /* error conditions */
+#define LOG_WARNING     4       /* warning conditions */
+#define LOG_NOTICE      5       /* normal but significant condition */
+#define LOG_INFO        6       /* informational */
+#define LOG_DEBUG       7       /* debug-level messages */
+#define LOG_NDELAY      8       /* don't delay open */
+
+#define LOG_KERN      (0<<3)  /* kernel messages */
+#define LOG_USER      (1<<3)  /* user-level messages */
+#define LOG_MAIL      (2<<3)  /* mail system */
+#define LOG_DAEMON    (3<<3)  /* system daemons */
+#define LOG_AUTH      (4<<3)  /* security/authorization messages */
+#define LOG_SYSLOG    (5<<3)  /* messages generated internally by syslogd */
+#define LOG_LPR       (6<<3)  /* line printer subsystem */
+#define LOG_NEWS      (7<<3)  /* network news subsystem */
+#define LOG_UUCP      (8<<3)  /* UUCP subsystem */
+#define LOG_CRON      (9<<3)  /* clock daemon */
+#define LOG_AUTHPRIV  (10<<3) /* security/authorization messages */
+#define LOG_FTP       (11<<3) /* FTP daemon */
+
+#define LOG_LOCAL0      (16<<3) /* reserved for local use */
+#define LOG_LOCAL1      (17<<3) /* reserved for local use */
+#define LOG_LOCAL2      (18<<3) /* reserved for local use */
+#define LOG_LOCAL3      (19<<3) /* reserved for local use */
+#define LOG_LOCAL4      (20<<3) /* reserved for local use */
+#define LOG_LOCAL5      (21<<3) /* reserved for local use */
+#define LOG_LOCAL6      (22<<3) /* reserved for local use */
+#define LOG_LOCAL7      (23<<3) /* reserved for local use */
+
+static inline void
+openlog(const char *ident, int option, int facility)
+{
+}
+
+static inline void
+syslog(int priority, const char *format, ...)
+{
+}
+
+#endif /* syslog.h */
index 9a9c075fc2bb47737ddc807c814f9fe837ee1292..bfd5ba475791e411d6a159be994b02af754356be 100644 (file)
@@ -32,7 +32,7 @@
 #include <vector>
 #include <map>
 
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun) || defined(_WIN32)
 #include <sys/statvfs.h>
 #else
 #include <sys/vfs.h>    /* or <sys/statfs.h> */
index f460ce1ae2d18b3d1ad9dd5e1aeb69c3f614f4fa..579a8f791e7902e103e8505095c3da6d9352f474 100644 (file)
@@ -16,7 +16,7 @@ else()
 endif()
 install(TARGETS rados DESTINATION bin)
 
-if(WITH_BOOST_CONTEXT)
+if(WITH_BOOST_CONTEXT AND NOT WIN32)
 set(neorados_srcs
   neorados.cc)
 add_executable(neorados ${neorados_srcs})
index ab62e9a7bf83599a22733a3cbbc2dd2c84fae8dd..78205f48c6bab951a4eb779dbbf1a1906faa6d1d 100644 (file)
@@ -21,6 +21,10 @@ 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
+  std::cerr << "rbd: nbd device is not supported" << std::endl;
+  return -EOPNOTSUPP;
+  #else
   char exe_path[PATH_MAX];
   ssize_t exe_path_bytes = readlink("/proc/self/exe", exe_path,
                                    sizeof(exe_path) - 1);
@@ -53,6 +57,7 @@ static int call_nbd_cmd(const po::variables_map &vm,
   }
 
   return 0;
+  #endif
 }
 
 int get_image_or_snap_spec(const po::variables_map &vm, std::string *spec) {
@@ -99,7 +104,7 @@ int parse_options(const std::vector<std::string> &options,
 
 int execute_list(const po::variables_map &vm,
                  const std::vector<std::string> &ceph_global_init_args) {
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(_WIN32)
   std::cerr << "rbd: nbd device is not supported" << std::endl;
   return -EOPNOTSUPP;
 #endif
@@ -120,7 +125,7 @@ int execute_list(const po::variables_map &vm,
 
 int execute_map(const po::variables_map &vm,
                 const std::vector<std::string> &ceph_global_init_args) {
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(_WIN32)
   std::cerr << "rbd: nbd device is not supported" << std::endl;
   return -EOPNOTSUPP;
 #endif
@@ -163,7 +168,7 @@ int execute_map(const po::variables_map &vm,
 
 int execute_unmap(const po::variables_map &vm,
                   const std::vector<std::string> &ceph_global_init_args) {
-#if defined(__FreeBSD__)
+#if defined(__FreeBSD__) || defined(_WIN32)
   std::cerr << "rbd: nbd device is not supported" << std::endl;
   return -EOPNOTSUPP;
 #endif