Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com To: cygwin AT cygwin DOT com From: Eric Blake Subject: Re: cp command - problem with sparse [sparse file support under NTFS (Win2k)] Date: Wed, 2 Feb 2005 17:18:29 +0000 (UTC) Lines: 42 Message-ID: References: <20050202112102 DOT GI7084 AT cygbert DOT vinschen DOT de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet AT sea DOT gmane DOT org X-Gmane-NNTP-Posting-Host: main.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 128.170.36.44 (Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)) X-Gmane-MailScanner: Found to be clean X-Gmane-MailScanner: Found to be clean X-MailScanner-From: goc-cygwin AT m DOT gmane DOT org X-MailScanner-To: cygwin AT cygwin DOT com X-IsSubscribed: yes RE yahoo.de> writes: > > I am not sure whether this is a 128 k problem. I tested with a file that > had 1 MB of data at the beginning and another 1 MB of data at the end. In > between there were some 18 MB of zeroes (checked this with a hex-editor). I did the following test on Win2000 SP4, using cygwin 1.5.12 and coreutils 5.3.0-2 (actually, I strace'd the following calls to more closely track what syscalls were happening). $ dd bs=1 seek=128K of=t < /dev/null 2> /dev/null $ cp --sparse=always t u $ cp u v Since fsutil is not present except on win2003 or XP, I used an alternative method to check whether a file is sparse: opening up Windows explorer, and viewing file properties. For t, the file is 128k and occupies 128k of disk space (t is not sparse), while for u and v, the file is 128k but occupies only 4k of disk space (both are sparse). So `cp --sparse=always' worked for me to create a sparse file when the source was not sparse, and plain `cp' worked to preserve sparseness of an existing sparse file. However, it points out a related bug in cygwin. cp uses lseek() followed by write(), so cygwin made u sparse because the write was at 128k beyond the end of the current file size. But dd uses lseek() followed by ftruncate(), and cygwin just moved the end of the file without checking whether the file should be made sparse. The logic in write() needs to be copied to truncate() and ftruncate() to allow dd to create sparse files in the first place. > > Hope I sent this mail to the correct address now, because I had some > problems with being blacklisted at cygwin.com, at least that's what an > autoresponder told me. You should still reply and attach the cygcheck -svr output, per http://cygwin.com/problems.html, so we can verify if your reported problem stems from using the wrong version of cygwin or coreutils. -- Eric Blake -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/