From owner-freebsd-questions@freebsd.org Sun Jan 19 05:42:04 2020 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 99583233CF5 for ; Sun, 19 Jan 2020 05:42:04 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.130]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mout.kundenserver.de", Issuer "TeleSec ServerPass Class 2 CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 480kFl2Y3lz3Nwh for ; Sun, 19 Jan 2020 05:42:02 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de ([94.222.10.201]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPA (Nemesis) id 1MA4ja-1ilrXx3rYo-00BcVr; Sun, 19 Jan 2020 06:41:52 +0100 Date: Sun, 19 Jan 2020 06:41:51 +0100 From: Polytropon To: Ihor Antonov Cc: freebsd-questions@freebsd.org Subject: Re: sysctl and /sysfs Message-Id: <20200119064151.7f781748.freebsd@edvax.de> In-Reply-To: <4538784.31r3eYUQgx@t800> References: <4538784.31r3eYUQgx@t800> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:kAPSybzOkGkYIkmJvdYzlLbukZ8wjCd0gL1RJ7BE73SV/5KBcK5 4rvg89kta1rVMORL4hkd+DyILZFkgn7D8HVoAwhN5FrhYwgZ2dg3MdEBDHhdFU9L9DZ8TwW GxBp03k69PD6JmwKImbjpUKfLnc4OmCW9Nqd5DB3A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++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of freebsd@edvax.de has no SPF policy when checking 212.227.126.130) smtp.mailfrom=freebsd@edvax.de X-Spamd-Result: default: False [5.03 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_REPLYTO(0.00)[freebsd@edvax.de]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; HAS_ORG_HEADER(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:8560, ipnet:212.227.0.0/16, country:DE]; MIME_TRACE(0.00)[0:+]; RECEIVED_SPAMHAUS_PBL(0.00)[201.10.222.94.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; ARC_NA(0.00)[]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[edvax.de]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(0.99)[0.990,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(1.00)[1.000,0]; MID_CONTAINS_FROM(1.00)[]; RCVD_IN_DNSWL_NONE(0.00)[130.126.227.212.list.dnswl.org : 127.0.5.0]; R_SPF_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; IP_SCORE(0.64)[ip: (2.13), ipnet: 212.227.0.0/16(-1.16), asn: 8560(2.26), country: DE(-0.02)] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Jan 2020 05:42:04 -0000 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, ...