Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Jan 2020 06:41:51 +0100
From:      Polytropon <>
To:        Ihor Antonov <>
Subject:   Re: sysctl and /sysfs
Message-ID:  <>
In-Reply-To: <4538784.31r3eYUQgx@t800>
References:  <4538784.31r3eYUQgx@t800>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
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...

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

> 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.


Watching "What UNIX Cost Us" by Benno Rice at ""
(LCA) 2020 does actually help understanding _why_ the use of
the "everything is a file" metaphor doesn't always work.

Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

Want to link to this message? Use this URL: <>