From patchwork Tue Jun 10 13:14:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Whitcroft X-Patchwork-Id: 357919 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id B818C140077; Tue, 10 Jun 2014 23:14:34 +1000 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1WuLsl-0002dU-1D; Tue, 10 Jun 2014 13:14:31 +0000 Received: from mail-we0-f169.google.com ([74.125.82.169]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1WuLsg-0002dK-G9 for kernel-team@lists.ubuntu.com; Tue, 10 Jun 2014 13:14:26 +0000 Received: by mail-we0-f169.google.com with SMTP id t60so2216054wes.0 for ; Tue, 10 Jun 2014 06:14:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YUnlUCN/VZeEIVk4OXtwCiarLbjz7RvBKG+yc8DWcxc=; b=S9Z/OLoYanbAij2D29+V5bTCC2le/ws1uR2M9fStZjIw8dLXLTpGVyo7QuUDrO/hOC auqwKvI+4KRBDBAXEMWyZ3SOg40KE6VFDPPh78OYVvGaVmXvjMoKTier37bFQ3nX7Ak2 rpYw4seHpPddtp22KIcwcgYSg/hr03hK7s+jIzQV35GANMKcUts24i0A3+DjEdyGFtEG 5QxJ8rznlSi5dyOJw43rFJQ0+Wzq1+iH0q/R7deQ3V7yDuUO2Xoa5lKBDHG/4vo2Puu/ D1K2DqlWJ8xOivgLVJTYSqleYRZVM2ZR7O+ETk1LfyRJc2NxQ9pvlg7QEaEM4txrug7h Zuhg== X-Gm-Message-State: ALoCoQlw9CmVxDISNfyBVDRRlrXf+PWfsEMq7sC2VngrlN3OQ9O7XAUCGsdIc+6M40Lis5P3PUAt X-Received: by 10.194.71.19 with SMTP id q19mr42046826wju.21.1402406066337; Tue, 10 Jun 2014 06:14:26 -0700 (PDT) Received: from localhost ([2001:470:6973:2:ede3:136c:5fc6:99c1]) by mx.google.com with ESMTPSA id f1sm19145035wix.14.2014.06.10.06.14.25 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 10 Jun 2014 06:14:25 -0700 (PDT) From: Andy Whitcroft To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/1] Tools: hv: Handle the case when the target file exists correctly Date: Tue, 10 Jun 2014 14:14:22 +0100 Message-Id: <1402406062-8524-2-git-send-email-apw@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1402406062-8524-1-git-send-email-apw@canonical.com> References: <1402406062-8524-1-git-send-email-apw@canonical.com> Cc: Andy Whitcroft X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: "K. Y. Srinivasan" 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 Cc: [3.14] Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 314672a2c2780212fb770bb02d2fffaa1019823f) BugLink: http://bugs.launchpad.net/bugs/1306215 Signed-off-by: Andy Whitcroft --- include/uapi/linux/hyperv.h | 1 + tools/hv/hv_fcopy_daemon.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/hyperv.h b/include/uapi/linux/hyperv.h index 9beb7c9..78e4a86 100644 --- a/include/uapi/linux/hyperv.h +++ b/include/uapi/linux/hyperv.h @@ -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 diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c index 4ecc4fd..fba1c75 100644 --- a/tools/hv/hv_fcopy_daemon.c +++ b/tools/hv/hv_fcopy_daemon.c @@ -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);