From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,4da5e030e6766a04 X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1994-11-15 12:26:42 PST Newsgroups: comp.unix.osf.osf1 Path: nntp.gmd.de!newsserver.jvnc.net!news.cac.psu.edu!news.pop.psu.edu!hudson.lm.com!godot.cc.duq.edu!news.duke.edu!news.mathworks.com!news.alpha.net!uwm.edu!cs.utexas.edu!newsfeed.rice.edu!rice!news.sesqui.net!uuneo.neosoft.com!nmtigw!peter From: peter@nmti.com (Peter da Silva) Subject: Re: Sparse files take up more space when copied Message-ID: Sender: peter@nmti.com (peter da silva) Organization: Network/development platform support, NMTI References: <3aaj2f$qql@xdm084.ccc.cranfield.ac.uk> Date: Tue, 15 Nov 1994 16:08:01 GMT In article <3aaj2f$qql@xdm084.ccc.cranfield.ac.uk>, Peter Lister wrote: > I tarred the directory and gzip managed 94% compression on the tar > file (yes, that's right, reduced the size by 94%), so these files are > obviously pretty sparse. It would seem that I-DEAS can take advantage > of some pretty good file compression in the OSF1 filesystem when it > writes it's files, but tar,cp,etc don't manage this. My guess is that > I-DEAS uses mmap(3) and that that virtual memory paging writes the file > blocks more efficiently than stream I/O as used by cp, tar, etc. To be precise... if you seek to a point beyond the end of a file then write, blocks between the end of the file and the new seek point will not be allocated until they are written to, and will read as blocks of zeros. A database program will tend to do this, producting what's called a "sparse file". If you write a block of zeros, it will be allocated, so tar and cp and so on will populate a sparse file. The fix is to have a program that seeks (on output) over blocks of zeroes (on input) as it writes. It's not a complex program... I wrote one that does this and also retries reads (I wrote it to recover data from a flakey Xenix disk, originally) but I don't know if I can post it (work stuff). In any case, as I said, it's not a complex program. while(read block) if (block is empty) seek end of file + blocksize else write block -- Peter da Silva `-_-' Network Management Technology Incorporated 'U` 1601 Industrial Blvd. Sugar Land, TX 77478 USA +1 713 274 5180 "Hast Du heute schon Deinen Wolf umarmt?"