Devices: Tell a device which name you want it to be instantiated with
This allows us to create a device in any path, with any filename.
This commit is contained in:
parent
eb03ae91e0
commit
96b1d1c2f2
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
namespace ConsoleDevice
|
namespace ConsoleDevice
|
||||||
{
|
{
|
||||||
VFS::Node* create_new();
|
VFS::Node* create_new(const char* devname);
|
||||||
|
|
||||||
ssize_t write(VFS::Node* node, size_t offset, size_t size, const char* buffer);
|
ssize_t write(VFS::Node* node, size_t offset, size_t size, const char* buffer);
|
||||||
}
|
}
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
namespace SerialDevice
|
namespace SerialDevice
|
||||||
{
|
{
|
||||||
VFS::Node* create_new();
|
VFS::Node* create_new(const char* devname);
|
||||||
|
|
||||||
ssize_t write(VFS::Node* node, size_t offset, size_t size, const char* buffer);
|
ssize_t write(VFS::Node* node, size_t offset, size_t size, const char* buffer);
|
||||||
}
|
}
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
namespace VersionDevice
|
namespace VersionDevice
|
||||||
{
|
{
|
||||||
VFS::Node* create_new();
|
VFS::Node* create_new(const char* devname);
|
||||||
|
|
||||||
ssize_t read(VFS::Node* node, size_t offset, size_t size, char* buffer);
|
ssize_t read(VFS::Node* node, size_t offset, size_t size, char* buffer);
|
||||||
}
|
}
|
@ -5,7 +5,7 @@
|
|||||||
#include "std/stdlib.h"
|
#include "std/stdlib.h"
|
||||||
#include "std/string.h"
|
#include "std/string.h"
|
||||||
|
|
||||||
VFS::Node* ConsoleDevice::create_new()
|
VFS::Node* ConsoleDevice::create_new(const char* devname)
|
||||||
{
|
{
|
||||||
VFS::Node* dev = new VFS::Node;
|
VFS::Node* dev = new VFS::Node;
|
||||||
dev->write_func = ConsoleDevice::write;
|
dev->write_func = ConsoleDevice::write;
|
||||||
@ -13,7 +13,7 @@ VFS::Node* ConsoleDevice::create_new()
|
|||||||
dev->length = 0;
|
dev->length = 0;
|
||||||
dev->type = VFS_FILE;
|
dev->type = VFS_FILE;
|
||||||
dev->flags = 0;
|
dev->flags = 0;
|
||||||
strncpy(dev->name, "console", sizeof(dev->name));
|
strncpy(dev->name, devname, sizeof(dev->name));
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,9 +22,9 @@ VFS::Node* DeviceFS::get()
|
|||||||
devfs_root->find_func = DeviceFS::finddir;
|
devfs_root->find_func = DeviceFS::finddir;
|
||||||
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();
|
devfs_files[devfs_file_count++] = VersionDevice::create_new("version");
|
||||||
devfs_files[devfs_file_count++] = ConsoleDevice::create_new();
|
devfs_files[devfs_file_count++] = ConsoleDevice::create_new("console");
|
||||||
devfs_files[devfs_file_count++] = SerialDevice::create_new();
|
devfs_files[devfs_file_count++] = SerialDevice::create_new("serial");
|
||||||
return devfs_root;
|
return devfs_root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "std/stdlib.h"
|
#include "std/stdlib.h"
|
||||||
#include "std/string.h"
|
#include "std/string.h"
|
||||||
|
|
||||||
VFS::Node* SerialDevice::create_new()
|
VFS::Node* SerialDevice::create_new(const char* devname)
|
||||||
{
|
{
|
||||||
VFS::Node* dev = new VFS::Node;
|
VFS::Node* dev = new VFS::Node;
|
||||||
dev->write_func = SerialDevice::write;
|
dev->write_func = SerialDevice::write;
|
||||||
@ -13,7 +13,7 @@ VFS::Node* SerialDevice::create_new()
|
|||||||
dev->length = 0;
|
dev->length = 0;
|
||||||
dev->type = VFS_FILE;
|
dev->type = VFS_FILE;
|
||||||
dev->flags = 0;
|
dev->flags = 0;
|
||||||
strncpy(dev->name, "serial", sizeof(dev->name));
|
strncpy(dev->name, devname, sizeof(dev->name));
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "std/stdlib.h"
|
#include "std/stdlib.h"
|
||||||
#include "std/string.h"
|
#include "std/string.h"
|
||||||
|
|
||||||
VFS::Node* VersionDevice::create_new()
|
VFS::Node* VersionDevice::create_new(const char* devname)
|
||||||
{
|
{
|
||||||
VFS::Node* dev = new VFS::Node;
|
VFS::Node* dev = new VFS::Node;
|
||||||
dev->read_func = VersionDevice::read;
|
dev->read_func = VersionDevice::read;
|
||||||
@ -12,7 +12,7 @@ VFS::Node* VersionDevice::create_new()
|
|||||||
dev->length = strlen(moon_version()) + 5;
|
dev->length = strlen(moon_version()) + 5;
|
||||||
dev->type = VFS_FILE;
|
dev->type = VFS_FILE;
|
||||||
dev->flags = 0;
|
dev->flags = 0;
|
||||||
strncpy(dev->name, "version", sizeof(dev->name));
|
strncpy(dev->name, devname, sizeof(dev->name));
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user