]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tool/cephfs: make EventOutput::binary() idempotent 8738/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Mon, 25 Apr 2016 02:23:00 +0000 (10:23 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Mon, 25 Apr 2016 02:23:00 +0000 (10:23 +0800)
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 <xie.xingguo@zte.com.cn>
src/tools/cephfs/EventOutput.cc

index 52eddba4879a168dfbc4ba274f6e5824961ac310..663aefd685fbe5d6c32f19346a83775a6566ced4 100644 (file)
@@ -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) {