Kernel: Add support for getdents() to DeviceFS
This commit is contained in:
parent
78d72c2f0c
commit
14367f07b5
@ -6,4 +6,5 @@ namespace DeviceFS
|
|||||||
VFS::Node* get();
|
VFS::Node* get();
|
||||||
|
|
||||||
VFS::Node* finddir(VFS::Node* node, const char* filename);
|
VFS::Node* finddir(VFS::Node* node, const char* filename);
|
||||||
|
VFS::Node* readdir(VFS::Node* node, long offset);
|
||||||
}
|
}
|
@ -23,6 +23,7 @@ VFS::Node* DeviceFS::get()
|
|||||||
devfs_root->inode = 0;
|
devfs_root->inode = 0;
|
||||||
devfs_root->type = VFS_DIRECTORY;
|
devfs_root->type = VFS_DIRECTORY;
|
||||||
devfs_root->find_func = DeviceFS::finddir;
|
devfs_root->find_func = DeviceFS::finddir;
|
||||||
|
devfs_root->readdir_func = DeviceFS::readdir;
|
||||||
strncpy(devfs_root->name, "dev", sizeof(devfs_root->name));
|
strncpy(devfs_root->name, "dev", sizeof(devfs_root->name));
|
||||||
|
|
||||||
devfs_files[devfs_file_count++] = VersionDevice::create_new("version");
|
devfs_files[devfs_file_count++] = VersionDevice::create_new("version");
|
||||||
@ -31,6 +32,7 @@ VFS::Node* DeviceFS::get()
|
|||||||
devfs_files[devfs_file_count++] = RandomDevice::create_new("random");
|
devfs_files[devfs_file_count++] = RandomDevice::create_new("random");
|
||||||
devfs_files[devfs_file_count++] = KeyboardDevice::create_new("kbd");
|
devfs_files[devfs_file_count++] = KeyboardDevice::create_new("kbd");
|
||||||
devfs_files[devfs_file_count++] = UptimeDevice::create_new("uptime");
|
devfs_files[devfs_file_count++] = UptimeDevice::create_new("uptime");
|
||||||
|
devfs_root->length = devfs_file_count;
|
||||||
return devfs_root;
|
return devfs_root;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,4 +44,11 @@ VFS::Node* DeviceFS::finddir(VFS::Node* node, const char* filename)
|
|||||||
if (strncmp(devfs_files[i]->name, filename, sizeof(VFS::Node::name)) == 0) { return devfs_files[i]; }
|
if (strncmp(devfs_files[i]->name, filename, sizeof(VFS::Node::name)) == 0) { return devfs_files[i]; }
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
VFS::Node* DeviceFS::readdir(VFS::Node* node, long offset)
|
||||||
|
{
|
||||||
|
if (!node) return 0;
|
||||||
|
if (offset >= devfs_file_count) return 0;
|
||||||
|
return devfs_files[offset];
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user