From: John Ferlan Date: Wed, 30 Sep 2015 21:37:27 +0000 (-0400) Subject: virfile: Fix error path for forked virFileRemove X-Git-Tag: v1.2.21-rc1~129 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb19cff468432e55366014658f405066ce06c2f2;p=thirdparty%2Flibvirt.git virfile: Fix error path for forked virFileRemove As it turns out the caller in this case expects a return < 0 for failure and to get/use "errno" rather than using the negative of returned status. Again different than the create path. If someone "deleted" a file from the pool without using virsh vol-delete, then the unlink/rmdir would return an error (-1) and set errno to ENOENT. The caller checks errno for ENOENT when determining whether to throw an error message indicating the failure. Without the change, the error message is: error: Failed to delete vol $vol error: cannot unlink file '/$pathto/$vol': Success This patch thus allows the fork path to follow the non-fork path where unlink/rmdir return -1 and errno. --- diff --git a/src/util/virfile.c b/src/util/virfile.c index 3d7efdc15e..a81f04c1a4 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -2364,8 +2364,10 @@ virFileRemove(const char *path, status = EACCES; } - if (status) - ret = -status; + if (status) { + errno = status; + ret = -1; + } return ret; }