c - How to perform sequential read in procfs? -


#include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/fs.h> #include <linux/proc_fs.h> #include <linux/jiffies.h> #include <linux/seq_file.h>  //extern uint64_t interrupt_time;  static struct proc_dir_entry *test_dir;  static int my_proc_show(struct seq_file *m, void *v) {     seq_printf(m, "%lu\n", jiffies);     //seq_printf(m, "%lu", interrupt_time);     return 0; }  static int my_proc_open(struct inode *inode, struct file *file) {     return single_open(file, my_proc_show, null); }  static const struct file_operations tst_fops = {     .open       = my_proc_open,     .read       = seq_read,     .llseek     = seq_lseek,     .release    = single_release, };  static int __init test_init(void) {     test_dir = proc_mkdir("myproc", null);      if (test_dir)             proc_create("jiffies", 0, test_dir, &tst_fops);      return 0; } static void __exit test_exit(void) {     remove_proc_entry ("jiffies", test_dir);     proc_remove (test_dir); } module_init(test_init); module_exit(test_exit);  module_license("gpl"); module_author("test"); 

the above code procfs driver in above code contains init function, exit function, file operation function how create seq_read() function kernel user. api that?

this code modified in /linuxversion/net/core/dev.c

int netif_rx(struct sk_buff *skb)  {   skb->tstamp = ktime_get_real();   //this give timestamp , stored in //skb buffer   //i calculating timestamp here. because whenever kernel receive data kernel    //interrupted , start executing newly arrived task have read time when   //interrupt  occurs , value of it. }  

my question is: how copy time-stamp procfs?

i'm not sure if issue how create , populate entries in /proc or how read existing one. regarding latter:

how read user application

from user program open /proc/foo/bar , read it, other file.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -