devfs: enable writing to device files
This commit is contained in:
parent
2009a9adb7
commit
4e2d2d0f4e
2 changed files with 3 additions and 11 deletions
|
|
@ -94,6 +94,7 @@ struct fs *devfs_init()
|
||||||
devfs->ops->open_dir = devfs_open_dir;
|
devfs->ops->open_dir = devfs_open_dir;
|
||||||
|
|
||||||
devfs->root->flags = VFS_VNO_DIR;
|
devfs->root->flags = VFS_VNO_DIR;
|
||||||
|
devfs->root->fs = devfs;
|
||||||
|
|
||||||
int res = vfs_mount(devfs, "dev");
|
int res = vfs_mount(devfs, "dev");
|
||||||
|
|
||||||
|
|
|
||||||
13
fs/vfs.c
13
fs/vfs.c
|
|
@ -184,11 +184,7 @@ int vfs_close(struct file *file)
|
||||||
|
|
||||||
ssize_t vfs_write(struct file *file, void *buf, off_t off, size_t count)
|
ssize_t vfs_write(struct file *file, void *buf, off_t off, size_t count)
|
||||||
{
|
{
|
||||||
/* TODO: implement */
|
if ((file->vnode->flags & VFS_VTYPE_MASK) == VFS_VNO_DIR)
|
||||||
if (file->type == FTYPE_CHARDEV)
|
|
||||||
return -EBADF;
|
|
||||||
|
|
||||||
if ((file->vnode->flags & VFS_VTYPE_MASK) != VFS_VNO_REG)
|
|
||||||
return -EISDIR;
|
return -EISDIR;
|
||||||
|
|
||||||
return file->vnode->fs->ops->write(file->vnode, buf, off, count);
|
return file->vnode->fs->ops->write(file->vnode, buf, off, count);
|
||||||
|
|
@ -196,12 +192,7 @@ ssize_t vfs_write(struct file *file, void *buf, off_t off, size_t count)
|
||||||
|
|
||||||
ssize_t vfs_read(struct file *file, void *buf, off_t off, size_t count)
|
ssize_t vfs_read(struct file *file, void *buf, off_t off, size_t count)
|
||||||
{
|
{
|
||||||
/* TODO: implement */
|
if ((file->vnode->flags & VFS_VTYPE_MASK) == VFS_VNO_DIR)
|
||||||
if (file->type == FTYPE_CHARDEV)
|
|
||||||
return -EBADF;
|
|
||||||
|
|
||||||
/* TODO: implement */
|
|
||||||
if ((file->vnode->flags & VFS_VTYPE_MASK) != VFS_VNO_REG)
|
|
||||||
return -EISDIR;
|
return -EISDIR;
|
||||||
|
|
||||||
if (off >= file->vnode->size)
|
if (off >= file->vnode->size)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue