From 021831ab981b9df22cd1ac5e5ac51f0f84ef49a7 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Sat, 26 Sep 2009 22:17:03 +0200 Subject: Nothing intresting --- Source/Kernel/VFS/DirectoryNode.class.cpp | 12 ++++++++++++ Source/Kernel/VFS/DirectoryNode.class.h | 9 ++++++++- Source/Kernel/VFS/File.class.h | 7 +++++++ Source/Kernel/VFS/FileNode.class.h | 1 - Source/Kernel/VFS/FileSystem.proto.h | 2 ++ 5 files changed, 29 insertions(+), 2 deletions(-) (limited to 'Source/Kernel/VFS') diff --git a/Source/Kernel/VFS/DirectoryNode.class.cpp b/Source/Kernel/VFS/DirectoryNode.class.cpp index 415899c..0c58ca1 100644 --- a/Source/Kernel/VFS/DirectoryNode.class.cpp +++ b/Source/Kernel/VFS/DirectoryNode.class.cpp @@ -7,6 +7,18 @@ bool DirectoryNode::removable() { return m_children.empty(); } +bool DirectoryNode::unmountable() { + if (!m_contentLoaded) return true; + for (u32int i = 0; i < m_children.size(); i++) { + if (m_children[i]->type() == NT_DIRECTORY) { + if (!((DirectoryNode*)m_children[i])->unmountable()) return false; + } else { + if (!m_children[i]->removable()) return false; + } + } + return true; +} + bool DirectoryNode::loadContent() { if (m_contentLoaded) return true; bool b = m_fs->loadContents(this); diff --git a/Source/Kernel/VFS/DirectoryNode.class.h b/Source/Kernel/VFS/DirectoryNode.class.h index 5de523e..2130458 100644 --- a/Source/Kernel/VFS/DirectoryNode.class.h +++ b/Source/Kernel/VFS/DirectoryNode.class.h @@ -13,12 +13,19 @@ class DirectoryNode : public FSNode { DirectoryNode(String name, FileSystem* fs, FSNode* parent, u32int permissions = 0777, u32int uid = 0, u32int gid = 0) : FSNode(name, fs, parent, 0, permissions, uid, gid), m_children(), m_contentLoaded(false) {} - virtual ~DirectoryNode() {} + virtual ~DirectoryNode() { + if (m_contentLoaded) { + for (u32int i = 0; i < m_children.size(); i++) { + delete m_children[i]; + } + } + } Vector &getChildren() { return m_children; } //MUST BE USED ONLY BY FILESYSTEMS u8int type() { return NT_DIRECTORY; } bool removable(); + bool unmountable(); bool loadContent(); FSNode* getChild(u32int index); diff --git a/Source/Kernel/VFS/File.class.h b/Source/Kernel/VFS/File.class.h index ef82a70..7831fb5 100644 --- a/Source/Kernel/VFS/File.class.h +++ b/Source/Kernel/VFS/File.class.h @@ -38,6 +38,13 @@ class File { u32int read(ByteArray &data); //Fills ByteArray at its current length or shrinks it if we can't read enough bool write(ByteArray &data); + template bool read(T* elem) { + return (read(sizeof(T), (u8int*)elem) == sizeof(T)); + } + template bool write(T* elem) { + return write(sizeof(T), (u8int*)elem); + } + bool seek(u64int count, u8int mode); u64int position() { return m_position; } u64int length() { return m_file->getLength(); } diff --git a/Source/Kernel/VFS/FileNode.class.h b/Source/Kernel/VFS/FileNode.class.h index ac170ae..7ab617f 100644 --- a/Source/Kernel/VFS/FileNode.class.h +++ b/Source/Kernel/VFS/FileNode.class.h @@ -21,7 +21,6 @@ class FileNode : public FSNode { bool used() { return (m_readers != 0 or m_writers != 0); } bool writable() { return m_fs->isWritable(); } - //protected: u32int read(u64int position, u32int max_length, u8int *data) { return m_fs->read(this, position, max_length, data); } diff --git a/Source/Kernel/VFS/FileSystem.proto.h b/Source/Kernel/VFS/FileSystem.proto.h index 2f768a7..5aec434 100644 --- a/Source/Kernel/VFS/FileSystem.proto.h +++ b/Source/Kernel/VFS/FileSystem.proto.h @@ -13,6 +13,8 @@ class FileSystem { DirectoryNode* m_rootNode; public: + bool unmount(); + bool isWritable() { return m_isWritable; } DirectoryNode* getRootNode() { return m_rootNode; } -- cgit v1.2.3