[prev in list] [next in list] [prev in thread] [next in thread] 

List:       coreutils-bug
Subject:    bug#59382: cp(1) tries to allocate too much memory if filesystem blocksizes are unusual
From:       Pádraig Brady <P () draigBrady ! com>
Date:       2023-01-02 23:24:01
Message-ID: bffe11e8-202e-ed40-e9ae-874254d6bbe4 () draigBrady ! com
[Download RAW message or body]

On 02/01/2023 23:18, Paul Eggert wrote:
> On 2023-01-02 15:03, Pádraig Brady wrote:
>> On 20/11/2022 03:50, Paul Eggert wrote:
>>> Although we inadvertently removed support for weird devices in 2009 by
>>> commit 55efc5f3ee485b3e31a91c331f07c89aeccc4e89, and nobody seems to
>>> care (because people use dd or whatever to deal with weird devices), I
>>> think it'd be better to limit the fix to regular files. And while we're
>>> at it we might as well resurrect support for weird devices.
>>
>> Paul I'm happy with your patch for this.
>> I've rebased and tweaked the summary and NEWS slightly in the attached.
>>
>> OK for me to apply?
> 
> Sure, that looks good, thanks.

I forgot about documenting the reinstated I/O block size multiple constraint,
which I'll do with the attached.

cheers,
Pádraig

["copy-doc-io-size.patch" (text/x-patch)]

From e01c06fb9c182151d4bbbe90873f79b5b2295245 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pádraig Brady?= <P@draigBrady.com>
Date: Mon, 2 Jan 2023 23:16:07 +0000
Subject: [PATCH] doc: copy: mention the reinstated I/O size constraints

* NEWS: Mention the change in behavior re block size multiples
to support unusual devices with this constraint.
* src/copy.c (copy_reg): Likewise.
---
 NEWS       | 4 ++++
 src/copy.c | 4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 7a655974a..dce09e9ba 100644
--- a/NEWS
+++ b/NEWS
@@ -58,6 +58,10 @@ GNU coreutils NEWS                                    -*- outline -*-
   'cp --reflink=always A B' no longer leaves behind a newly created
   empty file B merely because copy-on-write clones are not supported.

+  cp, mv, and install again read in multiples of the reported block size,
+  to support unusual devices that may have this constraint.
+  [behavior inadvertently changed in coreutils-7.2]
+
   'ls -v' and 'sort -V' go back to sorting ".0" before ".A",
   reverting to the behavior in coreutils-9.0 and earlier.
   This behavior is now documented.
diff --git a/src/copy.c b/src/copy.c
index 1058b08ec..251769300 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -1387,7 +1387,9 @@ copy_reg (char const *src_name, char const *dst_name,
       if (! make_holes)
         {
           /* Compute the least common multiple of the input and output
-             buffer sizes, adjusting for outlandish values.  */
+             buffer sizes, adjusting for outlandish values.
+             Note we read in multiples of the reported block size
+             to support (unusual) devices that have this constraint.  */
           size_t blcm_max = MIN (SIZE_MAX, SSIZE_MAX);
           size_t blcm = buffer_lcm (io_blksize (src_open_sb), buf_size,
                                     blcm_max);
--
2.26.2



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic