[libvirt] [PATCH] Fix directory removal in virStorageBackendFileSystemVolDelete

Sascha Peilicke saschpe at suse.de
Wed Jul 11 11:25:34 UTC 2012


---
 src/storage/storage_backend_fs.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 4894994..8e93aaa 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -1138,6 +1138,17 @@ virStorageBackendFileSystemVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED,
     virCheckFlags(0, -1);
 
     if (unlink(vol->target.path) < 0) {
+        if (errno == EISDIR /* linux */ ||
+            errno == EPERM /* posix */) {
+            if (rmdir(vol->target.path) < 0) {
+                virReportSystemError(errno,
+                                     _("cannot remove directory '%s'"),
+                                     vol->target.path);
+                return -1;
+            } else {
+                return 0;
+            }
+        }
         /* Silently ignore failures where the vol has already gone away */
         if (errno != ENOENT) {
             virReportSystemError(errno,
-- 
1.7.10.4




More information about the libvir-list mailing list