cc [ flag... ] file... -lkstat [ library... ]
#include <kstat.h>
kid_t *kstat_chain_update(kstat_ctl_t *kc);
kstat_chain_update() brings the user’s kstat header chain in sync with the kernel’s. The kstat chain is a linked list of kstat headers (kstat_t’s), pointed to by kc->kc_chain, which is initialized by kstat_open(3K) . This chain constitutes a list of all kstats currently in the system. During normal operation, the kernel will occasionally create new kstats and delete old ones, as various device instances come and go. When this happens, the user’s copy of the kstat chain becomes out of date.
kstat_chain_update() detects this by comparing the kernel’s current kstat chain ID (KCID), which is incremented every time the kstat chain changes, to the user’s KCID, kc->kc_chain_id. If the KCID ’s match, kstat_chain_update() does nothing. Otherwise, it deletes any invalid kstat headers from the user’s kstat chain, and adds any new ones, and sets kc->kc_chain_id to the new KCID . All other kstat headers in the user’s kstat chain are unmodified.