Import backup from 2005-06-20

This commit is contained in:
josh committed 2017-07-25 22:23:50 -04:00
1 parent 4689c11cc8
commit da90bcc164
12 files changed
+204 -37

No files matched your search

+31
View File
@@ -4,3 +4,34 @@
// Date: 05/10/05
// Modified: 05/10/05
#define _HOS_CPP_ _HOS_CPP_
extern "C" {
#include "display/kout.h"
}
#include "ext2.h"
Ext2fs::Ext2fs(device_t dev)
{
myDevice = dev;
if (block_read(DEV_MAJOR(dev), DEV_MINOR(dev), 2, 2, &mySuper) < 1024)
{
myError = -1;
return;
}
if (mySuper.s_magic != EXT2_MAGIC)
{
myError = -2;
return;
}
myError = 0;
mySuperDirty = 0;
kprintf("Device: %d\n", myDevice);
}
Ext2fs::~Ext2fs()
{
if (mySuperDirty)
block_write(DEV_MAJOR(myDevice), DEV_MINOR(myDevice), 2, 2, &mySuper);
}
+5 -4
View File
@@ -138,15 +138,16 @@ typedef struct
char name[EXT2_NAME_LEN];
} ext2_dir_entry_t;
#ifdef _HOS_CPP_
class Ext2 : public FileSystem
class Ext2fs : public FileSystem
{
protected:
ext2_super_block_t mySuper;
int mySuperDirty;
public:
Ext2fs(device_t dev);
~Ext2fs();
};
#endif
+51 -3
View File
@@ -12,6 +12,7 @@ extern "C" {
}
#include "vfs.h"
#include "ext2.h"
#include "lang/vector.h"
#include "lang/string.h"
#include "devices.h"
@@ -29,10 +30,43 @@ int vfs_mount(device_t device, int fsType, char *mountPoint)
{
string mountPt(mountPoint);
if (mountPt == "/")
{
if (mountPoints->size())
{
kprintf("/ must be the first filesystem mounted!\n");
return -1;
}
FileSystem *fs = vfs_attempt_mount(device, fsType);
if (fs == NULL)
return -2;
rootInode = fs->getRootInodeNumber();
mountPoints->add(VFSMount(device, fs, mountPt, 0));
return 0;
}
else
{
}
return 0;
return 500;
}
FileSystem *vfs_attempt_mount(device_t device, int fsType)
{
FileSystem *fs;
switch (fsType)
{
case FS_EXT2:
fs = new Ext2fs(device);
break;
default:
return NULL;
}
if (fs->check())
{
delete fs;
return NULL;
}
return fs;
}
VFSMount::VFSMount(device_t dev, FileSystem *fs, string mountPoint, inode_num_t mountInode)
@@ -47,7 +81,21 @@ VFSMount::VFSMount(device_t dev, FileSystem *fs, string mountPoint, inode_num_t
VFSMount::~VFSMount()
{
if (myFS)
{
delete myFS;
if (myRefs)
kprintf("Filesystem uncleanly mounted from %s\n", myMountPoint.data());
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;};
+9
View File
@@ -8,6 +8,7 @@
#define __HOS_VFS_H__ __HOS_VFS_H__
#define FS_EXT2 1
#define FS_MAX 5
#define VFS_FT_UNKNOWN 0
#define VFS_FT_FILE 1
@@ -52,7 +53,11 @@ int vfs_mount(device_t device, int fsType, char *mountPoint);
class FileSystem
{
protected:
int myError;
device_t myDevice;
public:
FileSystem();
FileSystem(device_t dev);
virtual ~FileSystem();
@@ -65,6 +70,8 @@ public:
virtual u32_t freeInodes();
virtual u32_t getRootInodeNumber();
virtual int check();
};
class VFSMount
@@ -81,6 +88,8 @@ public:
~VFSMount();
};
FileSystem *vfs_attempt_mount(device_t device, int fsType);
#endif
#endif