git: 9a2d163115f5 - stable/14 - kdump: Print splice structures

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Thu, 17 Oct 2024 16:16:38 UTC
The branch stable/14 has been updated by markj:

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

commit 9a2d163115f509c4a046295a6ffc4f2cd7162a7d
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-09-10 16:51:26 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-10-17 15:48:37 +0000

    kdump: Print splice structures
    
    MFC after:      3 months
    Sponsored by:   Klara, Inc.
    Sponsored by:   Stormshield
    
    (cherry picked from commit b76961e3a21a820f15ebff9d115ff67feb910cec)
---
 lib/libsysdecode/ktrace.out | Bin 0 -> 23596 bytes
 usr.bin/kdump/kdump.c       |  16 ++++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/lib/libsysdecode/ktrace.out b/lib/libsysdecode/ktrace.out
new file mode 100644
index 000000000000..29d35f0de3ce
Binary files /dev/null and b/lib/libsysdecode/ktrace.out differ
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c
index abbe57b0b75e..bde4eb7657e0 100644
--- a/usr.bin/kdump/kdump.c
+++ b/usr.bin/kdump/kdump.c
@@ -117,6 +117,7 @@ void ktruser(int, void *);
 void ktrcaprights(cap_rights_t *);
 void ktritimerval(struct itimerval *it);
 void ktrsockaddr(struct sockaddr *);
+void ktrsplice(struct splice *);
 void ktrstat(struct stat *);
 void ktrstruct(char *, size_t);
 void ktrcapfail(struct ktr_cap_fail *);
@@ -1935,6 +1936,14 @@ ktrsockaddr(struct sockaddr *sa)
 	printf(" }\n");
 }
 
+void
+ktrsplice(struct splice *sp)
+{
+	printf("struct splice { fd=%d, max=%#jx, idle=%jd.%06jd }\n",
+	    sp->sp_fd, (uintmax_t)sp->sp_max, (intmax_t)sp->sp_idle.tv_sec,
+	    (intmax_t)sp->sp_idle.tv_usec);
+}
+
 void
 ktrstat(struct stat *statp)
 {
@@ -2123,6 +2132,13 @@ ktrstruct(char *buf, size_t buflen)
 		memcpy(set, data, datalen);
 		ktrbitset(name, set, datalen);
 		free(set);
+	} else if (strcmp(name, "splice") == 0) {
+		struct splice sp;
+
+		if (datalen != sizeof(sp))
+			goto invalid;
+		memcpy(&sp, data, datalen);
+		ktrsplice(&sp);
 	} else {
 #ifdef SYSDECODE_HAVE_LINUX
 		if (ktrstruct_linux(name, data, datalen) == false)