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>
add_subdirectory(kv)
add_subdirectory(os)
+if(NOT WIN32)
add_subdirectory(blk)
+endif()
add_subdirectory(osd)
admin_socket_client.cc
assert.cc
bit_str.cc
- blkdev.cc
bloom_filter.cc
ceph_argparse.cc
ceph_context.cc
condition_variable_debug.cc
config.cc
config_values.cc
- dns_resolve.cc
dout.cc
entity_name.cc
environment.cc
histogram.cc
hobject.cc
hostname.cc
- ipaddr.cc
iso_8601.cc
- linux_version.c
lockdep.cc
mempool.cc
mime.c
pick_address.cc
random_string.cc
reverse.c
- run_cmd.cc
scrub_types.cc
shared_mutex_debug.cc
signal.cc
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)
close(stderr_pipe_in_fd);
}
+#ifndef _WIN32
void SubProcess::kill(int signo) const {
ceph_assert(is_spawned());
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,
}
static void dummy_sighandler(int sig) {}
+#ifndef _WIN32
void SubProcessTimed::exec() {
ceph_assert(is_child());
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 */
#include <signal.h>
#endif
+#ifndef _WIN32
#include <sys/wait.h>
+#endif
#include <sstream>
#include <vector>
// 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);
}
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);
--- /dev/null
+// -*- 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;
+}
{
#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)
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
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) {
--- /dev/null
+// -*- 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;
+}
+
+}
#include "debug.h"
#include "errno.h"
+#ifndef _WIN32
void dump_open_fds(CephContext *cct)
{
#ifdef __APPLE__
closedir(d);
}
+#else
+void dump_open_fds(CephContext *cct)
+{
+}
+#endif
#include <ostream>
#include <signal.h>
+#ifndef _WIN32
#include <sys/wait.h>
+#endif
#include <sys/types.h>
#include "include/ceph_assert.h"
// 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,
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
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;
#include <sys/wait.h>
#endif
+#ifndef _WIN32
/*
* TODO: Switch to libkmod when we abandon older platforms. The APIs
* we want are:
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 */
return 0;
}
-#elif defined(__FreeBSD__)
-
+#else
int parse_cpu_set_list(const char *s,
size_t *cpu_set_size,
cpu_set_t *cpu_set)
using namespace std::literals;
+#ifndef _WIN32
std::string signal_mask_to_str()
{
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 */
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
// 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 */
--- /dev/null
+/*
+ * 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 */
#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> */
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})
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);
}
return 0;
+ #endif
}
int get_image_or_snap_spec(const po::variables_map &vm, std::string *spec) {
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
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
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