Subject: Re: Linux "/proc/net/*" support in NetBSD?
To: Andrew Brown <atatat@atatdot.net>
From: Brian Grayson \(home\) <bgrayson@austin.rr.com>
List: port-i386
Date: 12/10/2001 12:11:05
On Mon, Dec 10, 2001 at 12:35:04AM -0500, Andrew Brown wrote:
>
> then there's the issue of the portal file system not really "doing"
> directory listings at all...
Yes, but I think that's unavoidable without some major changes
though. Plus it's downright impossible in some cases -- How would a
portal filesystem that mapped ftp: mounted on /p handle an ls of
/p/ftp:? I surely don't want to see all ftp sites on the
Internet.... nor do I want to wait as it tries to figure out all the
ftp sites on the Internet... :)
> >If you want information about the kernel's state, look in /kern.
>
> well...there's not that much there, but then again, (almost) all the
> stuff that's already there can be gotten at via sysctl.
And _everything_ that can be gotten via sysctl, can also be gotten
via a portal filesystem, if you want to be able to access this stuff
through the filesystem namespace (configuration etc. is at end of note):
% cat /tmp/p/sysctl/kern.boottime
Sun Dec 9 20:37:34 2001
% cat /tmp/p/sysctl/kern/hostname
cs242760-129.austin.rr.com
% cat /tmp/p/sysctl/kern/mbuf
msize = 256
mclbytes = 2048
nmbclusters = 2048
mblowat = 16
mcllowat = 8
% cat /tmp/p/sysctl/kern/mbuf/msize
256
(NOTE: The sysctl example in /usr/share/examples/mount_portal is broken in
two ways:
1. sysctlfs.sh is not marked executable.
2. sysctlfs.sh is not installed into /usr/share/examples/mount_portal
with everything else.
I'll be fixing both of these.)
Here's the configuration, /tmp/sysctl.conf (stripped down from
/usr/share/examples/mount_portal/advanced.1.conf):
------------------------------------------------------------------------------
sysctl/ rfilter sysctl/ /tmp/sysctlfs.sh %s
------------------------------------------------------------------------------
Here's /tmp/sysctlfs.sh (same as
/usr/src/sbin/mount_portal/examples/sysctlfs.sh, except it is marked
executable):
------------------------------------------------------------------------------
#!/bin/sh
## $NetBSD: sysctlfs.sh,v 1.1 2000/01/17 07:22:45 bgrayson Exp $
## Fast hack at a sysctl filesystem. The path can be either in
## dot-style (kern.mbuf.msize) or in slash-style (kern/mbuf/msize).
## Hacked as an example by Brian Grayson (bgrayson@netbsd.org) in Sep 1999.
for path in $*; do
## First, change any slashes into dots.
path=`echo $path | tr '/' '.'`
## Now invoke sysctl, and post-process the output to make it
## friendlier. In particular:
## 1. Remove the leading prefix.
## 2. Remove a now-leading ".", if any.
## 3. If we are left with " = <val>", strip out the " = " also.
sysctl $path | sed -e "s/$path//;s/^\.//;s/^ = //"
done
------------------------------------------------------------------------------
% mkdir /tmp/p
% mount_portal /tmp/sysctl.conf /tmp/p
% cat /tmp/p/sysctl/kern.mbuf
msize = 256
mclbytes = 2048
nmbclusters = 2048
mblowat = 16
mcllowat = 8
Brian