2005-03-23 13:20:40

by linux lover

[permalink] [raw]
Subject: Accessing data structure from kernel space

Hello all,
I have one linked list data structure added to
a file in kernel source code which has some kernel
info. I want to acess that linked list structure from
user space. Is that possible??
Also how to add own system call usable at user
level from kernel module??
regards,
linux_lover.



__________________________________
Do you Yahoo!?
Make Yahoo! your home page
http://www.yahoo.com/r/hs


2005-03-23 13:31:52

by linux-os (Dick Johnson)

[permalink] [raw]
Subject: Re: Accessing data structure from kernel space

On Wed, 23 Mar 2005, linux lover wrote:

> Hello all,
> I have one linked list data structure added to
> a file in kernel source code which has some kernel
> info. I want to acess that linked list structure from
> user space. Is that possible??
> Also how to add own system call usable at user
> level from kernel module??
> regards,
> linux_lover.
>

Many people will tell you to use the /proc file-system.
I suggest you make a simple "character" driver and access
your kernel structure using ioctl() or mmap().

You don't add your own system call __ever__, even if you
are a long-time kernel developer. The current API already
has lots of standard interface capabilities. Thinking, even
for an instant, that you need more means that you don't
understand Unix/Linux.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.11 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.

2005-03-23 13:45:46

by Jan Engelhardt

[permalink] [raw]
Subject: Re: Accessing data structure from kernel space

>> Hello all,
>> I have one linked list data structure added to
>> a file in kernel source code which has some kernel
>> info. I want to acess that linked list structure from
>> user space. Is that possible??

Yes!!

>> Also how to add own system call usable at user
>> level from kernel module??

!!

> Many people will tell you to use the /proc file-system.

*cough* sysfs *cough*
err...(due to new horizons):
*cough* relayfs *cough*



Jan Engelhardt
--

2005-03-23 16:45:42

by linux lover

[permalink] [raw]
Subject: Re: Accessing data structure from kernel space

Hello linux-os,
--- linux-os <[email protected]> wrote:
> On Wed, 23 Mar 2005, linux lover wrote:
>
> > Hello all,
> > I have one linked list data structure added
> to
> > a file in kernel source code which has some kernel
> > info. I want to acess that linked list structure
> from
> > user space. Is that possible??
> > Also how to add own system call usable at
> user
> > level from kernel module??
> > regards,
> > linux_lover.
> >
>
> Many people will tell you to use the /proc
> file-system.
> I suggest you make a simple "character" driver and
> access
> your kernel structure using ioctl() or mmap().
>
How can i access that linked list structure in
kernel at user space say if i write character driver
as /dev/readll then how to link that structure to
device driver
?
> You don't add your own system call __ever__, even if
> you
> are a long-time kernel developer. The current API
> already
> has lots of standard interface capabilities.
> Thinking, even
> for an instant, that you need more means that you
> don't
> understand Unix/Linux.
>
> Cheers,
> Dick Johnson
> Penguin : Linux version 2.6.11 on an i686 machine
> (5537.79 BogoMips).
> Notice : All mail here is now cached for review by
> Dictator Bush.
> 98.36% of all statistics are
> fiction.
>

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

2005-03-23 16:45:41

by linux lover

[permalink] [raw]
Subject: Re: Accessing data structure from kernel space

Hello sir,
--- Jan Engelhardt <[email protected]> wrote:
> >> Hello all,
> >> I have one linked list data structure added
> to
> >> a file in kernel source code which has some
> kernel
> >> info. I want to acess that linked list structure
> from
> >> user space. Is that possible??
>
> Yes!!
So that mean i can read that linked list
structure and print them in user space that will have
some kernel internel info.
>
> >> Also how to add own system call usable at
> user
> >> level from kernel module??
>
> !!
>
> > Many people will tell you to use the /proc
> file-system.
>
> *cough* sysfs *cough*
> err...(due to new horizons):
> *cough* relayfs *cough*
>
>

Whats that? Can you please elaborate to me as i
am newbie to those words. Pleaseeee.

>
> Jan Engelhardt
> --
>

Thanks in advance.
regards,
linux_lover.

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

2005-03-23 17:24:27

by linux-os (Dick Johnson)

[permalink] [raw]
Subject: Re: Accessing data structure from kernel space

On Wed, 23 Mar 2005, linux lover wrote:

> Hello linux-os,
> --- linux-os <[email protected]> wrote:
>> On Wed, 23 Mar 2005, linux lover wrote:
>>
>>> Hello all,
>>> I have one linked list data structure added
>> to
>>> a file in kernel source code which has some kernel
>>> info. I want to acess that linked list structure
>> from
>>> user space. Is that possible??
>>> Also how to add own system call usable at
>> user
>>> level from kernel module??
>>> regards,
>>> linux_lover.
>>>
>>
>> Many people will tell you to use the /proc
>> file-system.
>> I suggest you make a simple "character" driver and
>> access
>> your kernel structure using ioctl() or mmap().
>>
> How can i access that linked list structure in
> kernel at user space say if i write character driver
> as /dev/readll then how to link that structure to
> device driver
> ?

Gawd.... `man ioctl`. Execute that. Learn. Write code
that handles such a call in your module.
`man mmap`. execute that. Learn. Write code that
handles memory-mapping in your module.

>> You don't add your own system call __ever__, even if
>> you
>> are a long-time kernel developer. The current API
>> already
>> has lots of standard interface capabilities.
>> Thinking, even
>> for an instant, that you need more means that you
>> don't
>> understand Unix/Linux.
>>
>> Cheers,
>> Dick Johnson
>> Penguin : Linux version 2.6.11 on an i686 machine
>> (5537.79 BogoMips).
>> Notice : All mail here is now cached for review by
>> Dictator Bush.
>> 98.36% of all statistics are
>> fiction.
>>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>

Cheers,
Dick Johnson
Penguin : Linux version 2.6.11 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.

2005-03-23 18:17:03

by Paul Jackson

[permalink] [raw]
Subject: Re: Accessing data structure from kernel space

> Whats that [relayfs]?

Try http://www.google.com

> Can you please elaborate to me as i
> am newbie to those words. Pleaseeee.

Try http://kernelnewbies.org/

Thank-you.

--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.650.933.1373, 1.925.600.0401

2005-03-30 07:22:38

by linux lover

[permalink] [raw]
Subject: Re: Accessing data structure from kernel space

Hello sir,

I successfully added linked list data structure
in kernel in header file. Write a C source file and
add it to kernel directory. then write 2 system calls
that read and write to linked list from user space
through that syscalls.
recompile kernel. Now able to read/write that
linked list.
I want to write user data in that linked list
and allow kernel to use that info in linked list. Is
my approach to send data from user to kernel and
store there as long as OS is not rebooted is right?
Please reply me.
Thanks in advance.
regards,
linux_lover.





__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/

2005-03-30 13:48:53

by Bodo Eggert

[permalink] [raw]
Subject: Re: Accessing data structure from kernel space

linux lover <[email protected]> wrote:

> I successfully added linked list data structure
> in kernel in header file. Write a C source file and
> add it to kernel directory. then write 2 system calls
> that read and write to linked list from user space
> through that syscalls.
> recompile kernel. Now able to read/write that
> linked list.
> I want to write user data in that linked list
> and allow kernel to use that info in linked list. Is
> my approach to send data from user to kernel and
> store there as long as OS is not rebooted is right?

- A linked list is bad for random access to large amounts of data.
Why is a linked list suitable for your data?
- Did you think about SMP races?
- Why does it need to be in the kernel? Could a daemon do the job?
- to be continued