Re: Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi again:

I test it, but this is no t exactly wat I need, because designed like this, 
is the daemon who have to access the dev file, blocking (if exist) other 
callers processes, and what I realy need is that the kernel wake up the 
daemond. I meen, the daemond should wait until a kernel advise.
In the other hand, this daemon will be called by other proccesses, so I need 
a blocking mechanism that let me awake the daemon from another userland 
proccess.
thanks for your time...

On Monday 14 January 2002 02:59 pm, you wrote:
> On Mon, Jan 14, 2002 at 01:29:21PM -0500, Israel Fdez wrote:
> > I'm developing a file auditor kernel module. The auditing tasks are
> > performed by a userland daemond, and the sys_open and sys_exec system
> > calls are intercepted by the kernel module. I was using IPC V messages to
> > communicate both hte LKm anda the daemon, but I realize that they are not
> > designed to run within the kernel space. Now I'm tring with a /proc file,
> > but, this is my question:
>
> You actually want a real device driver, /proc wasn't designed to be
> abused like that.
>
> > Whow can I make my daemond to wait a "signal" or something else from the
> > kernel module. This "signal" should contain the file path to be audited.
>
> Use a semaphore (or some other kind of locking mechanism).
>
> struct semaphore sem;
>
> /* device "read" function */
> static ssize_t read_func(struct file *filp, char *buf, size_t count,
>                           loff_t *f_pos)
> {
> 	if(down_interruptible(&sem))
>                 return -ERESTARTSYS;
>
> 	/* copy data to userland */
>
> 	return number of bytes written to userland;
> }
>
> /* other part of the driver that wants to wakeup userland (interrupt
> /* handler, for example) */
>
> 	up(&sem);
>
> /* initialisation at module load*/
> 	sema_init(&sem, 1);
>
>
> Userland daemon reads the device, but blocks on the semaphore. Userland
> gets woken up either when it receives a signal (hence the
> down_interruptible()), or when the semaphore gets signaled with up()
> (probably when data comes available). Again, see "linux device drivers,
> 2nd edition".
>
>
> Erik
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux