Skip to content

Commit e013ac3

Browse files
yuezhgregkh
authored andcommitted
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>
1 parent da86920 commit e013ac3

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎tools/hv/hv_fcopy_daemon.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)
8888
}
8989
}
9090

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);
9293
if (target_fd == -1) {
9394
syslog(LOG_INFO, "Open Failed: %s", strerror(errno));
9495
goto done;

0 commit comments

Comments
 (0)