Re: /proc registration ?

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

 



Mcen navaraj wrote:

 > hi,
Hi, too.


 > what is the difference between proc_register and
 > create_proc_entry when creating an entry in
 > the /proc.

can't explain like the experts.
i wrote something about proc in my reply to steve lustbader. check this here.
hope it brings you forward. i think it points into the correct directions.

about proc_register:
to steve, i wrote about this, too. i think now, i made a litte mistake.
proc_register meant a function called by you in init_module().
you write proc_register. in the proc_register function you implement calls like:

if a real proc_register exists and i turned wrong now, please correct me. (-:

--- start of a part

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/proc_fs.h>

int test_read_proc(char *buf, char **start, off_t off, int count, int *eof, void *data);
int test_write_proc(struct file *file, const char *buffer, unsigned long count, void *data);

struct proc_dir_entry *dir_entry, *fil_entry;

register_proc_files()
{
  /* create directory */                                  /*  &proc_root */
  (struct proc_dir_entry*) dir_entry = proc_mkdir("test_dir", &proc_root);
  /* create now a file */
  (struct proc_dir_entry*) fil_entry = create_proc_entry("test_fil", 0770, dir_entry);
  fil_entry->read_proc = test_read_proc;
  fil_entry->write_proc = test_write_proc;
  /*** this is closely like registering a device driver, isn't it ? ***/
}
unregister_proc_files()
{
  /* remove files first */
  remove_proc_entry("test_fil", dir_entry);
  /* remove directory at NULL (register at proc_root) */
  remove_proc_entry("test_dir", NULL);
}

int init_module(void)
{ register_proc_files(); }
void cleanup_module(void)
{ unregister_proc_files(); }

--- end of a part

i think this kind of pseudocode isn't insmodable. but explains how to.

about create_proc_entry(name, mode, parent)
creates a file with the name "name" in the proc dir.
"mode" ist the filemask for the creation.
"parent" is a pointer to a proc_dir_entry struct.
the func proc_mkdir creates a directory in the proc fs like shown above.

The struct proc_dir_entry contains function pointers to proc_read and proc_write.
And at last function pointers to get_info() and readlink_proc() for more /proc-ing.
the structure has some interesting attributes. find them out. i'll have to, too.


 > when i try to use the proc_register in the program it
 > shows error.I can able to compile the program
 > but i cannot able to insmod the program.It shows
 > unresolved symbol error.

Try to synchronize your code with my example.
Taken from a book. Tested in my third module.
Works great. And the read/write is implemented ;-).


 > when i use the create_proc_entry it create an entry in
 > the /proc directory.

try like in the example above.
add the rest of your code into the gaps :-).


 > what is the difference in the  /boot/System.map and
 > /proc/ksyms ?

can't answer now. would like to know, too.


 > Thanks
 > bye

Edward.


--
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