From: arlie@worldash.org (Arlie Stephens)
To: kernelnewbies@lists.kernelnewbies.org
Subject: So I want to get some kernel routine called....
Date: Tue, 16 Apr 2013 16:33:17 -0700 [thread overview]
Message-ID: <20130416233317.GA24731@worldash.org> (raw)
Hi Folks,
It's that BSD engineer again, trying to do something in linux and
unable to see the _linux_ way to do it ;-)
I have some kernel routine I'd like to get called, with the decision
to call it made in user space. Obviously I could do this by making it
into a full blown system call, but that's pretty much never the right
answer, except for a quick hack.
In FreeBSD, I'd make it into a sysctl, and have my user space script
do something like "sysctl debug.call_my_hack=1" I'd then define
call_my_hack to to be the type of sysctl that calls a procedure, using
a convenient macro, and I'd be done.
In linux I've determined that the /proc/sys interface is the preferred
way to access sysctl's, but that even that is possibly deprecated in
favour of sysfs. Documentation on implementing sysctl's is conspicuous
by its absence, and much of what I've found applies only to the
deprecated interface. In particular, the "strategy" routine appears
designed for my purpose - but is never called if you come in to the
kernel with read/write to /proc/sys/whatever. Probably I can get the
effect I want by (ab)using the proc_handler function pointer - but is
that what I "should be doing"?
As for sysfs, it's tightly tied to the physical device hierarchy. I
can't even find how one is supposed to deal with pseudo-devices. There
do however seem to be a few interesting things in /sys/kernel which
clearly have nothing to do with the device hierarchy. Probably
checking their implementation will teach me how to use this ... but
not whether it's the "right thing to do".
For what it's worth, there is a pseudo-device driver involved, but no
convenient /dev interface to issue ioctls on. (Probably calling it a
pseudo-device exagerates its abilities.)
As always, I'm looking primarily at 2.6.32, but want to write code
that's good for the long haul, and potentially upstreamable.
So, how would someone who thinks in linux go about doing this?
Thanks for any enlightenment.
--
Arlie
(Arlie Stephens arlie at worldash.org)
next reply other threads:[~2013-04-16 23:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-16 23:33 Arlie Stephens [this message]
2013-04-16 23:56 ` So I want to get some kernel routine called Valdis.Kletnieks at vt.edu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130416233317.GA24731@worldash.org \
--to=arlie@worldash.org \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).