Q2 The Filing Systemq   DWhat is a filing system?d Almost all computer applications need some kind of access to an external storage medium, for example a disk, to save information. The most common reason for this is that the computer does not remember what is in its memory after it has been switched off. Also, some programs may need to use large amounts of data that will not all fit into memory at the same time. To use this external data, some means of accessing it must be provided in order to retrieve or modify existing items and to create new items. The items are refered to as Efilese. A Efiling systeme provides a convenient way of performing these tasks. DWhat about DFS?d Many BBC series computers are fitted with DFS to access disks with. DFS is useful, but suffers from one major limitation. You are only allowed to have 31 files on each disk (62 if you count both sides of a disk). You could use ADFS, but that requires different hardware. HADFS allows you to use the existing DFS hardware and uses a modified DFS-format disk to provide a full hierarchial disk-based filing system. It also provides easy access to cheap hard drives and other large storage devices. DDirectories and subdirectoriesd HADFS is a hierarchial filing system. What this means is that the disk can contain files and directories. Directories are collections of files and can also contain more directories, or subdirectories. The structure is called a 'tree' because it looks like an upside-down tree. Everything starts at the 'root', which, being upside-down, is at the top. ÉÍ» º$º (Root directory) ÈѼ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÁÄÄ¿ ÉÍÍÏÍÍÍ» ÉÍÍÏÍÍÍ» ÉÍÍÍÏÍÍÍ» ÉÍÍÏÍÍ» ³!Boot³ ºExtrasº ºManualº ºLibraryº ºUtilsº ÀÄÄÄÄÄÙ ÈÍÍÍÍÍͼ ÈÍÍÍÍÍͼ ÈÍÍÍÑÍÍͼ ÈÍÍÑÍͼ ³ ³ ÚÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÂÄÄÙ ÚÄÄÄÄÄÄÁÄÄ¿ ÚÄÁÄÄ¿ ÚÄÄÁÄÄ¿ ÚÄÄÁÄÄ¿ ÉÏÍ» ÚÄÄÁÄÄÄ¿ ÚÄÄÄÄÁÄÄÄ¿ ÚÄÄÄÁÄ¿ ÚÄÄÄÁÄÄ¿ ³Copy³ ³Disks³ ³ETree³ ºlpº ³MakeLP³ ³TreeCopy³ ³HEdit³ ³HUtils³ ÀÄÄÄÄÙ ÀÄÄÄÄÄÙ ÀÄÄÄÄÄÙ ÈÑͼ ÀÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÙ ÀÄÄÄÄÄÄÙ ³ ÚÄÄÄÄÄÄÄÂÄÄÄÁÄÄÂÄÄÄÄÄÄÄ¿ ÚÁÄ¿ ÚÄÄÁÄÄ¿ ÚÁÄ¿ ÚÄÄÁÄÄ¿ ³a4³ ³nlqa4³ ³66³ ³nlq66³ ÀÄÄÙ ÀÄÄÄÄÄÙ ÀÄÄÙ ÀÄÄÄÄÄÙ The root directory is called I$i. This diagram, which shows part of the HADFS System disk, shows the root directory containing several sub- directories, IExtrasi, IManuali, ILibraryi and IUtilsi. ILibraryi and IUtilsi in turn each have files and subdirectories of their own. When HADFS is first used, or a B*MOUNTb command is used, the I$i directory becomes the 'Currently Selected Directory', or CSD. When you type B*CATb or B*.b a catalogue of the CSD is displayed. You can also show other directories by giving the B*.b command a directory name, eg: B*CAT Libraryb or B*.Utilsb DMoving around the directory structured For directories to be useful, you have to 'move around' and create new directories. The B*DIRb command is used to change the CSD and move around the directory tree, for example to make the root the CSD, use: B*DIR $b You can use pathnames of any length, eg: B*DIR $.Library.lpb If you want to move back 'up' the directory tree, you use the B^b symbol, pronounced 'up'. Suppose you had set the CSD to I$.Library.lpi using the above command, then B*DIR ^b would move you back to I$.Libraryi. You can also select another disk by starting the pathname with B:b, so for example B*DIR :1b would set the CSD to B$b on drive 1. DCreating directoriesd You can create new directories anywhere on the disk using the B*CDIRb command. As an example B*CDIR $.Utils.Gamesb would create the directory IGamesi inside the IUtilsi directory. If the CSD was already set to I$.Utilsi, you could use B*CDIR Gamesb for the same effect. Once you have created a directory, you can move into it with the B*DIRb command and move back out of it with B*DIR ^b. DWildcardsd A means of abbreviating long names is provided by the 'wildcard' facility. The wildcards are B#b and B*b. The B*b character is used to ignore everything after the position it is used in. For instance B*INFO Let*b would show the information on the first object that started with the letters 'Let'. If would match ILettersi, ILettacei and ILettingsi. The B#b character matches to any character for one position only. For instance B*INFO F##Db would match to IFoodi, IFindi, IFordi or IFredi. It would not match to IFindsi, IFlyi or IFeedingi. DAccess codesd Files and directories have associated with them an access code which descibes what operations can be done on them. These are: D - Directory. This is a directory which may contain more files and directories. R - Read. If this letter is present, the file can be read using LOAD or OPENIN, or can be run using B*RUNb or B*nameb. W - Write. If this letter is absent, the file cannot be written to with OPENOUT. The file can however be overwritten with SAVE. L - Locked. A locked file cannot be deleted or renamed and cannot be overwritten with SAVE. Directories are locked by default. E - Execute. If this option is present, the file can only be run as machine code with B*nameb, B*/nameb or B*RUNb. If the Execute option is set, the Read option is masked out. P - Private. This can make an entry invisible to a user that does not own the directory. By default, the whole disk is owned. Each file has two sets of access codes. The ones to the left of the '/' are the owner's access code, the ones to the right are the public's access codes. In general use, you will only need to be concerned with the owner codes as the entire disk is owned by you. See Chapter 4 for more information. The B*ACCESSb comand allows a file's access code to be changed: B*ACCESS DATA LWRb Allows the file to be read and written with OPEN, but cannot be renamed, deleted or overwritten with SAVE. B*ACCESS PROG WR/Rb Allows the file to be read by anyone, but can be written to with OPEN only by its owner. It can be deleted, overwritten or renamed (only by its owner). The default attributes are BWR/wrb for a file and BLb for a directory. DDeleting, renaming and copyingd When a file is no longer needed, it can be deleted from the disk. This releases the space it used for use by other files. The B*DELETEb command removes a single named entry from a directory; the filename must not have any wildcards in it. For example: B*DELETE Rubbishb You cannot delete a file which has been locked with the 'BLb' access code. To successfully delete such a file, the access must be removed, eg: B*ACCESS datab B*DELETE datab Directories are created locked, and they must also be empty when you delete them. Being able to rename files is very useful, as it can be used not only to change the name of a file, but to move it around the directory structure. The B*RENAMEb command is followed by the old filename, and then the new filename. The command B*RENAME old newb will change the file Ioldi to have the name Inewi. Furthermore, the command B*RENAME test $.Programs.testb actually moves the file Itesti from the CSD to the directory I$.Programsi. You can also change the name of a file while moving it, so B*RENAME OldFile ^.NewFileb will move IOldFilei into the directory above the CSD, and change its name to INewFilei. Directories as well as files can be renamed like this. You cannot use wildcards in the newname part of a B*RENAMEb command and you cannot rename a directory into a subdirectory of itself. The B*COPYb command makes a copy of a file whilst retaining the original. The command is followed by the source filename, and the the destination filename. An example would be: B*COPY ThisFile $.Data.ThatFileb B*COPYb uses as much unused shadow memory as possible to transfer the file and avoids using the program memory. If you want to copy lots of files, or copy files between different disks in the same drive or between different filing systems, the ITreeCopyi program should be used, see Chapter 5. In current versions of HADFS, the B*COPYb command is a transient command in the system ILibraryi directory. DLibrariesd When a B*bcommand is issued, the MOS and sideways ROMs fitted in the computer are searched to find a match. If the command cannot be found there, then it is passed on to the filing system. HADFS looks in the CSD for a file of the name. If it cannot find one, then it looks in the currently selected library directory, the LIB. By default, the LIB is set to a directory called ILibraryi on the default drive or the drive mounted on. To set the CSD to the parent of the current directory. To specify a new library, the B*LIBb command is used, eg: B*LIB $.Utilsb You could set the LIB to be the same as the CSD by using B@b, which refers to the CSD: B*LIB @b DFile and disk informationd HADFS knows more things about each file that is shown in the display given by B*CATb. The B*INFOb command displays this extra information. The result of a B*INFOb command might look like this: BChapter1 FFFFFF00 FFFFFFFF 001B78 WR/WR 28/12/1993 00078Bb The numbers shown are the load address, the execution address and the length, then the access code, date and sector address. There is also a command B*EXb which does a B*INFOb on all the entries in the specified directory. If you use B*INFO $b information about the disk is displayed, for example: B$ 00006400 00015556 000300 DL/ 28/12/1993 000047b The load address is the disk size, the execution address holds the disk flags in the top 16 bits, and the disk ID in the bottom 16 bits, and the date is the date the disk was *INSTALLed. Disks have only a finite amount of space on them. To find out how much space is available, the B*FREEb command is used. A typical display would be: B>*FREE 0001A4 Sectors = 107,520 bytes free 00049C Sectors = 302,808 bytes usedb The first hexadecimal figures are the number of sectors free or used, the decimal number is the space in bytes. DFormatting disksd Before a new disk can be used, it must be formatted. Blank disks are like a blank piece of paper, formatting it is like drawing lines on it. Note that formatting completely erases everything that may be on a disk, so if you accidently format a disk that already has information on it, there is no way to recover its contents. To format an HADFS disk, you use the B*FORMb command, followed by the number of tracks. The most common size is double-sided 80 tracks, making 160 tracks in total, so you would use: B*FORM160 0b to format the disk in drive 0. Before formatting, you are asked to confirm the operation: BFormat drive 0 Go? (Y/N)b You must respond by pressing BYb. Anything else will abort the process. Once a disk has been formatted, it can be used immediately. Freshly formatted disks are Data disks with the title '(Untitled)'. This can be changed using B*TITLEb or B*INSTALLb. If you want the disk to be a system disk, you must copy the IHADFSROMi file into the root directory, or use B*INSTALLb, for example: B*INSTALL 0 $ NewDisk 400Kb This installs the system files onto the disk in drive 0, setting its title to 'NewDisk'. Non-floppy disks, such as hard drives and RAM disks, usually do not need formatting or will be supplied with a program to format them. You then just need to initialise the drive with the B*INSTALLb command. For instance, to install HADFS on a 16M hard disk in drive 4, use: B*INSTALL 4 $ IDEDisk4 16384Kb DAutostartd Sometimes it is useful to make a program automatically start when you first use a disk. This can be done using a file called I!Booti and the B*OPT4b command. This file can be in any directory, but the most common place for it is in the B$b directory. When you log on to a directory using B*I AMb, then the boot option set with B*OPT4b is looked at and the I!Booti file is loaded, run or executed. Pressing Shift-Break is the same as doing B*I AM BOOTb If there is no I$.BOOTi directory, then the I$i directory is logged into. Doing B*I AMb is similar to doing B*MOUNT b then B*DIR b. DChanging disksd An important fact to realise is that HADFS stores some disk information in memory, and that information will stay there even if the disk is removed from the drive. For example, if you take a disk out, and put a different one in the same drive and try to do B*CATb you will get a listing from the previous disk. If you try to write or save anything, or select another directory, a BDisk changedb error will occur. You have to inform the computer that you have changed the disk. You do this using B*BYEb and B*MOUNTb. B*BYEb closes all open files, and then goes into a 'dismounted' state. After using B*BYEb, all disks can be removed and replaced. B*MOUNTb forgets all information, and selects a new drive. If no parameter is given, then the default drive (usually drive 0) is selected. If a drive parameter is given, then that drive is selected. B*BYEb is the same as B*CLOSEb followed by B*MOUNTb. DSpecial charactersd B$b means 'root directory' and points to the top of the directory tree. B^b means 'parent directory' and points to the directory that is the parent of the current one. The parent of the I$i directory is I$i. B%b means 'library directory' and points to the directory set with B*LIBb or the one selected after doing B*MOUNTb, B*BYEb or B*I AMb. B@b means 'current directory', the one selected with B*DIRb. If a command needs a directory and you need to select the CSD, you use this, eg using B*LIB @b makes the library directory the same as the currently selected directory. B:b means 'drive', and is followed by a drive number. Drive numbers can be from 0 to 9, and A to V. DCommands on other systemsd MSDOS disks have a similar directory structure, but the commands to move around it are slightly different. In summary: Operation: BBC MSDOS Show this directory: B*CATb or B*CAT @b BDIRb or BDIR .b Move down a directory: B*DIRb Inamei BCDb Inamei Move up a directory: B*DIR ^ CD ..b Move to another drive: B*DIR :bIdi BCD bIdiB:b To change a disk: B*MOUNTb or B*MOUNTb Idi -C