Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This call to open() fails whenever /tmp/some_file already exists, including when it is a symbolic link. Care should be observed when using O_EXCL with remote file systems as it does not work with NFSv2 (but is supported in NFSv3 and later).The problem with this solution is that open() will fail if /tmp/some_file already exists. One solution This is a good thing, but a temporary file is presumably still required. One approach that can be used with open() is to generate random file names and attempt to open() each until we find a unique name is discovered. Luckily, there are predefined functions that perform this function.

Care should be observed when using O_EXCL with remote file systems as it does not work with NFS version 2. NFS version 3 added support for O_EXCL mode in open(); see IETF RFC 1813 Callaghan 95, in particular the EXCLUSIVE value to the mode argument of CREATE.

Non-Compliant Code Example: tmpnam()

...