提交 ed8c503a 编写于 作者: M Michal Privoznik

virfile: Handle directories in virFileBindMountDevice()

The @src is not always a file. It may also be a directory (for
instance qemuDomainCreateDeviceRecursive() assumes that) - even
though it doesn't happen usually. Anyway, mount() can mount only
a dir onto a dir and a file onto a file.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NPavel Mores <pmores@redhat.com>
上级 14003623
......@@ -3743,8 +3743,17 @@ int
virFileBindMountDevice(const char *src,
const char *dst)
{
if (virFileTouch(dst, 0666) < 0)
return -1;
if (!virFileExists(dst)) {
if (virFileIsDir(src)) {
if (virFileMakePath(dst) < 0) {
virReportSystemError(errno, _("Unable to make dir %s"), dst);
return -1;
}
} else {
if (virFileTouch(dst, 0666) < 0)
return -1;
}
}
if (mount(src, dst, "none", MS_BIND, NULL) < 0) {
virReportSystemError(errno, _("Failed to bind %s on to %s"), src,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册