Path: utzoo!mnetor!uunet!cbmvax!daveh From: daveh@cbmvax.UUCP (Dave Haynie) Newsgroups: comp.sys.amiga Subject: Re: Is AmigaDOS sane? Message-ID: <3171@cbmvax.UUCP> Date: 20 Jan 88 20:12:46 GMT References: <30217R38@PSUVM> Organization: Commodore Technology, West Chester, PA Lines: 60 in article <30217R38@PSUVM>, R38@PSUVM.BITNET (aka Marc Rifkin) says: > > First of all, a newly formatted disk does not have even close to '880k', > I know there is usually some overhead used by the DOS, but HOW MUCH? > Also, I have noticed some inconsistencies in block allocation- such as > putting say 600k on a disk and then checking to find close to 100k free. > What is going on here? Newly formatted disk has 2 heads, 80 cylinders/head, and 11 blocks/cylinder available from the trackdisk.device's point of view. That amounts to 2 * 80 * 11 = 1760 blocks. Each block can store 512 bytes, so you get a total of 901,120 bytes, or exactly 880K, of low level storage on each floppy. And blocks are never subdivided, so even if you're not using the whole block, you still pay for it. The DOS does eat some of this as overhead before you do anything. Two blocks are reserved at the beginning of the disk (for Bootblock), plus 1 for ROOT (in the center of the disk) and 1 for bitmap (near the ROOT), leaving 899,072 bytes free. For each subdirectory, you use one block. That's the easy part. Files complicate things a bit. Each file needs a file header block, which takes one block, and generally at least one block for data storage. Each data storage block takes 24 byte for DOS overhead, leaving 488 bytes for the actual data. Each file header stores pointers to 72 data blocks. If there are more than 72 data blocks in a file, an extension block must also be allocated. And if there's more than that, another extension, and so on. So if you know how large a file is in raw bytes, you can figure out how much it'll take to store the thing out on floppy. Something like: BLOCKS = 1 + (RAWSIZE+487)/488 + (RAWSIZE+487)/(488*72) ^ ^ ^ FileBlock DataBlocks ExtensionBlocks The "+487" indicates that even one extra byte must be stored in a new block, assuming integer division above (or the floor() function if not). This implies that if I wanted to make one giant file on a formatted disk, I could store 844728 bytes of data in it, or just under 825K. Of course, if you have no use for a single, 844728 byte file, you may choose to instead store subdirectories and/or multiple files. Still, that's not all that far from 880K. I don't know the level of overhead required in the filesystems of other DOS's, but they don't give you files and directories completely for free, either. The standard overhead in each block is an array of 6 longwords. These blocks contain the checksum for that block (important on floppies, pretty useless on hard drives), various block pointers to parents and children, and often a self-referential pointer. This makes recovery of a disk something that can be done pretty throughly. Like, you can trash every directory on a floppy, and still get back every single file, and even the disk's directory structure. Try that on MS-DOS some day. Excuse any math errors in the above, once you get that Mathematics degree, you have to surrender any and all ability in Arithmetic. > * RAEGIS aka Marc Rifkin * -- Dave Haynie "The B2000 Guy" Commodore-Amiga "The Crew That Never Rests" {ihnp4|uunet|rutgers}!cbmvax!daveh PLINK: D-DAVE H BIX: hazy "I can't relax, 'cause I'm a Boinger!"