git: bd23e71f91ce - main - libsysdecode: add a decoder for pollfd events

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Tue, 05 Mar 2024 05:44:15 UTC
The branch main has been updated by kevans:

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

commit bd23e71f91ceec5dfdffc28bbd0020849fdd20b4
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2024-03-05 04:14:06 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2024-03-05 05:44:09 +0000

    libsysdecode: add a decoder for pollfd events
    
    We'll use this in another change to read pollfd arrays coming from a
    successful poll(2) operation.
    
    Reviewed by:    bapt, jhb
    Differential Revision:  https://reviews.freebsd.org/D44159
---
 lib/libsysdecode/Makefile         |  1 +
 lib/libsysdecode/flags.c          |  8 ++++++++
 lib/libsysdecode/mktables         |  1 +
 lib/libsysdecode/sysdecode.h      |  1 +
 lib/libsysdecode/sysdecode_mask.3 | 12 +++++++++++-
 5 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/lib/libsysdecode/Makefile b/lib/libsysdecode/Makefile
index e1d6c7e02ff0..504701ee99a2 100644
--- a/lib/libsysdecode/Makefile
+++ b/lib/libsysdecode/Makefile
@@ -93,6 +93,7 @@ MLINKS+=sysdecode_mask.3 sysdecode_accessmode.3 \
 	sysdecode_mask.3 sysdecode_msync_flags.3 \
 	sysdecode_mask.3 sysdecode_open_flags.3 \
 	sysdecode_mask.3 sysdecode_pipe2_flags.3 \
+	sysdecode_mask.3 sysdecode_pollfd_events.3 \
 	sysdecode_mask.3 sysdecode_reboot_howto.3 \
 	sysdecode_mask.3 sysdecode_rfork_flags.3 \
 	sysdecode_mask.3 sysdecode_semget_flags.3 \
diff --git a/lib/libsysdecode/flags.c b/lib/libsysdecode/flags.c
index 33c778c391ee..32829d35dbe0 100644
--- a/lib/libsysdecode/flags.c
+++ b/lib/libsysdecode/flags.c
@@ -34,6 +34,7 @@
 #include <sys/linker.h>
 #include <sys/mman.h>
 #include <sys/mount.h>
+#include <sys/poll.h>
 #include <sys/procctl.h>
 #include <sys/ptrace.h>
 #include <sys/reboot.h>
@@ -565,6 +566,13 @@ sysdecode_pipe2_flags(FILE *fp, int flags, int *rem)
 	return (print_mask_0(fp, pipe2flags, flags, rem));
 }
 
+bool
+sysdecode_pollfd_events(FILE *fp, int flags, int *rem)
+{
+
+	return (print_mask_int(fp, pollfdevents, flags, rem));
+}
+
 const char *
 sysdecode_prio_which(int which)
 {
diff --git a/lib/libsysdecode/mktables b/lib/libsysdecode/mktables
index bf0dc34511d3..beb18e97f898 100644
--- a/lib/libsysdecode/mktables
+++ b/lib/libsysdecode/mktables
@@ -114,6 +114,7 @@ gen_table "mountflags"      "MNT_[A-Z]+[[:space:]]+0x[0-9]+"               "sys/
 gen_table "msyncflags"      "MS_[A-Z]+[[:space:]]+0x[0-9]+"                "sys/mman.h"
 gen_table "nfssvcflags"     "NFSSVC_[A-Z0-9]+[[:space:]]+0x[0-9]+"         "nfs/nfssvc.h"
 gen_table "pathconfname"    "_PC_[A-Z4_]+[[:space:]]+[0-9]+"               "sys/unistd.h"
+gen_table "pollfdevents"    "POLL[A-Z]+[[:space:]]+"                       "sys/poll.h"
 gen_table "prio"            "PRIO_[A-Z]+[[:space:]]+[0-9]"                 "sys/resource.h"
 gen_table "procctlcmd"      "PROC_[A-Z_]+[[:space:]]+[0-9]"                 "sys/procctl.h"	"PROC_TRACE_CTL_"
 gen_table "ptraceop"        "PT_[[:alnum:]_]+[[:space:]]+[0-9]+"           "sys/ptrace.h"
diff --git a/lib/libsysdecode/sysdecode.h b/lib/libsysdecode/sysdecode.h
index 4c091bb14343..8dc0bbea6f0d 100644
--- a/lib/libsysdecode/sysdecode.h
+++ b/lib/libsysdecode/sysdecode.h
@@ -83,6 +83,7 @@ const char *sysdecode_nfssvc_flags(int _flags);
 bool	sysdecode_open_flags(FILE *_fp, int _flags, int *_rem);
 const char *sysdecode_pathconf_name(int _name);
 bool	sysdecode_pipe2_flags(FILE *_fp, int _flags, int *_rem);
+bool	sysdecode_pollfd_events(FILE *fp, int flags, int *rem);
 const char *sysdecode_prio_which(int _which);
 const char *sysdecode_procctl_cmd(int _cmd);
 const char *sysdecode_ptrace_request(int _request);
diff --git a/lib/libsysdecode/sysdecode_mask.3 b/lib/libsysdecode/sysdecode_mask.3
index 171a086a5079..efcab331fe29 100644
--- a/lib/libsysdecode/sysdecode_mask.3
+++ b/lib/libsysdecode/sysdecode_mask.3
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd March 3, 2022
+.Dd February 29, 2024
 .Dt sysdecode_mask 3
 .Os
 .Sh NAME
@@ -43,6 +43,7 @@
 .Nm sysdecode_msync_flags ,
 .Nm sysdecode_open_flags ,
 .Nm sysdecode_pipe2_flags ,
+.Nm sysdecode_pollfd_events ,
 .Nm sysdecode_reboot_howto ,
 .Nm sysdecode_rfork_flags ,
 .Nm sysdecode_semget_flags ,
@@ -96,6 +97,8 @@
 .Ft bool
 .Fn sysdecode_pipe2_flags "FILE *fp" "int flags" "int *rem"
 .Ft bool
+.Fn sysdecode_pollfd_events "FILE *fp" "int flags" "int *rem"
+.Ft bool
 .Fn sysdecode_reboot_howto "FILE *fp" "int howto" "int *rem"
 .Ft bool
 .Fn sysdecode_rfork_flags "FILE *fp" "int flags" "int *rem"
@@ -191,6 +194,13 @@ and
 .Dv F_SETFL
 .Xr fcntl 2
 commands.
+.It Fn sysdecode_pollfd_events
+The
+.Fa events
+and
+.Fa revents
+members of a
+.Vt struct pollfd .
 .It Fn sysdecode_sctp_nxt_flags
 The
 .Fa nxt_flags