HCP OS File Organization:

	I.  Basic Overview
		A. The FAT consists of a -directory listing-, a -file location- table, and a -file list- table.
		B. The Directories are listed in order of creation and subdirectories of that directory are listed
		   immediately after the directory.
		C. The System supports up to 2^32/6 files and 255 directories/subdirectories in any location.
		D. The ATA System supports hard drives up to 65536 * 16 * 63 * 512 bytes = 31.5 GB. Although if
		   it is upgraded to use a more advanced hard drive access system (newer than ATA) the File System
		   should be able to support 65536 * 256 * 256 * ?512? bytes = at least 2 TB = 2048 GB.
		E. The -file location- table is an index table. Each file has a dword file number. Look up the
		   Cylinder, Head, and Sector of the file number in this table. EX: File 5's entry would be found at
		   offset 8 (see II,B,1&2) + 5 (file) * 6 (2bytes Cyl, 1byte H, 1byte S, word offset) = 38 in the table.
		F. The -file list- table is a list of all files on disk and their info.
		G. Each file has a file # and this acts as an ID & offset for listing the file in directories and in tables
	II. Specifics
		A. Format of directory listing:
			1. dword = length (in bytes) of directory listing (including this dword)
			2. dword reserved (FOR NOW, IGNORE THIS WHOLE FAT IF THIS IS NOT 0)
			3. byte = number of directories
			4. byte reserved
			5. dword = # files in this main directory (/)
			6. [5] dwords for file #'s found in this directory
			7. ? dwords of reserved space for files to be added to this directory (ALL 0'S!!!)
			8. Each directory:
				a. dword = length (in bytes) of the space this directory list takes up (including this dword)
				b. dword reserved (IGNORE THIS DIRECTORY IF THIS IS ANYTHING BUT 0 !)
				c. dword = offset within this directory list of actual list of files/subdirectories
				d. dword = # files in this directory
				e. byte = # subdirectories within this directory
				f. byte = length of this directory's name
				g. [f] bytes = Directory's name
				h. byte = flags (condition applies if flag is set)
					(1. bit7 - this directory and all files, subdirectories, etc. within it are
						   read-only.
					(2. bit6 - User protection present (j applies)(SEE III,B!!!)
					(3. bit5 - Encryption protection present
					(4. bit3 = 0xb
					(5. bit2 - If this and bit6 are set, user list lists users that CANNOT access this
					(6. bit1 - If this and bit6 are set, user list is a list of PRIVELEGE LEVELS that
						   can or cannot access this directory. Bit2 may modify this.
					(7. bit0 = 0xb
				i. byte reserved
				j. byte reserved for steps II,A,8,h,(2 & (3 = number of users that have access to this dir
				k. [j] words = 1 word for each user with access (user #'s)
				l. [d] dwords for file #'s found in this directory
				m. ? dwords of reserved space for files to be added to this directory (ALL 0'S!!!)
				n. [e] subdirectories with the same format as II,A (a directory in the list)
				o. ? bytes of reserved space for subdirectories to be added to this directory (ALL 0'S!!!)
			9. ? byte of reserved space for subdirectories to be added to this directory (ALL 0'S!!!)
		B. Format of file location table
			1. Signature bytes = "HCPF" - IGNORE THE WHOLE FAT IF THIS IS ANYTHING ELSE!
			2. dword = length (in entries!!!) of this table (including reserved entries)
			3. File entries:
				a. word = Cylinder of corresponding file
				b. byte = Head of corresponding file
				c. byte = Sector of corresponding file
				d. word = byte Offset within sector
			4. ? x 6bytes of reserved space for files to be added (should be 0's until occupied)
		C. Format of file list table entries
			1. 12 bytes = File Name (enough to have 8chars, ".", and a 3 bytes extension)
			2. Attribute bytes
				a. byte 0
					(1. bit7 - read-only
					(2. bit6 - User protection (an additional entry is required to list users who have
						   access to this file (see III,B!!!))
					(3. bit5 - Encryption protection present
					(4. bit4 - executable
					(5. bit3 - Requires an extra entry for an extended Filename (see III,B)
					(6. bit2 - If this and bit6 are set, user list lists users that CANNOT access this
					(6. bit1 - If this and bit6 are set, user list is a list of PRIVELEGE LEVELS that
						   can or cannot access this file. Bit2 may modify this.
					(7. bit0 = 0xb
				b. byte 1
					(1. bits7-6 - DPL of this file's Code Segment (IF EXECUTABLE!!) This may require
						      authorization at runtime.
					(2. bits5-0 = 000000xb
			3. 12 bytes: 4 for each: CREATED, MODIFIED, ACCESSED
				a. byte0 = Month
				b. byte1 = Day
				c. word = Year
			4. dword = File length (bytes)
	III.Special Notes
		A. [?], where ? is a wildcard character, refers to the number that would be placed in ?'s location
			EX: In Roman Numeral II,A,6, [5] means that the number of dwords in its location will equal
				the number placed in step 5 in the actual directory.
		B. The file list table will have an entry for each file that currently exists, ? reserved entries,
		   and an additional entry after the blank ones for each entry that requires additional space for
		   a filename or user list.
			1. If both an extended filename and user list are needed, first byte tells #chars the filename
			   needs extended and that many bytes are used (starting immediately after that first byte)
			   to extend the filename. The rest of the bytes are used for a user list.
			2. If only the filename needs extended, no length byte is necessary. Instead the filename
			   is terminated by either a 0 byte or by reaching the end of the entry...
			3. If only the userlist is needed, all bytes are reserved for this and the list of users is
			   terminated in the same way as for filenames in the last step.
			4. VERY USEFUL: Because there may be times when many users need to share access to a file
			   without others or many users need to be blocked while allowing the rest, the following system
			   applies: If the first word in the user list (wherever it starts regardless of whether a file
			   extension is present) is a 0, then all users listed only require a single byte (instead of a 
			   word) for their username. NOTE: Root user will ALWAYS be user 0 and will ALWAYS have access to
			   ALL files!!! Therefore, it is never necessary to list the root user and this 0 condition won't
			   suffer from any possible conflicts with the Root user. If the first two words are BOTH 0's then
			   ONLY the Root user has access to this file...
			5. Therefore, the maximum number of characters that a filename can be is 12 + 30 = 42 chars
			6. Therefore, the maximum number of users that can specifically be given access to or blocked
			   from a user protected file is 28 (30 - null word to indicate user #'s only need bytes)
			7. If bit1 is set, the list lists user levels instead of user #'s and all entries are bytes and
			   the 0 as first word trick (step 4) doesn't apply for obvious reasons. Also, if bit2 is set,
			   the list is a list of user levels that CANNOT access the file/directory.
			8. Keep In Mind: It is a good idea to assign the most priveleged users user #'s within the first
			   255 users so that they can easily be chosen to be included as one of the 28 referred to in 
			   step 4.
			9. Keep In Mind: Super secure files should be encrypted or even double encrypted (encrypt a file
			   using a third party program and then user system encryption on top of that)
		C. Leaving LOW or NO reserve space for additional files/subdirectories will SLOW DOWN the demounting process
		   and the creation of new files/subdirectories A LOT!!! It will, however, make MAXIMUM use of the
		   storage space... Leaving LOTS of reserve space will speed up the demounting and creation of new
		   files/subdirectories, but will make VERY POOR use of storage space. Therefore it is somewhat important
		   to leave just the right amount of reserve space.
		D. If files are written starting from the back of the storage space, it will be easier to expand the FAT
		   because files will not need to be moved.
		E. Every storage device should have 2 FAT systems: 1 normal and 1 backup
		F. ****** The maximum size for a FAT on a floppy is 32KB.
	IV. Idea of Space Necessary for an HCP FAT system
		A. Length of a directory listing = (about) 14+4u+4v+(w^x * (29 + 4u + 4v))+(y^z * (29 + 4v)), where
		   	u represents the average number of files to be located in any directory/subdirectory,
			v represents the avg. number of files have reserved space for within any directory/subdirectory,
			w represents the avg. number of subdirectories to be found within any other directory/subdirectory,
			x represents the avg. number of subdirectories deep a directory will go
			y represents the avg. number of subdirectories to have reserved space for within another dir/subdir
			z represents the avg. number of subdirectories deep a reserved directory/subdir will have reserved.
			1. So, lets fill in some numbers say: u=15,v=5,w=10,x=4,y=5,z=2 and punch in the numbers:
			   14 + 4*15 + 4*5 + (10^4 * (29 + 4*15 + 4*5)) + (5^2 * (29 + 4*5)) = about 1 MB
			2. The example before (step 1) is actually a rather large file system. It would have 150,015 files
			   in 10,000 directories/subdirectories and would have reserve space for 145 new files and
			   25 new subdirectories. Remember, however, that this equation didn't take into account possible
			   space required for a user access/restriction list or directories with names longer than 8 bytes.
			3. A good setup for a floppy disk would have room for 30 directories/subdirectories and 200 files
			   This would require: 30 * 29 + 200 * 4 = 1670 bytes or probably 4 sectors for safety.
		B. Length of a file location table
			1. This is fairly simple - It's size = 8 (signature & length dword) + number_entries * 6
			2. A floppy disk designed with room for 200 files would take up 8 + 200 * 6 = 1208 bytes or
			   about 3 sectors
		C. Length of a file list table
			1. Another simple one - It's size = 30 (size per entry) * number_entries
			2. A floppy disk designed with room for 200 files would take up 30 * 200 = 6000 bytes or
			   about 12 sectors.
			3. This excludes any extra entries that may be necessary for filename extensions or user access
			   lists.
		D. Total length
			1. Simply add the result from A,B, and C above.
			2. The floppy example would take approximately 1670 + 1208 + 6000 = 8878 bytes ~= 18 sectors.
			   But to play it safe, it would be nice to use about 4 + 3 + 12 = 19 or even 20 sectors.