From 593bf4df3d8db49286c1a7ae4ef75c887b629930 Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Thu, 17 May 2012 17:56:23 +0200 Subject: Devices using the VFS structure. Basic keyboard handler. --- src/kernel/vfs/node.cpp | 10 +++++----- src/kernel/vfs/node.h | 8 ++++++++ src/kernel/vfs/vdir.h | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) (limited to 'src/kernel/vfs') diff --git a/src/kernel/vfs/node.cpp b/src/kernel/vfs/node.cpp index 9900a3c..e174bd6 100644 --- a/src/kernel/vfs/node.cpp +++ b/src/kernel/vfs/node.cpp @@ -1,6 +1,5 @@ #include "node.h" #include "vdir.h" -#include int node::open(process *proc, int mode) { //TODO : permission checks @@ -17,13 +16,14 @@ int node::stat(file_info *info) { return 0; } -node *root = 0; +node *root = 0, *dot_dev = 0, *dot_ui = 0; void vfs_setup() { root = new vdir(0); - root->add_child(".dev", new vdir(root)); - - monitor_write("[VFS] "); + dot_dev = new vdir(root); + root->add_child(".dev", dot_dev); + dot_ui = new vdir(root); + root->add_child(".ui", dot_ui); } node* vfs_find(node* root, char* path) { diff --git a/src/kernel/vfs/node.h b/src/kernel/vfs/node.h index 2d16dab..9005d55 100644 --- a/src/kernel/vfs/node.h +++ b/src/kernel/vfs/node.h @@ -6,6 +6,8 @@ #include +class display; + class node { public: node* parent; @@ -13,6 +15,7 @@ class node { int mode, uid, gid; node(node* p, int t) : parent(p), type(t) {} + virtual ~node() {} virtual int open(process *proc, int mode); virtual void close(process *proc) {} @@ -22,11 +25,16 @@ class node { virtual node* get_child(char* name) { return 0; } virtual int add_child(char* name, node *child) { return E_NOT_IMPLEMENTED; } virtual size_t get_size() { return 0; } + + // kind of like dynamic_cast'int these things + virtual display *as_display() { return 0; } }; void vfs_setup(); node* vfs_find(node* root, char* filename); +extern node *root, *dot_dev, *dot_ui; + // syscall interface FILE open(char* filename, int mode); FILE open_relative(FILE root, char* filename, int mode); diff --git a/src/kernel/vfs/vdir.h b/src/kernel/vfs/vdir.h index 9595409..609a504 100644 --- a/src/kernel/vfs/vdir.h +++ b/src/kernel/vfs/vdir.h @@ -20,6 +20,7 @@ class vdir : public node { public: vdir(node* parent); + virtual ~vdir() {} virtual int read(size_t offset, size_t len, char* buffer); virtual int write(size_t offset, size_t len, char* buffer); // rename file -- cgit v1.2.3