Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Tools: hv: Handle the case when the target file exists correctly

Return the appropriate error code and handle the case when the target
file exists correctly. This fixes a bug.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: <stable@vger.kernel.org> [3.14]
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

K. Y. Srinivasan and committed by
Greg Kroah-Hartman
314672a2 177581fa

+4 -1
+1
include/uapi/linux/hyperv.h
··· 305 305 #define HV_ERROR_DEVICE_NOT_CONNECTED 0x8007048F 306 306 #define HV_INVALIDARG 0x80070057 307 307 #define HV_GUID_NOTFOUND 0x80041002 308 + #define HV_ERROR_ALREADY_EXISTS 0x80070050 308 309 309 310 #define ADDR_FAMILY_NONE 0x00 310 311 #define ADDR_FAMILY_IPV4 0x01
+3 -1
tools/hv/hv_fcopy_daemon.c
··· 82 82 83 83 if (!access(target_fname, F_OK)) { 84 84 syslog(LOG_INFO, "File: %s exists", target_fname); 85 - if (!smsg->copy_flags & OVER_WRITE) 85 + if (!(smsg->copy_flags & OVER_WRITE)) { 86 + error = HV_ERROR_ALREADY_EXISTS; 86 87 goto done; 88 + } 87 89 } 88 90 89 91 target_fd = open(target_fname, O_RDWR | O_CREAT | O_CLOEXEC, 0744);