From: xie xingguo Date: Mon, 25 Apr 2016 02:23:00 +0000 (+0800) Subject: tool/cephfs: make EventOutput::binary() idempotent X-Git-Tag: v11.0.0~380^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bb64222b80b18c54bcee063c541d4004989c22f8;p=ceph.git tool/cephfs: make EventOutput::binary() idempotent We may passed a path in which has already been created. So we shall tolerate the EEXIST error, which shall also make this funciton idempotent. Besides, we shall reset return code to errno on mkdir() system call error for better tracing. Signed-off-by: xie xingguo --- diff --git a/src/tools/cephfs/EventOutput.cc b/src/tools/cephfs/EventOutput.cc index 52eddba4879a..663aefd685fb 100644 --- a/src/tools/cephfs/EventOutput.cc +++ b/src/tools/cephfs/EventOutput.cc @@ -29,8 +29,11 @@ int EventOutput::binary() const // Binary output, files int r = ::mkdir(path.c_str(), 0755); if (r != 0) { - std::cerr << "Error creating output directory: " << cpp_strerror(r) << std::endl; - return r; + r = -errno; + if (r != -EEXIST) { + std::cerr << "Error creating output directory: " << cpp_strerror(r) << std::endl; + return r; + } } for (JournalScanner::EventMap::const_iterator i = scan.events.begin(); i != scan.events.end(); ++i) {