Yeela Kaplan has uploaded a new change for review.
Change subject: remoteFileHandler: Add create exclusive option for truncateFile
......................................................................
remoteFileHandler: Add create exclusive option for truncateFile
Change-Id: Idfeff348e0f6fc240954e7d304b794dd99ea098c
Bug-Url:
https://bugzilla.redhat.com/show_bug.cgi?id=979193
Signed-off-by: Yeela Kaplan <ykaplan(a)redhat.com>
---
M vdsm/storage/remoteFileHandler.py
1 file changed, 7 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/22/19022/1
diff --git a/vdsm/storage/remoteFileHandler.py b/vdsm/storage/remoteFileHandler.py
index 779b045..f01461f 100644
--- a/vdsm/storage/remoteFileHandler.py
+++ b/vdsm/storage/remoteFileHandler.py
@@ -347,8 +347,13 @@
return f.writelines(lines)
-def truncateFile(path, size, mode=None):
- with open(path, "w") as f:
+def truncateFile(path, size, mode=None, creatExcl=False):
+ flags = os.O_CREAT | os.O_WRONLY
+ if creatExcl:
+ flags |= os.O_EXCL
+
+ fd = os.open(path, flags)
+ with os.fdopen(fd, 'w') as f:
if mode is not None:
os.chmod(path, mode)
f.truncate(size)
--
To view, visit
http://gerrit.ovirt.org/19022
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idfeff348e0f6fc240954e7d304b794dd99ea098c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yeela Kaplan <ykaplan(a)redhat.com>