int file_creat(ARCHD *arcn) { int fd = -1; mode_t file_mode; int oerrno; /* * Assume file doesn't exist, so just try to create it, most * times this works. We have to take special handling when the * file does exist. To detect this, we use O_EXCL. For example * when trying to create a file and a character device or fifo * exists with the same name, we can accidently open the device * by mistake (or block waiting to open). If we find that the * open has failed, then spend the effort to figure out why. This * strategy was found to have better average performance in * common use than checking the file (and the path) first * with lstat. */