[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ProDOS Directory



In article <68a2ec1b.0211050922.6500f48b@posting.google.com>,
Lazarus I. Long <me@lazilong.com> wrote:
>"Charles Claypoole" <Charles.Claypoole@p0.f114.n117.z1.fidonet.org> wrote in message news:<00000bc1@Bungholio.net>...
>> What is the max number of files that can be in a prodos directory?
>
>The root directory of a ProDOS volume maxes out at 51 files.  Why I
>don't know, there is no structural or technical limit necessary, it
>seems arbitrary.
>
>Subdirectories (folders) have no limit.

Many have responded to this question with good answers.  I can not do
better, but I may be able to explain the limits.

A Prodos volume can store 13 entries per directory block (includes volume
directory).  So, the 1st dir block holds the volume entry, plus room for
12 file/subdir entries.  The 2nd and succeeding blocks also have room for
13 entries, but they are all file/subdir entries.

So, the IIe/IIc /RAM disk has ONE directory block (block 2) and can hold
13 entries, the /RAM vol header, and 12 more entries for files or
subdirectories.  Hence, the magical "12" file limit.

A standard ProDOS formatted with Apple's utiliities (the earlier ProDOS
utilities disk, or the later System Utilites disks) format a ProDOS volume
(5.25, 3.5, or 32Meg HD partition) with 4 dir blocks,(blocks 2,3,4,5) each
holding 13 entries.  The 1st block has the volume header entry, and room
for 12 more entries, the rest each have room for 13 subdiror file entries.
So, most ProDOS volumes, have a 4 block volume directory and can hold
12+13+13+13=51 files or subdirs in the root directory.

Subdirs do have a finite limit, but it is rather large.  13 entries/block
and a subdir can grow from seedling to sapling and I presume tree file.
So a sapling file is 256 blocks*13files/block=3328 files and a tree file
is up to 16M, or 32768 blocks * 13 entries/block = 425984 subdirs or files
(this is 3328 * 128, not * 256) (someone else can argue if the limit is
425984 or 851968 files.)  At 851968 entries, the ProDOS volume is full and
there is no room for file data, so there are NO real files on teh volume
:-).  At 425984 files, only the first 32767 files can be one block in
length, the rest 0 bytes; so probably 32768 files is the max for a subdir.

I don't even want to argue form subdirs contain subdir contain subsirs.
The volume can only hold 32768 blocks, and a file needs at least one
block.  So, a ProDOS volume can hold at most 32767 files in whatever
hierarchy ones wants for subdir nesting.

Back to topic, a Prodos volume has a loader in blocks 0 and 1, volume
directory (key block) in blocks 2 ... n, volume bitmap in block n+1 ... p,
and 32768 (max) - p blocks for files.  Even the #entries per block is set
in the volume header key block and does NOT have to 13 (it could be less).
The volume directory can be from 1 to 32768-(2+?blocks), with ?blocks for
the volume bitmap.

So, a ProDOS pgm or utility which assumes 13 entries/block and a 4 block
volume directory is wrong.  It should determine this from the volume
header and not assume the usual 4&13.

ProDOS can 'theoretically' handle larger limits if using file system like
Appleshare.  There, the file limit in root dir is set by HFS, and
Appleshare does NOT have to return 13 entries/block.  I've run across a
few pgms not Appleshare friendly because of their assumptions of 13
entries/block, or a root dir limit of 51 files.  Bad, bad.  Ususally the
first problem is that less than 13 entries mean end of directory, and the
bad pgm will refuse to show more entries.  Tsk, tsk.  (I know why this
happens, because that was Apple's first recommendation on determining end
of directory: less than full number entries in block.  Apple restated the 
rules, but not all programmers followed new rules.)


In summary, 12 files for /RAM, 51 files for /anyp8vol, and 32767 or so
files for subdirs is usual.  But ProDOS file system is flexible and these
limits are easily changed, except for the 32768 block volume size.

Complex answer to simple question.

  --Steve

-- 

 --Steve  (apple2pd@ground.ecn.uiowa.edu)