fix ref count check error

This commit is contained in:
zhao maosheng 2024-07-30 15:05:09 +08:00
parent 3e91a6836a
commit d0a5b34567
1 changed files with 6 additions and 4 deletions

View File

@ -31,8 +31,10 @@ static int dfs_procfs_open(struct dfs_file *file)
struct proc_dentry *entry = (struct proc_dentry *)file->vnode->data; struct proc_dentry *entry = (struct proc_dentry *)file->vnode->data;
RT_ASSERT(file->vnode->ref_count > 0); RT_ASSERT(file->ref_count > 0);
if (file->vnode->ref_count > 1)
// this file is opened and in an fdtable
if (file->ref_count > 1)
{ {
file->fpos = 0; file->fpos = 0;
return ret; return ret;
@ -377,7 +379,7 @@ static int dfs_procfs_free_vnode(struct dfs_vnode *vnode)
return 0; return 0;
} }
static const struct dfs_file_ops _dev_fops = static const struct dfs_file_ops _procfs_fops =
{ {
.open = dfs_procfs_open, .open = dfs_procfs_open,
.close = dfs_procfs_close, .close = dfs_procfs_close,
@ -394,7 +396,7 @@ static const struct dfs_filesystem_ops _procfs_ops =
{ {
.name = "procfs", .name = "procfs",
.default_fops = &_dev_fops, .default_fops = &_procfs_fops,
.mount = dfs_procfs_mount, .mount = dfs_procfs_mount,
.umount = dfs_procfs_umount, .umount = dfs_procfs_umount,