--- /dev/null
+#include "common/errno.h"
+
+#include <sstream>
+#include <string>
+#include <string.h>
+
+std::string cpp_strerror(int err)
+{
+ char buf[128];
+
+ std::ostringstream oss;
+ oss << "error " << err << ": " << strerror_r(err, buf, sizeof(buf));
+
+ return oss.str();
+}
*/
#include "config.h"
+#include "common/errno.h"
#include "FileJournal.h"
#include "include/color.h"
int FileJournal::_open(bool forwrite, bool create)
{
- char buf[80];
int flags, ret;
if (forwrite) {
::close(fd);
fd = ::open(fn.c_str(), flags, 0644);
if (fd < 0) {
- dout(2) << "_open failed " << errno << " " << strerror_r(errno, buf, sizeof(buf)) << dendl;
- cerr << "unable to open journal " << fn << ": " << strerror_r(errno, buf, sizeof(buf)) << std::endl;
- return -errno;
+ int err = errno;
+ dout(2) << "_open failed " << cpp_strerror(err) << dendl;
+ cerr << "unable to open journal " << fn << ": " << cpp_strerror(err) << std::endl;
+ return -err;
}
struct stat st;
ret = ::fstat(fd, &st);
if (ret) {
int err = errno;
- dout(2) << "_open failed to fstat! " << err << " "
- << strerror_r(err, buf, sizeof(buf)) << dendl;
+ dout(2) << "_open failed to fstat! " << cpp_strerror(err) << dendl;
return -err;
}