From 2cefd9441c2524db5f7d709a9e7f3be3d9c32e28 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 21 Jun 2005 22:00:00 -0400 Subject: [PATCH] Import backup from 2005-06-21 --- kernel/Makefile | 30 ++++++++------ kernel/Makefile.bak | 28 +++++++------ kernel/fs/FileSystem.cpp | 19 +++++++++ kernel/fs/FileSystem.h | 36 +++++++++++++++++ kernel/fs/VFSMount.cpp | 35 ++++++++++++++++ kernel/fs/VFSMount.h | 29 +++++++++++++ kernel/fs/devices_old.c | 72 --------------------------------- kernel/fs/devices_old.h | 41 ------------------- kernel/fs/{ => ext2}/ext2.cpp | 0 kernel/fs/{ => ext2}/ext2.h | 2 +- kernel/fs/{ => ext2}/ext2_old.c | 0 kernel/fs/{ => ext2}/ext2_old.h | 0 kernel/fs/vfs.cpp | 34 ++-------------- kernel/fs/vfs.h | 39 +----------------- kernel/kernel.c | 2 +- 15 files changed, 160 insertions(+), 207 deletions(-) create mode 100644 kernel/fs/FileSystem.cpp create mode 100644 kernel/fs/FileSystem.h create mode 100644 kernel/fs/VFSMount.cpp create mode 100644 kernel/fs/VFSMount.h delete mode 100644 kernel/fs/devices_old.c delete mode 100644 kernel/fs/devices_old.h rename kernel/fs/{ => ext2}/ext2.cpp (100%) rename kernel/fs/{ => ext2}/ext2.h (99%) rename kernel/fs/{ => ext2}/ext2_old.c (100%) rename kernel/fs/{ => ext2}/ext2_old.h (100%) diff --git a/kernel/Makefile b/kernel/Makefile index ccf42b9..7bc1b40 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -18,12 +18,17 @@ LD=ld LDFLAGS=-nodefaultlibs -nostdlib --no-demangle -T link.ld # Files -OBJS=boot.o kernel.o lang/lang_a.o mm/mm.o mm/vmm.o lang/conv.o \ - display/kout.o char/vconsole.o display/display.o devices.o \ - sys/pic.o char/keyboard.o block/ramdisk.o fs/vfs.o \ - lang/lang.o lang/string.o lang/new.o fs/ext2.o char/misc_char.o -CSRC=kernel.c mm/mm.c mm/vmm.c lang/conv.c display/kout.c display/display.c sys/pic.c char/keyboard.c lang/lang.c -CXXSRC=lang/string.cpp lang/new.cpp fs/vfs.cpp fs/ext2.cpp char/misc_char.cpp block/ramdisk.cpp char/vconsole.cpp devices.cpp +OBJS=boot.o lang/lang_a.o \ + kernel.o mm/mm.o mm/vmm.o lang/conv.o display/kout.o display/display.o \ + sys/pic.o char/keyboard.o lang/lang.o \ + lang/string.o lang/new.o char/misc_char.o char/vconsole.o \ + devices.o block/ramdisk.o fs/vfs.o fs/FileSystem.o fs/VFSMount.o \ + fs/ext2/ext2.o +CSRC=kernel.c mm/mm.c mm/vmm.c lang/conv.c display/kout.c display/display.c \ + sys/pic.c char/keyboard.c lang/lang.c +CXXSRC=lang/string.cpp lang/new.cpp char/misc_char.cpp char/vconsole.cpp \ + block/ramdisk.cpp devices.cpp fs/vfs.cpp fs/FileSystem.o fs/VFSMount.o \ + fs/ext2/ext2.cpp .PHONY: all depend clean html @@ -55,7 +60,7 @@ html: kernel.o: kernel.h hos_defines.h multiboot.h module.h lang/lang.h functions.h kernel.o: sys/io.h mm/mm.h mm/vmm.h lang/conv.h devices.h display/display.h kernel.o: display/kout.h sys/pic.h char/keyboard.h block/ramdisk.h fs/vfs.h -kernel.o: fs/ext2.h fs/vfs.h +kernel.o: fs/ext2/ext2.h mm/mm.o: kernel.h hos_defines.h multiboot.h mm/mm.h mm/vmm.o: hos_defines.h kernel.h multiboot.h mm/vmm.h lang/lang.h mm/mm.h lang/conv.o: lang/conv.h hos_defines.h @@ -70,14 +75,15 @@ char/keyboard.o: lang/conv.h display/kout.h display/display.h devices.h lang/lang.o: lang/lang.h hos_defines.h lang/string.o: lang/string.h lang/lang.h hos_defines.h lang/new.o: hos_defines.h mm/vmm.h multiboot.h -fs/vfs.o: hos_defines.h display/kout.h fs/vfs.h fs/ext2.h lang/vector.h -fs/vfs.o: lang/string.h devices.h -fs/ext2.o: fs/ext2.h fs/vfs.h char/misc_char.o: hos_defines.h devices.h char/misc_char.h sys/io.h -block/ramdisk.o: functions.h hos_defines.h sys/io.h mm/vmm.h multiboot.h -block/ramdisk.o: lang/lang.h block/ramdisk.h devices.h char/vconsole.o: hos_defines.h mm/vmm.h multiboot.h lang/lang.h char/vconsole.o: display/display.h devices.h functions.h sys/io.h char/vconsole.o: char/vconsole.h +block/ramdisk.o: functions.h hos_defines.h sys/io.h mm/vmm.h multiboot.h +block/ramdisk.o: lang/lang.h block/ramdisk.h devices.h devices.o: hos_defines.h devices.h char/misc_char.h char/misc_char.h devices.o: char/vconsole.h block/ramdisk.h +fs/vfs.o: hos_defines.h display/kout.h fs/vfs.h devices.h lang/string.h +fs/vfs.o: fs/ext2/ext2.h fs/vfs.h lang/vector.h +fs/ext2/ext2.o: display/kout.h hos_defines.h fs/ext2/ext2.h fs/vfs.h +fs/ext2/ext2.o: devices.h diff --git a/kernel/Makefile.bak b/kernel/Makefile.bak index ccf42b9..cab05d8 100644 --- a/kernel/Makefile.bak +++ b/kernel/Makefile.bak @@ -18,12 +18,15 @@ LD=ld LDFLAGS=-nodefaultlibs -nostdlib --no-demangle -T link.ld # Files -OBJS=boot.o kernel.o lang/lang_a.o mm/mm.o mm/vmm.o lang/conv.o \ - display/kout.o char/vconsole.o display/display.o devices.o \ - sys/pic.o char/keyboard.o block/ramdisk.o fs/vfs.o \ - lang/lang.o lang/string.o lang/new.o fs/ext2.o char/misc_char.o -CSRC=kernel.c mm/mm.c mm/vmm.c lang/conv.c display/kout.c display/display.c sys/pic.c char/keyboard.c lang/lang.c -CXXSRC=lang/string.cpp lang/new.cpp fs/vfs.cpp fs/ext2.cpp char/misc_char.cpp block/ramdisk.cpp char/vconsole.cpp devices.cpp +OBJS=boot.o lang/lang_a.o \ + kernel.o mm/mm.o mm/vmm.o lang/conv.o display/kout.o display/display.o \ + sys/pic.o char/keyboard.o lang/lang.o \ + lang/string.o lang/new.o char/misc_char.o char/vconsole.o \ + devices.o block/ramdisk.o fs/vfs.o fs/ext2/ext2.o +CSRC=kernel.c mm/mm.c mm/vmm.c lang/conv.c display/kout.c display/display.c \ + sys/pic.c char/keyboard.c lang/lang.c +CXXSRC=lang/string.cpp lang/new.cpp char/misc_char.cpp char/vconsole.cpp \ + block/ramdisk.cpp devices.cpp fs/vfs.cpp fs/ext2/ext2.cpp .PHONY: all depend clean html @@ -55,7 +58,7 @@ html: kernel.o: kernel.h hos_defines.h multiboot.h module.h lang/lang.h functions.h kernel.o: sys/io.h mm/mm.h mm/vmm.h lang/conv.h devices.h display/display.h kernel.o: display/kout.h sys/pic.h char/keyboard.h block/ramdisk.h fs/vfs.h -kernel.o: fs/ext2.h fs/vfs.h +kernel.o: fs/ext2/ext2.h mm/mm.o: kernel.h hos_defines.h multiboot.h mm/mm.h mm/vmm.o: hos_defines.h kernel.h multiboot.h mm/vmm.h lang/lang.h mm/mm.h lang/conv.o: lang/conv.h hos_defines.h @@ -70,14 +73,15 @@ char/keyboard.o: lang/conv.h display/kout.h display/display.h devices.h lang/lang.o: lang/lang.h hos_defines.h lang/string.o: lang/string.h lang/lang.h hos_defines.h lang/new.o: hos_defines.h mm/vmm.h multiboot.h -fs/vfs.o: hos_defines.h display/kout.h fs/vfs.h fs/ext2.h lang/vector.h -fs/vfs.o: lang/string.h devices.h -fs/ext2.o: fs/ext2.h fs/vfs.h char/misc_char.o: hos_defines.h devices.h char/misc_char.h sys/io.h -block/ramdisk.o: functions.h hos_defines.h sys/io.h mm/vmm.h multiboot.h -block/ramdisk.o: lang/lang.h block/ramdisk.h devices.h char/vconsole.o: hos_defines.h mm/vmm.h multiboot.h lang/lang.h char/vconsole.o: display/display.h devices.h functions.h sys/io.h char/vconsole.o: char/vconsole.h +block/ramdisk.o: functions.h hos_defines.h sys/io.h mm/vmm.h multiboot.h +block/ramdisk.o: lang/lang.h block/ramdisk.h devices.h devices.o: hos_defines.h devices.h char/misc_char.h char/misc_char.h devices.o: char/vconsole.h block/ramdisk.h +fs/vfs.o: hos_defines.h display/kout.h fs/vfs.h devices.h lang/string.h +fs/vfs.o: fs/ext2/ext2.h lang/vector.h +fs/ext2/ext2.o: display/kout.h hos_defines.h fs/ext2/ext2.h fs/vfs.h +fs/ext2/ext2.o: devices.h lang/string.h diff --git a/kernel/fs/FileSystem.cpp b/kernel/fs/FileSystem.cpp new file mode 100644 index 0000000..67e961c --- /dev/null +++ b/kernel/fs/FileSystem.cpp @@ -0,0 +1,19 @@ +// FileSystem.cpp +// Virtual file system subsystem for HOS +// Author: Josh Holtrop +// Date: 06/21/05 +// Modified: 06/21/05 + +#include "FileSystem.h" +#include "hos_defines.h" + +FileSystem::FileSystem() {myError = -10278;} +FileSystem::~FileSystem() {} +u32_t FileSystem::totalBlocks(){return 0;} +u32_t FileSystem::usedBlocks(){return 0;}; +u32_t FileSystem::freeBlocks(){return 0;}; +u32_t FileSystem::totalInodes(){return 0;}; +u32_t FileSystem::usedInodes(){return 0;}; +u32_t FileSystem::freeInodes(){return 0;}; +u32_t FileSystem::getRootInodeNumber(){return 0;}; +int FileSystem::check(){return myError;}; diff --git a/kernel/fs/FileSystem.h b/kernel/fs/FileSystem.h new file mode 100644 index 0000000..0b1fdf9 --- /dev/null +++ b/kernel/fs/FileSystem.h @@ -0,0 +1,36 @@ +// FileSystem.h +// Virtual file system subsystem for HOS +// Author: Josh Holtrop +// Date: 06/21/05 +// Modified: 06/21/05 + +#ifndef __HOS_FILESYSTEM__ +#define __HOS_FILESYSTEM__ __HOS_FILESYSTEM__ + +#include "devices.h" +#include "hos_defines.h" + +class FileSystem +{ +protected: + int myError; + device_t myDevice; +public: + FileSystem(); + FileSystem(device_t dev); + virtual ~FileSystem(); + + virtual u32_t totalBlocks(); /* 512 byte blocks */ + virtual u32_t usedBlocks(); + virtual u32_t freeBlocks(); + + virtual u32_t totalInodes(); + virtual u32_t usedInodes(); + virtual u32_t freeInodes(); + + virtual u32_t getRootInodeNumber(); + + virtual int check(); +}; + +#endif diff --git a/kernel/fs/VFSMount.cpp b/kernel/fs/VFSMount.cpp new file mode 100644 index 0000000..7631f6d --- /dev/null +++ b/kernel/fs/VFSMount.cpp @@ -0,0 +1,35 @@ +// VFSMount.cpp +// Virtual file system subsystem for HOS +// Author: Josh Holtrop +// Date: 06/21/05 +// Modified: 06/21/05 + +extern "C" { +#include "display/kout.h" +} + +#include "VFSMount.h" +#include "hos_defines.h" +#include "devices.h" +#include "lang/string.h" +#include "fs/vfs.h" + +VFSMount::VFSMount(device_t dev, FileSystem *fs, string mountPoint, inode_num_t mountInode) +{ + myDev = dev; + myFS = fs; + myRefs = 0; + myMountPoint = mountPoint; + myMountInode = mountInode; +} + +VFSMount::~VFSMount() +{ + if (myFS) + { + delete myFS; + if (myRefs) + kprintf("Filesystem uncleanly mounted from %s\n", myMountPoint.data()); + } +} + diff --git a/kernel/fs/VFSMount.h b/kernel/fs/VFSMount.h new file mode 100644 index 0000000..c34e9ac --- /dev/null +++ b/kernel/fs/VFSMount.h @@ -0,0 +1,29 @@ +// VFSMount.h +// Virtual file system subsystem for HOS +// Author: Josh Holtrop +// Date: 06/21/05 +// Modified: 06/21/05 + +#ifndef __HOS_VFSMOUNT__ +#define __HOS_VFSMOUNT__ __HOS_VFSMOUNT__ + +#include "lang/string.h" +#include "devices.h" +#include "FileSystem.h" +#include "fs/vfs.h" + +class VFSMount +{ +protected: + device_t myDev; + FileSystem *myFS; + int myRefs; + string myMountPoint; + inode_num_t myMountInode; + +public: + VFSMount(device_t dev, FileSystem *fs, string mountPoint, inode_num_t mountInode); + ~VFSMount(); +}; + +#endif diff --git a/kernel/fs/devices_old.c b/kernel/fs/devices_old.c deleted file mode 100644 index 2a97f62..0000000 --- a/kernel/fs/devices_old.c +++ /dev/null @@ -1,72 +0,0 @@ -// devices.c -// Author: Josh Holtrop -// Date: 08/02/04 -// Modified: 08/16/04 - - -#include "fs/devices.h" -#include "kernel.h" -#include "char/parallel.h" -#include "char/vconsole.h" -#include "block/ramdisk.h" - -dev_driver_t *drivers[2][256]; - - -// initialization routine for devices subsystem -void devices_init() -{ - parallel_init(MAJORC_PARALLEL); - vconsole_init(MAJORC_VCONSOLE); - ramdisk_init(MAJORB_RAMDISK); -} - - -int devices_register_major(char type, major_t major, dev_driver_t *dev) -{ - int idx; - if (type == 'b') - idx = 0; - else if (type == 'c') - idx = 1; - else - return -1; - if (drivers[idx][major]) - return -2; //driver already registered - drivers[idx][major] = dev; - return 0; -} - - -int block_read(major_t major, minor_t minor, u32_t blockStart, u32_t blocks, void *buffer) -{ - if (drivers[0][major] && drivers[0][major]->block_read) - return drivers[0][major]->block_read(minor, blockStart, blocks, buffer); - return INT_MIN; -} - - -int block_write(major_t major, minor_t minor, u32_t blockStart, u32_t blocks, void *buffer) -{ - if (drivers[0][major] && drivers[0][major]->block_write) - return drivers[0][major]->block_write(minor, blockStart, blocks, buffer); - return INT_MIN; -} - - -int char_read(major_t major, minor_t minor) -{ - if (drivers[1][major] && drivers[1][major]->char_read) - return drivers[1][major]->char_read(minor); - return INT_MIN; -} - - -int char_write(major_t major, minor_t minor, int c) -{ - if (drivers[1][major] && drivers[1][major]->char_write) - return drivers[1][major]->char_write(minor, c); - return INT_MIN; -} - - diff --git a/kernel/fs/devices_old.h b/kernel/fs/devices_old.h deleted file mode 100644 index 6020d97..0000000 --- a/kernel/fs/devices_old.h +++ /dev/null @@ -1,41 +0,0 @@ -// devices.h -// Author: Josh Holtrop -// Date: 08/02/04 -// Modified: 08/22/04 - -#ifndef __HOS_DEVICES_H__ -#define __HOS_DEVICES_H__ __HOS_DEVICES_H__ - -#include "hos_defines.h" - -#define MAJORC_VCONSOLE 4 -#define MAJORC_PARALLEL 6 -#define MAJORC_KEYBOARD 11 - -#define MAJORB_RAMDISK 1 - -#define BLOCK_SIZE 512 -#define BLOCK_SIZE_LOG 9 - -typedef short major_t; -typedef short minor_t; -typedef unsigned int device_t; - -typedef struct { - int (*block_read)(minor_t minor, u32_t blockStart, u32_t blocks, void *buffer); - int (*block_write)(minor_t minor, u32_t blockStart, u32_t blocks, void *buffer); - int (*char_read)(minor_t minor); - int (*char_write)(minor_t minor, int c); -} dev_driver_t; - -void devices_init(); -int devices_register_major(char type, major_t major, dev_driver_t *dev); - -int block_read(major_t major, minor_t minor, u32_t blockStart, u32_t blocks, void *buffer); -int block_write(major_t major, minor_t minor, u32_t blockStart, u32_t blocks, void *buffer); -int char_read(major_t major, minor_t minor); -int char_write(major_t major, minor_t minor, int c); - - -#endif - diff --git a/kernel/fs/ext2.cpp b/kernel/fs/ext2/ext2.cpp similarity index 100% rename from kernel/fs/ext2.cpp rename to kernel/fs/ext2/ext2.cpp diff --git a/kernel/fs/ext2.h b/kernel/fs/ext2/ext2.h similarity index 99% rename from kernel/fs/ext2.h rename to kernel/fs/ext2/ext2.h index 6187960..184a4e5 100644 --- a/kernel/fs/ext2.h +++ b/kernel/fs/ext2/ext2.h @@ -59,7 +59,7 @@ #define EXT2_FT_SYMLINK 7 #define EXT2_FT_MAX 8 -#include "vfs.h" +#include "fs/vfs.h" typedef struct { diff --git a/kernel/fs/ext2_old.c b/kernel/fs/ext2/ext2_old.c similarity index 100% rename from kernel/fs/ext2_old.c rename to kernel/fs/ext2/ext2_old.c diff --git a/kernel/fs/ext2_old.h b/kernel/fs/ext2/ext2_old.h similarity index 100% rename from kernel/fs/ext2_old.h rename to kernel/fs/ext2/ext2_old.h diff --git a/kernel/fs/vfs.cpp b/kernel/fs/vfs.cpp index 7cb51da..8407827 100644 --- a/kernel/fs/vfs.cpp +++ b/kernel/fs/vfs.cpp @@ -12,7 +12,9 @@ extern "C" { } #include "vfs.h" -#include "ext2.h" +#include "fs/FileSystem.h" +#include "fs/VFSMount.h" +#include "fs/ext2/ext2.h" #include "lang/vector.h" #include "lang/string.h" #include "devices.h" @@ -69,33 +71,3 @@ FileSystem *vfs_attempt_mount(device_t device, int fsType) return fs; } -VFSMount::VFSMount(device_t dev, FileSystem *fs, string mountPoint, inode_num_t mountInode) -{ - myDev = dev; - myFS = fs; - myRefs = 0; - myMountPoint = mountPoint; - myMountInode = mountInode; -} - -VFSMount::~VFSMount() -{ - if (myFS) - { - delete myFS; - if (myRefs) - kprintf("Filesystem uncleanly mounted from %s\n", myMountPoint.data()); - } -} - -FileSystem::FileSystem() {myError = -10278;} -FileSystem::~FileSystem() {} -u32_t FileSystem::totalBlocks(){return 0;} -u32_t FileSystem::usedBlocks(){return 0;}; -u32_t FileSystem::freeBlocks(){return 0;}; -u32_t FileSystem::totalInodes(){return 0;}; -u32_t FileSystem::usedInodes(){return 0;}; -u32_t FileSystem::freeInodes(){return 0;}; -u32_t FileSystem::getRootInodeNumber(){return 0;}; -int FileSystem::check(){return myError;}; - diff --git a/kernel/fs/vfs.h b/kernel/fs/vfs.h index 2fe4c51..1b52c37 100644 --- a/kernel/fs/vfs.h +++ b/kernel/fs/vfs.h @@ -50,43 +50,8 @@ int vfs_mount(device_t device, int fsType, char *mountPoint); } #include "lang/string.h" - -class FileSystem -{ -protected: - int myError; - device_t myDevice; -public: - FileSystem(); - FileSystem(device_t dev); - virtual ~FileSystem(); - - virtual u32_t totalBlocks(); /* 512 byte blocks */ - virtual u32_t usedBlocks(); - virtual u32_t freeBlocks(); - - virtual u32_t totalInodes(); - virtual u32_t usedInodes(); - virtual u32_t freeInodes(); - - virtual u32_t getRootInodeNumber(); - - virtual int check(); -}; - -class VFSMount -{ -protected: - device_t myDev; - FileSystem *myFS; - int myRefs; - string myMountPoint; - inode_num_t myMountInode; - -public: - VFSMount(device_t dev, FileSystem *fs, string mountPoint, inode_num_t mountInode); - ~VFSMount(); -}; +#include "fs/FileSystem.h" +#include "fs/VFSMount.h" FileSystem *vfs_attempt_mount(device_t device, int fsType); diff --git a/kernel/kernel.c b/kernel/kernel.c index f2fe42e..ef7cdcb 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -20,7 +20,7 @@ #include "char/keyboard.h" #include "block/ramdisk.h" #include "fs/vfs.h" -#include "fs/ext2.h" +#include "fs/ext2/ext2.h" mb_info_t mb_info_block; mb_mmap_t mb_mmap[MAX_MMAP];