]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common/compat: add strerror_r
authorluo.runbing <luo.runbing@zte.com.cn>
Thu, 19 Sep 2019 09:30:37 +0000 (17:30 +0800)
committerluo.runbing <luo.runbing@zte.com.cn>
Tue, 22 Oct 2019 08:44:15 +0000 (16:44 +0800)
Signed-off-by: luo.runbing <luo.runbing@zte.com.cn>
src/common/compat.cc
src/include/compat.h

index f681969fff6a06e43384262a611112a39446aa80..bea5dba96e35421b8d462f2ac2af32b8878eef1a 100644 (file)
@@ -193,3 +193,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
+}
index 3b38af544272e84ebb81117f5e3b6c91cd8e755f..bfb12579d692c5282cdaf6ec6dc1a47c6eb10ed1 100644 (file)
@@ -195,4 +195,14 @@ int ceph_posix_fallocate(int fd, off_t offset, off_t len);
 
 int pipe_cloexec(int pipefd[2], int flags);
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char *ceph_strerror_r(int errnum, char *buf, size_t buflen);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* !CEPH_COMPAT_H */