fs: added some checks

This commit is contained in:
Matheus
2024-05-30 10:18:44 -03:00
parent 1821e0cb52
commit b13b317172
3 changed files with 23 additions and 1 deletions
+21
View File
@@ -1150,6 +1150,9 @@ static int ext2_getdents(vnode_t *vnode, dent_t *buffer, size_t count, uintmax_t
ext2node_t *node = (ext2node_t *)vnode;
ext2fs_t *fs = (ext2fs_t *)node->vnode.vfs;
if (vnode->type != V_TYPE_DIR)
return ENOTDIR;
VOP_LOCK(vnode);
int err = 0;
@@ -1231,6 +1234,12 @@ static int ext2_readlink(vnode_t *vnode, char **link, cred_t *cred) {
}
static int ext2_read(vnode_t *vnode, void *buffer, size_t size, uintmax_t offset, int flags, size_t *readc, cred_t *cred) {
if (vnode->type == V_TYPE_DIR)
return EISDIR;
if (vnode->type != V_TYPE_REGULAR)
return EINVAL;
ext2node_t *node = (ext2node_t *)vnode;
ext2fs_t *fs = (ext2fs_t *)vnode->vfs;
uintmax_t endoffset = offset + size;
@@ -1266,6 +1275,12 @@ static int ext2_read(vnode_t *vnode, void *buffer, size_t size, uintmax_t offset
}
int ext2_write(vnode_t *vnode, void *buffer, size_t size, uintmax_t offset, int flags, size_t *writec, cred_t *cred) {
if (vnode->type == V_TYPE_DIR)
return EISDIR;
if (vnode->type != V_TYPE_REGULAR)
return EINVAL;
ext2node_t *node = (ext2node_t *)vnode;
ext2fs_t *fs = (ext2fs_t *)vnode->vfs;
uintmax_t endoffset = offset + size;
@@ -1300,6 +1315,12 @@ int ext2_write(vnode_t *vnode, void *buffer, size_t size, uintmax_t offset, int
}
int ext2_resize(vnode_t *vnode, size_t newsize, cred_t *cred) {
if (vnode->type == V_TYPE_DIR)
return EISDIR;
if (vnode->type != V_TYPE_REGULAR)
return EINVAL;
__assert(vnode->type == V_TYPE_REGULAR);
ext2node_t *node = (ext2node_t *)vnode;
ext2fs_t *fs = (ext2fs_t *)vnode->vfs;
+1
View File
@@ -55,6 +55,7 @@ int pipefs_close(vnode_t *node, int flags, cred_t *cred) {
return 0;
}
// TODO for pipefs_read and pipefs_write, the return actually depends on how much data is in the pipe
static int internalpoll(vnode_t *node, polldata_t *data, int events) {
pipenode_t *pipenode = (pipenode_t *)node;
int revents = 0;
+1 -1
View File
@@ -245,7 +245,7 @@ static int tmpfs_link(vnode_t *node, vnode_t *dir, char *name, cred_t *cred) {
if (dir->type != V_TYPE_DIR)
return ENOTDIR;
if (node->tyé == V_TYPE_DIR)
if (node->vfs == V_TYPE_DIR)
return EISDIR;
tmpfsnode_t *tmpdir = (tmpfsnode_t *)dir;