Index | Thread | Search

From:
Martin Ziemer <horrad@horrad.de>
Subject:
Re: nnn refuses to create new file
To:
Maksim Rodin <a23s4a2008@yandex.ru>
Cc:
ports@openbsd.org
Date:
Thu, 4 Apr 2024 15:31:58 +0200

Download raw body.

Thread
Am Thu, Apr 04, 2024 at 02:13:19PM +0300 schrieb Maksim Rodin:
> Hello
> When I try to create new file using "nf" the file manager shows the
> message "invalid argument" at the bottom.
Was able to recreate this issue.

The problem ist we NEED a Mode Flag, which is not given.

The patch below would fix the issue. I will try to get the fix in
upstream.

> When I hit "nd" it creates a new directory as expected.
> I suppose this happens after I recently upgraded the system to 7.4
> and the packages to their last version.
> 
> OpenBSD 7.4 stable
> nnn -V: 4.9
> 
> -- 
> Best regards
> Maksim Rodin

Index: Makefile
===================================================================
RCS file: /cvs/ports/sysutils/nnn/Makefile,v
retrieving revision 1.26
diff -u -p -r1.26 Makefile
--- Makefile	27 Sep 2023 17:16:31 -0000	1.26
+++ Makefile	4 Apr 2024 13:28:13 -0000
@@ -3,6 +3,7 @@ COMMENT =		the missing terminal file bro
 V =			4.9
 DISTNAME =		nnn-v${V}
 PKGNAME =		nnn-${V}
+REVISION =		0
 
 CATEGORIES =		sysutils
 
Index: patches/patch-src_nnn_c
===================================================================
RCS file: patches/patch-src_nnn_c
diff -N patches/patch-src_nnn_c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_nnn_c	4 Apr 2024 13:28:13 -0000
@@ -0,0 +1,14 @@
+Fix creation of Files
+
+Index: src/nnn.c
+--- src/nnn.c.orig
++++ src/nnn.c
+@@ -4692,7 +4692,7 @@ next:
+ 			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!");