]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common: add platform checks
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Fri, 18 Oct 2019 11:05:47 +0000 (11:05 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Mon, 27 Jul 2020 08:26:31 +0000 (08:26 +0000)
O_CLOEXEC is not available on Windows. Subprocesses do not inherit
handles unless explicitly requested when creating the handle.
That being considered, we'll avoid setting this flag on Windows.

The zfs check will also be skipped for now.

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
src/common/compat.cc

index a8d57bd7758f53bf1f14096ad97f51d0f56213bd..c039ae9bb2f14e80211f1573a65158b974ce8478 100644 (file)
@@ -19,7 +19,9 @@
 #include <fcntl.h>
 #include <stdint.h>
 #include <string.h>
+#ifndef _WIN32
 #include <sys/mount.h>
+#endif
 #include <sys/param.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
@@ -63,9 +65,13 @@ int manual_fallocate(int fd, off_t offset, off_t len) {
 }
 
 int on_zfs(int basedir_fd) {
+  #ifndef _WIN32
   struct statfs basefs;
   (void)fstatfs(basedir_fd, &basefs);
   return (basefs.f_type == FS_ZFS_TYPE);
+  #else
+  return 0;
+  #endif
 }
 
 int ceph_posix_fallocate(int fd, off_t offset, off_t len) {
@@ -102,6 +108,7 @@ int pipe_cloexec(int pipefd[2], int flags)
   if (pipe(pipefd) == -1)
     return -1;
 
+  #ifndef _WIN32
   /*
    * The old-fashioned, race-condition prone way that we have to fall
    * back on if pipe2 does not exist.
@@ -113,6 +120,7 @@ int pipe_cloexec(int pipefd[2], int flags)
   if (fcntl(pipefd[1], F_SETFD, FD_CLOEXEC) < 0) {
     goto fail;
   }
+  #endif
 
   return 0;
 fail:
@@ -133,8 +141,10 @@ int socket_cloexec(int domain, int type, int protocol)
   if (fd == -1)
     return -1;
 
+  #ifndef _WIN32
   if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0)
     goto fail;
+  #endif
 
   return fd;
 fail:
@@ -156,11 +166,13 @@ int socketpair_cloexec(int domain, int type, int protocol, int sv[2])
   if (rc == -1)
     return -1;
 
+  #ifndef _WIN32
   if (fcntl(sv[0], F_SETFD, FD_CLOEXEC) < 0)
     goto fail;
 
   if (fcntl(sv[1], F_SETFD, FD_CLOEXEC) < 0)
     goto fail;
+  #endif
 
   return 0;
 fail:
@@ -180,8 +192,10 @@ int accept_cloexec(int sockfd, struct sockaddr* addr, socklen_t* addrlen)
   if (fd == -1)
     return -1;
 
+  #ifndef _WIN32
   if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0)
     goto fail;
+  #endif
 
   return fd;
 fail: