diff options
author | Alexis211 <alexis211@gmail.com> | 2009-09-26 22:17:03 +0200 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2009-09-26 22:17:03 +0200 |
commit | 021831ab981b9df22cd1ac5e5ac51f0f84ef49a7 (patch) | |
tree | 90e9eeab0c0f72d65ba4e4ac6a798aa2ae05d7b3 /Source/Kernel/VFS | |
parent | 5d7ad3933bc2de69c2b7d09791adf305de019d8a (diff) | |
download | Melon-021831ab981b9df22cd1ac5e5ac51f0f84ef49a7.tar.gz Melon-021831ab981b9df22cd1ac5e5ac51f0f84ef49a7.zip |
Nothing intresting
Diffstat (limited to 'Source/Kernel/VFS')
-rw-r--r-- | Source/Kernel/VFS/DirectoryNode.class.cpp | 12 | ||||
-rw-r--r-- | Source/Kernel/VFS/DirectoryNode.class.h | 9 | ||||
-rw-r--r-- | Source/Kernel/VFS/File.class.h | 7 | ||||
-rw-r--r-- | Source/Kernel/VFS/FileNode.class.h | 1 | ||||
-rw-r--r-- | Source/Kernel/VFS/FileSystem.proto.h | 2 |
5 files changed, 29 insertions, 2 deletions
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<FSNode*> &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 <typename T> bool read(T* elem) { + return (read(sizeof(T), (u8int*)elem) == sizeof(T)); + } + template <typename T> 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; } |