Import backup from 2005-06-02
This commit is contained in:
1 parent
b0132c866e
commit
692cf2fc08
22 files changed
+512
-244
No files matched your search
+135
-1
@@ -2,17 +2,151 @@
|
||||
// ext2 filesystem driver for HOS
|
||||
// Author: Josh Holtrop
|
||||
// Date: 05/10/05
|
||||
// Modified: 05/10/05
|
||||
// Modified: 05/23/05
|
||||
|
||||
#ifndef __HOS_EXT2_H__
|
||||
#define __HOS_EXT2_H__ __HOS_EXT2_H__
|
||||
|
||||
#define EXT2_MAGIC 0xEF53
|
||||
#define EXT2_NAME_LEN 255
|
||||
|
||||
#define EXT2_I_MODE_ATTR_MASK 0x0FFF
|
||||
#define EXT2_I_MODE_OX 0x0001
|
||||
#define EXT2_I_MODE_OW 0x0002
|
||||
#define EXT2_I_MODE_OR 0x0004
|
||||
#define EXT2_I_MODE_GX 0x0008
|
||||
#define EXT2_I_MODE_GW 0x0010
|
||||
#define EXT2_I_MODE_GR 0x0020
|
||||
#define EXT2_I_MODE_UX 0x0040
|
||||
#define EXT2_I_MODE_UW 0x0080
|
||||
#define EXT2_I_MODE_UR 0x0100
|
||||
#define EXT2_I_MODE_STICKY 0x0200
|
||||
#define EXT2_I_MODE_SGID 0x0400
|
||||
#define EXT2_I_MODE_SUID 0x0800
|
||||
|
||||
#define EXT2_I_MODE_TYPE_MASK 0xF000
|
||||
#define EXT2_I_MODE_FIFO 0x1000
|
||||
#define EXT2_I_MODE_CHAR 0x2000
|
||||
#define EXT2_I_MODE_DIR 0x4000
|
||||
#define EXT2_I_MODE_BLOCK 0x6000
|
||||
#define EXT2_I_MODE_FILE 0x8000
|
||||
#define EXT2_I_MODE_SYM 0xA000
|
||||
#define EXT2_I_MODE_SOCK 0xC000
|
||||
|
||||
#define EXT2_I_FLAGS_SEC_DEL 0x01
|
||||
#define EXT2_I_FLAGS_UNDELETE 0x02
|
||||
#define EXT2_I_FLAGS_COMPRESS 0x04
|
||||
#define EXT2_I_FLAGS_SYNC 0x08
|
||||
#define EXT2_I_FLAGS_IMMUTABLE 0x10
|
||||
#define EXT2_I_FLAGS_APPEND 0x20
|
||||
#define EXT2_I_FLAGS_NODUMP 0x40
|
||||
|
||||
#define EXT2_INODE_BAD_BLOCKS 1
|
||||
#define EXT2_INODE_ROOT 2
|
||||
#define EXT2_INODE_ACL_INDEX 3
|
||||
#define EXT2_INODE_ACL_DATA 4
|
||||
#define EXT2_INODE_BOOT_LOADER 5
|
||||
#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
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32_t s_inodes_count; /* Inodes count */
|
||||
u32_t s_blocks_count; /* Blocks count */
|
||||
u32_t s_r_blocks_count; /* Reserved blocks count */
|
||||
u32_t s_free_blocks_count; /* Free blocks count */
|
||||
u32_t s_free_inodes_count; /* Free inodes count */
|
||||
u32_t s_first_data_block; /* First Data Block */
|
||||
u32_t s_log_block_size; /* Block size: 0->1024, 1->2048, 2->4096 */
|
||||
int s_log_frag_size; /* Fragment size */
|
||||
u32_t s_blocks_per_group; /* # Blocks per group */
|
||||
u32_t s_frags_per_group; /* # Fragments per group */
|
||||
u32_t s_inodes_per_group; /* # Inodes per group */
|
||||
u32_t s_mtime; /* Mount time */
|
||||
u32_t s_wtime; /* Write time */
|
||||
u16_t s_mnt_count; /* Mount count */
|
||||
short s_max_mnt_count; /* Maximal mount count */
|
||||
u16_t s_magic; /* Magic signature */
|
||||
u16_t s_state; /* File system state */
|
||||
u16_t s_errors; /* Behaviour when detecting errors */
|
||||
u16_t s_minor_rev_level; /* minor revision level */
|
||||
u32_t s_lastcheck; /* time of last check */
|
||||
u32_t s_checkinterval; /* max. time between checks */
|
||||
u32_t s_creator_os; /* OS */
|
||||
u32_t s_rev_level; /* Revision level */
|
||||
u16_t s_def_resuid; /* Default uid for reserved blocks */
|
||||
u16_t s_def_resgid; /* Default gid for reserved blocks */
|
||||
|
||||
u32_t s_reserved[235];
|
||||
} ext2_super_block_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32_t bg_block_bitmap; // Blocks bitmap block
|
||||
u32_t bg_inode_bitmap; // Inode bitmap block
|
||||
u32_t bg_inode_table; // Inode table block
|
||||
u16_t bg_free_blocks_count; // Free blocks count
|
||||
u16_t bg_free_inodes_count; // Free Inodes count
|
||||
u16_t bg_used_dirs_count; // Directories count
|
||||
u16_t bg_pad1;
|
||||
u32_t bg_reserved[3];
|
||||
} ext2_group_desc_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u16_t i_mode; // File mode
|
||||
u16_t i_uid; // Owner UID
|
||||
u32_t i_size; // Size in bytes
|
||||
u32_t i_atime; // Access time
|
||||
u32_t i_ctime; // Creation time
|
||||
u32_t i_mtime; // Modification time
|
||||
u32_t i_dtime; // Deletion time
|
||||
u16_t i_gid; // Group ID
|
||||
u16_t i_links_count; // Links count
|
||||
u32_t i_blocks; // Blocks count
|
||||
u32_t i_flags; // File flags
|
||||
u32_t i_reserved1;
|
||||
u32_t i_block[15]; // Pointers to blocks (12 direct, single, double, triple indirect)
|
||||
u32_t i_version; // File version (for NFS)
|
||||
u32_t i_file_acl; // File ACL
|
||||
u32_t i_dir_acl; // Directory ACL
|
||||
u32_t i_faddr; // Fragment address
|
||||
u8_t i_frag; // Fragment number
|
||||
u8_t i_fsize; // Fragment size
|
||||
u16_t i_pad1;
|
||||
u32_t i_reserved2[2];
|
||||
} ext2_inode_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32_t inode; // inode number
|
||||
u16_t length; // directory entry length
|
||||
u8_t name_length; // name length
|
||||
u8_t file_type; // File type
|
||||
char name[EXT2_NAME_LEN];
|
||||
} ext2_dir_entry_t;
|
||||
|
||||
|
||||
#ifdef _HOS_CPP_
|
||||
|
||||
class Ext2 : public FileSystem
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -75,11 +75,11 @@ typedef struct
|
||||
u32_t s_blocks_per_group; /* # Blocks per group */
|
||||
u32_t s_frags_per_group; /* # Fragments per group */
|
||||
u32_t s_inodes_per_group; /* # Inodes per group */
|
||||
u32_t s_mtime; /* Mount time */
|
||||
u32_t s_wtime; /* Write time */
|
||||
u32_t s_mtime; /* Mount time */
|
||||
u32_t s_wtime; /* Write time */
|
||||
u16_t s_mnt_count; /* Mount count */
|
||||
short s_max_mnt_count; /* Maximal mount count */
|
||||
u16_t s_magic; /* Magic signature */
|
||||
short s_max_mnt_count; /* Maximal mount count */
|
||||
u16_t s_magic; /* Magic signature */
|
||||
u16_t s_state; /* File system state */
|
||||
u16_t s_errors; /* Behaviour when detecting errors */
|
||||
u16_t s_minor_rev_level; /* minor revision level */
|
||||
|
||||
@@ -6,11 +6,48 @@
|
||||
|
||||
#define _HOS_CPP_ _HOS_CPP_
|
||||
|
||||
extern "C" {
|
||||
#include "hos_defines.h"
|
||||
#include "display/kout.h"
|
||||
}
|
||||
|
||||
#include "vfs.h"
|
||||
#include "lang/vector.h"
|
||||
#include "lang/string.h"
|
||||
#include "devices.h"
|
||||
|
||||
inode_num_t rootInode;
|
||||
vector<VFSMount> *mountPoints;
|
||||
|
||||
int vfs_init()
|
||||
{
|
||||
mountPoints = new vector<VFSMount>;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vfs_mount(device_t device, int fsType, char *mountPoint)
|
||||
{
|
||||
string mountPt(mountPoint);
|
||||
if (mountPt == "/")
|
||||
{
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
+60
-2
@@ -7,20 +7,78 @@
|
||||
#ifndef __HOS_VFS_H__
|
||||
#define __HOS_VFS_H__ __HOS_VFS_H__
|
||||
|
||||
#define FS_EXT2 1
|
||||
|
||||
#define VFS_FT_UNKNOWN 0
|
||||
#define VFS_FT_FILE 1
|
||||
#define VFS_FT_DIR 2
|
||||
#define VFS_FT_CHAR 3
|
||||
#define VFS_FT_BLOCK 4
|
||||
#define VFS_FT_FIFO 5
|
||||
#define VFS_FT_SOCK 6
|
||||
#define VFS_FT_SYMLINK 7
|
||||
|
||||
#define VFS_PERMS_OX 0x0001
|
||||
#define VFS_PERMS_OW 0x0002
|
||||
#define VFS_PERMS_OR 0x0004
|
||||
#define VFS_PERMS_GX 0x0008
|
||||
#define VFS_PERMS_GW 0x0010
|
||||
#define VFS_PERMS_GR 0x0020
|
||||
#define VFS_PERMS_UX 0x0040
|
||||
#define VFS_PERMS_UW 0x0080
|
||||
#define VFS_PERMS_UR 0x0100
|
||||
#define VFS_PERMS_STICKY 0x0200
|
||||
#define VFS_PERMS_SGID 0x0400
|
||||
#define VFS_PERMS_SUID 0x0800
|
||||
|
||||
#define EOF 1000000
|
||||
|
||||
#include "hos_defines.h"
|
||||
#include "devices.h"
|
||||
|
||||
#ifdef _HOS_CPP_
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef u64_t inode_num_t;
|
||||
|
||||
int vfs_init();
|
||||
int vfs_mount(device_t device, int fsType, char *mountPoint);
|
||||
|
||||
#ifdef _HOS_CPP_
|
||||
}
|
||||
|
||||
#include "lang/string.h"
|
||||
|
||||
class FileSystem
|
||||
{
|
||||
public:
|
||||
FileSystem();
|
||||
~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();
|
||||
};
|
||||
|
||||
class VFSMount
|
||||
{
|
||||
protected:
|
||||
device_t myDev;
|
||||
FileSystem *myFS;
|
||||
int myRefs;
|
||||
string myMountPoint;
|
||||
inode_num_t myMountInode;
|
||||
VFSMount
|
||||
public:
|
||||
VFSMount(device_t dev, FileSystem *fs, string mountPoint, inode_num_t mountInode);
|
||||
~VFSMount();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -162,57 +162,5 @@ int vfs_read_block_file(vfs_open_file_t *open_file, void *buffer);
|
||||
int vfs_block_file_seek(vfs_open_file_t *open_file, u32_t block_number);
|
||||
int vfs_close_block_file(vfs_open_file_t *open_file);
|
||||
|
||||
#ifdef _HOS_CPP_
|
||||
|
||||
class FileSystem
|
||||
{
|
||||
public:
|
||||
FileSystem();
|
||||
virtual void out();
|
||||
};
|
||||
|
||||
FileSystem::FileSystem()
|
||||
{
|
||||
kprintf("FileSystem()\n");
|
||||
}
|
||||
void FileSystem::out()
|
||||
{
|
||||
kprintf("I am a FileSystem object.\n");
|
||||
}
|
||||
|
||||
class Ext2 : public FileSystem
|
||||
{
|
||||
public:
|
||||
Ext2();
|
||||
void out();
|
||||
};
|
||||
|
||||
Ext2::Ext2()
|
||||
{
|
||||
kprintf("Ext2()\n");
|
||||
}
|
||||
void Ext2::out()
|
||||
{
|
||||
kprintf("I am an Ext2 object.\n");
|
||||
}
|
||||
|
||||
class JoshsFS : public FileSystem
|
||||
{
|
||||
public:
|
||||
JoshsFS();
|
||||
void out();
|
||||
};
|
||||
|
||||
JoshsFS::JoshsFS()
|
||||
{
|
||||
kprintf("JoshsFS()\n");
|
||||
}
|
||||
void JoshsFS::out()
|
||||
{
|
||||
kprintf("I am an JoshsFS object.\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user