Skip to content

Commit

Permalink
Fix file creation on OpenBSD
Browse files Browse the repository at this point in the history
On OpenBSD at least one of O_RDONLY, O_WRONLY or O_RDWR is needed to open a file.

In creating a new file none of those is set, which leads to an EINVAL error ("invalid argument").

Since the new file is only created and never read, I chose to use O_WRONLY.
  • Loading branch information
Martin Ziemer committed Apr 4, 2024
1 parent 22aa145 commit 28d993a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/nnn.c
Original file line number Diff line number Diff line change
Expand Up @@ -4732,7 +4732,7 @@ static bool xmktree(char *path, bool dir)
return FALSE;
}
} else {
int fd = open(path, O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR); /* Forced create mode for files */
int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR); /* Forced create mode for files */

if (fd == -1 && errno != EEXIST) {
DPRINTF_S("open!");
Expand Down

0 comments on commit 28d993a

Please sign in to comment.