Re: [PATCH] Fix directory removal in virStorageBackendFileSystemVolDelete

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 11, 2012 at 01:25:34PM +0200, Sascha Peilicke wrote:
> ---
>  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;
> +            }
> +        }

The vol->type field should already tell us whether the volume is a FILE,
BLOCK, NETWORK or DIR object. We should make this code switch(vol->type)
and use unlink or rmdir as appropriate, and raise an error for BLOCK
or NETWORK types


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]