summaryrefslogtreecommitdiff
path: root/Source/Kernel/VFS
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-11-25 18:42:44 +0100
committerAlexis211 <alexis211@gmail.com>2009-11-25 18:42:44 +0100
commita40fe1166ab1db972a8ca0380d603c4d90eede62 (patch)
treef92c2c02d9d78d68f7c116dff9ac508895f757af /Source/Kernel/VFS
parentf367fe4e5a7712bafc121ce5c228f15e90fc5c93 (diff)
downloadMelon-a40fe1166ab1db972a8ca0380d603c4d90eede62.tar.gz
Melon-a40fe1166ab1db972a8ca0380d603c4d90eede62.zip
Re-organized file system stuff.
Diffstat (limited to 'Source/Kernel/VFS')
-rw-r--r--Source/Kernel/VFS/File.class.cpp3
-rw-r--r--Source/Kernel/VFS/Part.ns.cpp27
-rw-r--r--Source/Kernel/VFS/Part.ns.h3
3 files changed, 32 insertions, 1 deletions
diff --git a/Source/Kernel/VFS/File.class.cpp b/Source/Kernel/VFS/File.class.cpp
index c5ddcd6..84561a5 100644
--- a/Source/Kernel/VFS/File.class.cpp
+++ b/Source/Kernel/VFS/File.class.cpp
@@ -33,7 +33,7 @@ bool File::open(String filename, u8int mode, FSNode* start, bool vrfyperm) {
if (node == NULL){
if (mode == FM_READ) return false;
node = VFS::createFile(filename, start, vrfyperm);
- if (node == 0) return false;
+ if (node == NULL) return false;
}
if (node->type() != NT_FILE) return false;
@@ -137,6 +137,7 @@ bool File::seek(u64int count, u8int mode) {
}
bool File::eof() {
+ if (!m_valid) return false;
return m_position == m_file->getLength();
}
diff --git a/Source/Kernel/VFS/Part.ns.cpp b/Source/Kernel/VFS/Part.ns.cpp
index 6408dbd..7184f90 100644
--- a/Source/Kernel/VFS/Part.ns.cpp
+++ b/Source/Kernel/VFS/Part.ns.cpp
@@ -56,4 +56,31 @@ u32int getDeviceID(BlockDevice* dev) {
return (u32int) - 1;
}
+BlockDevice* dev(String _class, u32int idx) {
+ for (u32int i = 0; i < devices.size(); i++) {
+ String devclass = devices[i]->getClass();
+ if (devclass == _class or (devclass.size() > _class.size() and devclass.substr(0, _class.size()) == _class)) {
+ if (idx == 0) {
+ return devices[i];
+ } else {
+ idx--;
+ }
+ }
+ }
+ return NULL;
+}
+
+Partition* part(BlockDevice* dev, u32int idx) {
+ for (u32int i = 0; i < partitions.size(); i++) {
+ if (partitions[i]->getDevice() == dev) {
+ if (idx == 0) {
+ return partitions[i];
+ } else {
+ idx--;
+ }
+ }
+ }
+ return NULL;
+}
+
}
diff --git a/Source/Kernel/VFS/Part.ns.h b/Source/Kernel/VFS/Part.ns.h
index 40a0fb2..4373a2d 100644
--- a/Source/Kernel/VFS/Part.ns.h
+++ b/Source/Kernel/VFS/Part.ns.h
@@ -13,6 +13,9 @@ namespace Part {
void unregisterDevice(BlockDevice* dev);
u32int getDeviceID(BlockDevice* dev);
+
+ BlockDevice* dev(String _class, u32int idx);
+ Partition* part(BlockDevice* dev, u32int idx);
}
#endif