proc_mkdir

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

 



Hi,

I'm creating several files and directories under /proc. I created two functions to achieve this and for common error handling... they look like these:

-----------------------------------------------------------------------
static int
create_procfs_file(struct proc_dir_entry *entry, mode_t mode, const char *name,
                   struct proc_dir_entry *parent, int constant)
{
        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 */
        entry->read_proc = (read_proc_t *) my_read_function;
        entry->owner = THIS_MODULE;
        entry->data = "" (int), GFP_KERNEL);
        entry->data = "" *) constant;
        return 0;

}
-----------------------------------------------------------------------

and

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

        return 0;
}
-----------------------------------------------------------------------

In addition I have some declarations like these:

static struct proc_dir_entry *pid_file;
and
static struct proc_dir_entry *my_process_dir;

When I use create_procfs_file to create my files, there is no problem, but when I try to create directories doing this:

create_procfs_dir(my_root_dir, "program", NULL);
create_procfs_dir(my_syscall_dir, "dir_sys", my_root_dir);
create_procfs_dir(my_process_dir, "dir_process", my_root_dir);

The three directories are created under /proc and my tree is not properly created. The problem, as I can see is that when returning from create_procfs_dir, my_root_dir is NULL (I checked this point). So I suppose that I'm doing something wrong, but I can't see what... moreover taking into account that the create_profs_file is working fine...

Any ideas?

Thanks in advance (and apologyze me for the length of this mail)



[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