提交 ab03b63d 编写于 作者: S Sripathi Kodi 提交者: Anthony Liguori

[virtio-9p] open should not return EBADF

When 9P server fails to create a file due to permission problems it should
return EPERM. However the current 9P2000.L code returns EBADF. EBADF is NOT
a valid return value from open() call.

The problem is because we do not preserve the errno variable properly. If the
file open had failed, the call to close() on the fd in v9fs_post_lcreate()
fails and sets errno to EBADF. We should preserve the errno that we got from
open() and we should call close() only if we had a valid fd.
Signed-off-by: NSripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: NVenkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
上级 a12c668f
......@@ -1760,8 +1760,10 @@ static void v9fs_post_lcreate(V9fsState *s, V9fsLcreateState *vs, int err)
err = vs->offset;
} else {
vs->fidp->fid_type = P9_FID_NONE;
close(vs->fidp->fs.fd);
err = -errno;
if (vs->fidp->fs.fd > 0) {
close(vs->fidp->fs.fd);
}
}
complete_pdu(s, vs->pdu, err);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册