Skip to content

Commit 28d993a

Browse files
author
Martin Ziemer
committed
Fix file creation on OpenBSD
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.
1 parent 22aa145 commit 28d993a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/nnn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4732,7 +4732,7 @@ static bool xmktree(char *path, bool dir)
47324732
return FALSE;
47334733
}
47344734
} else {
4735-
int fd = open(path, O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR); /* Forced create mode for files */
4735+
int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR | S_IRUSR); /* Forced create mode for files */
47364736

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

0 commit comments

Comments
 (0)