Index | Thread | Search

From:
Theo Buehler <tb@theobuehler.org>
Subject:
Re: [PATCH]: Add POSIX O_CLOFORK flag
To:
Ricardo Branco <rbranco@suse.de>
Cc:
Philip Guenther <guenther@gmail.com>, tech@openbsd.org
Date:
Wed, 25 Jun 2025 12:09:31 +0200

Download raw body.

Thread
> How can I do this?  Extending current tests is not worth it, imo.

That would look something like this.

Attached is a tarball for a new port, illumos-os-tests.tgz, to be
extracted in /usr/ports/devel. It bundles the CDDL and all the stuff
beneath os-tests in illumos-gate with the patches from your gist applied
into a port installing these files in /usr/local/share/illumos-os-tests.

I also attached a package, illumos-os-tests-20250625.tgz, which you can
install as root with

# env TRUSTED_PKG_PATH=/path/to/tgz pkg_add illumos-os-tests

so you don't need to fiddle with the ports tree yourself.

This part of the kern_descrip.c diff from your
2bd21db4e48d499abaac013009cda6d0769e0049 doesn't compile:

 	case F_SETFD:
 		fdplock(fdp);
-		if ((long)SCARG(uap, arg) & 1)
-			fdp->fd_ofileflags[fd] |= UF_EXCLOSE;
-		else
-			fdp->fd_ofileflags[fd] &= ~UF_EXCLOSE;
+		fdp->fd_ofileflags[fd] =
+		    (fdp->fd_ofileflags[fd] & ~(UF_EXCLOSE | UF_FORKCLOSE)) |
+		    ((SCARG(uap, arg) & FD_CLOEXEC) ? UF_EXCLOSE : 0) |
+		    ((SCARG(uap, arg) & FD_CLOFORK) ? UF_FORKCLOSE : 0);
 		fdpunlock(fdp);
 		break;

/sys/kern/kern_descrip.c:470:25: error: invalid operands to binary expression ('void *' and 'int')
  470 |                     ((SCARG(uap, arg) & FD_CLOEXEC) ? UF_EXCLOSE : 0) |
      |                       ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~

I assume the two SCARG should be (long)SCARG to match what was removed.

> These tests are more than enough...  Still waiting for a response if
> they can relicense them to BSD though.

Finally, here's a diff for the regress tests. With the (long)SCARG
change applied to your diff and with the illumos-os-tests package
installed, these tests compile and pass on my amd64 laptop. If the
package isn't installed, you get

===> illumos
===> illumos/oclo
package illumos-os-tests is required for this regress
SKIPPED

commit db54671d22ce4adf21cb47b7201bb3633526d24f
Author: Theo Buehler <tb@openbsd.org>
Date:   Wed Jun 25 11:10:19 2025 +0200

    Hook illumos-os-tests for oclo to libc regress
    
    Based on work by Ricardo Branco
    
    Change-Id: I6a6a6964af35f8d5c9eaeb3606b26b88b2ff2d19

diff --git a/regress/lib/libc/Makefile b/regress/lib/libc/Makefile
index 59d043c62fe..8bdc7809717 100644
--- a/regress/lib/libc/Makefile
+++ b/regress/lib/libc/Makefile
@@ -11,7 +11,7 @@ SUBDIR+= ffs fmemopen fnmatch fpclassify fread
 SUBDIR+= gcvt getaddrinfo getcap getopt getopt_long glob
 SUBDIR+= hash
 SUBDIR+= hsearch
-SUBDIR+= ieeefp ifnameindex
+SUBDIR+= ieeefp ifnameindex illumos
 SUBDIR+= ldexp locale longjmp
 SUBDIR+= malloc mkstemp modf
 SUBDIR+= netdb
diff --git a/regress/lib/libc/illumos/Makefile b/regress/lib/libc/illumos/Makefile
new file mode 100644
index 00000000000..7fdceb00349
--- /dev/null
+++ b/regress/lib/libc/illumos/Makefile
@@ -0,0 +1,7 @@
+#	$OpenBSD$
+
+SUBDIR += oclo
+
+install:
+
+.include <bsd.subdir.mk>
diff --git a/regress/lib/libc/illumos/Makefile.inc b/regress/lib/libc/illumos/Makefile.inc
new file mode 100644
index 00000000000..574d9f3d970
--- /dev/null
+++ b/regress/lib/libc/illumos/Makefile.inc
@@ -0,0 +1,7 @@
+ILLUMOS_OS_TESTDIR = /usr/local/share/illumos-os-tests
+
+.if !exists(${ILLUMOS_OS_TESTDIR})
+regress:
+	@echo package illumos-os-tests is required for this regress
+	@echo SKIPPED
+.endif
diff --git a/regress/lib/libc/illumos/oclo/Makefile b/regress/lib/libc/illumos/oclo/Makefile
new file mode 100644
index 00000000000..d808c54ab2a
--- /dev/null
+++ b/regress/lib/libc/illumos/oclo/Makefile
@@ -0,0 +1,14 @@
+#	$OpenBSD$
+
+.if exists(/usr/local/share/illumos-os-tests)
+
+PROGS =		oclo
+PROGS +=	oclo_errors
+PROGS +=	ocloexec_verify
+
+LDADD_ocloexec_verify = -lkvm
+
+.PATH: /usr/local/share/illumos-os-tests/tests/oclo
+.endif
+
+.include <bsd.regress.mk>