LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 07-31-2011, 10:21 PM   #1
FrankRizzo
LQ Newbie
 
Registered: Jan 2007
Location: Tennessee
Distribution: SUSE 10.1 / Core 6
Posts: 8

Rep: Reputation: 0
Question create_proc_entry "path" help?


Guys, my code:

Code:
int init_module(void)
{
    proc_entry = create_proc_entry( "bus/usb/005/004", 0666, NULL );

    if (proc_entry == NULL)
    {
      printk(KERN_INFO "Couldn't create proc entry\n");
    } 
    else 
    {
      proc_entry->proc_fops = &fops;
      printk(KERN_INFO "Module loaded.\n");
    }

    // This is intentionally forced.  Ignore it.  :-)
    return -EINVAL;
}
Always fails to create the proc entry requested. It was my understanding from a LOT of Google searching that this is permissible. As you might imagine, "/proc/bus/usb/005" already exists, as do items 001-003.

Anyone have any idea what's going on here?

Thanks!
 
Old 08-01-2011, 12:19 AM   #2
bsat
Member
 
Registered: Feb 2009
Posts: 347

Rep: Reputation: 72
The arguments to the create proc entries are
name : The name of the entry you want to create, not the path
mode: Permissions for read and write
parent dir: This is where you give the full path to the parent directory under which you want the entry.

So in your case, if you want entry named 004 under bus/usb/005, pass 004 as the first argument and bus/usb/005/ as the third.
 
Old 08-01-2011, 09:14 AM   #3
FrankRizzo
LQ Newbie
 
Registered: Jan 2007
Location: Tennessee
Distribution: SUSE 10.1 / Core 6
Posts: 8

Original Poster
Rep: Reputation: 0
The prototype for create_proc_entry is this:

Code:
struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,  struct proc_dir_entry *parent)
So, in order to be able to pass the dir as the 3rd parameter, I'll need to be able to get the "proc_dir_entry" for it.

How do I do that without calling proc_mkdir?
 
Old 08-01-2011, 01:52 PM   #4
FrankRizzo
LQ Newbie
 
Registered: Jan 2007
Location: Tennessee
Distribution: SUSE 10.1 / Core 6
Posts: 8

Original Poster
Rep: Reputation: 0
Found the answer.

Hopefully this might help someone in the future if they're having the same problem.

Code:
    struct file *filp = filp_open("/proc/bus/usb/005", O_RDONLY, 0);
    struct proc_dir_entry *parent = PDE(filp->f_dentry->d_inode);
    filp_close(filp, NULL);

    proc_entry = create_proc_entry( "004", 0666, parent );
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to modify my "PATH" in Ubuntu "bashrc" for a software? msbstar Linux - Newbie 3 01-25-2011 08:47 AM
can't locate object method "path" via package "Autom4te::Request" at/usr/bin/autom4te wjh513 Linux - Software 1 08-13-2010 02:31 PM
"Could not init font path element""Unix /: 7100 removing from list/ zameer_india Linux - Networking 7 07-03-2006 06:11 AM
Cedega from Fat32 (Invalid path "." given for "--use-dos-cwd") bdox Linux - Software 0 03-30-2005 11:24 AM
Cedega and Fat32 (Invalid path "." given for "--use-dos-cwd") bdox Linux - Games 0 03-26-2005 02:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 10:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration