Skip to content

What should a file system do if asked to create a file that already exists? #209

@jacobsa

Description

@jacobsa

What are the expections of osxfuse when the userspace daemon is sent a create request, but the file already exists? Should it return EEXIST, just open the file, or what?

Some notes on what I've determined experimentally:

  • If I call open(2) with several workers in parallel using O_CREAT, on Linux I only ever receive a single create request, but with osxfuse I receive many. So I conclude that Linux is holding a lock around the "look up, find doesn't exist, send create request" process, but osxfuse isn't.
  • Of course this question still applies on Linux if a file may be created remotely, so that it springs into existence after the kernel does a lookup but before it calls create.
  • Unless I've missed something, osxfuse doesn't seem to pass on the O_EXCL flag to the userspace daemon, so the daemon probably can't be responsible for deciding whether it is safe to open the file if it already exists.
  • Returning EEXIST appears to do the right thing whether O_EXCL is set or not, but just opening fails to work right if O_EXCL is set.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions