Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Nov 1995 03:48:02 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        peter@jhome.dialix.com, phk@freefall.freebsd.org
Cc:        CVS-commiters@freefall.freebsd.org, cvs-sys@freefall.freebsd.org
Subject:   Re: cvs commit: src/sys/kern kern_sysctl.c
Message-ID:  <199511071648.DAA10078@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>Umm, I've not been following your sysctl() work closely, and indeed I'm 
>not too fresh on sysctl in general these days, but does sysctl(8) 
>automatically adapt to new entries being added into the kernel?

No.  You have to edit 2 or 3 kernel files, 1 or 2 man pages, and
sometimes the sysctl(8) for each new entry.

>It's all done with linker_sets, right?  Is there any chance of getting 
>the system to automatically catalog all the sysctl's?  for example, 

I think linker sets are the wrong approach.  There's no way a linker
set in the kernel can update the manpage or specially handle a new
struct in sysctl(8).  I'd like either a static or dynamic central
catalog.  The static version would involve a text file that you edit
and run utilities on to produce man pages, kernel and user code.  The
dynamic version would involve a text file that you edit and run to
produce only kernel code, and more general handling of structs in
sysctl(8), and a more general man page that doesn't mention any
particular variable.

The sysctl interface uses a fixed binding of names to numbers.  I
think there should be a separate binding step.  E.g.,

	/* Interface: return a `name' suitable for passing to sysctl(8). */
	int sysctl_bind(const char *varname, u_int max_namelen, int *name,
			u_int *namelen);

Even better, redesign sysctl() to support accessing an arbitrary subset
of the database:

	/*
	 * Interface: return a sysctl descriptor suitable for passing to
	 * new_sysctl(8).  Indirectly return the names (possibly null;
	 * concatenated) of each component of each variable, and layout
	 * information (perhaps the number of components for each variable).
	 */
	int sysctl_bind(const char * const *varnames, u_int nvarnames,
			char *varsubnames, u_int *varlayoutinfo);
	/*
	 * Interface: like sysctl(3) except the variables of interest are
	 * determined by a previous sysctl_bind() and the data is an array
	 * of u_longs packed according to the layout info (perhaps not
	 * packed at all, i.e., with all scalars expanded to u_longs).
	 */
	int new_sysctl(int sd, u_long *oldp, u_int *oldlenp, u_long *newp,
		       u_int newlen);

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199511071648.DAA10078>