jarun / nnn

n³ The unorthodox terminal file manager
BSD 2-Clause "Simplified" License
19.1k stars 760 forks source link

Fix file creation on OpenBSD #1864

Closed horrad closed 6 months ago

horrad commented 6 months ago

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.

N-R-K commented 6 months ago

@horrad Please put what you wrote in the PR description in the commit message body as well.

horrad commented 6 months ago

@horrad Please put what you wrote in the PR description in the commit message body as well. Done.

jarun commented 6 months ago

Can you please make the patch BSD-specific?

KlzXS commented 6 months ago

I think it's best we avoid adding unnecessary #ifdefs. open(2) says:

The argument flags must include one of the following access modes: O_RDONLY, O_WRONLY, or O_RDWR.

We have none of those.

jarun commented 6 months ago

Makes sense. Merged. Thanks!