git: ea4042246d61 - main - libsysdecode: Add O_CLOFORK flags to sysdecode

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Sun, 06 Jul 2025 23:18:46 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=ea4042246d618ed67275ed8fc0685c1dd6bcb8e5

commit ea4042246d618ed67275ed8fc0685c1dd6bcb8e5
Author:     Ricardo Branco <rbranco@suse.de>
AuthorDate: 2025-05-17 18:27:37 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-07-06 23:09:18 +0000

    libsysdecode: Add O_CLOFORK flags to sysdecode
    
    Reviewed by:    kib
    MFC after:      1 month
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/1698
---
 lib/libsysdecode/flags.c               | 13 +++++++------
 lib/libsysdecode/sysdecode_fcntl_arg.3 |  3 ++-
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/lib/libsysdecode/flags.c b/lib/libsysdecode/flags.c
index dc09c5747968..f8e26e6a9dae 100644
--- a/lib/libsysdecode/flags.c
+++ b/lib/libsysdecode/flags.c
@@ -196,7 +196,7 @@ sysdecode_vmprot(FILE *fp, int type, int *rem)
 }
 
 static struct name_table sockflags[] = {
-	X(SOCK_CLOEXEC) X(SOCK_NONBLOCK) XEND
+	X(SOCK_CLOEXEC) X(SOCK_CLOFORK) X(SOCK_NONBLOCK) XEND
 };
 
 bool
@@ -206,16 +206,17 @@ sysdecode_socket_type(FILE *fp, int type, int *rem)
 	uintmax_t val;
 	bool printed;
 
-	str = lookup_value(socktype, type & ~(SOCK_CLOEXEC | SOCK_NONBLOCK));
+	str = lookup_value(socktype,
+	    type & ~(SOCK_CLOEXEC | SOCK_CLOFORK | SOCK_NONBLOCK));
 	if (str != NULL) {
 		fputs(str, fp);
 		*rem = 0;
 		printed = true;
 	} else {
-		*rem = type & ~(SOCK_CLOEXEC | SOCK_NONBLOCK);
+		*rem = type & ~(SOCK_CLOEXEC | SOCK_CLOFORK | SOCK_NONBLOCK);
 		printed = false;
 	}
-	val = type & (SOCK_CLOEXEC | SOCK_NONBLOCK);
+	val = type & (SOCK_CLOEXEC | SOCK_CLOFORK | SOCK_NONBLOCK);
 	print_mask_part(fp, sockflags, &val, &printed);
 	return (printed);
 }
@@ -563,7 +564,7 @@ sysdecode_nfssvc_flags(int flags)
 }
 
 static struct name_table pipe2flags[] = {
-	X(O_CLOEXEC) X(O_NONBLOCK) XEND
+	X(O_CLOEXEC) X(O_CLOFORK) X(O_NONBLOCK) XEND
 };
 
 bool
@@ -873,7 +874,7 @@ sysdecode_fcntl_cmd(int cmd)
 }
 
 static struct name_table fcntl_fd_arg[] = {
-	X(FD_CLOEXEC) X(0) XEND
+	X(FD_CLOEXEC) X(FD_CLOFORK) X(0) XEND
 };
 
 bool
diff --git a/lib/libsysdecode/sysdecode_fcntl_arg.3 b/lib/libsysdecode/sysdecode_fcntl_arg.3
index ee3a030a79e4..d5648ce0adc3 100644
--- a/lib/libsysdecode/sysdecode_fcntl_arg.3
+++ b/lib/libsysdecode/sysdecode_fcntl_arg.3
@@ -54,7 +54,8 @@ are determined by
 .It Sy Command Ta Fa arg Sy Type Ta Sy Output Format
 .It
 .It Dv F_SETFD Ta Vt int Ta
-.Dq FD_CLOEXEC
+.Dq FD_CLOEXEC ,
+.Dq FD_CLOFORK
 or the value of
 .Fa arg
 in the indicated