Skip to contentSkip to conversation

Tools: hv: fix file overwriting of hv_fcopy_daemon

PATCH Superseded Yue Zhang 3 participants 4 messages Jun 27, 2014 Hyper-V/Azure core and drivers

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Yue Zhang

author
#0 lore raw

PATCH 1/1 Tools: hv: fix file overwriting of hv_fcopy_daemon

From: Yue Zhang <[email protected]>

hv_fcopy_daemon fails to overwrite a file if the target file already exits.

Add O_TRUNC flag on opening.

MS-TFS: 341345

---
 tools/hv/hv_fcopy_daemon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/hv/hv_fcopy_daemon.c +2 -1
index fba1c75..2a86297 100644
@@ -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;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 11 lines

-----Original Message-----
From: Yue Zhang [mailto:[email protected]]
Sent: Friday, June 27, 2014 5:17 PM
To: KY Srinivasan; Haiyang Zhang; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: Dexuan Cui; Thomas Shao
Subject: [PATCH] Tools: hv: fix file overwriting of hv_fcopy_daemon

Quoted 7 lines

From: Yue Zhang <[email protected]>

hv_fcopy_daemon fails to overwrite a file if the target file already exits.

Add O_TRUNC flag on opening.

MS-TFS: 341345

You need to include Greg in the "to list". Also get rid of the MS-TFS tag.

Quoted 11 lines
---
 tools/hv/hv_fcopy_daemon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/hv/hv_fcopy_daemon.c +0 -0
index fba1c75..2a86297 100644

tools/hv/hv_fcopy_daemon.c static int hv_start_fcopy(struct hv_start_fcopy *smsg) · line 94

Quoted 8 lines
tools/hv/hv_fcopy_daemon.c +2 -1
@@ -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);

Please align properly and there is no need for three lines here.

K. Y

#2 lore raw
In reply to Yue Zhang
Quoted 8 lines · Yue Zhang

From: Yue Zhang <[email protected]>

hv_fcopy_daemon fails to overwrite a file if the target file already exits.

Add O_TRUNC flag on opening.

MS-TFS: 341345

It's as if the people on your team don't talk to each other about what they should, or should not, include in their patch descriptions...

Please remove.

greg k-h

#3 lore raw
Quoted 9 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]

Quoted 5 lines

From: Yue Zhang <[email protected]>

hv_fcopy_daemon fails to overwrite a file if the target file already exits.

Quoted 8 lines
Quoted 3 lines

Add O_TRUNC flag on opening.

MS-TFS: 341345

It's as if the people on your team don't talk to each other about what they should, or should not, include in their patch descriptions...

Please remove.

Sorry for this. It is added by mistake. I will remove it.

Yue Zhang