From unknown Tue Jun 24 15:38:34 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#14618 <14618@debbugs.gnu.org> To: bug#14618 <14618@debbugs.gnu.org> Subject: Status: cp: erroneous sparse copy command results in empty file Reply-To: bug#14618 <14618@debbugs.gnu.org> Date: Tue, 24 Jun 2025 22:38:34 +0000 retitle 14618 cp: erroneous sparse copy command results in empty file reassign 14618 coreutils submitter 14618 Koen De Wit severity 14618 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 14 11:59:09 2013 Received: (at submit) by debbugs.gnu.org; 14 Jun 2013 15:59:09 +0000 Received: from localhost ([127.0.0.1]:44308 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UnWP5-0001pD-UN for submit@debbugs.gnu.org; Fri, 14 Jun 2013 11:59:08 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38796) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UnSJl-00060w-9i for submit@debbugs.gnu.org; Fri, 14 Jun 2013 07:37:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UnSJb-0004K8-SL for submit@debbugs.gnu.org; Fri, 14 Jun 2013 07:37:16 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:60472) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnSJb-0004K2-P7 for submit@debbugs.gnu.org; Fri, 14 Jun 2013 07:37:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnSJV-00036t-1j for bug-coreutils@gnu.org; Fri, 14 Jun 2013 07:37:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UnSJO-0004Dg-OT for bug-coreutils@gnu.org; Fri, 14 Jun 2013 07:37:04 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:41106) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnSJO-0004B0-Ex for bug-coreutils@gnu.org; Fri, 14 Jun 2013 07:36:58 -0400 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r5EBasO6021395 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 14 Jun 2013 11:36:54 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r5EBau6r026010 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 14 Jun 2013 11:36:56 GMT Received: from abhmt116.oracle.com (abhmt116.oracle.com [141.146.116.68]) by userz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r5EBataA011323 for ; Fri, 14 Jun 2013 11:36:55 GMT Received: from [10.175.49.92] (/10.175.49.92) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 14 Jun 2013 04:36:55 -0700 Message-ID: <51BB001F.905@oracle.com> Date: Fri, 14 Jun 2013 13:35:59 +0200 From: Koen De Wit User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20111110 Icedove/3.0.11 MIME-Version: 1.0 To: bug-coreutils@gnu.org Subject: Erroneous sparse copy command results in empty file Content-Type: text/plain; charset=windows-1252; format=flowed X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp1040.oracle.com id r5EBasO6021395 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Fri, 14 Jun 2013 11:59:06 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) When trying to create a sparse copy of a file on a different filesystem=20 you get an "Invalid cross-device link" error, as expected. However, an=20 empty file is created instead of the sparse copy: # mkfs.btrfs -f /dev/sde1 # mkfs.btrfs -f /dev/sde2 # mount /dev/sde1 /mnt/part1 # mount /dev/sde2 /mnt/part2 # echo "abc" > /mnt/part1/testfile # ./cp --reflink /mnt/part1/testfile /mnt/part2/testcopy ./cp: failed to clone =91/mnt/part2/testcopy=92 from =91/mnt/part1/testfi= le=92:=20 Invalid cross-device link # ls -la /mnt/part1/testfile -rw-r--r--. 1 root root 4 Jun 14 14:49 /mnt/part1/testfile # ls -la /mnt/part2/testcopy -rw-r--r--. 1 root root 0 Jun 14 14:49 /mnt/part2/testcopy The same occurs when trying to create a sparse copy on a filesystem that=20 does not support sparse copies: # mkfs.ext3 /dev/sde1 # mount /dev/sde1 /mnt/part1 # echo "abc" > /mnt/part1/testfile # ./cp --reflink /mnt/part1/testfile /mnt/part1/testcopy ./cp: failed to clone =91/mnt/part1/testcopy=92 from =91/mnt/part1/testfi= le=92:=20 Inappropriate ioctl for device # ls -la /mnt/part1 (...) -rw-r--r--. 1 root root 0 Jun 14 14:58 testcopy -rw-r--r--. 1 root root 4 Jun 14 14:58 testfile If creating a sparse copy fails, no file should be created. ln treats this error in the right way: # ln /mnt/part1/testfile /mnt/part2/testlink ln: creating hard link `/mnt/part2/testlink' =3D> `/mnt/part1/testfile':=20 Invalid cross-device link # ls -la /mnt/part2/testlink ls: cannot access /mnt/part2/testlink: No such file or directory Tested with coreutils today's git HEAD and kernel 3.9.5. From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 14 16:04:00 2013 Received: (at 14618) by debbugs.gnu.org; 14 Jun 2013 20:04:00 +0000 Received: from localhost ([127.0.0.1]:44706 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UnaE4-0005XO-4E for submit@debbugs.gnu.org; Fri, 14 Jun 2013 16:04:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6806) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UnaE0-0005XF-Sz for 14618@debbugs.gnu.org; Fri, 14 Jun 2013 16:03:57 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5EK3tkR011757 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 14 Jun 2013 16:03:55 -0400 Received: from [10.36.116.40] (ovpn-116-40.ams2.redhat.com [10.36.116.40]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r5EK3q3M019685 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Fri, 14 Jun 2013 16:03:54 -0400 Message-ID: <51BB7728.7010702@draigBrady.com> Date: Fri, 14 Jun 2013 21:03:52 +0100 From: =?windows-1252?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Koen De Wit Subject: Re: bug#14618: Erroneous sparse copy command results in empty file References: <51BB001F.905@oracle.com> In-Reply-To: <51BB001F.905@oracle.com> X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 14618 Cc: 14618@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) On 06/14/2013 12:35 PM, Koen De Wit wrote: > When trying to create a sparse copy of a file on a different filesystem you get an "Invalid cross-device link" error, as expected. However, an empty file is created instead of the sparse copy: As a side note, sparse copying is a separate thing to reflinking. > # mkfs.btrfs -f /dev/sde1 > # mkfs.btrfs -f /dev/sde2 > # mount /dev/sde1 /mnt/part1 > # mount /dev/sde2 /mnt/part2 > # echo "abc" > /mnt/part1/testfile > # ./cp --reflink /mnt/part1/testfile /mnt/part2/testcopy > ./cp: failed to clone ‘/mnt/part2/testcopy’ from ‘/mnt/part1/testfile’: Invalid cross-device link > # ls -la /mnt/part1/testfile > -rw-r--r--. 1 root root 4 Jun 14 14:49 /mnt/part1/testfile > # ls -la /mnt/part2/testcopy > -rw-r--r--. 1 root root 0 Jun 14 14:49 /mnt/part2/testcopy > > The same occurs when trying to create a sparse copy on a filesystem that does not support sparse copies: > > # mkfs.ext3 /dev/sde1 > # mount /dev/sde1 /mnt/part1 > # echo "abc" > /mnt/part1/testfile > # ./cp --reflink /mnt/part1/testfile /mnt/part1/testcopy > ./cp: failed to clone ‘/mnt/part1/testcopy’ from ‘/mnt/part1/testfile’: Inappropriate ioctl for device > # ls -la /mnt/part1 > (...) > -rw-r--r--. 1 root root 0 Jun 14 14:58 testcopy > -rw-r--r--. 1 root root 4 Jun 14 14:58 testfile > > If creating a sparse copy fails, no file should be created. > > ln treats this error in the right way: > > # ln /mnt/part1/testfile /mnt/part2/testlink > ln: creating hard link `/mnt/part2/testlink' => `/mnt/part1/testfile': Invalid cross-device link > # ls -la /mnt/part2/testlink > ls: cannot access /mnt/part2/testlink: No such file or directory > > Tested with coreutils today's git HEAD and kernel 3.9.5. This was discussed previously: http://lists.gnu.org/archive/html/coreutils/2013-03/msg00056.html Summary of that is that it may be best handled outside of cp. cheers, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 19 12:50:38 2018 Received: (at 14618) by debbugs.gnu.org; 19 Oct 2018 16:50:38 +0000 Received: from localhost ([127.0.0.1]:59709 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gDXyw-0008Q8-LI for submit@debbugs.gnu.org; Fri, 19 Oct 2018 12:50:38 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37036) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gDXyr-0008Pj-Qn; Fri, 19 Oct 2018 12:50:34 -0400 Received: by mail-pf1-f196.google.com with SMTP id j23-v6so16729585pfi.4; Fri, 19 Oct 2018 09:50:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=PRrrp6KDhTeHOgMPkIHxTO1GjxuXHHeU4ff4rLBlngk=; b=dC2xZrywPuPjIMVM+yiq4a4ecOo3u/W/zmlOVcVSmeNn0x9C4JG/66L7IIA4CqcYEh OK5afsqIAbY7FLxHMH2FjCnt6TBy8Ktac6hBkp5wVuf/zRKvh+RlCvMZjz7slmVH9E6F iRKmTxTPssKny8H/k3rU/qO5C1+hl7qHt2fhfuk+wbDxRkmMRTZNVCJiHHR56XvPrq0X X6iol4oO1JiBnxS8HIDlxLLQNilEk+bNcca/JMqk8e3bfnVOqji454yzqOYgv3XBdthz cmEzPpqngf6Z9dnp0nPG8f8IjZKSR9M8Fr+qrQFRctsLVadH+nmMz6f3s2s8K0C3TU6q lz2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=PRrrp6KDhTeHOgMPkIHxTO1GjxuXHHeU4ff4rLBlngk=; b=Wql1kCU2V8vlGpiytRyOGzgp45Xk2ecCyFYwwrYfcS2hw/YY9/OMHKt491e1ITFQC/ cSzXuEmIuODJmtus4mDT+C8y0nv8oILqKhiy7620UR3U+jIp1ytnFRJpSyKE8uQP2968 mH5CwYNux3rnyuQtQQqKWPCM/shzyi46YcDYWNPCU5eAFsSkris90PeCJAp0VCx1FFtf qDsBhibSKT9VsujRoB1Gy1Pwh3V0eyl47+cVWljhbKiegp3dQIBt7Ya8izzGkCUbvmP7 m38+o/2+KyXDY6pZVCFI8g1lYocXNu1XAGHR9Sy0yTrC2BToes5yLTVTp6ffgXDt80d7 eseQ== X-Gm-Message-State: ABuFfoi8cVuriqF5zfQMK0vHTdOeo1NylcvVRP9cS6pvP4LiXmdJXlhQ uWOTCOsqzZzvgumCeo7uxp9BzzoY/24= X-Google-Smtp-Source: ACcGV625VhyWLHvkD/850cv1Ji4Hc2fFFloHyFGH1GT7Bl/UnCFc6QcP8PvDUCMpZohHSsjyer8A7A== X-Received: by 2002:a63:2c4:: with SMTP id 187-v6mr32631121pgc.304.1539967827109; Fri, 19 Oct 2018 09:50:27 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id e189-v6sm9212270pfa.91.2018.10.19.09.50.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Oct 2018 09:50:25 -0700 (PDT) Subject: Re: bug#14618: Erroneous sparse copy command results in empty file To: 14618@debbugs.gnu.org References: <51BB001F.905@oracle.com> <51BB7728.7010702@draigBrady.com> From: Assaf Gordon Message-ID: <20653294-f2c7-52f5-ecea-a13dd34d8e27@gmail.com> Date: Fri, 19 Oct 2018 10:50:24 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <51BB7728.7010702@draigBrady.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 14618 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) retitle 14618 cp: erroneous sparse copy command results in empty file close 14618 stop (triaging old bugs) On 14/06/13 02:03 PM, Pádraig Brady wrote: > On 06/14/2013 12:35 PM, Koen De Wit wrote: >> When trying to create a sparse copy of a file on a different filesystem you get an "Invalid cross-device link" error, as expected. However, an empty file is created instead of the sparse copy: > > This was discussed previously: > http://lists.gnu.org/archive/html/coreutils/2013-03/msg00056.html > Summary of that is that it may be best handled outside of cp. With no further follow-ups in 5 years, I'm closing this bug. -assaf From unknown Tue Jun 24 15:38:34 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 17 Nov 2018 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator