Go to main content

man pages section 9: DDI and DKI Kernel Functions

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

kstat2_lookup_template (9F)

Name

kstat2_create_with_template, kstat2_lookup_template - lookup a system template, create and initialize a new kstat using a template

Synopsis

#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);

Interface Level

Solaris DDI specific (Solaris DDI)

Parameters

kstat2_lookup_template() function

tmpl_id

ID of the system template to be returned.

kstat2_create_with_template() function

ks_pseg

The segments used to construct a path that uniquely identifies this kstat. For example, “unix”, “cpu”, “cpu_info”, “1”.

ks_npseg

The number of path segments in the array kstat_pseg.

ks_zone

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.

ks_tmpl

The pointer to the template data structure which is used to create and populate the data for this kstat.

ks_flags

A bit-field of flags for this kstat. For more information about the flags, see the kstat2_create(9F) man page.

ks_data

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.

ks_desc

A brief string describing the purpose of this kstat.

ks_mflags

Meta-flags for the kstat as a whole. Either KSTAT2_MF_NONE or KSTAT2_MF_STABLE

KSTAT2_MF_NONE

Indicates that this kstat has no meta-flags set.

KSTAT2_MF_STABLE

Indicates that this kstat is considered stable and will not be removed from Solaris without prior notification.

Description

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.

Return Values

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.

Context

kstat2_lookup_template() and kstat2_create_with_template() can be called from user or kernel context.

See Also

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)