proc: hack in special file descriptors
The previos commit broke executions of all program files due to a NULL memory access when inserting special file descriptors. This will be replaced when some sort of /dev fs is implemented
This commit is contained in:
parent
b7c10e80c2
commit
e2ea205129
5 changed files with 28 additions and 11 deletions
10
fs/vfs.c
10
fs/vfs.c
|
|
@ -16,7 +16,7 @@ typedef struct fs *(*vfs_init_t)(struct block_device *);
|
|||
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_CHARDEV)
|
||||
if (file->type == FTYPE_CHARDEV)
|
||||
return -EBADF;
|
||||
|
||||
if ((file->vnode.flags & VFS_VTYPE_MASK) != VFS_VNO_REG)
|
||||
|
|
@ -28,7 +28,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)
|
||||
{
|
||||
/* TODO: implement */
|
||||
if ((file->vnode.flags & VFS_VTYPE_MASK) == VFS_VNO_CHARDEV)
|
||||
if (file->type == FTYPE_CHARDEV)
|
||||
return -EBADF;
|
||||
|
||||
/* TODO: implement */
|
||||
|
|
@ -56,12 +56,16 @@ struct file *vfs_open(const char *pathname, int *err)
|
|||
/* allocate a file */
|
||||
struct file *file = slab_alloc(file_slab);
|
||||
if (!file) {
|
||||
kprintf(LOG_ERROR "Failed to allocate file descriptor\n");
|
||||
kprintf(LOG_ERROR "Failed to allocate file struct\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(file, 0, sizeof(struct file));
|
||||
|
||||
/* terrible temporary hack */
|
||||
if (pathname == NULL && (uintptr_t)err == 0x4)
|
||||
return file;
|
||||
|
||||
/* find the file */
|
||||
int result = rootfs->ops->open(rootfs, &file->vnode, pathname);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue