This is the mail archive of the
mailing list for the Cygwin project.
Re: Sparse file criteria malfunction - binutils produces sparse .exe & .dll files
On Wed, Jun 04, 2003 at 05:33:46PM +0200, Markus Mauhart wrote:
> Now it has been proven that each cygwin installation manipulating 1000s of
> files only suffers from this "feature"; not to mention that it breaks
> winfile.exe :-(((.
The next Cygwin version will produce sparse files only if the application
decides to write 64K or more beyond EOF.
> If this (my) interpretation of SetFileValidData() is correct, wouldnt
> then SetFileValidData() do exactly what people can expect from
> 'traditional unix sparse files' (except XP beeing secure) ?
No, the function just tells the OS not to overwrite the hole with 0.
But that's a security problem, in contrast of not having allocated
blocks at all for that hole. Cygwin has special code which does exactly
that, writing 0 into all blocks in the hole on 9x/Me. Funny, but in
9x/Me this is a bug. The SetFileValidData() function converts this
into a performance gain.
> Otherwise, has anyone of the cygwin-is-sparse proponents the information
> whether 'traditional unix sparse files' support unallocated holes inside
> files ? If yes, since when ?
I don't know since when but a simple application helps to show that Linux
supports sparseness "just so":
main(int argc, char **argv)
off_t seek = 184;
struct stat st;
if (argc > 1 && atol (argv) > 0)
seek = atol (argv);
printf ("Creating file of size %luK\n", seek + 8);
int fd = open ("sparse.test", O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (fd < 0)
printf ("open failed: %d \"%s\"\n", errno, strerror(errno));
// Write first block
memset (buf, 1, 4096);
write (fd, buf, 4096);
lseek (fd, seek * 1024, SEEK_CUR);
// Write second block
memset (buf, 2, 4096);
write (fd, buf, 4096);
// Print size values
if (!fstat (fd, &st))
printf ("st_size : %10lu\n", st.st_size);
printf ("st_blocks: %10lu\n", st.st_blocks);
$ gcc -o sp sp.c
$ ./sp 200
Creating file of size 208K
st_size : 212992
$ ./sp 2000
Creating file of size 2008K
st_size : 2056192
$ ls -sl sparse.test
12 -rw-r--r-- 1 corinna users 2056192 Jun 5 13:54 sparse.test
> If no, how is the security of reusing other
> peoples not-overwritten clusters handled ?
Security isn't affected. Unused blocks are never written or allocated.
As soon as a block is coming into use, it's overwritten, that's it.
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:email@example.com
Red Hat, Inc.
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html