diff --git a/fs/vfs/main.c b/fs/vfs/main.c index ea9bba8e87d6cde50bcebfd00e65e32a1c25f425..e2d69c1d1323b24e1b60ae250c5af6bcc8444e66 100755 --- a/fs/vfs/main.c +++ b/fs/vfs/main.c @@ -793,7 +793,6 @@ int dup(int oldfd) t->t_ofile[newfd] = fp; /* Increment file reference */ - vref(fp->f_vnode); fp->f_count++; return newfd; @@ -832,7 +831,6 @@ int dup3(int oldfd, int newfd, int flags) t->t_ofile[newfd] = fp; /* Increment file reference */ - vref(fp->f_vnode); fp->f_count++; return newfd; out_errno: @@ -869,7 +867,6 @@ int fcntl(int fd, int cmd, int arg) t->t_ofile[new_fd] = fp; /* Increment file reference */ - vref(fp->f_vnode); fp->f_count++; return new_fd; case F_GETFD: diff --git a/fs/vfs/vfs_syscalls.c b/fs/vfs/vfs_syscalls.c index 91e1ce5718bf8fd1315f97c653e73b938e6942a1..c8a0d4f3e39657d6e4be3100ff83a017ce7a5891 100755 --- a/fs/vfs/vfs_syscalls.c +++ b/fs/vfs/vfs_syscalls.c @@ -152,11 +152,10 @@ sys_close(file_t fp) if (fp->f_count <= 0) sys_panic("sys_close"); - vp = fp->f_vnode; - if (--fp->f_count > 0) { - vrele(vp); + if (--fp->f_count > 0) return 0; - } + + vp = fp->f_vnode; vn_lock(vp); if ((error = VOP_CLOSE(vp, fp)) != 0) { vn_unlock(vp);