Amiga.org
Amiga computer related discussion => Amiga Hardware Issues and discussion => Topic started by: PanterHZ on July 15, 2010, 12:57:29 AM
-
When a file is saved to a FFS formatted floppy disk, it will in addition to the blocks used by the actual file data also use an extra block for the file information. If this information can't fit into a single block, several extension blocks might be used as well.
My question: Is there an easy way to calculate how many extension blocks any given file will use before it is copied to a floppy disk?
-
Assuming 512-byte blocks, and FFS rather than OFS, this C code should give it:
extblocks = (filesize / 512 - 1) / 72;
-
I finally got around to check this out, and yes this seems to work. So thanks a lot ncafferkey :-)
BTW. I wondered about where 72 came from, and after searching a bit on the net, I discovered this:
Files are composed of a file header block, which contains information about the file (size, last access time, data block pointers, etc), and the data blocks, which contain the actual data. The file header block contains up to BSIZE/4-56 data block pointers (which amounts to 72 entries with the usual 512 byte blocks). If a file is larger than that, file extension blocks will be allocated to hold the data block pointers. File extension blocks are organised in a linked list, which starts in the File header block ('extension' field).
Source: http://en.wikipedia.org/wiki/Amiga_Old_File_System
So I guess that with OFS and 488 byte blocks, the following would then be true:
extblocks = (filesize / 488 - 1) / 66;
-
So I guess that with OFS and 488 byte blocks, the following would then be true:
extblocks = (filesize / 488 - 1) / 66;
I think it would still be 72 rather than 66. The 488 vs 512 bytes issue only applies to data blocks AFAIK.