0

I am calculating a timestamp in kernel and storing it in a buffer as shown in the code below. I want to make this data available to the user space program by using process file system (procfs). I am finding it very difficult to understand the procfs file system. Can someone help me understand how to do this, or point me in the right direction of some document or tutorial regarding this?

//this code is at network device driver level.
int netif_rx(struct sk_buff *skb) 
{
    __net_timestamp(skb);//I modify the code in kernel to get the timestamp and store in buffer
}
Walls
  • 3,972
  • 6
  • 37
  • 52
user3458454
  • 291
  • 1
  • 4
  • 20
  • For example IBM: http://www.ibm.com/developerworks/library/l-proc/ – osgx Apr 15 '14 at 10:37
  • thank you very much . but where the location for lkm.c file in linux source code to add or remove the code ?? – user3458454 Apr 15 '14 at 11:03
  • The document is showing the lkm code to be added in /proc filesystem but he did not mention the location of lkm.c !! – user3458454 Apr 15 '14 at 11:12
  • `simple-lkm.c` is the main source of module. Its location - is the directory of the module. – osgx Apr 15 '14 at 11:18
  • shall i create simple-lkm.c in /proc directory ?? i did not understand!! could you be more precise. where is the location of simple-lkm.c ? – user3458454 Apr 15 '14 at 11:20
  • It is the source file of module. Create it in the own directory or in some directory inside kernel. You will build the module from this directory. PS: it can be easier to use LTTng tracing to get timestamps from kernel's internal paths, like netif_rx. Defining new tracepoint is easier than writing new linux module. – osgx Apr 15 '14 at 11:26
  • thank you. In my question: I am getting the timestamp (you can see the code) but later how to send this data to the user space ?? please suggest me some ideas ?? I was planning to use ftrace for kernel debugging but later came to know that it works as a storing a timestamp in a file (it is like a offline). I want to do it online i.e I am calculating the time when the kernel as been interrrupted and sending the data to the user space. PLEASE HELP. – user3458454 Apr 15 '14 at 11:31
  • An answer was posted by [deo](http://stackoverflow.com/users/1377418/deo) which said `Using copyout and copystr function.`. That was the entire answer. It was marked for the Low Quality Posts review queue and deleted because it wasn't an acceptable answer, but I'm reproducing it as a comment because it *might* be useful and there are no answers as of yet. – Adi Inbar Apr 15 '14 at 17:44
  • where should I use the copyout api (kernel space or user space) ?? If it is kernel space then could you please tell me the location of it ?? – user3458454 Apr 15 '14 at 19:58
  • possible duplicate of [reading the timestamp from kernel using procfs - where is it stored after reading from kernel?](http://stackoverflow.com/questions/23183838/reading-the-timestamp-from-kernel-using-procfs-where-is-it-stored-after-readin) – Abhijeet Kasurde Apr 23 '14 at 15:17

0 Answers0