]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: import/export/mergediff: use STD[IN|OUT]_FILENO instead of 0 or 1 10487/head
authorDongsheng Yang <dongsheng.yang@easystack.cn>
Thu, 3 Nov 2016 10:47:11 +0000 (06:47 -0400)
committerDongsheng Yang <dongsheng.yang@easystack.cn>
Sun, 19 Feb 2017 12:42:03 +0000 (20:42 +0800)
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
src/tools/rbd/action/Export.cc
src/tools/rbd/action/Import.cc
src/tools/rbd/action/MergeDiff.cc

index 485b0ad841da07c27f8b4d4d41e23b69a21dfb95..eae06aeb51fcbd07513779a8d0d540f8e2446388 100644 (file)
@@ -214,7 +214,7 @@ int do_export_diff(librbd::Image& image, const char *fromsnapname,
   int fd;
 
   if (strcmp(path, "-") == 0)
-    fd = 1;
+    fd = STDOUT_FILENO;
   else
     fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0644);
   if (fd < 0)
index 75c07c67d1aa76afcacc1936de2ccf4827d25f1b..663a3986bf6f7c60e7c7e2fb798881da07894a7c 100644 (file)
@@ -33,7 +33,7 @@ int do_import_diff_fd(librbd::Image &image, int fd,
   string banner = (format == 1 ? utils::RBD_DIFF_BANNER : utils::RBD_DIFF_BANNER_V2);
   char buf[banner.size() + 1];
 
-  bool from_stdin = (fd == 0);
+  bool from_stdin = (fd == STDIN_FILENO);
   if (!from_stdin) {
     r = ::fstat(fd, &stat_buf);
     if (r < 0)
@@ -201,7 +201,7 @@ int do_import_diff(librbd::Image &image, const char *path,
   int fd;
 
   if (strcmp(path, "-") == 0) {
-    fd = 0;
+    fd = STDIN_FILENO;
   } else {
     fd = open(path, O_RDONLY);
     if (fd < 0) {
@@ -320,7 +320,7 @@ static int do_import_header(int fd, int import_format, uint64_t &size, librbd::I
   if (import_format == 1)
     return r;
 
-  if (fd == 0 || size < utils::RBD_IMAGE_BANNER_V2.size()) {
+  if (fd == STDIN_FILENO || size < utils::RBD_IMAGE_BANNER_V2.size()) {
     r = -EINVAL;
     return r;
   }
@@ -494,7 +494,7 @@ static int do_import_v1(int fd, librbd::Image &image, uint64_t size,
   size_t blklen = 0;            // amount accumulated from reads to fill blk
   char *p = new char[imgblklen];
   uint64_t image_pos = 0;
-  bool from_stdin = (fd == 0);
+  bool from_stdin = (fd == STDIN_FILENO);
 
   reqlen = min(reqlen, size);
   // loop body handles 0 return, as we may have a block to flush
@@ -546,7 +546,7 @@ static int do_import_v1(int fd, librbd::Image &image, uint64_t size,
     goto out;
   }
 
-  if (fd == 0) {
+  if (fd == STDIN_FILENO) {
     r = image.resize(image_pos);
     if (r < 0) {
       std::cerr << "rbd: final image resize failed" << std::endl;
@@ -583,7 +583,7 @@ static int do_import(librbd::RBD &rbd, librados::IoCtx& io_ctx,
   bool from_stdin = !strcmp(path, "-");
   if (from_stdin) {
     throttle.reset(new SimpleThrottle(1, false));
-    fd = 0;
+    fd = STDIN_FILENO;
     size = 1ULL << order;
   } else {
     throttle.reset(new SimpleThrottle(
index 5c31769d0c4080965c7fcf4593ce6120bddaf032..6dfca77a32bdbda34665a9b349ba0f65d990fdd0 100644 (file)
@@ -171,7 +171,7 @@ static int do_merge_diff(const char *first, const char *second,
 
   bool first_stdin = !strcmp(first, "-");
   if (first_stdin) {
-    fd = 0;
+    fd = STDIN_FILENO;
   } else {
     fd = open(first, O_RDONLY);
     if (fd < 0) {