Re: Nothing printed from custom /proc/foo

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

 



JP Beaudry wrote:
Hi,

I want to add a virtual file under /proc for my module (kernel 2.4.21). The "registration" seems to work because /proc/foo shows up once my module is loaded. Here's the call:

create_proc_read_entry("foo", 0, NULL, foo_read, NULL);

My problem is that nothing shows up when I read foo with 'cat' or 'less'. Here's foo():

int foo_read(char *buf, char **start, off_t offset, int count, int *eof, void *data)
{
 printk("Got into foo_read\n");
 int len = sprintf(buf, "hello");
 *eof = 1;
 return len;
}

As you can see, I've used printk() in the hope of asserting that foo() is called. Unfortunately, I can't see anything in /var/log/messages. I don't even know if I should expect printk() to work in this context. I tried both with and without with the same result.

What am I missing?
Thanks,
JP
Hi,

replace
	create_proc_read_entry("foo", 0, NULL, foo_read, NULL);
by
	create_proc_read_entry("foo", 0644, NULL, foo_read, NULL);
to have correct permissions on the file.

I don't think this will resolve the problem. Maybe you could test the value return by create_proc_read_entry() to check if the file has effectively been created.
	
Anyway, here's a guide for procfs :
http://kernelnewbies.org/documents/kdoc/procfs-guide/lkprocfsguide.html

If your error persist, send the complete code.


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[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