Linux确保文件的内容在close()后被刷新到光盘上? [英] Does Linux guarantee the contents of a file is flushed to disc after close()?
问题描述
close()
或 fclose()
来关闭文件时,Linux保证该文件被写回到(永久)光盘? 我的意思是,如果 close()
返回0,然后立即电源失败,先前写入的数据保证持久,即是持久的?
我找不到任何东西,使得任何索赔的方式或另一个目前。 问题2: 如果 从< 成功关闭并不能保证数据已经被成功保存到磁盘 When a file is closed using What I mean is, if The I can't find anything which makes any claim one way or another at the moment. Question 2: If From " A successful close does not guarantee that the data has been
successfully saved to disk, as the
kernel defers writes. The man page says that if you want to be sure that your data are on disk, you have to use fsync() yourself. 这篇关于Linux确保文件的内容在close()后被刷新到光盘上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! fsync()$ c系统调用确实提供了这个保证。关闭一个文件也是足够的吗?
close()
确实隐式地做了一个 fsync()
,有没有告诉它的方法?
,因为
内核推迟写入。
<手册页说,如果你想确保你的数据在磁盘上,你必须自己使用fsync()。close()
or fclose()
(for example), does Linux guarantee that the file is written back to (persistent) disc?close()
returns 0 and then immediately afterwards the power fails, are previously written data guaranteed to persist, i.e. be durable?fsync()
system call does provide this guarantee. Is closing a file also sufficient?
close()
does implicitly do an fsync()
, is there a way of telling it not to?man 2 close
":