Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

kstat_named_init(9f) [sunos man page]

kstat_named_init(9F)					   Kernel Functions for Drivers 				      kstat_named_init(9F)

NAME
kstat_named_init, kstat_named_setstr - initialize a named kstat SYNOPSIS
#include <sys/types.h> #include <sys/kstat.h> void kstat_named_init(kstat_named_t *knp, char *name, uchar_t data_type); void kstat_named_setstr(kstat_named_t *knp, const char *str); INTERFACE LEVEL
Solaris DDI specific (Solaris DDI) PARAMETERS
knp Pointer to a kstat_named(9S) structure. name The name of the statistic. data_type The type of value. This indicates which field of the kstat_named(9S) structure should be used. Valid values are: KSTAT_DATA_CHAR The "char" field. KSTAT_DATA_LONG The "long" field. KSTAT_DATA_ULONG The "unsigned long" field. KSTAT_DATA_LONGLONG Obsolete. Use KSTAT_DATA_INT64. KSTAT_DATA_ULONGLONG Obsolete. Use KSTAT_DATA_UINT64. KSTAT_DATA_STRING Arbitrary length "long string" field. str Pointer to a NULL-terminated string. DESCRIPTION
kstat_named_init() associates a name and a type with a kstat_named(9S) structure. kstat_named_setstr() associates str with the named kstat knp. It is an error for knp to be of type other than KSTAT_DATA_STRING. This is the only supported method of changing the value of long strings. RETURN VALUES
None. CONTEXT
kstat_named_init() and kstat_named_setstr() can be called from user or kernel context. SEE ALSO
kstat_create(9F), kstat_install(9F), kstat(9S), kstat_named(9S) Writing Device Drivers SunOS 5.10 8 Mar 2004 kstat_named_init(9F)

Check Out this Related Man Page

kstat(9S)						    Data Structures for Drivers 						 kstat(9S)

NAME
kstat - kernel statistics structure SYNOPSIS
#include <sys/types.h> #include <sys/kstat.h> #include <sys/ddi.h> #include <sys/sunddi.h> INTERFACE LEVEL
Solaris DDI specific (Solaris DDI) DESCRIPTION
Each kernel statistic (kstat) exported by device drivers consists of a header section and a data section. The kstat structure is the header portion of the statistic. A driver receives a pointer to a kstat structure from a successful call to kstat_create(9F). Drivers should never allocate a kstat struc- ture in any other manner. After allocation, the driver should perform any further initialization needed before calling kstat_install(9F) to actually export the kstat. STRUCTURE MEMBERS
void *ks_data; /* kstat type-specific data */ ulong_t ks_ndata; /* # of type-specific data records */ ulong_t ks_data_size; /* total size of kstat data section */ int (*ks_update)(struct kstat *, int); void *ks_private; /* arbitrary provider-private data */ void *ks_lock; /* protects this kstat's data */ The members of the kstat structure available to examine or set by a driver are as follows: ks_data Points to the data portion of the kstat. Either allocated by kstat_create(9F) for the drivers use, or by the driver if it is using virtual kstats. ks_ndata The number of data records in this kstat. Set by the ks_update(9E) routine. ks_data_size The amount of data pointed to by ks_data. Set by the ks_update(9E) routine. ks_update Pointer to a routine that dynamically updates kstat. This is useful for drivers where the underlying device keeps cheap hardware statistics, but where extraction is expensive. Instead of constantly keeping the kstat data section up to date, the driver can supply a ks_update(9E) function that updates the kstat data section on demand. To take advantage of this feature, set the ks_update field before calling kstat_install(9F). ks_private Is a private field for the driver's use. Often used in ks_update(9E). ks_lock Is a pointer to a mutex that protects this kstat. kstat data sections are optionally protected by the per-kstat ks_lock. If ks_lock is non-NULL, kstat clients (such as /dev/kstat) will acquire this lock for all of their operations on that kstat. It is up to the kstat provider to decide whether guaranteeing consistent data to kstat clients is sufficiently important to justify the locking cost. Note, however, that most statistic updates already occur under one of the provider's mutexes. If the provider sets ks_lock to point to that mutex, then kstat data locking is free. ks_lock is really of type (kmutex_t*) and is declared as (void*) in the kstat header. That way, users do not have to be exposed to all of the kernel's lock- related data structures. SEE ALSO
kstat_create(9F) Writing Device Drivers SunOS 5.10 4 Apr 1994 kstat(9S)
Man Page