提交 f8303be9 编写于 作者: F Far

fix: VnodeInUseIter and VnodeFreeAll used to be recursive

Function VnodeInUseIter and VnodeFreeAll used to be recursive.
Now we traverse the current in-use vnode list to find the vnode in
1 filesystem

Close #I3NN3U
上级 9f69ada9
...@@ -220,7 +220,7 @@ int mount(const char *source, const char *target, ...@@ -220,7 +220,7 @@ int mount(const char *source, const char *target,
errcode = -EINVAL; errcode = -EINVAL;
goto errout_with_lock; goto errout_with_lock;
} }
if (mountpt_vnode->flag & VNODE_FLAG_MOUNT_ORIGIN) if (mountpt_vnode->flag & VNODE_FLAG_MOUNT_NEW)
{ {
PRINT_ERR("can't mount to %s, already mounted.\n", target); PRINT_ERR("can't mount to %s, already mounted.\n", target);
errcode = -EINVAL; errcode = -EINVAL;
...@@ -280,8 +280,8 @@ int mount(const char *source, const char *target, ...@@ -280,8 +280,8 @@ int mount(const char *source, const char *target,
#endif #endif
goto errout_with_mountpt; goto errout_with_mountpt;
} }
mnt->vnodeBeCovered->flag |= VNODE_FLAG_MOUNT_NEW; mnt->vnodeBeCovered->flag |= VNODE_FLAG_MOUNT_ORIGIN;
mnt->vnodeCovered->flag |= VNODE_FLAG_MOUNT_ORIGIN; mnt->vnodeCovered->flag |= VNODE_FLAG_MOUNT_NEW;
mnt->ops = mops; mnt->ops = mops;
mnt->mountFlags = mountflags; mnt->mountFlags = mountflags;
ret = strcpy_s(mnt->pathName, PATH_MAX, target); ret = strcpy_s(mnt->pathName, PATH_MAX, target);
......
...@@ -82,7 +82,7 @@ BOOL fs_in_use(struct Mount *mnt, const char *target) ...@@ -82,7 +82,7 @@ BOOL fs_in_use(struct Mount *mnt, const char *target)
return TRUE; return TRUE;
} }
} }
return VnodeInUseIter(mnt->vnodeCovered); return VnodeInUseIter(mnt);
} }
int umount(const char *target) int umount(const char *target)
...@@ -113,7 +113,7 @@ int umount(const char *target) ...@@ -113,7 +113,7 @@ int umount(const char *target)
goto errout; goto errout;
} }
/* Verify that the vnode is a mountpoint */ /* Verify that the vnode is a mountpoint */
if (!mountpt_vnode || !(mountpt_vnode->flag & VNODE_FLAG_MOUNT_ORIGIN)) if (!mountpt_vnode || !(mountpt_vnode->flag & VNODE_FLAG_MOUNT_NEW))
{ {
ret = -EINVAL; ret = -EINVAL;
goto errout; goto errout;
...@@ -127,7 +127,7 @@ int umount(const char *target) ...@@ -127,7 +127,7 @@ int umount(const char *target)
goto errout; goto errout;
} }
covered_vnode = mnt->vnodeBeCovered; covered_vnode = mnt->vnodeBeCovered;
if (!covered_vnode || !(covered_vnode->flag & VNODE_FLAG_MOUNT_NEW)) if (!covered_vnode || !(covered_vnode->flag & VNODE_FLAG_MOUNT_ORIGIN))
{ {
ret = -EINVAL; ret = -EINVAL;
goto errout; goto errout;
...@@ -191,7 +191,7 @@ int umount(const char *target) ...@@ -191,7 +191,7 @@ int umount(const char *target)
} }
#endif #endif
covered_vnode->newMount = NULL; covered_vnode->newMount = NULL;
covered_vnode->flag &= ~(VNODE_FLAG_MOUNT_NEW); covered_vnode->flag &= ~(VNODE_FLAG_MOUNT_ORIGIN);
VnodeDrop(); VnodeDrop();
return OK; return OK;
......
...@@ -86,13 +86,13 @@ static int check_rename_target(struct Vnode *old_vnode, struct Vnode *old_parent ...@@ -86,13 +86,13 @@ static int check_rename_target(struct Vnode *old_vnode, struct Vnode *old_parent
{ {
return -EXDEV; return -EXDEV;
} }
if ((old_vnode->flag & VNODE_FLAG_MOUNT_NEW) if ((old_vnode->flag & VNODE_FLAG_MOUNT_ORIGIN)
|| (old_vnode->flag & VNODE_FLAG_MOUNT_ORIGIN)) || (old_vnode->flag & VNODE_FLAG_MOUNT_NEW))
{ {
return -EBUSY; return -EBUSY;
} }
if (new_vnode != NULL && ((new_vnode->flag & VNODE_FLAG_MOUNT_NEW) if (new_vnode != NULL && ((new_vnode->flag & VNODE_FLAG_MOUNT_ORIGIN)
|| (new_vnode->flag & VNODE_FLAG_MOUNT_ORIGIN))) || (new_vnode->flag & VNODE_FLAG_MOUNT_NEW)))
{ {
return -EBUSY; return -EBUSY;
} }
......
...@@ -68,8 +68,8 @@ static int check_target(struct Vnode *vnode, char *name) { ...@@ -68,8 +68,8 @@ static int check_target(struct Vnode *vnode, char *name) {
return -EBUSY; return -EBUSY;
} }
if ((vnode->flag & VNODE_FLAG_MOUNT_NEW) if ((vnode->flag & VNODE_FLAG_MOUNT_ORIGIN)
|| (vnode->flag & VNODE_FLAG_MOUNT_ORIGIN)) || (vnode->flag & VNODE_FLAG_MOUNT_NEW))
{ {
return -EBUSY; return -EBUSY;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册