LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-02-2010, 04:57 AM   #1
greplinux
Member
 
Registered: Jun 2007
Posts: 118

Rep: Reputation: 17
udev rules


Hi all,

I am little curious about how udev rules work to create device files.

Following is what I did for that:

Up on plugging in my phone (sony w800i), I am getting a device file '\dev\cdc-wdm0' created. I just tried to figure out the rule which is responsible for the creation of this particular file.

I searched in '\etc\udev\rules.d' and '\lib\udev\rules.d' for the string 'cdc-wdm' to find that rule. But I am not getting any hits in that search. Could any one help me out in this one.

BTW: I am using Ubuntu 9 :-)

Thanks
 
Old 06-02-2010, 09:05 AM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Hi.

That device name's coming straight from the 'cdc-wdm' kernel module - it creates devices called '/dev/cdc-wdmX' by default, so there's no udev rule applied in this case.

Dave
 
1 members found this post helpful.
Old 06-03-2010, 01:52 AM   #3
greplinux
Member
 
Registered: Jun 2007
Posts: 118

Original Poster
Rep: Reputation: 17
Thanks ilikejam. I went through the source and got two references of cdc-wdm. one is a class driver structure and another one in dev_info. Can you point me to the exact method of creating the device file from the module itself.

Thanks again.
 
Old 06-03-2010, 06:34 AM   #4
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Usual disclaimer - I'm not a kernel hacker.

According to http://www.makelinux.net/ldd3/chp-13-sect-4.shtml
Quote:
The usb_register_dev function requires a pointer to a struct usb_interface and a pointer to a struct usb_class_driver. This struct usb_class_driver is used to define a number of different parameters that the USB driver wants the USB core to know when registering for a minor number. This structure consists of the following variables:

char *name

The name that sysfs uses to describe the device. A leading pathname, if present, is used only in devfs and is not covered in this book. If the number of the device needs to be in the name, the characters %d should be in the name string. For example, to create the devfs name usb/foo1 and the sysfs class name foo1, the name string should be set to usb/foo%d.
It's actually the devfs bit that we're interested in, but at least we know where devfs gets the names from - the usb_class_driver struct.

A quick shufty at the cdc-wdm source tips up:
Code:
static struct usb_class_driver wdm_class = {
	.name =		"cdc-wdm%d",
	.fops =		&wdm_fops,
	.minor_base =	WDM_MINOR_BASE,
};
So it's the 'name' string in the usb_class_driver struct that decides the device name. I haven't looked up how that name gets propagated up to devfsd, though.

Dave
 
Old 06-03-2010, 10:42 AM   #5
greplinux
Member
 
Registered: Jun 2007
Posts: 118

Original Poster
Rep: Reputation: 17
Hi Dave,

Thank you very much. I really appreciate your reply. Given below is my understanding:

The 'cdc-wdm' references in the driver is for 'sysfs' entries. By using them , they get in to sysfs system. So these entries only help us to create rules and they don't create device files.

Still, I dont get how his device file is getting created. :-)

Will search and post that in this, if I find anything.

Thanks again!!

Regards,
 
Old 06-03-2010, 11:10 AM   #6
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Hi again.

When you add or remove a device, the kernel generates a 'uevent', and passes that to udevd (via a socket). That uevent contains the name of sysfs device amongst other things. I believe the default action is to create a /dev device that matches the sysfs device name.

Above disclaimer still applies, but that's how the docs read to me.

Dave
 
1 members found this post helpful.
Old 06-04-2010, 12:46 AM   #7
greplinux
Member
 
Registered: Jun 2007
Posts: 118

Original Poster
Rep: Reputation: 17
Thanks Dave. Will look into uevent thing. :-)

Regards,
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
udev.rules Linux~Powered Linux - General 1 02-13-2010 06:05 PM
How to edit "/etc/udev/rules.d/40-basic-permissions.rules" file cygan Linux - Newbie 11 03-09-2009 06:22 AM
cat: /etc/udev/rules.d/70-persistent-net.rules: No such file or directory rcg1984 Linux From Scratch 2 09-17-2008 08:02 AM
slackware-current, udev 0.96, and custom udev rules not working rignes Slackware 6 08-10-2006 04:43 AM
need help fixing my udev rules or ivman rules hedpe Linux - Hardware 2 03-18-2006 11:07 AM


All times are GMT -5. The time now is 04:56 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration