static int
create_procfs_file(struct proc_dir_entry **entry, mode_t mode, const char *name,
struct proc_dir_entry *parent, int constant, void *read_func)
{
printk(KERN_INFO "entry=%p\n", entry);
*entry = create_proc_entry(name, mode, parent);
if (entry == NULL) {
printk(KERN_ALERT "Can't create %s file", name);
return -1;
}
/*Assign read function and owner to prevent removing entry while in use */
((struct proc_dir_entry *) (*entry))->read_proc =
(read_proc_t *) read_func;
((struct proc_dir_entry *) (*entry))->owner = THIS_MODULE;
((struct proc_dir_entry *) (*entry))->data =""> kmalloc(sizeof (int), GFP_KERNEL);
((struct proc_dir_entry *) (*entry))->data = "" *) constant;
printk(KERN_INFO "entry=%p\n", entry);
return 0;
}
I was confused cause the files were created.
One more question, not directly related with this one: where can I find documentation about static modifier(?). I'm thinking about if there is a problem trying to write into a extern declared variable while inside a static function. So I would like to read about static
Thanks
On 7/5/06, Om. <om.turyx@xxxxxxxxx> wrote:
> -----------------------------------------------------------------------
> static int
> create_procfs_dir(struct proc_dir_entry *entry, const char *name,
> struct proc_dir_entry *parent)
> {
> entry = proc_mkdir(name, parent);
> if (entry == NULL) {
> /*Failed when creating file */
> printk(KERN_ALERT "Error while creating %s directory\n",
> name);
> return -1;
> }
Print the value of variable entry in create_procfs_dir() in the
beginning and before return. You would understand. It is a problem
with your understanding of C pointers.
If you did not, change the create_procfs_dir() first param to struct
proc_dir_entry ** and pass the address of the variable.
All the best,
Om.