summaryrefslogtreecommitdiff
path: root/kernel/fs/block.c
AgeCommit message (Collapse)Author
2018-12-23Corrected a bug in the hard-disk driver where calls to hd_read_block()Jake Mannens
after hd_init() failed (on a system without a disk), would hang. Now, hd_read_block() will fail if no hard disk is present on the system (as indicated by the nblocks count being equal to zero). The same fix also applies to the hd_write_block() function. The hd_init() function now returns a status indicating either successful drive detection and initialization, or failure. This return status won't likely be needed due to the above bug-fix, but may prove useful in the future. Added framework for a block buffer subsystem. This subsystem uses pre-allocated memory to cache blocks that are requested from the block device subsystem. Cached blocks are stored on a linked list sorted in order of usage frequency. Modified the block read/write functions so that they no longer accept a length parameter. The block I/O functions will only read or write a single block at a time. If multiple blocks are required, multiple calls will have to be made. This is to reduce complexity of block device drivers and make integration with the new buffer subsystem easier. Removed all calls to the ATA hard-disk driver. For now, it seems that floppy media will be best as it allows for real-world hardware testing. Furthermore, large portions of the hard-disk driver will need to be re-written anyway once the block buffer subsystem is complete as it only supports PIO transfers, whilst a buffer system will require DMA transfers. As the hard-disk was previously the only supported block device, the block device read/write functions will now always fail, returning -1.
2018-09-09Re-ordered system call numbers and definitions into alphabetical orderJake Mannens
to make management/maintenance easier. Defined the structures super_block and m_inode in kernel/fs.h for super blocks and inodes respectively. Added the new header file sys/stat.h which contains basic definitions for inode types and permissions. These definitions will be required by any functions handling m_inode structures. Moved the sys_read and sys_write system calls to the filesystem's main source file at kernel/fs/fs.c. Added the file kernel/fs/mount.c which will contain the super-blocks table as well as the function mount_root() which will attempt to mount the root filesystem during boot. Eventually, this file will be expanded to include a general-purpose mount function to mount any filesystem as well as the system call handler for sys_mount. Seperated block I/O functions into their own subsystem under kernel/fs/block.c which currently supports two functions; block_read() and block_write() to read and write blocks from block devices. Currently, no device can be specified since the primary ATA master drive is the only possible target. This will change in the future however. Modified the hard disk driver's read and write functions to use filesystem blocks rather than sectors as the units of transfer. This is intended to keep the block I/O subsystem simple by ensuring a uniform transfer unit is used across all block devices and drivers. The hard disk driver is no longer initialized during the main boot procedure. Instead, a call is made to the new function fs_init() which will setup filesystem tables and structures, call hd_init() to initialize the disk and finally, attempt to load the super-block for the root filesystem. The hard disk driver now stores the disk's size and sanity checks addresses and sizes in read and write calls against this value.