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. The question is, can I rely on this behavior and not check for existence in create/mkdir?

有帮助吗?

解决方案

I would better check for file existence anyway cause (a) OS behavior can change in future (i.e. 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. In the latter case you rely on the state which is not more valid.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top