Copyright © Curt Rostenbach
Last month I attempted to teach the basics of the major new concept for the ProDOS operating system, pathnames. This month I will expand on the pathname concept and introduce subdirectories. But first, a review.
In DOS 3.3 (3.21 3.2, 3.1, ...) disks had Volume numbers, files had names, access speed was awful, and disk/file sizes were limited to 140K (400K with expert fudging). For ProDOS, disks have names, you get to a file by giving a path(name), disk access is fast, disk size limit is 32MB (MB=megabyte, a K of Ks, or 1,024 x 1,024 = 1,048,576 bytes) and file size limitation is 16MB.
Obviously, ProDOS will be more at home on larger disk drives, but before going on to those, let’s look at the standard 5 1/4" floppy disk.
For the standard Apple disk drive, the 5 1/4" diskette is organized into 35 concentric storage rings (tracks) and each track is broken into 16 sectors (3.2 and earlier had only 13 sectors per track). Each sector can hold 256 bytes of data. So, in raw numbers, 35 trks x 16 sct/trk = 560 sectors/disk. 560 sct x 256 bytes/sct = 143,360 bytes. 143,360 bytes / 1,024 bytes/K = 140K.
How DOS 3.3 and ProDOS uses that 140K is different, that’s why you have to use CONVERT (in ProDOS) to move between formats. Without going into gory detail (I need something to write about later), here is the basic usage; DOS 3.3 uses the outer 3 tracks to contain a copy of the operating system that is loaded once at bootup. To keep track of the files on a disk, 15 more sectors in the center of the disk are used, and to keep track of which sectors are in use and which are available, 1 more sector on the center track is used. Altogether, DOS 3.3 uses 4 tracks of each disk before we even store any files on it. 4 trks x 16 sct/trk = 64 sct x 256 bytes/ sct = 16,384 bytes / 1,024 bytes/K = 16K. Therefore under DOS 3.3, we can store 124K/disk. Each of the sectors in the "Catalog" track can hold information on 7 files, so 15 x 7 = 105. We can have up to 105 files per disk or one file up to 124K in size (actually in terms of real data, the file is smaller since there are some sectors lost again to housekeeping, but that’s a more involved story).
ProDOS groups 2 sectors together and calls them a "Block" which is 512 bytes in size, a standard (compared to the rest of the computing world) unit of storage. But I will convert all the numbers so we will be comparing sector usage to sector usage, rather than sectors to blocks. ProDOS once again has a more universal method of using a disk. ProDOS uses the first 2 blocks (4 sectors) to contain the boot code. The next 4 blocks (8 sectors) contain what is known as the volume (or root) directory. The next block (2 sectors) is the bitmap (the map of used/unused blocks). So, 14 sectors are required for housekeeping on a ProDOS disk, compared to 64 for DOS 3.3. So under ProDOS, a formatted disk can contain 136.5K. But wait! I didn’t mention where the ProDOS operating system is stored. I didn’t have to because the two parts of ProDOS don’t have to be on a ProDOS formatted disk. ProDOS is treated just like a regular file! And since you generally boot up the operating system just once, you don’t need it sitting on all your data disks. You can use the extra 12.5K for your data files. Speaking of files, 8 sectors are set aside for the volume root directory, each block can contain information on 13 files for a total of 52 files per root directory. Seems we lost some here. Well, enough numbers, now to practicality.
In the management of our 5 1/4" floppy disks under DOS 3.3, we rarely need catalogs that contain 105 filenames. Generally we fill our disks with 10 to 20 files, if that many. Why then, waste sectors in the catalog track? So, having a ProDOS root directory with 52 names in it is not really a restriction, it is a space saver.
So far I haven’t said a thing about subdirectories. For all intents and purposes, you won’t use them on 5 1/4" floppy disks. BUT, they do work there and have some advantages when used properly.
To sneak up on what a subdirectory is and why do we need them, let’s look again at some of the numbers we went through above and some other numbers that were given without the mathematical proof. ProDOS can support files that are 16 megabytes long. Not many of us have drives with that much storage. But time marches on, and so does technology. When I was selling Apple ]['s at the Data Domain of Schaumburg five years ago, I sold 16K models and wondered what people would do in the 48K models, now 64K is standard and 128K expected with some programs. The same is going to happen with disk drives. Macintosh owners are waiting for 512K Mac upgrades, while their disk drives hold only 400K. So you know something bigger has to be in the works. As I’ve also mentioned old DOS 3.3 is not up to the task of supporting these larger devices. Supposing if we had a 5 megabyte Profile (a hard drive for the Apple ///) connected to our Apple ][ and our average file size was 16K, our catalog would be about 320 names long (just imagine the catalog on a 32MB disk, 2000+ !). Even with programs to sort the files to alphabetical order, that’s a lot of names to sift through when looking for a particular file. Besides, alphabetical order may break up related files from being listed together. The solution? You guessed it, SUBDIRECTORIES!
Subdirectories have been likened to branches (hence the references to root directories above) and are the main reason pathnames came to be. From a given directory, which is whatever you see when you catalog a disk, you can create a subdirectory. This subdirectory can contain files just like the directory you normally use. In fact, in ProDOS, a subdirectory can contain as many files as you want (more than the 52 file limit of the root directory). A practical example of a subdirectory, may be DATABASES, or WORDPROCESSING, or that all important GAMES. GAMES are a good example of where you would want sub-subdirectories (and yes, you can have sub-sub-sub-…), such as ARCADE, ADVENTURE, STRATEGY, or SIMULATIONS.
To get to the files we store in a subdirectory, we need to specify our new friend, the pathname. We can specify the complete pathname to a file, or we can set the PREFIX to the pathname that gets us to the subdirectory the file we are interested is in. Let’s suppose a complete disk directory looks like this;
PROFILE (volume name)
| DBMASTER (program)
| DATA.FACTORY (program)
| MAGIC.WINDOW (program)
| APPLEWRITER (program)
| ARCADE (subdirectory)
| | \
| | SPACE.INVADERS (program)
| ADVENTURE (subdirectory)
| ZORK.I (program)
| ZORK.II (program)
| ZORK.III (program)
To run ZORK.I, we could type ‘RUN /PROFILE/GAMES/ADVENTURES/ZORK.I’.
If our PREFIX was /PROFILE, a catalog would look like this (names only),
then to run ZORK.I, ‘RUN GAMES/ADVENTURE/ZORK.I’.
If we set the PREFIX to /PROFILE/GAMES, we would see,
to run ZORK.I., ‘RUN ADVENTURE/ZORK.I’ is necessary.
And if we set PREFIX to /PROFILE/GAMES/ADVENTURE,
to run ZORK.I. ‘RUN ZORK.I’
Note how we used the subdirectory to categorize and cut down the size of the catalog we would be looking at. But, once again, in the 5 1/4" floppy environment, we generally categorize our files by what disk we put them on. Subdirectories are best used on larger storage devices but in some instances can be helpful on the floppies. For the most part, don’t sweat ‘em, just be aware of what they are and how they can be used. They will become important at a later date.
Next month I will start on the new commands of ProDOS.
Last modified 07/05/1998