[Mono-dev] Sparse files

Robert Jordan robertj at gmx.net
Sun Mar 25 16:29:36 EDT 2007


Alan McGovern wrote:
> Hi,
> 
> Not quite, a sparse file is different to a normal file in how allocations
> happen. For example if i wanted to write 1 megabyte at an index of 100
> megabytes, a seek + write would result in a 101 megabyte file on the disk.

The file system will fake a 101 MB file (stat(2) st_size will be 101MB),
but on disk there will be only 1MB allocated (stat(2) st_blocks = 2048).

However, this is only true for "real" Unix file systems. Apple's HFS+
doesn't support sparse file semantics, for example.

Robert

> 
> With a sparse file, there'd actually be 1 megabyte physically taken up on
> disk but any program that tries to read that file would see that 1 megabyte
> existing at an offset of 100 megabytes. (At least that's my 
> understanding of
> it).
> 
> Alan,
> 
> On 3/25/07, Miguel de Icaza <miguel at novell.com> wrote:
>>
>> Hello,
>>
>> > I'm just wondering if there's a cross platform way of creating sparse
>> > files in c#. I was taking a look at the Mono.Unix namespace, but there
>> > doesn't seem to be anything there that'd do it.
>>
>> Not that am aware of.  I imagine that you are using the standard Unix
>> operations to create a sparse file (seek + write).
>>
>> Miguel
>>
>>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list




More information about the Mono-devel-list mailing list