提交 5079a7b3 编写于 作者: S Sascha Peilicke 提交者: Daniel P. Berrange

Fix directory removal in filesystem storage driver

Fix the virStorageBackendFileSystemVolDelete method to not use
unlink() unconditionally. It must use rmdir() for volumes which
are directories. It should also raise an error if given a volume
which has the network/block type.
上级 8a544719
......@@ -247,6 +247,7 @@ Patches have also been contributed by:
Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Thang Pham <thang.pham@us.ibm.com>
Eiichi Tsukata <eiichi.tsukata.xh@hitachi.com>
Sascha Peilicke <saschpe@suse.de>
[....send patches to get your name here....]
......
......@@ -1127,7 +1127,7 @@ virStorageBackendFileSystemVolBuildFrom(virConnectPtr conn,
}
/**
* Remove a volume - just unlinks for now
* Remove a volume - no support for BLOCK and NETWORK yet
*/
static int
virStorageBackendFileSystemVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED,
......@@ -1137,6 +1137,8 @@ virStorageBackendFileSystemVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED,
{
virCheckFlags(0, -1);
switch (vol->type) {
case VIR_STORAGE_VOL_FILE:
if (unlink(vol->target.path) < 0) {
/* Silently ignore failures where the vol has already gone away */
if (errno != ENOENT) {
......@@ -1146,6 +1148,23 @@ virStorageBackendFileSystemVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED,
return -1;
}
}
break;
case VIR_STORAGE_VOL_DIR:
if (rmdir(vol->target.path) < 0) {
virReportSystemError(errno,
_("cannot remove directory '%s'"),
vol->target.path);
return -1;
}
break;
case VIR_STORAGE_VOL_BLOCK:
case VIR_STORAGE_VOL_NETWORK:
default:
virStorageReportError(VIR_ERR_NO_SUPPORT,
_("removing block or network volumes is not supported: %s"),
vol->target.path);
return -1;
}
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册