Hello,
I have a device driver and I need to have a /proc entry for my driver.
I added an entry looking at fs/proc/root.c
What happens now is that when I cat /proc/mydriverinfo, it displays the
stuff, but in an infinite loop. It comes out if I hit a ctrl-c.
I have explained what I have done below.
Could anyone tell me why is it going in an infinite loop.
Thanks,
Pramodh
fs/proc/root.c
--------------
static struct proc_dir_entry proc_root_mydriver = {
PROC_MYDRIVER, 8, "mydriver",
S_IFREG | S_IRUGO, 1, 0, 0,
0, &mydriver_iops,
};
proc_register(&proc_root, &proc_root_mydriver);
mydriver.c
----------
static struct file_operations mydriver_fops = {
....
mydriver_read, // This read is only used for proc purpose
.....
};
struct inode_operations mydriver_iops = {
&mydriver_fops
};
static int mydriver_read(struct file * file, char * buf, size_t count,
loff_t *ppos)
{
int len;
char *buffer;
unsigned long page;
if (!(page = __get_free_page(GFP_KERNEL)))
return -ENOMEM;
buffer = (char *)page;
len = sprintf(buffer, "blah blah blah");
copy_to_user(buf, (void *)page, len);
*ppos += len;
free_page(page);
return len;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Thu Jun 15 2000 - 21:00:14 EST