Skip to content

Commit 314672a

Browse files
kattisrinivasangregkh
authored andcommitted
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>
1 parent 177581f commit 314672a

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎include/uapi/linux/hyperv.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ enum hv_kvp_exchg_pool {
305305
#define HV_ERROR_DEVICE_NOT_CONNECTED 0x8007048F
306306
#define HV_INVALIDARG 0x80070057
307307
#define HV_GUID_NOTFOUND 0x80041002
308+
#define HV_ERROR_ALREADY_EXISTS 0x80070050
308309

309310
#define ADDR_FAMILY_NONE 0x00
310311
#define ADDR_FAMILY_IPV4 0x01

‎tools/hv/hv_fcopy_daemon.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)
8282

8383
if (!access(target_fname, F_OK)) {
8484
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;
8687
goto done;
88+
}
8789
}
8890

8991
target_fd = open(target_fname, O_RDWR | O_CREAT | O_CLOEXEC, 0744);

0 commit comments

Comments
 (0)