简体   繁体   中英

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. 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 (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. In the latter case you rely on the state which is not more valid.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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