struct task_struct

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

 



Hi all,

i have written a kernel module while modifies the sys_call_table and inserts 
new syscalls to bring some performance counters to the userland.
I m stuck in bringing process counters.
The idea behind it is, instead of reading /proc/<pid>/ for data
we decided to bring the data down to the userland from the kernel through our 
system call.

This is what my assumption is:

the process information is stored in a link list of struct task_struct.
If i can copy the contents of the link list to the user memory 
using the macro for_each_task(p) defined in linux/sched.h

         for_each_task (p) {
	/*do copy and all that stuff*/
        }

i can read the appropriate values from that copied link list from that 
userland program.

Now my questions are:
i have used copy_to_user to copy a structure to the userland program
but i donno how to copy a link list.

initially i thought of allocating memory in the module and copy the original 
contents to the memory and give it to useprogram.but i donno whether it is 
possible to allocate userland memory from kernel or not.

Is there any other decent way of doing it.

pls clarify if i my understanding is wrong.

thanks and regards,
mohan.
-
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