Import backup from 2005-08-17

This commit is contained in:
josh committed 2017-07-25 22:23:50 -04:00
1 parent 2cefd9441c
commit e1682a2fe7
10 files changed
+141 -84

No files matched your search

+32 -13
View File
@@ -8,26 +8,45 @@
extern "C" {
#include "display/kout.h"
#include "mm/vmm.h"
#include "lang/lang.h"
}
#include "ext2.h"
Ext2fs::Ext2fs(device_t dev)
int ext2_init()
{
vfs_register("ext2", ext2__mount_func);
return 0;
}
FileSystem *ext2__mount_func(device_t dev)
{
ext2_super_block_t *super =
(ext2_super_block_t *) New(ext2_super_block_t);
if ( (block_read(DEV_MAJOR(dev), DEV_MINOR(dev), 2, 2, super) < 1024)
|| (super->s_magic != EXT2_MAGIC) )
{
kfree(super);
return NULL;
}
Ext2fs *fs = new Ext2fs(super, dev);
kfree(super);
return fs;
}
Ext2fs::Ext2fs(ext2_super_block_t *super, 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;
memcpy(&mySuper, super, sizeof(ext2_super_block_t));
mySuperDirty = 0;
kprintf("Device: %d\n", myDevice);
kprintf("Blocks: %d (%d free), Inodes: %d (%d free) Creator OS:\n",
mySuper.s_blocks_count,
mySuper.s_free_blocks_count,
mySuper.s_inodes_count,
mySuper.s_free_inodes_count,
mySuper.s_creator_os);
}
Ext2fs::~Ext2fs()
+17 -11
View File
@@ -41,6 +41,7 @@
#define EXT2_I_FLAGS_APPEND 0x20
#define EXT2_I_FLAGS_NODUMP 0x40
/* ext2 standard inode numbers */
#define EXT2_INODE_BAD_BLOCKS 1
#define EXT2_INODE_ROOT 2
#define EXT2_INODE_ACL_INDEX 3
@@ -49,15 +50,16 @@
#define EXT2_INODE_UNDELETE_DIR 6
#define EXT2_INODE_AVAIL 11
#define EXT2_FT_UNKNOWN 0
#define EXT2_FT_FILE 1
#define EXT2_FT_DIR 2
#define EXT2_FT_CHAR 3
#define EXT2_FT_BLOCK 4
#define EXT2_FT_FIFO 5
#define EXT2_FT_SOCK 6
#define EXT2_FT_SYMLINK 7
#define EXT2_FT_MAX 8
/* The directory entry file type field values */
#define EXT2_FT_UNKNOWN 0
#define EXT2_FT_FILE 1
#define EXT2_FT_DIR 2
#define EXT2_FT_CHAR 3
#define EXT2_FT_BLOCK 4
#define EXT2_FT_FIFO 5
#define EXT2_FT_SOCK 6
#define EXT2_FT_SYMLINK 7
#define EXT2_FT_MAX 8
#include "fs/vfs.h"
@@ -140,13 +142,17 @@ typedef struct
#ifdef _HOS_CPP_
int ext2_init();
FileSystem *ext2__mount_func(device_t dev);
class Ext2fs : public FileSystem
{
protected:
device_t myDevice;
int mySuperDirty;
ext2_super_block_t mySuper;
int mySuperDirty;
public:
Ext2fs(device_t dev);
Ext2fs(ext2_super_block_t *super, device_t dev);
~Ext2fs();
};