On Mon, Sep 14, 2009 at 2:19 PM, Leonidas . <[email protected]> wrote:

>
>
> On Mon, Sep 14, 2009 at 1:57 PM, Pei Lin <[email protected]> wrote:
>
>> SO u can use the first method,write files from the kernel space.....
>> See the hyperlink i give.
>>
>> Lin
>>
>> 2009/9/14 Leonidas . <[email protected]>:
>> >
>> >
>> > On Mon, Sep 14, 2009 at 1:22 PM, Leonidas . <[email protected]>
>> wrote:
>> >>
>> >>
>> >> Hi List
>> >>
>> >> I have written a kernel module which implements a char device. An
>> >> userspace app
>> >> is supposed to get data from my module and then dump it into a file for
>> >> further processing.
>> >>
>> >> The kind of data which kernel module is going to pass to userspace is
>> >> going to be a 4K buffer,
>> >> and the data traffic is not going to be really heavy, meaning may be a
>> 4K
>> >> buffer every 1 min or so.
>> >> I am not very sure though, but certainly not heavy traffic the way they
>> >> describe for network traffic etc.
>> >>
>> >> And this data needs to be logged to a file either from kernel or
>> userspace
>> >> and an userspace all will work
>> >> on that data. This data needs to be logged as soon as it arrives
>> meaning,
>> >> I might not be able to write it to
>> >> /proc since from module I can update /proc only when user actually
>> >> accesses it. This data needs to be
>> >> static in nature, meaning I get one error and I write it to a file
>> somehow
>> >> and user can see it anytime.
>> >>
>> >> I hope I have described the situation clearly. I have explored some
>> >> mechanism like ioctls, mmaping the
>> >> kernel buffer etc but all these would require the user module to poll
>> or
>> >> notified somehow by kernel that
>> >> the data is available. I dont want the user module to poll.
>> >>
>> >>
>> >> -Leo.
>> >>
>> >
>> > When we do a printk it writes to kernel log buffer, correct? This is
>> real in
>> > time operation i.e. as soon as we do a
>> > printk the messages get logged. Now this log file can be accesses from
>> > /var/log/messages right? How is this done?
>> >
>> > I want to so something similar, so I can log my messages to a seprate
>> file
>> > which is going to stay around so user can
>> > see at across reboots as well.
>> >
>> >
>> >
>> > -Leo.
>> >
>> >
>>
>
>
> No, Greg KH mentions that is should not be done!
> And I have been reading that 'It is a bad..bad thing to access files from
> kernel space'
> since I started doing Linux stuff.
>
> _Leo.
>


I am aware of other legitimate mechanisms as I have described on my origianl
post.
It is just that I have certain constraints under which I cant use many of
the methods
since I dont want to user space entity to do polling or get signal from
kernel.

-Leo.

Reply via email to