mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 15:08:21 +00:00
tmpfs: some more safety checks
This commit is contained in:
+12
-1
@@ -209,6 +209,9 @@ static int tmpfs_unlink(vnode_t *node, char *name, cred_t *cred) {
|
|||||||
if (node->type != V_TYPE_DIR)
|
if (node->type != V_TYPE_DIR)
|
||||||
return ENOTDIR;
|
return ENOTDIR;
|
||||||
|
|
||||||
|
if (node->vfsmounted)
|
||||||
|
return EBUSY;
|
||||||
|
|
||||||
size_t namelen = strlen(name);
|
size_t namelen = strlen(name);
|
||||||
void *r;
|
void *r;
|
||||||
VOP_LOCK(node);
|
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)
|
if (dir->type != V_TYPE_DIR)
|
||||||
return ENOTDIR;
|
return ENOTDIR;
|
||||||
|
|
||||||
|
if (node->tyé == V_TYPE_DIR)
|
||||||
|
return EISDIR;
|
||||||
|
|
||||||
tmpfsnode_t *tmpdir = (tmpfsnode_t *)dir;
|
tmpfsnode_t *tmpdir = (tmpfsnode_t *)dir;
|
||||||
size_t namelen = strlen(name);
|
size_t namelen = strlen(name);
|
||||||
void *v;
|
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
|
else if (error == 0) // found
|
||||||
oldnode = v;
|
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)
|
if (sourcedir == targetdir && strcmp(oldname, newname) == 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user