View Single Post
Old 17th August 2009
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

A random thought while I wait for a *huge* rsync to finish:

use a pseudo device file for the driver to expose the information to the user space (assuming it actually does more then harvest information).

write a user-land program to query information through the device file (in terms of user interface: think ps, not top). I personally like a character device, and any kind you can read & write data from

Judging by your words, I assume your user-side program needs to be more like top, a program that regularly refreshes a display of the data; then like ps which just dumps it out ala batch job. If the data can be read from a device file related to your driver, the usual access control model can be used to control access to the data (through that file), and I would assume that you can use any of the available solutions to the "Hey, when there's something to read from this file, give me a shout!" problem. That should range from BSD kqueue()/kevent(), Linux inofity, and other OS-specifics, to the standard select()/poll(), and GOD knows how many libraries and packages; fam, gamin, their source codes, blah blah blah. Personally I would see if kqueue/kevent can be used with performance gains, then use it on systems that support the interface.



Thus, the problem would then be simplified from: how the hell do I send data from a 'kernel driver' to a user space app, down to 0/ implementing the device file and 1/ finding a suitable method of file system notification.




I'm sure the latter one has been done to death and back again; the former should have enough drivers available to examine how it can be done. If the kqueue interface is portable enough for your needs, take a look at the paper on it, check source code for various programs that have the same problem (monitoring a file for change), and take a look see at what options there are.




Call me a fool, a moron, or just a mad and insane geek - but I learned well at an early age, the value of breaking down complex problems into small simple to understand pieces. Living around computers has like wise made me appreciate simple, uniform, and easy to side-step interfaces....
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote