From e013ac312c79379b26cf29012cfbb37c68f79283 Mon Sep 17 00:00:00 2001 From: Yue Zhang Date: Fri, 27 Jun 2014 18:19:48 -0700 Subject: 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 Signed-off-by: Greg Kroah-Hartman --- tools/hv/hv_fcopy_daemon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c index fba1c75aa48..8f96b3ee072 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) } } - target_fd = open(target_fname, O_RDWR | O_CREAT | O_CLOEXEC, 0744); + target_fd = open(target_fname, + O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0744); if (target_fd == -1) { syslog(LOG_INFO, "Open Failed: %s", strerror(errno)); goto done; -- cgit v1.2.3-70-g09d2