Skip to content
Snippets Groups Projects
Commit 6cbf4b92 authored by Christoph Hellwig's avatar Christoph Hellwig
Browse files

Ensure internal buffers are flushed json after dumping json to disk


A power-outage, unexpected reboot, etc can lead to zero byte file
after a saveconfig.

Based on a rtslib-fb patch from Jon Magrini <jmagrini@redhat.com>.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent a202c7cb
No related branches found
No related tags found
No related merge requests found
......@@ -240,7 +240,9 @@ class Root(CFSNode):
os.fchmod(f.fileno(), stat.S_IRUSR | stat.S_IWUSR)
f.write(json.dumps(self.dump(), sort_keys=True, indent=2))
f.write("\n")
f.flush()
os.fsync(f.fileno())
f.close()
os.rename(savefile + ".temp", savefile)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment