toaruos/kernel/fs/nulldev.c

50 lines
1.2 KiB
C
Raw Normal View History

2012-01-24 09:01:23 +04:00
/* vim: tabstop=4 shiftwidth=4 noexpandtab
* Null Device
*/
#include <system.h>
#include <fs.h>
uint32_t read_null(fs_node_t *node, uint32_t offset, uint32_t size, uint8_t *buffer);
uint32_t write_null(fs_node_t *node, uint32_t offset, uint32_t size, uint8_t *buffer);
void open_null(fs_node_t *node, uint8_t read, uint8_t write);
void close_null(fs_node_t *node);
uint32_t read_null(fs_node_t *node, uint32_t offset, uint32_t size, uint8_t *buffer) {
2012-01-25 03:56:35 +04:00
if (size < 1) {
return 0;
}
memset(buffer, 0x00, 1);
2013-03-15 11:52:09 +04:00
return 0;
2012-01-24 09:01:23 +04:00
}
uint32_t write_null(fs_node_t *node, uint32_t offset, uint32_t size, uint8_t *buffer) {
return size;
}
void open_null(fs_node_t * node, uint8_t read, uint8_t write) {
return;
}
void close_null(fs_node_t * node) {
return;
}
fs_node_t * null_device_create() {
fs_node_t * fnode = malloc(sizeof(fs_node_t));
2013-03-15 11:20:55 +04:00
memset(fnode, 0x00, sizeof(fs_node_t));
2012-01-24 09:01:23 +04:00
fnode->inode = 0;
2012-12-01 06:26:47 +04:00
strcpy(fnode->name, "null");
2012-01-24 09:01:23 +04:00
fnode->uid = 0;
fnode->gid = 0;
2013-03-15 11:20:55 +04:00
fnode->flags = FS_CHARDEVICE;
2012-01-24 09:01:23 +04:00
fnode->read = read_null;
fnode->write = write_null;
fnode->open = open_null;
fnode->close = close_null;
fnode->readdir = NULL;
fnode->finddir = NULL;
2013-03-19 10:57:40 +04:00
fnode->ioctl = NULL;
2012-01-24 09:01:23 +04:00
return fnode;
}