Hi, Patch 4 of 5. Juan PREVIOUS OPERATION AND BUGS 1. In file fs/inode.c, in the initialization of the inode list, functions inode_init() and setup_inodes(), pointer "first_inode" is set to NULL and then all inode structures are inserted from there. This results on dereferencing a null pointer, reading and writing to the first memory locations of the kernel data segment, and a corrupt inode list right from the boot. 2. The list always contain all the inode structures. If a structure is removed from the list, it is immediately inserted at the beginning if the inode is free, or at the end if busy. It is unclear whether the inode list should be a linear list or a circular list. Function remove_inode_free() checks if the inode to be removed is the last of the linear list. On the other hand, sync_inodes() walks through the list twice!!? the total of available inodes, obviously only possible with a circular list. 3. Despite ordering free inodes at the beginning of the list, and busy inodes at the end, all functions always walks though the complete list. Function get_empty_inode() even dispenses altogether of the list and looks for a free inode directly from the inode_block[] array. 4. In file arch/i86/drivers/block/doshd.c, the number of floppy and hard drives is needed at several places, and each time it is calculated from the drive_info[] array, wasting time and space. NEW OPERATION 1. Assumed that the inode list is a circular list. Otherwise, fixing the problem would require many modifications to inode.c. Initialization of inode list is fixed and at the same time reducing code size. Also slightly modified some other functions to make them faster and smaller. 2. In file arch/i86/drivers/block/doshd.c the number of drives is saved in variables after being calculated the first time. From then on, they are read from those variables. 3. In file arch/i86/drivers/block/doshd.c, function "bioshd_open()", fixed a mess of conditional compilation statements involving the CONFIG_BLK_DEV_BFD macro. 4. Fixed a bug in printk() function, when printing strings. OTHER CHANGES Modified a misleading comment in file arch/i86/kernel/process.c, suggesting that a syscall might not use more then 3 parameters. Indeed, at least sys_select() requires 5 parameters. Simplified two functions in fs directory to remove unnecesary checks. Code size reduced by 96 bytes. The Image builded without errors. The kernel was tested with QEMU and dioscuri emulators. Also in a PPro pc booting from floppy.
Attachment:
elksR.patch
Description: Binary data