Re: Creating arbitrary length file using unbuffered IO???

From: Gary G. Little (gglittle.nospam_at_sbcglobal.net)
Date: 08/14/04


Date: Sat, 14 Aug 2004 19:19:40 GMT

Of course you can have an arbitrary file size. However, the media to which
you write any given sized data is constrained to store your data in a
physical representation. If it is an HDD, then you must store your
arbitrarily sized file to a sequence of fixed size sectors on that HDD. You
may create a file containing "REM HELLO WORLD" that only occupies 11 bytes,
and if you look at the file size using DIR or explorer it will say 11 bytes.
However, when you write that to disc it will OCCUPY a minimum of 512 bytes
or the minimum amount of data you can access on typical HDD media. Windows
and NTFS typically group HDD sectors into a cluster, so that 11 byte batch
file will typically occupy SECTOR SIZE times SECTORS per CLUSTER. In a FAT
system on a 1 GIG HDD, that 11 bytes could easily tie up 64K of media space.
Anytime you access that file the minimum you can access is that cluster
size, so in the example given, the disc controller will transfer 64k to and
from memory.

-- 
The personal opinion of
Gary G. Little
"Jean Cyr" <jcyr@online.nospam> wrote in message
news:%23vwVpJZgEHA.1356@TK2MSFTNGP09.phx.gbl...
> Not sure if this group is the appropriate place for this posting but I
could not
> find an more appropriate group.
>
> The Windows SDK docs state that when using unbuffered output the length
> of the buffer to be written must be a multiple of the sector size of the
device
> where the file is being written. Furthermore the buffer must be written
starting
> at an offset in the file that is also a multiple of the sector size. This
> implies that the size of a file thusly created must also be a multiple of
the
> sector size.
>
> I find it hard to accept that an arbitrary size file cannot be created
using
> unbuffered IO! Is that indeed the case, or am I missing something?
>
>
> Jean Cyr
>
> /* Time ain't money when all you got is time. */


Relevant Pages

  • Re: Kaypro Format
    ... Media compatability even between systems using very similar ... >Kaypro disks are indeed numbered from sector 0 to 9. ... I never willingly program floppy systems to produce a sector zero ... development and interchange it was the CP/M exchange media ...
    (comp.os.cpm)
  • Re: SortMerge avoids thrashing (was: Baileys "two pass" FFT algorithm question)
    ... of size that match the backing store to assure locality of reference. ... For RAM backed by disk, the key thing which takes the most time is ... you need to localize sector reads within that one ... Sweeps your RAM once when you load original data from disk. ...
    (comp.programming)
  • Linux Kernel 2.6.5 - Severe Bug(s) With DVD Read Support For Burned DVD-Rs?
    ... hdd: TOSHIBA DVD-ROM SD-M1712, ATAPI CD/DVD-ROM drive ... hdd: media error (bad sector): error=0x30 ... I/O error, dev hdd, sector 8173440 ...
    (Linux-Kernel)
  • Re: XP boot CD
    ... media sets, for the warranty period, and removes it afterwards. ... The second link in that section, talks about burning your own recovery ... you could use the "dd" disk dump command ... in Linux, to do a sector by sector copy of your old hard drive, ...
    (microsoft.public.windowsxp.general)
  • Re: [opensuse] How do I mount a UDF CD?
    ... A client gave me a CD written with a UDF filesystem. ... I/O error, dev sr0, sector 173316 ... good at recovering data from damaged media. ...
    (SuSE)