From bb64222b80b18c54bcee063c541d4004989c22f8 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Mon, 25 Apr 2016 10:23:00 +0800 Subject: [PATCH] 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 --- src/tools/cephfs/EventOutput.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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) { -- 2.47.3