sysctl stuff and your article in daemon news zine 200305

Paolo Pisati p.pisati at oltrelinux.com
Thu Sep 16 16:44:51 PDT 2004


Hi guys

i was looking for some material about sysctl stuff 
when i found out phk's article in daemonews.
Sysctl are simple to use but i'm stuck 
with SYSCTL_ADD_PROC().
Lets' take this:

sysctl_ctx_init(&xxx_clist);		
o = SYSCTL_ADD_NODE(&xxx_clist,
			SYSCTL_STATIC_CHILDREN(_net),
			OID_AUTO, "xxx", CTLFLAG_RW, 0,
			"Virtual Network XXX");		
SYSCTL_ADD_INT(&xxx_clist, SYSCTL_CHILDREN(o), OID_AUTO, 
		       "status", CTLFLAG_RW, &status, 0, "status of xxx");

SYSCTL_ADD_PROC(&xxx_clist, SYSCTL_CHILDREN(o), OID_AUTO, 
			"text_xxx", CTLTYPE_STRING|CTLFLAG_WR, string, 10, 
			sysctl_xxx_text_prg, "A", "baubaubau");

Here i create xxx under _net and start to add oid but,
while "status" appear in the sysctl tree, "text_xxx"
it doesn't show up.
And the function sysctl_xxx_text_prg is called 
EVERY time i issue sysctl -a.

Why it works this way?
I mean, why don't "text_xxx" show up in sysctl tree?
And why sysctl -a trigger sysctl_xxx_text_prg?

I expected to see text_xxx near status in the sysctl tree, 
to be a text buffer and that sysctl_xxx_text_prg get 
called when i manipulate it and not everytime i list
the complete sysctl tree.

To put it clear, i would like something like
this:

net-
    \
     |-foo
     |-bar
     |-xxx-
     |-... \
            |-status
            |-text_xxx
            |-other_text_xxx

and i would like that ONLY when i modify
text_xxx my function sysctl_xxx_text_prg, 
it reads the content of text_prg, modify it and
then write the results in other_text_xxx.
 
Well, i know i'm wrong somewhere, but i don't know 
where... =P
I read some sources of geom and random but i couldn't 
find where's my mistake, hope someone can help me... =P

Thank you.
-- 
Paolo

Italian FreeBSD User Group: http://www.gufi.org


More information about the freebsd-hackers mailing list