简体   繁体   English

保险丝:我需要检查create / mkdir中文件/目录是否存在吗?

[英]FUSE: do I need to check for file/dir existence in create/mkdir?

I'm implementing a FUSE-based filesystem (osxfuse, actually, since it's on Mac), and I noticed that before create or mkdir call getattr is always called, and if a node already exists, create/mkdir does not get called. 我正在实现一个基于FUSE的文件系统(实际上是OSXFUSE,因为它在Mac上,因为它在Mac上),所以我注意到在create或mkdir调用之前总是调用getattr,并且如果已经存在一个节点,则不会调用create / mkdir。 The question is, can I rely on this behavior and not check for existence in create/mkdir? 问题是,我可以依靠这种行为而不在create / mkdir中检查是否存在吗?

I would better check for file existence anyway cause (a) OS behavior can change in future (ie your simplification would play a low-down trick later), and (b) there's often a chance that the file is created outside of your FS on your backend storage. 无论如何,我都会更好地检查文件是否存在,因为(a)将来操作系统的行为可能会发生变化(即,您的简化操作将在以后发挥低调的作用),并且(b)通常有可能在FS外部创建文件您的后端存储。 In the latter case you rely on the state which is not more valid. 在后一种情况下,您依赖的状态无效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM