]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/common/compat.cc
import 15.2.0 Octopus source
[ceph.git] / ceph / src / common / compat.cc
index ceb8a0115b47936a5e83c3548fab8263214ab43e..e38aff4fb1d279ae469b0f692e6282437004f3ba 100644 (file)
@@ -13,6 +13,8 @@
  *
  */
 
+#include <cstdio>
+
 #include <errno.h>
 #include <fcntl.h>
 #include <stdint.h>
@@ -92,10 +94,10 @@ int ceph_posix_fallocate(int fd, off_t offset, off_t len) {
 #endif
 } 
 
-int pipe_cloexec(int pipefd[2])
+int pipe_cloexec(int pipefd[2], int flags)
 {
 #if defined(HAVE_PIPE2)
-  return pipe2(pipefd, O_CLOEXEC);
+  return pipe2(pipefd, O_CLOEXEC | flags);
 #else
   if (pipe(pipefd) == -1)
     return -1;
@@ -194,3 +196,14 @@ int sched_setaffinity(pid_t pid, size_t cpusetsize,
 }
 #endif
 
+char *ceph_strerror_r(int errnum, char *buf, size_t buflen)
+{
+#ifdef STRERROR_R_CHAR_P
+  return strerror_r(errnum, buf, buflen);
+#else
+  if (strerror_r(errnum, buf, buflen)) {
+    snprintf(buf, buflen, "Unknown error %d", errnum);
+  }
+  return buf;
+#endif
+}