提交 58e916ff 编写于 作者: J John Ferlan 提交者: Cole Robinson

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.

(cherry picked from commit cb19cff4)
上级 74909e96
......@@ -2381,9 +2381,10 @@ virFileUnlink(const char *path,
path, msg);
VIR_FREE(msg);
if (WIFEXITED(status))
ret = -WEXITSTATUS(status);
errno = WEXITSTATUS(status);
else
ret = -EACCES;
errno = EACCES;
ret = -errno;
}
parenterror:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册