]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
Tools: hv: Handle the case when the target file exists correctly
authorK. Y. Srinivasan <kys@microsoft.com>
Thu, 10 Apr 2014 00:24:16 +0000 (17:24 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Apr 2014 21:10:36 +0000 (14:10 -0700)
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>
include/uapi/linux/hyperv.h
tools/hv/hv_fcopy_daemon.c

index 9beb7c991638ad90d235a0221e6d30d3b7fc2292..78e4a86030dd2d295a1abba8ad6249668fdf7fef 100644 (file)
@@ -305,6 +305,7 @@ enum hv_kvp_exchg_pool {
 #define HV_ERROR_DEVICE_NOT_CONNECTED  0x8007048F
 #define HV_INVALIDARG                  0x80070057
 #define HV_GUID_NOTFOUND               0x80041002
+#define HV_ERROR_ALREADY_EXISTS                0x80070050
 
 #define ADDR_FAMILY_NONE       0x00
 #define ADDR_FAMILY_IPV4       0x01
index 4ecc4fd0bc1bd9f21effb6b3792f8029c808a91b..fba1c75aa484f6923ac562f5402f3bad4b2f1a0d 100644 (file)
@@ -82,8 +82,10 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)
 
        if (!access(target_fname, F_OK)) {
                syslog(LOG_INFO, "File: %s exists", target_fname);
-               if (!smsg->copy_flags & OVER_WRITE)
+               if (!(smsg->copy_flags & OVER_WRITE)) {
+                       error = HV_ERROR_ALREADY_EXISTS;
                        goto done;
+               }
        }
 
        target_fd = open(target_fname, O_RDWR | O_CREAT | O_CLOEXEC, 0744);