The PowerFile code provides a filing system for embedded applications. It can be used in conjunction with the PowerNet TCP/IP stack and web server, and with the PowerView embedded GUI. PowerFile was originally developed by CEM Systems Ltd. for use in networked access control systems. This release of PowerFile is distributed under license by MicroProcessor Engineering.
PowerFile is written for the MPE Forth cross compilers, and takes full advantage of the VFX code generator. The use of a 32 bit Forth is assumed. PowerFile provides:
The PowerFile data structures are loosely based on the pSOS pHILE system. All data items except for strings are 32 bit items known as elements.
The media surface is divided into blocks, which usually correspond to disk sectors. The size of these blocks vary depending on the media. Normally each block is 512 bytes long.
Disk blocks are allocated from a volume bitmap, which indicates whether or not the block is available for use. The bitmap is contained in a special file called bitmap.sys.
Each file on the disc is controlled by a File List Descriptor (FLDs). When these entries are read into RAM they are referred to as File Control Blocks (FCBs). All the FLDs are contained in a special file called flist.sys. Each FLD contains data that describes the file's location on the disk
Directories are files which contain records consisting of the file name and a record number in flist.sys. The current directory is called '.' and the next directory level down (closer to the root) is called '..'. The directory separator character is '/' by default. File and directory names have a maximum length of 12 characters including a count byte. A subdirectory is just a special file in a directory.
When the disc is initialised (formatted), the first few blocks are set up and a root directory and the special files are created. The special files are of fixed length.
|
|
Each entry has a size of 16 bytes, so each block of 512 bytes will hold 32 file names.
|
This table is a binary representation of the blocks on the media surface. When a block is defined as used, its state will be changed from a 0 to a 1. This has the file name of bitmap.sys and its size is fixed when the media is initialised, based on the size of the media device in use.
Every file has a file list descriptor record associated with it. They are contained in the special file flist.sys whose size is fixed when the media is initialised. This size is determined by data in the configuration file FSconfig.fth from the maximum number of files and directories that can be held on the media. Each entry is 128 bytes long, and is copied into RAM when the file is opened.
|
Only the two most important structures are described here. All the others can be found in the source code file STRUCTS.FTH.
Every task has a series of Open File Tables, one for every open file it is using. There is a limit to the number of files that a task may have open at the same time.
|
Every open file has a File Control Block (FCB) associated with it. More than one task can have access to the same FCB. The system has a fixed number of FCBs, created at startup of the system. These contain a copy of the FLD for the particular open file to permit access to the data.