DF-2573 / ngdpoc_append.c
/* ==== NGDPOC epilogue (appended AFTER the verbatim ng_device.c body) ==== */ /* * Read-only accessors into the static ngd_softc state so the driver harness * (kern/df_ngdpoc.c) can observe the connection list without the verbatim * file exporting anything. These run against the REAL static structures. */ #include <sys/kernel.h> #include <sys/sysctl.h> size_t ngdpoc_conn_size(void) { return (sizeof(struct ngd_connection)); } int ngdpoc_list_count(void) { struct ngd_softc *sc = &ngd_softc; struct ngd_connection *tmp; int n = 0; SLIST_FOREACH(tmp, &sc->head, links) n++; return (n); } void ngdpoc_list_dump(char *buf, size_t len) { struct ngd_softc *sc = &ngd_softc; struct ngd_connection *tmp; size_t o = 0; int n = 0; if (len == 0) return; o += (size_t)ksnprintf(buf + o, len - o, "conn=%d sz=%zu list:", ngdpoc_list_count(), sizeof(struct ngd_connection)); SLIST_FOREACH(tmp, &sc->head, links) { o += (size_t)ksnprintf(buf + o, len - o, " [unit=%d loc=%d ngddev=%p readq=%p]", tmp->unit, tmp->loc, tmp->ngddev, tmp->readq); if (o >= len - 1 || ++n > 30) break; } } /* boot-time attestation: sha256 of the verbatim source baked in by * gen_ngdpoc.sh at generation time */ static void ngdpoc_boot_attest(void *dummy __unused) { kprintf("NGDPOC: verbatim ng_device.c sha256=%s conn_size=%zu\n", NGDPOC_VSRC_SHA256, sizeof(struct ngd_connection)); } SYSINIT(ngdpoc_attest, SI_SUB_PSEUDO, SI_ORDER_MIDDLE, ngdpoc_boot_attest, NULL); |