首页 \ 问答 \ 保证文件操作的顺序(Guarantees of order of the operations on file)

保证文件操作的顺序(Guarantees of order of the operations on file)

我想知道文件/文件系统上的操作顺序是否有任何保证。

考虑我有一个文件foo.dat ,我将其更新如下:

 lseek(fd,pos_a,SEEK_SET);
 write(fd,data_a,size_a);  //< - Operation A
 lseek(fd,pos_b,SEEK_SET);
 write(fd,data_b,size_b);  //< - Operation B
 lseek(fd,pos_c,SEEK_SET);
 write(fd,data_c,size_c);  //< - Operation C

这样我在文件A,B,C中进行更新。并且可能发生一些故障 - 软件崩溃或例如电源故障。

是否有任何保证,如果执行的操作是以相同的顺序完成的。

即没有任何东西或“A”或“A和B”或“A和B和C”

但不是像“A和C”或“B”这样的情况。

我知道如果我在A和B之间fsync(fd)并在A和C之间fsync(fd) ,但它也保证实际上是在文件系统上。

我不太关心数据的松散,而是关注它的一致性。

POSIX标准是否保证不会出现无序执行?

所以:

  • 有没有这样的保证?
  • 在POSIX平台上?
  • 在Windows平台上?
  • 如果没有什么保证(除了fsync )我可以有?

I'd like to know if there any guarantees on the order of the operations on file/file system.

Consider I have a file foo.dat and I update it as following:

 lseek(fd,pos_a,SEEK_SET);
 write(fd,data_a,size_a);  //< - Operation A
 lseek(fd,pos_b,SEEK_SET);
 write(fd,data_b,size_b);  //< - Operation B
 lseek(fd,pos_c,SEEK_SET);
 write(fd,data_c,size_c);  //< - Operation C

Such that I do updates in file A, B, C. And some fault may occur - software crash or for example power failure.

Is there any guarantees that the operations if they are executed are done in same order.

i.e. That there would be either nothing or "A" or "A and B" or "A and B and C"

But not situations like "A and C" or "B" only.

I know that if I call between A and B fsync(fd) and same between A and C but it also guarantees that is actually on file system.

I less care about loose of data but rather about its consistency.

Does POSIX standard guarantees that there will be no out-of-order execution?

So:

  • As there any such guarantees?
  • On POSIX platform?
  • On Windows platform?
  • If not what guarantees (besides fsync) I can have?

原文:https://stackoverflow.com/questions/7463925
更新时间:2021-12-21 12:12

相关问答

更多
  • 解决了nfc.addTagDiscoveredListener而不是nfc.addNdefListener Solved with nfc.addTagDiscoveredListener instead of nfc.addNdefListener
  • 我想这是因为你的插件使用得太早了。 由于js是动态加载的,因此设备准备就绪时只能使用插件代码。 如果你这样做,它应该工作: document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { if(navigator.compass) alert("ok"); else alert("not supported..."); ...
  • 我不认为Cordova明确说明它兼容哪个操作系统版本,但似乎只要您使用的是IOS 8+,Cordova应该可以工作。 https://cordova.apache.org/docs/en/latest/guide/platforms/ios/index.html (“要求和支持”部分的第2段) 有关更一般的参考: https : //cordova.apache.org/docs/en/latest/guide/support/ I don't think Cordova explicitly states ...
  • 查看本教程,它涵盖了相当好的主题: http://coenraets.org/blog/cordova-phonegap-3-tutorial/ 如何在Ubuntu上安装/运行PhoneGap,分步指南 Check this tutorial, it covers quite well the subject : http://coenraets.org/blog/cordova-phonegap-3-tutorial/ How to install/run PhoneGap on Ubuntu, Step ...
  • 是的,您需要使用Mac进行构建和签名并将其上传到商店。 您还需要许多不同苹果设备的应用截图和视频。 iOS模拟器仅在Mac中运行。 您可以在互联网上租用Mac。 我建议,买自己的机器。 如果您的预算有限,可以购买二手mac mini。 你可以尝试WM的机会,但ipad的全高清模拟器非常糟糕。 Yes, you need Mac for build & sign and upload it to store. You will need your app screenshots and videos for ...
  • 要直接回答你的问题“Icenium如何与Phonegap不同?”,我们发布了一篇博文: Icenium和PhoneGap Build之间有什么区别? 你可能也有兴趣: 什么是Icenium真的吗? To answer directly your question "How is Icenium different from Phonegap?", we've published a blog post: What's the Difference Between Icenium and PhoneGap B ...
  • 取决于您要实施的内容; 只是流桌面或使用桌面上的应用程序。 流媒体桌面只是简单地拍摄桌面图像并将其作为视频流式传输到浏览器。 要利用可用的应用程序,您需要不同的解决方案。 利用COM自动化(C ++中的函数)用于Excel或Chrome,并通过JavaScript调用它。 这意味着创建插件。 虽然你的意思是插件,你不需要在Excel / Chrome或桌面上安装任何东西,但不,你不能。 应该有一个发送数据/流的组件和另一个接收它的组件。 我希望这可以帮助你前进。 Depending on what you ...
  • 我找到了根本原因。 问题是,通过使用angular-cli工具,标签会自动添加。 根据标签文档 ,它为解析所有文档的相对URL提供基础。 对于这种用例,删除基本标记或将其配置为有效值(如修复问题。 因为我没有使用路由功能(还),所以我觉得更容易删除它或设置一个像这样的值,它适合更多的平台构建。 I have found the root cause. The problem is ...
  • 你需要检查以下事项: 确保“screen.png”的路径未设置为“只读”。 确保构建服务使用的帐户具有足够的权限来访问该文件。 (尝试使用管理员帐户运行构建服务) 如果仍然无效,请尝试在构建之前添加一个步骤以检出文件。 同样的问题可以在这里提到: https : //social.msdn.microsoft.com/Forums/vstudio/en-US/81d5e57c-49bd-4487-a198-7930b48412b5/error-building-windows-x64-windows-x86 ...
  • 用“javascript parse csv”在Google上花了两秒钟来查找: http : //papaparse.com Spent two seconds on Google with "javascript parse csv" to find: http://papaparse.com

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。