Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Sep 2004 01:55:05 +0200
From:      Paolo Pisati <p.pisati@oltrelinux.com>
To:        FreeBSD_Hackers <freebsd-hackers@freebsd.org>
Subject:   sysctl stuff and your article in daemon news zine 200305
Message-ID:  <20040916235505.GA8460@tin.it>

next in thread | raw e-mail | index | archive | help
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



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