History log of /freebsd-11-stable/sbin/sysctl/sysctl.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 344984 10-Mar-2019 wulf

MFC r344494,r344495:

evdev: export event device properties through sysctl interface

A big security advantage of Wayland is not allowing applications to read
input devices all the time. Having /dev/input/* accessible to the user
account subverts this advantage.

libudev-devd was opening the evdev devices to detect their types (mouse,
keyboard, touchpad, etc). This don't work if /dev/input/* is inaccessible.
With the kernel exposing this information as sysctls (kern.evdev.input.*),
we can work w/o /dev/input/* access, preserving the Wayland security model.

Submitted by: Greg V <greg@unrelenting.technology>
Reviewed by: wulf, imp
Differential Revision: https://reviews.freebsd.org/D18694


# 338680 14-Sep-2018 kib

MFC r338522, r338523, r338533:
Teach sysctl(8) about the Persistent memory type.
Improve nearby code.


# 331722 29-Mar-2018 eadler

Revert r330897:

This was intended to be a non-functional change. It wasn't. The commit
message was thus wrong. In addition it broke arm, and merged crypto
related code.

Revert with prejudice.

This revert skips files touched in r316370 since that commit was since
MFCed. This revert also skips files that require $FreeBSD$ property
changes.

Thank you to those who helped me get out of this mess including but not
limited to gonzo, kevans, rgrimes.

Requested by: gjb (re)


# 331603 27-Mar-2018 jhb

MFC 330711:
Permit sysctl(8) to set an array of numeric values for a single node.

Most sysctl nodes only return a single value, but some nodes return an
array of values (e.g. kern.cp_time). sysctl(8) understand how to display
the values of a node that returns multiple values (it prints out each
numeric value separated by spaces). However, until now sysctl(8) has
only been able to set sysctl nodes to a single value. This change
allows sysctl to accept a new value for a numeric sysctl node that contains
multiple values separated by either spaces or commas. sysctl(8) parses
this list into an array of values and passes the array as the "new" value
to sysctl(2).

Sponsored by: Chelsio Communications


# 330897 14-Mar-2018 eadler

Partial merge of the SPDX changes

These changes are incomplete but are making it difficult
to determine what other changes can/should be merged.

No objections from: pfg


# 311689 08-Jan-2017 avos

MFC r310961:
sysctl(8): fix typename for uint32_t


# 306316 25-Sep-2016 kib

MFC r305942:
Consolidate four efi_next_descriptor() definitions.


# 302408 07-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/cddl
/freebsd-11-stable/cddl/contrib/opensolaris
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/zfs
/freebsd-11-stable/cddl/contrib/opensolaris/lib/libzfs
/freebsd-11-stable/contrib/amd
/freebsd-11-stable/contrib/apr
/freebsd-11-stable/contrib/apr-util
/freebsd-11-stable/contrib/atf
/freebsd-11-stable/contrib/binutils
/freebsd-11-stable/contrib/bmake
/freebsd-11-stable/contrib/byacc
/freebsd-11-stable/contrib/bzip2
/freebsd-11-stable/contrib/com_err
/freebsd-11-stable/contrib/compiler-rt
/freebsd-11-stable/contrib/dialog
/freebsd-11-stable/contrib/dma
/freebsd-11-stable/contrib/dtc
/freebsd-11-stable/contrib/ee
/freebsd-11-stable/contrib/elftoolchain
/freebsd-11-stable/contrib/elftoolchain/ar
/freebsd-11-stable/contrib/elftoolchain/brandelf
/freebsd-11-stable/contrib/elftoolchain/elfdump
/freebsd-11-stable/contrib/expat
/freebsd-11-stable/contrib/file
/freebsd-11-stable/contrib/gcc
/freebsd-11-stable/contrib/gcclibs/libgomp
/freebsd-11-stable/contrib/gdb
/freebsd-11-stable/contrib/gdtoa
/freebsd-11-stable/contrib/groff
/freebsd-11-stable/contrib/ipfilter
/freebsd-11-stable/contrib/ldns
/freebsd-11-stable/contrib/ldns-host
/freebsd-11-stable/contrib/less
/freebsd-11-stable/contrib/libarchive
/freebsd-11-stable/contrib/libarchive/cpio
/freebsd-11-stable/contrib/libarchive/libarchive
/freebsd-11-stable/contrib/libarchive/libarchive_fe
/freebsd-11-stable/contrib/libarchive/tar
/freebsd-11-stable/contrib/libc++
/freebsd-11-stable/contrib/libc-vis
/freebsd-11-stable/contrib/libcxxrt
/freebsd-11-stable/contrib/libexecinfo
/freebsd-11-stable/contrib/libpcap
/freebsd-11-stable/contrib/libstdc++
/freebsd-11-stable/contrib/libucl
/freebsd-11-stable/contrib/libxo
/freebsd-11-stable/contrib/llvm
/freebsd-11-stable/contrib/llvm/projects/libunwind
/freebsd-11-stable/contrib/llvm/tools/clang
/freebsd-11-stable/contrib/llvm/tools/lldb
/freebsd-11-stable/contrib/llvm/tools/llvm-dwarfdump
/freebsd-11-stable/contrib/llvm/tools/llvm-lto
/freebsd-11-stable/contrib/mdocml
/freebsd-11-stable/contrib/mtree
/freebsd-11-stable/contrib/ncurses
/freebsd-11-stable/contrib/netcat
/freebsd-11-stable/contrib/ntp
/freebsd-11-stable/contrib/nvi
/freebsd-11-stable/contrib/one-true-awk
/freebsd-11-stable/contrib/openbsm
/freebsd-11-stable/contrib/openpam
/freebsd-11-stable/contrib/openresolv
/freebsd-11-stable/contrib/pf
/freebsd-11-stable/contrib/sendmail
/freebsd-11-stable/contrib/serf
/freebsd-11-stable/contrib/sqlite3
/freebsd-11-stable/contrib/subversion
/freebsd-11-stable/contrib/tcpdump
/freebsd-11-stable/contrib/tcsh
/freebsd-11-stable/contrib/tnftp
/freebsd-11-stable/contrib/top
/freebsd-11-stable/contrib/top/install-sh
/freebsd-11-stable/contrib/tzcode/stdtime
/freebsd-11-stable/contrib/tzcode/zic
/freebsd-11-stable/contrib/tzdata
/freebsd-11-stable/contrib/unbound
/freebsd-11-stable/contrib/vis
/freebsd-11-stable/contrib/wpa
/freebsd-11-stable/contrib/xz
/freebsd-11-stable/crypto/heimdal
/freebsd-11-stable/crypto/openssh
/freebsd-11-stable/crypto/openssl
/freebsd-11-stable/gnu/lib
/freebsd-11-stable/gnu/usr.bin/binutils
/freebsd-11-stable/gnu/usr.bin/cc/cc_tools
/freebsd-11-stable/gnu/usr.bin/gdb
/freebsd-11-stable/lib/libc/locale/ascii.c
/freebsd-11-stable/sys/cddl/contrib/opensolaris
/freebsd-11-stable/sys/contrib/dev/acpica
/freebsd-11-stable/sys/contrib/ipfilter
/freebsd-11-stable/sys/contrib/libfdt
/freebsd-11-stable/sys/contrib/octeon-sdk
/freebsd-11-stable/sys/contrib/x86emu
/freebsd-11-stable/sys/contrib/xz-embedded
/freebsd-11-stable/usr.sbin/bhyve/atkbdc.h
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.c
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.h
/freebsd-11-stable/usr.sbin/bhyve/console.c
/freebsd-11-stable/usr.sbin/bhyve/console.h
/freebsd-11-stable/usr.sbin/bhyve/pci_fbuf.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.h
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.c
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.h
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.c
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.h
/freebsd-11-stable/usr.sbin/bhyve/rfb.c
/freebsd-11-stable/usr.sbin/bhyve/rfb.h
/freebsd-11-stable/usr.sbin/bhyve/sockstream.c
/freebsd-11-stable/usr.sbin/bhyve/sockstream.h
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.c
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.h
/freebsd-11-stable/usr.sbin/bhyve/usb_mouse.c
/freebsd-11-stable/usr.sbin/bhyve/vga.c
/freebsd-11-stable/usr.sbin/bhyve/vga.h
# 302174 24-Jun-2016 asomers

Fix "sysctl vm.vmtotal" output on machines with > 2TB virtual memory

sbin/sysctl/sysctl.c
Fix integer overflows in printf format strings

PR: 199673
Submitted by: Vitaly Magerya
Reviewed by: cem
Approved by: re (marius)
MFC after: 4 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D6941


# 292045 10-Dec-2015 araujo

Add -t option to display field types.

PR: bin/203918
Submitted by: ota <ota@j.email.ne.jp>
Reviewed by: cem
Approved by: bapt (mentor)
Differential Revision: https://reviews.freebsd.org/D4451


# 290476 07-Nov-2015 cem

Follow-up to r290475: Add sysctl(8) support for added types

Sponsored by: EMC / Isilon Storage Division


# 289835 23-Oct-2015 cem

sysctl(8): Fix style nits

Suggested by: bde
Sponsored by: EMC / Isilon Storage Division


# 289773 22-Oct-2015 cem

Sysctl: Add common support for U8, U16 types

Sponsored by: EMC / Isilon Storage Division


# 288984 07-Oct-2015 bapt

Only print the errno string in case sysctl(3) does not file with ENOENT
This reduces the noise in error reporing from sysctl(8):

Before:
$ sysctl bla=something
sysctl: unknown oid 'bla': No such file or directory

After:
$ sysctl bla=something
sysctl: unknown oid 'bla'

MFC after: 1 week
Sponsored by: Gandi.net


# 288981 07-Oct-2015 bapt

Trim spaces at the end of the buffer before trying to convert it to an oid

This allows to write entries in sysctl.conf with spaces before the '=' like
kern.ipc.shmmax = 9663676416

MFC after: 1 week
Sponsored by: Gandi.net


# 285994 29-Jul-2015 imp

Teach sysctl about the new optional suffix after IK to specify
precision. Update input as well. Add IK to the manual (it was missing
completely).

Differential Revision: https://reviews.freebsd.org/D3181


# 278654 12-Feb-2015 jmg

add support for specifying an initial buffer size when fetching a
sysctl... This is useful for kern.arandom which (without -B) will
happily return 0 bytes, which isn't too useful or random...

fix spelling (thanks igor!) of settable while I'm here...


# 275377 01-Dec-2014 delphij

Fix inverted logic introduced in r272154.

Noticed by: trasz
MFC after: 2 weeks


# 272154 26-Sep-2014 delphij

Refactor the code a little bit to reduce duplicated code.

Reviewed by: mjg
MFC after: 2 weeks


# 272145 25-Sep-2014 delphij

Explicitly set errno to 0 before calling strto*.

Suggested by: mjg
MFC after: 2 weeks


# 272144 25-Sep-2014 delphij

The strtol(3) family of functions would set errno when it hits one.
Check errno and handle it as invalid input.

Obtained from: HardenedBSD
Submitted by: David CARLIER <devnexen@gmail.com>
MFC after: 2 weeks


# 272044 23-Sep-2014 delphij

Constify a parameter of name2oid. No functional change.

MFC after: 2 months


# 271495 13-Sep-2014 jhb

Add a sysctl to export the EFI memory map along with a handler in the
sysctl(8) binary to format it.

Reviewed by: emaste
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D771


# 271487 12-Sep-2014 jhb

Pass the length of an structure to the pretty-printer backends as a
size_t instead of an int.


# 270828 29-Aug-2014 jhb

- Add a new structure type for the ACPI 3.0 SMAP entry that includes the
optional attributes field.
- Add a 'machdep.smap' sysctl that exports the SMAP table of the running
system as an array of the ACPI 3.0 structure. (On older systems, the
attributes are given a value of zero.) Note that the sysctl only
exports the SMAP table if it is available via the metadata passed from
the loader to the kernel. If an SMAP is not available, an empty array
is returned.
- Add a format handler for the ACPI 3.0 SMAP structure to the sysctl(8)
binary to format the SMAP structures in a readable format similar to
the format found in boot messages.

MFC after: 2 weeks


# 267960 27-Jun-2014 hselasky

Don't hide zero-length strings when doing sysctl listings.

MFC after: 1 week


# 258659 26-Nov-2013 trasz

Fix warnings to not append "No error: 0".

MFC after: 1 month
Sponsored by: The FreeBSD Foundation


# 245361 13-Jan-2013 delphij

Use the right format string for line buffer.

PR: bin/174910
Submitted by: Fabian Keil <fk fabiankeil.de>


# 244198 13-Dec-2012 delphij

Teach sysctl(8) about parsing a file (while I'm there also give it
capability of parsing both = and : formats).

Submitted by: hrs (initial version, bugs are mine)
MFC after: 3 months


# 244133 12-Dec-2012 alfred

Make Tflag and Wflag filters work for more sysctl options.

To do this move the Tflag and Wflag checks earlier in show_var() so
we bail earlier for variables not matching our query.


# 244106 10-Dec-2012 alfred

Allow sysctl to filter boot and runtime tunables.

Add the following flags to sysctl:
-W - show only writable sysctls
-T - show only tuneable sysctls

This can be used to create a /var/run/sysctl.boot to
compare set tunables versus booted tunables.

Sponsored by: iXsystems


# 244104 10-Dec-2012 delphij

In parse():

- Only operate on copy, don't operate on source.
- Eliminate home-rolled strsep().
- Constify the parameter.

MFC after: 2 weeks


# 234134 11-Apr-2012 eadler

s/Free Memory Pages/Free Memory/ to avoid confusion, since we're
reporting a number of bytes rather than a number of pages

PR: misc/165208
Submitted by: Arnaud Lacombe <lacombar@gmail.com>
Approved by: cperciva
MFC after: 3 days


# 228181 01-Dec-2011 jhb

If the -d flag is specified, ignore any new values specified and only
display the descriptions of specified nodes.

Reported by: Jason Hellenthal jhell of dataix net
MFC after: 2 weeks


# 217616 19-Jan-2011 mdf

Introduce signed and unsigned version of CTLTYPE_QUAD, renaming
existing uses. Rename sysctl_handle_quad() to sysctl_handle_64().


# 217586 19-Jan-2011 mdf

sysctl(8) should use the CTLTYPE to determine the type of data when
reading. (This was already done for writing to a sysctl). This
requires all SYSCTL setups to specify a type. Most of them are now
checked at compile-time.

Remove SYSCTL_*X* sysctl additions as the print being in hex should be
controlled by the -x flag to sysctl(8).

Succested by: bde


# 217521 17-Jan-2011 mdf

The kernel is not exporting any "T,dev_t" sysctl nodes anymore, so
remove the capability and mention from sysctl(8).


# 212726 16-Sep-2010 zec

Make the format of "Real Memory" and "Virtual Memory" lines more
consistent with the rest of sysctl vm.vmtotal output.

MFC after: 3 days


# 205118 13-Mar-2010 brucec

Free the memory allocated via strdup.

PR: bin/113881
Submitted by: Alexander Drozdov dzal_mail mtu-net.ru
Approved by: rrs (mentor)
MFC after: 1 week


# 203917 15-Feb-2010 uqs

sysctl(8): make WARNS=3 clean

Fixes inspired by work done in DragonflyBSD.

PR: bin/140016
Approved by: ed (Co-mentor)


# 203717 09-Feb-2010 gavin

Add -i to usage()

Noticed by: ru
MFC after: 5 days


# 203310 31-Jan-2010 gavin

Implement the "-i" option to sysctl(8), to ignore failures while
retrieving individual OIDs. This allows the same list of OIDs to be
passed to sysctl(8) across different systems where particular OIDs may not
exist, and still get as much information as possible from them.

PR: bin/123644
Submitted by: dhw
Approved by: ed (mentor)
MFC after: 2 weeks


# 198850 03-Nov-2009 ed

Just use devname(3) to print device names.

Right now sysctl just prints the major/minor numbers of a device.
Instead of rolling our own routine for this, we'd better just call
devname(3) to perform a translation to a device name for us.


# 198340 21-Oct-2009 ed

Make input parsing in Farhenheit actually work.

Don't clobber *p with '\0' when testing whether it has the value of 'F'.
Just use the semantics of strtof() properly. If it returns p, we know
that it parsed the string until it reached 'C' or 'F'.

The code has not changed since it has been imported (r161951, Sep 3,
2006).

Submitted by: Alexandre Perrin <kaworu@kaworu.ch>
MFC after: 1 week


# 194684 23-Jun-2009 jhay

time_t does not always fit into long, for instance on arm. So rather cast
it intmax_t and use %j in printf.


# 179965 23-Jun-2008 mtm

The sysctl(8) program exits on some errors and only emits warnings on
others. In the case where it displayed warnings it would still return
succesfully. Modify it so that it returns the number of sysctls that
it was not able to set.

Make use of this in rc.d to display only *unsuccessfull* attempts to
set sysctls.


# 172674 15-Oct-2007 netchild

Backout sensors framework.

Requested by: phk
Discussed on: cvs-all


# 172631 14-Oct-2007 netchild

Import OpenBSD's sysctl hardware sensors framework.

This commit includes the following core components:

* sample configuration file for sensorsd
* rc(8) script and glue code for sensorsd(8)
* sysctl(3) doc fixes for CTL_HW tree
* sysctl(3) documentation for hardware sensors
* sysctl(8) documentation for hardware sensors
* support for the sensor structure for sysctl(8)
* rc.conf(5) documentation for starting sensorsd(8)
* sensor_attach(9) et al documentation
* /sys/kern/kern_sensors.c
o sensor_attach(9) API for drivers to register ksensors
o sensor_task_register(9) API for the update task
o sysctl(3) glue code
o hw.sensors shadow tree for sysctl(8) internal magic
* <sys/sensors.h>
* HW_SENSORS definition for <sys/sysctl.h>
* sensors display for systat(1), including documentation
* sensorsd(8) and all applicable documentation

The userland part of the framework is entirely source-code
compatible with OpenBSD 4.1, 4.2 and -current as of today.

All sensor readings can be viewed with `sysctl hw.sensors`,
monitored in semi-realtime with `systat -sensors` and also
logged with `sensorsd`.

Submitted by: Constantine A. Murenin <cnst@FreeBSD.org>
Sponsored by: Google Summer of Code 2007 (GSoC2007/cnst-sensors)
Mentored by: syrinx
Tested by: many
OKed by: kensmith
Obtained from: OpenBSD (parts)


# 170558 11-Jun-2007 bde

When we return from a "show" function without printing anything except
a warning, return 1 instead of 0 to indicate that we didn't print
anything, so that top-level callers don't print a spurious newline.
This is mainly to fix output formatting when stderr is redirected. It
also helps in some cases when stderr is interleaved with stdout,
depending on the details of the interleaving (this program has the
usual null explicit support for syncing stderr with stdout).

Return 1 instead of -1 after printing the "malloc failed" warning, since
the return value is boolean.


# 170514 10-Jun-2007 dwmalone

Some improvements to the int-type printing code based on suggestions by bde.


# 170513 10-Jun-2007 dwmalone

Fix a number of WARNS, including printf, constness and unsigned comparison
warnings.


# 170512 10-Jun-2007 dwmalone

Some style improvements suggested by bde, including removing an
unused include, adding parens for return and sizeof and renaming,
adding some missing whitespace and sorting some variables.


# 170287 04-Jun-2007 dwmalone

Use common code for printing ints and longs by coppying the sysctl
value into a variable of the right type and then printing it via
an intmax_t. This makes avoids some duplication and makes it easy
to add a new integer format Q for printing things of type CTLTYPE_QUAD.


# 165070 10-Dec-2006 imp

Style: Shorten a couple of lines with u_int and u_long.


# 164718 28-Nov-2006 ru

- Revert signedness type changes to "struct vmtotal"; by making
them unsigned I made the possible overflows hard to detect,
and it only saved 1 bit which isn't principal, even less now
that the underlying issue with the total of virtual memory has
been fixed. (For the record, it will overflow with >=2T of
VM total, with 32-bit ints used to keep counters in pages.)

- While here, fix printing of other "struct vmtotal" members
such as t_rq, t_dw, t_pw, and t_sw as they are also signed.

Reviewed by: bde
MFC after: 3 days


# 164557 23-Nov-2006 ru

Fix the format specifier suitable for uintmax_t.


# 164443 20-Nov-2006 ru

- Fix types of "struct vmmeter" members so they are unsigned.

- Fix overflow bugs in sysctl(8), systat(1), and vmstat(8)
when printing values of "struct vmmeter" in kilobytes as
they don't necessarily fit into 32 bits. (Fix sysctl(8)
reporting of a total virtual memory; it's in pages too.)


# 163277 12-Oct-2006 harti

Remove a debugging statement from the previous commit.


# 163275 12-Oct-2006 harti

Don't free the buffer with the sysctl value before printing it.


# 162073 06-Sep-2006 ru

While convenient, avoid using alloca() for reasons specified in
the BUGS section of the alloca(3) manpage. In particular, when
the number of TCP sockets is several tens of thousand, trying to
"sysctl -a" would SIGSEGV on the net.inet.tcp.pcblist entry (it
would exceed the stacksize ulimit, in an undetectable manner).

Reported by: Igor Sysoev


# 161951 03-Sep-2006 ume

Support Celsius (nn.nC), Fahrenheit (nn.nF) and Kelvin (nnnn) to
specify temperature.

Reviewed by: njl
MFC after: 3 days


# 161313 15-Aug-2006 ru

Fix printing of integer Kelvins broken in rev. 1.71, which is
fatal on sizeof(int) != sizeof(long) systems (such as amd64).

MFC after: 1 day


# 161256 12-Aug-2006 obrien

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.


# 160963 04-Aug-2006 njl

Use floating point instead of hacking something together. Suggested by
bde@. Fix nearby int conversion and a couple style bugs.

MFC after: 1 day


# 160658 25-Jul-2006 njl

Fix printing of negative decimal values in Kelvin to Celsius conversion.

MFC after: 3 days


# 152995 01-Dec-2005 ru

Add -q to usage().


# 150167 15-Sep-2005 rwatson

Add "-q" argument to sysctl(8), which suppresses a limited set of warnings/
errors generated. In particular, it suppresses "unknown oid" when
attempting to get or set a sysctl not present in the kernel.

MFC after: 1 week


# 144998 13-Apr-2005 mdodd

Show descriptions for type CTLTYPE_NODES.


# 144997 13-Apr-2005 mdodd

Zero buffers. Seatbelt against sysctl(3) returning non-NUL terminated
string data.


# 141611 10-Feb-2005 ru

Sync program's usage() with manpage's SYNOPSIS.


# 140818 25-Jan-2005 ssouhlal

Get rid of a NULL dereference when oid is too long.

Reviewed by: keramida
Approved by: grehan (mentor)
MFC after: 1 week


# 135387 17-Sep-2004 le

Use correct format string.

Submitted by: ssouhlal


# 134541 30-Aug-2004 peter

Add a suffix descriptor for the acpi thermal values as a hint for the userland
sysctl tool to print a more readable value for temperatures.


# 128073 09-Apr-2004 markm

Remove advertising clause from University of California Regent's license,
per letter dated July 22, 1999.

Approved by: core, imp


# 126472 02-Mar-2004 dd

Add CTLTYPE_QUAD to the list of types for which we don't want an empty
value. All the other numeric types are doing it . . .


# 122234 07-Nov-2003 des

Whitespace cleanup.


# 122233 07-Nov-2003 des

Add a command-line option to format output for human readability.
Currently, the only effect it has is to print some (but not all) numbers
using thousands separators.


# 121849 01-Nov-2003 silby

Fix a few style glitches in the previous commit and make the
tunable error message more brief.

Suggested by: bde


# 121542 26-Oct-2003 peter

Fix a 64 bit warning. Have set_T_dev_t() take a pointer to a size_t rather
than a pointer to an int, since that is what it really wants anyway.


# 121308 21-Oct-2003 silby

Wrap a long line in the previous commit

Suggested by: njl


# 121306 21-Oct-2003 silby

Have sysctl print out a more useful error message when it detects that the
user has attempted to write to a read only, tunable value.


# 116383 15-Jun-2003 rwatson

Tighten up the string->integer conversion in sysctl(8):

(1) Reject zero-length strings for CTLTYPE_INT, _UINT, _LONG,
_ULONG. Do not silently convert to 0.

(2) When converting CTLTYPE_INT, _UINT, _LONG, and _ULONG, check the
end pointer generated by strtol() and strtoul() rather than
discarding it. Reject the string if either none of the string
was useful for conversion to an integer, or if there was
trailing garbage.

I.e., we will not allow you to set a numeric sysctl to a value unless
we can completely convert the string argument to a numeric value.
I tripped over this when I put the following in /etc/sysctl.conf:

kern.maxfiles="4000"

Ouch.


# 113039 03-Apr-2003 phk

Output machdep.guessed_bootdev as an integer rather than try to format
it according to ancient and obsolete rules.

This removes one more user of <sys/diskslice.h>


# 109671 21-Jan-2003 peter

Fix what I think is an off-by-one in certain worst-case scenarios
caused by rev 1.45. (eg: the estimate being exactly half of the result.)


# 109113 11-Jan-2003 dillon

Cleanup the formatting from the last commit, convert everything to
a more human-readable 'kilobytes' instead of pages.


# 109097 11-Jan-2003 dillon

Make 'sysctl vm.vmtotal' work properly using updated patch from Hiten.
(the patch in the PR was stale).

PR: kern/5689
Submitted by: Hiten Pandya <hiten@unixdaemons.com>


# 106829 12-Nov-2002 peter

Fix a "bug" in sysctl(8). Limit the length when we print a string from
the kernel rather than ignoring the length and keeping on going till we
finally hit a \0 character in the buffer.


# 102411 25-Aug-2002 charnier

Replace various spelling with FALLTHROUGH which is lint()able


# 97232 24-May-2002 alfred

Don't err(3) (and exit prematurely) when a sysctl's object size has
changed, instead just warn(3)


# 96234 08-May-2002 ache

Don't forget to null-terminate string we got from sysctl (f.e. in 'A' format).
Stack garbadge may be printed otherwise.


# 94752 15-Apr-2002 phk

Take the "tickadj" element out of struct clockinfo. Our adjtime(2)
implementation is being changed and the very concept of tickadj will
no longer be meaningful.


# 92066 11-Mar-2002 luigi

Make the handling of machdep.guessed_bootdev compiled on i386 only.


# 92018 10-Mar-2002 luigi

Export a (machine dependent) kernel variable bootdev as
machdep.guessed_bootdev, and add code to sysctl to parse its value
and give a (not necessarily correct) name to the device we booted
from (the main motivation for this code is to use the info in the
PicoBSD boot scripts, and the impact on the kernel is minimal).

NOTE: the information available in bootdev is not always reliable,
so you should not trust it too much. The parsing code is the same
as in boot2.c, and cannot cover all cases -- as it is, it seems to
work fine with floppies and IDE disks recognised by the BIOS. It
_should_ work as well with SCSI disks recognised by the BIOS.
Booting from a CDROM in floppy emulation will return /dev/fd0 (because
this is what the BIOS tells us).
Booting off the network (e.g. with etherboot) leaves bootdev unset so
the value will be printed as "invalid (0xffffffff)".

Finally, this feature might go away at some point, hopefully when we
have a more reliable way to get the same information.

MFC-after: 5 days


# 91217 25-Feb-2002 bde

#include <sys/time.h> instead of depending on namespace pollution in
<sys/stat.h> for its prerequisite <sys/time.h>.

#include <sys/param.h> in the correct place instead of bogusly including
<sys/types.h>.


# 88696 30-Dec-2001 phk

Allow setting of variables of type dev_t by indicating the name of
a special file on the command line, eg:
sysctl kern.dumpdev=/dev/ad1s1b

In parse(), when a value is given for a CTLTYPE_QUAD variable,
newval and newsize erroneously fail to be set because of an early
"break".

show_var() contains code that duplicates the functionality of the
oidfmt() function.

PR: 33151, 33150
Submitted by: Thomas Quinot <thomas@cuivre.fr.eu.org>


# 88006 16-Dec-2001 luigi

Add code to export and print the description associated to sysctl
variables. Use the -d flag in sysctl(8) to see this information.

Possible extensions to sysctl:
+ report variables that do not have a description
+ given a name, report the oid it maps to.

Note to developers: have a look at your code, there are a number of
variables which do not have a description.

Note to developers: do we want this in 4.5 ? It is a very small change
and very useful for documentation purposes.

Suggested by: Orion Hodson


# 85747 30-Oct-2001 tobez

Implement -e option. It modifies the output produced by sysctl(8) in
such a way that the name and the value of the variable(s) are separated
with `=' instead of the usual `: '. This is useful for producing output
that can be fed back to the sysctl utility (pasted to sysctl.conf, for
example).

Reviewed by: rwatson
Approved by: markm
MFC after: 2 weeks


# 78434 18-Jun-2001 pirzyk

modfied sysctl command to allow setting values > 2GB if the mib supports it.

PR: kern/21132
Reviewed by: no objections to by -arch
MFC after: 1 month


# 77928 09-Jun-2001 dd

Normalize the use of sizeof according to style(9).

Reviewed by: md5(1)


# 77567 01-Jun-2001 dd

Remove unused variable (descr) in show_var().

PR: 22582
Submitted by: Giorgos Keramidas <charon@gray.westgate.gr>


# 77332 28-May-2001 des

Perform random drive-by style cleanups, and rewrite a while loop that
offended my artistic sensibilities.


# 77331 28-May-2001 des

Forgotten in previous commit log:

- don't print an ellipsis after the hex dump if the variable is exactly
16 bytes long (the less-than-16-bytes case already worked as expected).


# 77330 28-May-2001 des

Try to make sysctl options slightly more orthogonal:

- introduce a -o option that displays opaque variables.
- introduce a -x option that displays opaque variables in full.
- deprecate -A in favor of -ao and -X in favor of -ax.
- remove -A and -X from usage() and SYNOPSIS (but not from DESCRIPTION).
- ignore -a if one or more variables were listed on the command line.
- deprecate -w, it is not needed to determine the user's intentions.
- some language and style cleanup in the man page.

This commit should not break any existing scripts.

MFC after: 4 weeks


# 71043 14-Jan-2001 des

Document the -N option in the usage message and the man page.


# 71034 14-Jan-2001 des

Add a -N option that makes sysctl(8) print out just the variable names.
Zsh users can add the following to their .zshrc for sysctl completion:

function listsysctls {
case $1 in
*.*) set -A reply $(sysctl -AN ${1%.*}) ;;
*) set -A reply $(sysctl -AN) ;;
esac
}
compctl -K listsysctls sysctl

While I'm here, brucify the getopt() switch.


# 67476 23-Oct-2000 gallatin

Give correct results for SYSCTL_LONG arrays when sizeof(int) != sizeof(long)
This fixes unaligned access on alpha for, eg, sysctl kern.ipc.mbtypes.


# 62975 11-Jul-2000 phk

Array of long support.

Submitted by: Ian Dowse <iedowse@maths.tcd.ie>


# 62622 05-Jul-2000 jhb

Support for unsigned integer and long sysctl variables. Update the
SYSCTL_LONG macro to be consistent with other integer sysctl variables
and require an initial value instead of assuming 0. Update several
sysctl variables to use the unsigned types.

PR: 15251
Submitted by: Kelly Yancey <kbyanc@posi.net>


# 61514 10-Jun-2000 phk

Handle minors like ls(1) does it.

PR: 19179
Submitted by: Kelly Yancey <kbyanc@posi.net>


# 53562 22-Nov-1999 des

To clarify the previous log message: belatedly back out rev. 1.20 of
sysctl.c and rev. 1.18 of sysctl.8, which added an option to show sysctl
descriptions instead of their values. The kernel side of this was ripped
out by a certain axe-bearing Dane a long time ago.

PR: 15012


# 53561 22-Nov-1999 des

Belatedly back out rev. 1.20.


# 53317 17-Nov-1999 grog

Allow octal or hex input.
Suggested-by: Geoff Steckel <gwes@sitaranetworks.com>


# 50476 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 48956 21-Jul-1999 billf

Avoid ambigious if/else


# 42456 10-Jan-1999 des

Clean up option handling a little.
Add an option for showing sysctl descriptions instead of their values.


# 41019 08-Nov-1998 phk

Allow for printing out integer arrays.


# 38533 25-Aug-1998 dfr

Change length arguments to sysctl to size_t.


# 37266 29-Jun-1998 bde

Don't assume that time_t is long.


# 31214 18-Nov-1997 jdp

Add missing argument detected by "-Wformat".


# 30602 20-Oct-1997 charnier

Use err(3). Change err(-1,... to err(1,...


# 26899 24-Jun-1997 jhay

Display tickadj in struct clockinfo.


# 24428 31-Mar-1997 imp

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# 22997 22-Feb-1997 peter

Revert $FreeBSD$ to $Id$


# 21673 14-Jan-1997 jkh

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# 15172 09-Apr-1996 smpatel

Fix a core dump when the user gives "-w" without an "="


# 12946 21-Dec-1995 phk

The rewamped sysctl program that will find all the variables itself.
Also a couple of handy new options.


# 12344 17-Nov-1995 phk

Make sysctl compile again by removing all the debug stuff.


# 9202 11-Jun-1995 rgrimes

Merge RELENG_2_0_5 into HEAD


# 8857 30-May-1995 rgrimes

Remove trailing whitespace.


# 8479 12-May-1995 wollman

Learn how to print out kern.dumpdev as a name.


# 6473 15-Feb-1995 wollman

Allow the user access to net.inet.igmp, even though there's nothing
sysctl(8) can interpret there. (Someday there might be.)


# 6284 09-Feb-1995 wollman

Implement TCP MIB variables.


# 1951 08-Aug-1994 wollman

Suppress irritating extra newline after kern.boottime.


# 1554 26-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1553,
which included commits to RCS files with non-trunk default branches.


# 1553 26-May-1994 rgrimes

BSD 4.4 Lite usr.sbin Sources