Add an extension to the UINT & ULONG types. The XINT & XLONG types behave
the same, except sysctl(8) will print out the values in hex.
This commit is contained in:
parent
b58bbb1e90
commit
f6dcb46835
@ -578,7 +578,11 @@ show_var(int *oid, int nlen)
|
||||
while (len >= sizeof(int)) {
|
||||
fputs(val, stdout);
|
||||
if (*fmt == 'U')
|
||||
printf(hflag ? "%'u" : "%u", *(unsigned int *)p);
|
||||
printf(hflag ? "%'u" : "%u",
|
||||
*(unsigned int *)p);
|
||||
else if (*fmt == 'X')
|
||||
printf(hflag ? "%'#010x" : "%#010x",
|
||||
*(unsigned int *)p);
|
||||
else if (*fmt == 'K') {
|
||||
if (*(long *)p < 0)
|
||||
printf("%ld", *(long *)p);
|
||||
@ -601,7 +605,11 @@ show_var(int *oid, int nlen)
|
||||
while (len >= sizeof(long)) {
|
||||
fputs(val, stdout);
|
||||
if (*fmt == 'U')
|
||||
printf(hflag ? "%'lu" : "%lu", *(unsigned long *)p);
|
||||
printf(hflag ? "%'lu" : "%lu",
|
||||
*(unsigned long *)p);
|
||||
else if (*fmt == 'X')
|
||||
printf(hflag ? "%'#018lx" : "%#018lx",
|
||||
*(unsigned long *)p);
|
||||
else if (*fmt == 'K') {
|
||||
if (*(long *)p < 0)
|
||||
printf("%ld", *(long *)p);
|
||||
|
@ -38,7 +38,9 @@
|
||||
.Nm SYSCTL_STRING ,
|
||||
.Nm SYSCTL_STRUCT ,
|
||||
.Nm SYSCTL_UINT ,
|
||||
.Nm SYSCTL_ULONG
|
||||
.Nm SYSCTL_ULONG ,
|
||||
.Nm SYSCTL_XINT ,
|
||||
.Nm SYSCTL_XLONG
|
||||
.Nd Static sysctl declaration functions
|
||||
.Sh SYNOPSIS
|
||||
.In sys/types.h
|
||||
@ -129,6 +131,24 @@
|
||||
.Fa "val"
|
||||
.Fa "descr"
|
||||
.Fc
|
||||
.Fo SYSCTL_XINT
|
||||
.Fa "parent"
|
||||
.Fa "nbr"
|
||||
.Fa "name"
|
||||
.Fa "access"
|
||||
.Fa "ptr"
|
||||
.Fa "val"
|
||||
.Fa "descr"
|
||||
.Fc
|
||||
.Fo SYSCTL_XLONG
|
||||
.Fa "parent"
|
||||
.Fa "nbr"
|
||||
.Fa "name"
|
||||
.Fa "access"
|
||||
.Fa "ptr"
|
||||
.Fa "val"
|
||||
.Fa "descr"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
@ -153,8 +173,10 @@ New nodes are declared using one of
|
||||
.Nm SYSCTL_STRING ,
|
||||
.Nm SYSCTL_STRUCT ,
|
||||
.Nm SYSCTL_UINT ,
|
||||
.Nm SYSCTL_ULONG ,
|
||||
.Nm SYSCTL_XINT ,
|
||||
and
|
||||
.Nm SYSCTL_ULONG .
|
||||
.Nm SYSCTL_XLONG .
|
||||
Each macro accepts a parent name, as declared using
|
||||
.Nm SYSCTL_DECL ,
|
||||
an OID number, typically
|
||||
@ -271,6 +293,7 @@ Examples of integer, opaque, string, and procedure sysctls follow:
|
||||
* Example of a constant integer value. Notice that the control
|
||||
* flags are CTLFLAG_RD, the variable pointer is NULL, and the
|
||||
* value is declared.
|
||||
* If sysctl(8) should print this value in hex, use 'SYSCTL_XINT'.
|
||||
*/
|
||||
SYSCTL_INT(_debug_sizeof, OID_AUTO, bio, CTLFLAG_RD, NULL,
|
||||
sizeof(struct bio), "sizeof(struct bio)");
|
||||
|
@ -259,6 +259,14 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
|
||||
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|(access), \
|
||||
ptr, val, sysctl_handle_int, "IU", __DESCR(descr))
|
||||
|
||||
#define SYSCTL_XINT(parent, nbr, name, access, ptr, val, descr) \
|
||||
SYSCTL_OID(parent, nbr, name, CTLTYPE_UINT|(access), \
|
||||
ptr, val, sysctl_handle_int, "IX", descr)
|
||||
|
||||
#define SYSCTL_ADD_XINT(ctx, parent, nbr, name, access, ptr, val, descr) \
|
||||
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|(access), \
|
||||
ptr, val, sysctl_handle_int, "IX", __DESCR(descr))
|
||||
|
||||
/* Oid for a long. The pointer must be non NULL. */
|
||||
#define SYSCTL_LONG(parent, nbr, name, access, ptr, val, descr) \
|
||||
SYSCTL_OID(parent, nbr, name, CTLTYPE_LONG|(access), \
|
||||
@ -277,6 +285,14 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
|
||||
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|(access), \
|
||||
ptr, 0, sysctl_handle_long, "LU", __DESCR(descr))
|
||||
|
||||
#define SYSCTL_XLONG(parent, nbr, name, access, ptr, val, descr) \
|
||||
SYSCTL_OID(parent, nbr, name, CTLTYPE_ULONG|(access), \
|
||||
ptr, val, sysctl_handle_long, "LX", __DESCR(descr))
|
||||
|
||||
#define SYSCTL_ADD_XLONG(ctx, parent, nbr, name, access, ptr, descr) \
|
||||
sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_ULONG|(access), \
|
||||
ptr, 0, sysctl_handle_long, "LX", __DESCR(descr))
|
||||
|
||||
/* Oid for an opaque object. Specified by a pointer and a length. */
|
||||
#define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \
|
||||
SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access), \
|
||||
|
Loading…
x
Reference in New Issue
Block a user