Subj : Re: Block based virtual harddisk library To : comp.programming From : Steve O'Hara-Smith Date : Thu Sep 15 2005 06:02 pm On 15 Sep 2005 08:38:29 -0700 M.Barren@gmail.com wrote: > Hi, > > I'm trying to implement a library that will provide API to access a > file as if it is a harddisk with a fixed capacity of 281474976710656 > (max. of 48bit uint) blocks of specific size (eg. 100B-4KB). The access > to the virtual disk is block based (not byte based). > > Since the size of this virtual disk is beyond the phyisical limit of my > disk, I can only afford to save the useful data (eg. non-zero) to an > actual file (container) on disk. You don't mention what platform you are doing this on - some platforms (eg unix family) do not store unwritten blocks so you can just lseek to the required offset and read or write your blocks without worrying about it. You will always get zeroes back for reads up to the highest block written and EOF after that - to make this behaviour uniform you can write a block of zeroes at the end of the virtual disc as an initialisation operation. -- C:>WIN | Directable Mirror Arrays The computer obeys and wins. | A better way to focus the sun You lose and Bill collects. | licences available see | http://www.sohara.org/ .