Control: tags 1017558 + patch

Control: tags 1017558 + pending


Dear maintainer,

I've prepared a patch for boost1.74 (versioned as 1.74.0+ds1-21.1) that should 
close 1017558.

The patch fixes a bug with copy_file when copying between devices or 
filesystems by using the fallback copy_write implementation.

This issue has been fixed with >boost1.77 but this patch should fix the issue 
for current version of boost without the need to actually upgrade.


Regards,

Elisei
diff -Nru boost1.74-1.74.0+ds1/debian/changelog boost1.74-1.74.0+ds1/debian/changelog
--- boost1.74-1.74.0+ds1/debian/changelog	2023-05-19 09:24:56.000000000 +0200
+++ boost1.74-1.74.0+ds1/debian/changelog	2024-05-21 09:36:57.000000000 +0200
@@ -1,3 +1,11 @@
+boost1.74 (1.74.0+ds1-21.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fixed copy_file to fallback on copy_write if copy_file_range/sendfile fails.
+    (Closes: #1017558)
+
+ -- Elisei Pogirneata <e.pogirne...@ds-automotion.com>  Tue, 21 May 2024 09:36:57 +0200
+
 boost1.74 (1.74.0+ds1-21) unstable; urgency=medium
 
   [ Andreas Beckmann ]
diff -Nru boost1.74-1.74.0+ds1/debian/patches/fix_copy_file.patch boost1.74-1.74.0+ds1/debian/patches/fix_copy_file.patch
--- boost1.74-1.74.0+ds1/debian/patches/fix_copy_file.patch	1970-01-01 01:00:00.000000000 +0100
+++ boost1.74-1.74.0+ds1/debian/patches/fix_copy_file.patch	2024-05-21 09:36:57.000000000 +0200
@@ -0,0 +1,43 @@
+Index: boost1.74-1.74.0+ds1/libs/filesystem/src/operations.cpp
+===================================================================
+--- boost1.74-1.74.0+ds1.orig/libs/filesystem/src/operations.cpp
++++ boost1.74-1.74.0+ds1/libs/filesystem/src/operations.cpp
+@@ -446,6 +446,14 @@ int copy_file_data_sendfile(int infile,
+       int err = errno;
+       if (err == EINTR)
+         continue;
++
++      if (offset == 0)
++      {
++        // Fallback to read_write implementations if sendfile fails
++        if (err == EINVAL || err == ENOSYS)
++          return copy_file_data_read_write(infile, from_stat, outfile, to_stat);
++      }
++
+       return err;
+     }
+ 
+@@ -481,6 +489,23 @@ int copy_file_data_copy_file_range(int i
+       int err = errno;
+       if (err == EINTR)
+         continue;
++
++        if (offset == 0)
++        {
++          // Use fallback implementations if copy_range fails with any of the errors:
++          if (   err == EINVAL
++              || err == EOPNOTSUPP
++              || err == EXDEV
++              || err == ENOSYS)
++          {
++#if defined(BOOST_FILESYSTEM_USE_SENDFILE)
++            return copy_file_data_sendfile(infile, from_stat, outfile, to_stat);
++#else
++            return copy_file_data_read_write(infile, from_stat, outfile, to_stat);
++#endif
++          }
++        }
++
+       return err;
+     }
+ 
diff -Nru boost1.74-1.74.0+ds1/debian/patches/series boost1.74-1.74.0+ds1/debian/patches/series
--- boost1.74-1.74.0+ds1/debian/patches/series	2023-05-19 09:22:57.000000000 +0200
+++ boost1.74-1.74.0+ds1/debian/patches/series	2024-05-21 09:36:57.000000000 +0200
@@ -27,3 +27,4 @@
 74a94fe7f47b2e3f707cf4589fbb635a50f22ad2.patch
 15.patch
 python-enum.patch
+fix_copy_file.patch

Reply via email to