kstat2_create_with_template, kstat2_lookup_template - lookup a system template, create and initialize a new kstat using a template
#include <sys/types.h> #include <sys/kstat2.h> kstat2_template_t *kstat2_lookup_template(uint32_t tmpl_id); const kstat2_t *kstat2_create_with_template( const char *ks_pseg[], uint32_t ks_npseg, zoneid_t ks_zone, kstat2_template_t *ks_tmpl, uint32_t ks_flags, kstat2_named_t *ks_data, const char *ks_desc, kstat2_metaflag_t ks_mflags);
Solaris DDI specific (Solaris DDI)
kstat2_lookup_template() function
ID of the system template to be returned.
kstat2_create_with_template() function
The segments used to construct a path that uniquely identifies this kstat. For example, “unix”, “cpu”, “cpu_info”, “1”.
The number of path segments in the array kstat_pseg.
The ID of the zone in which this kstat is initially visible. The constant ALL_ZONES is used to make the kstat visible in all zones, and the constant, GLOBAL_ZONEID is used to make it visible only in the global zone. kstat2_zone_add(9F) function can be used to make the kstat visible in other zones.
The pointer to the template data structure which is used to create and populate the data for this kstat.
A bit-field of flags for this kstat. For more information about the flags, see the kstat2_create(9F) man page.
For kstats whose data is managed by the driver, this field must point to an appropriate name-value pair array structure in the driver. For kstats whose storage is managed by the kstats framework, this field must be NULL.
A brief string describing the purpose of this kstat.
Meta-flags for the kstat as a whole. Either KSTAT2_MF_NONE or KSTAT2_MF_STABLE
Indicates that this kstat has no meta-flags set.
Indicates that this kstat is considered stable and will not be removed from Solaris without prior notification.
The kstat2_lookup_template() function fetches the system template associated with the given ID. This template is passed to kstat2_create_with_template() to create a kstat.
The kstat2_create_with_template() function is used to allocate and initialize a kstat2 structure. The majority of the data required to create the kstat is provided in supplied template.
After a successful call to kstat2_create_with_template() function the driver should set the ks2_update, ks2_private, and ks2_lock fields as needed.
Once the kstat is completely initialized, the kstat2_install(9F) function is used to make it accessible to the outside world.
The kstat2_create_with_template() function returns a pointer to a template or returns NULL if an invalid template ID is given.
The kstat2_create_with_template() function returns a pointer to the allocated kstat or returns NULL upon failure.
kstat2_lookup_template() and kstat2_create_with_template() can be called from user or kernel context.
kstat2_create(9F), kstat2_install(9F), kstat2_zone_add(9F), kstat2_zone_remove(9F), kstat2(9S) kstat2_md(9S), kstat2_named(9S), kstat2_template(9S)