aboutsummaryrefslogtreecommitdiffstats
path: root/tools/hv
diff options
context:
space:
mode:
authorYue Zhang <yuezha@microsoft.com>2014-06-27 21:19:48 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-07-09 17:21:26 -0400
commite013ac312c79379b26cf29012cfbb37c68f79283 (patch)
tree684ca9c3ada56901c9c8756cce25a6353045873f /tools/hv
parentda86920f4a193c8d55cfcb006e2e74b4bfab21d0 (diff)
Tools: hv: fix file overwriting of hv_fcopy_daemon
hv_fcopy_daemon fails to overwrite a file if the target file already exits. Add O_TRUNC flag on opening. Signed-off-by: Yue Zhang <yuezha@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/hv')
-rw-r--r--tools/hv/hv_fcopy_daemon.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
index fba1c75aa484..8f96b3ee0724 100644
--- a/tools/hv/hv_fcopy_daemon.c
+++ b/tools/hv/hv_fcopy_daemon.c
@@ -88,7 +88,8 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)
88 } 88 }
89 } 89 }
90 90
91 target_fd = open(target_fname, O_RDWR | O_CREAT | O_CLOEXEC, 0744); 91 target_fd = open(target_fname,
92 O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0744);
92 if (target_fd == -1) { 93 if (target_fd == -1) {
93 syslog(LOG_INFO, "Open Failed: %s", strerror(errno)); 94 syslog(LOG_INFO, "Open Failed: %s", strerror(errno));
94 goto done; 95 goto done;