You’re going to write to the /proc filesystem?!
Yeah; a number of files in /proc do things when you write to them;
notably the ACPI stuff that I’m interested in. To change your speedstep
state, for instance, you write a “1” or “0” to
/proc/acpi/processor/CPU0/performance; to go into sleep mode, write a
"1" (for S1 state) to /proc/acpi/sleep. There are other things too,
I think you need to write a 1 to start IP forwarding and khttpd and a
few other things.
Ah, interesting. Your documenation then should probably start with
"THIS MODULE REQUIRES ROOT PERMISSIONS TO THE /proc FILESYSTEM!!!".
But yeah, I know that /proc is significantly different across OSs; I
prefer to think of it as Linux being right and the rest being broken,
but that’s not a very pragmatic approach. So, I’m going to try the
namespace shorthand trick for now.
It has the advantage that any ol’ program can read it, true. The
drawback is that you can’t seem to trust the folks at “Linux, Inc” to
keep the format the same. Mike Hall has already mentioned to me that
some stuff is out of order in my Sys::ProcTable module between 2.2 and
2.4 on Linux. Puke. A built-in library eliminates this hazard (I’m
only going to deal with 2.4, btw). A C library is probably going to be
faster as well. Six one way, half a dozen the other, I guess. But,
this is getting OT…
I’d prefer to avoid a C extension library if possible; Linux lets me do
this by reading all the data from /proc. In fact, I’m not sure if there
is any other way to get a lot of the hardware information. How do other
UNIXes let you get things like processor model/speed, memory
There might be. I find going to www.deja.com and searching on all of
the “comp” hierarchy a very useful thing to do. I just scoured CPAN
a bit to see what was already out there - not a heck of a lot, but a
couple cpu modules. Dunno how good they are, though. I also noticed
the Solaris::Procfs module, which I had seen before but forgotten about.
That might be useful as a starting point for cross-platform support (?).
I’d like to put the model under the Sys:: namespace for consistency; if
you think it’s a good idea; then I’m left with the question of what to
call it again. Sys::Hardware? Sys::Info seems too generic a name
(since Uptime, ProcTable, and Uname are both “Info” too).
Sys::ACPI seems appropriate. If you’re interested, I could investigate
Solaris support once you’ve got your api fleshed out.
From: Joe Wreschnig firstname.lastname@example.org