tmpfs: some more safety checks

This commit is contained in:
Matheus
2024-05-29 19:15:41 -03:00
parent e50768d0a1
commit ad756016b9
+12 -1
View File
@@ -209,6 +209,9 @@ static int tmpfs_unlink(vnode_t *node, char *name, cred_t *cred) {
if (node->type != V_TYPE_DIR)
return ENOTDIR;
if (node->vfsmounted)
return EBUSY;
size_t namelen = strlen(name);
void *r;
VOP_LOCK(node);
@@ -242,6 +245,9 @@ 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)
return EISDIR;
tmpfsnode_t *tmpdir = (tmpfsnode_t *)dir;
size_t namelen = strlen(name);
void *v;
@@ -299,7 +305,12 @@ static int tmpfs_rename(vnode_t *source, char *oldname, vnode_t *target, char *n
else if (error == 0) // found
oldnode = v;
// same link, rename is a no-op
if (node->vfsmounted || oldnode->vfsmounted) {
error = EBUSY;
goto cleanup;
}
// same link, rename is a no-op TODO still gotta unlink it though
if (sourcedir == targetdir && strcmp(oldname, newname) == 0)
goto cleanup;