Import backup from 2005-08-18

This commit is contained in:
josh committed 2017-07-25 22:23:50 -04:00
1 parent e1682a2fe7
commit 345ef6c9f3
35 files changed
+804 -89

No files matched your search

+2 -1
View File
@@ -14,13 +14,14 @@ extern "C" {
#include "lang/string.h"
#include "fs/vfs.h"
VFSMount::VFSMount(device_t dev, FileSystem *fs, string mountPoint, inode_num_t mountInode)
VFSMount::VFSMount(device_t dev, FileSystem *fs, string mountPoint, inode_num_t mountInode, inode_num_t thisInode)
{
myDev = dev;
myFS = fs;
myRefs = 0;
myMountPoint = mountPoint;
myMountInode = mountInode;
myThisInode = thisInode;
}
VFSMount::~VFSMount()
+3 -3
View File
@@ -14,15 +14,15 @@
class VFSMount
{
protected:
public:
device_t myDev;
FileSystem *myFS;
int myRefs;
string myMountPoint;
inode_num_t myMountInode;
inode_num_t myThisInode;
public:
VFSMount(device_t dev, FileSystem *fs, string mountPoint, inode_num_t mountInode);
VFSMount(device_t dev, FileSystem *fs, string mountPoint, inode_num_t mountInode, inode_num_t thisInode);
~VFSMount();
};
+44
View File
@@ -0,0 +1,44 @@
// sysfs.cpp
// sysfs filesystem driver for HOS
// Author: Josh Holtrop
// Date: 06/27/05
// Modified: 06/27/05
#define _HOS_CPP_ _HOS_CPP_
extern "C" {
#include "display/kout.h"
}
#include "fs/vfs.h"
#include "sysfs.h"
#include "sysfs_entry.h"
int sysfs_init()
{
vfs_register("sysfs", sysfs__mount_func);
return 0;
}
FileSystem *sysfs__mount_func(device_t dev)
{
if (dev)
kprintf("sysfs: warning: device parameter ignored\n");
return new Sysfs();
}
Sysfs::Sysfs()
{
myEntries.add(Sysfs_Entry(SYSFS_FILE, "timer", SYSFS_TIMER));
}
Sysfs::~Sysfs()
{
}
u32_t Sysfs::getRootInodeNumber()
{
return 2;
}
+37
View File
@@ -0,0 +1,37 @@
// sysfs.h
// sysfs filesystem driver for HOS
// Author: Josh Holtrop
// Date: 06/27/05
// Modified: 06/27/05
#ifndef __HOS_SYSFS_H__
#define __HOS_SYSFS_H__ __HOS_SYSFS_H__
#define SYSFS_TIMER 1
#ifdef _HOS_CPP_
#include "fs/FileSystem.h"
#include "fs/vfs.h"
#include "lang/vector.h"
#include "lang/string.h"
#include "sysfs_entry.h"
int sysfs_init();
FileSystem *sysfs__mount_func(device_t dev);
class Sysfs : public FileSystem
{
protected:
vector<Sysfs_Entry> myEntries;
public:
Sysfs();
~Sysfs();
u32_t getRootInodeNumber();
};
#endif
#endif
+22
View File
@@ -0,0 +1,22 @@
// sysfs_entry.cpp
// sysfs filesystem driver for HOS
// Author: Josh Holtrop
// Date: 06/27/05
// Modified: 06/27/05
#define _HOS_CPP_ _HOS_CPP_
#include "sysfs_entry.h"
#include "lang/string.h"
Sysfs_Entry::Sysfs_Entry(int type, string name, int id)
{
myType = type;
myName = name;
myID = id;
}
Sysfs_Entry::~Sysfs_Entry()
{
}
+30
View File
@@ -0,0 +1,30 @@
// sysfs_entry.h
// sysfs filesystem driver for HOS
// Author: Josh Holtrop
// Date: 06/27/05
// Modified: 06/27/05
#ifndef __HOS_SYSFS_ENTRY_H__
#define __HOS_SYSFS_ENTRY_H__ __HOS_SYSFS_ENTRY_H__
#include "lang/vector.h"
#include "lang/string.h"
#define SYSFS_DIR 1
#define SYSFS_FILE 2
class Sysfs_Entry
{
protected:
int myType;
string myName;
int myID;
vector<Sysfs_Entry> myChildren;
public:
Sysfs_Entry(int type, string name, int id);
~Sysfs_Entry();
};
#endif
+16 -9
View File
@@ -19,7 +19,6 @@ extern "C" {
#include "lang/string.h"
#include "devices.h"
inode_num_t rootInode;
vector<VFSMount> *mountPoints;
vector<FSHandle> *fses;
@@ -31,7 +30,7 @@ int vfs_init()
return 0;
}
int vfs_register(char *fs, FileSystem *(*mount_func)(device_t))
int vfs_register(char *fs, mount_func_t mount_func)
{
string fsName(fs);
if (vfs_get_mount_func(fsName))
@@ -57,15 +56,18 @@ int vfs_mount(device_t device, char *fsType, char *mountPoint)
FileSystem *fs = vfs_attempt_mount(device, fsType);
if (fs == NULL)
return -2;
rootInode = fs->getRootInodeNumber();
mountPoints->add(VFSMount(device, fs, mountPt, 0));
mountPoints->add(VFSMount(device, fs, mountPt, 0, fs->getRootInodeNumber()));
return 0;
}
else
{
// TODO: mount a second filesystem
}
return 500;
inode_num_t mtInode = vfs_get_inode(mountPt);
if (mtInode == 0)
return -3;
FileSystem *fs = vfs_attempt_mount(device, fsType);
if (fs == NULL)
return -2;
inode_num_t thisInode = ((u64_t)(mountPoints->size()) << 32) | fs->getRootInodeNumber();
mountPoints->add(VFSMount(device, fs, mountPt, mtInode, thisInode));
return 0;
}
FileSystem *vfs_attempt_mount(device_t device, char *fsType)
@@ -77,6 +79,11 @@ FileSystem *vfs_attempt_mount(device_t device, char *fsType)
return NULL;
}
inode_num_t vfs_get_inode(const string & path)
{
return 0;
}
mount_func_t vfs_get_mount_func(const string & fsName)
{
for (unsigned int i = 0; i < fses->size(); i++)
+23 -4
View File
@@ -34,6 +34,23 @@
#include "hos_defines.h"
#include "devices.h"
typedef struct
{
u16_t type; // file type, of VFS_FILE_TYPE_*
u32_t size;
u32_t inode;
u16_t permissions;
u16_t uid;
u16_t gid;
u32_t atime;
u32_t mtime;
u32_t ctime;
u16_t links;
u32_t dev;
} vfs_stat_t;
typedef u64_t inode_num_t;
#ifdef _HOS_CPP_
@@ -42,6 +59,7 @@ extern "C" {
int vfs_init();
int vfs_mount(device_t device, char *fsType, char *mountPoint);
int vfs_stat(char *name, vfs_stat_t *buff);
#ifdef _HOS_CPP_
}
@@ -50,17 +68,18 @@ int vfs_mount(device_t device, char *fsType, char *mountPoint);
#include "fs/FileSystem.h"
#include "fs/VFSMount.h"
typedef FileSystem *(*mount_func_t)(device_t);
typedef struct
{
string name;
mount_func_t mount_func;
FileSystem *(*mount_func)(device_t);
} FSHandle;
typedef FileSystem *(*mount_func_t)(device_t);
FileSystem *vfs_attempt_mount(device_t device, char *fsType);
int vfs_register(char *fs, FileSystem *(*mount_func)(device_t));
int vfs_register(char *fs, mount_func_t mount_func);
mount_func_t vfs_get_mount_func(const string & fsName);
inode_num_t vfs_get_inode(const string & path);
#endif