sysctl and /sysfs
Polytropon
freebsd at edvax.de
Sun Jan 19 05:42:04 UTC 2020
On Sat, 18 Jan 2020 20:27:27 -0800, Ihor Antonov wrote:
> Hi everyone,
>
> I am coming to FreeBSD from Linux and I have questions about
> system structure.
>
> I noticed that FreeBSD makes heavy use of `sysctl` to read and
> write kernel
> parameters. Linux has /proc and /sys filesystems that represent
> various kernel
> data structures, some of which could be writable.
>
> In the spirit of Unix philosophy "everything is a file" [...]
In context of Linux...
https://www.youtube.com/watch?v=9-IWMbJXoLM#t=8m20s
Sorry, couldn't resist. ;-)
> [...] I was wondering if
> FreeBSD provides a view into kernel's parameters similar to
> sysfs on linux?
I hope not. :-)
> It feels a bit strange that instead of naturally exposing
> hierarchical kernel
> data structures in a form of filesystem one has to use sysctl
> and text values
> in a "parend.child.subchild" pattern. So the question is why?
The primary reason is that this is historically grown, and
brought forward through decades of kernel and system parts
development.
> It is possible that I am missing something or maybe FreeBSD has
> a different
> view on this problem - I would love to understand!
The core "problem" (which actually isn't a problem at all)
is that exposing _everything_ as a file or a hierarchical
filesystem doesn't seem to work for each and every case.
That's why different approaches have been taken that worked
out in a better way. With sysctl, direct access to kernel
system information has been unified. There is still some
kind of hierarchy preserved.
See "man 3 sysctl" and "man 1 sysctl" for details.
Sidenote:
Watching "What UNIX Cost Us" by Benno Rice at "linux.conf.au"
(LCA) 2020 does actually help understanding _why_ the use of
the "everything is a file" metaphor doesn't always work.
--
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
More information about the freebsd-questions
mailing list