From: luo.runbing Date: Thu, 19 Sep 2019 09:30:37 +0000 (+0800) Subject: common/compat: add strerror_r X-Git-Tag: v15.1.0~1138^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=157bd362bdab05b0762bba88af766abff422e683;p=ceph-ci.git common/compat: add strerror_r Signed-off-by: luo.runbing --- diff --git a/src/common/compat.cc b/src/common/compat.cc index f681969fff6..bea5dba96e3 100644 --- a/src/common/compat.cc +++ b/src/common/compat.cc @@ -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 +} diff --git a/src/include/compat.h b/src/include/compat.h index 3b38af54427..bfb12579d69 100644 --- a/src/include/compat.h +++ b/src/include/compat.h @@ -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 */