LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions
User Name
Password
Linux - Distributions This forum is for Distribution specific questions.
Red Hat, Slackware, Debian, Novell, LFS, Mandriva, Ubuntu, Fedora - the list goes on and on... Note: An (*) indicates there is no official participation from that distribution here at LQ.

Notices

Reply
 
Search this Thread
Old 08-19-2009, 09:46 AM   #1
paldebojyoti
Member
 
Registered: Aug 2009
Posts: 32

Rep: Reputation: 15
Creation of device node after USB insertion


Hi,

When a USB device is inserted into a linux system a device node is created in /deb. I need to know the following information:
1) Who creates this node, is it USBcore?
2) Why it takes 4-5 seconds to be created?
3) Is there any other location apart from /dev where the device node corresponding to the same USB device is created?
Thanks in advance.

Regards,
Debojyoti
 
Old 08-19-2009, 11:14 AM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Hi.

1) All the /dev entries in recent-ish Linux systems are handled by 'udev'. This is a userland daemon that the kernel notifies every time there's a hardware change. It creates the appropriate node in /dev according to some built in rules, and the rules in /etc/udev/rules.d
2) Some (all?) USB devices take a few seconds to 'settle' before they are probed. Some devices also require firmware which has to be uploaded to the device before it'll work, which may take a couple of seconds.
3) Nope, not as far as I can see. There's nothing stopping you creating your own device node wherever you like, with the right major and minor numbers, though. 'mknod' is the command.

Dave
 
Old 08-19-2009, 11:54 PM   #3
paldebojyoti
Member
 
Registered: Aug 2009
Posts: 32

Original Poster
Rep: Reputation: 15
Hi Dave,

Thanks a lot for your information. It really helpful. I do have some queries:
1) If UDEV creates the device node, then if I change the udev rule then I hope this device node will not be created.
2) In Windows, file system has been created instantly after USB device insertion, but in Linux it takes bit longer time, is there any other mechanism to create the device node faster?
3) Can I stop UDEV from creating the device node, instead my application will create the device node as I have seen that SYSFS contains all the information regarding a USB device?

Regards,
Deb
 
Old 08-20-2009, 05:14 AM   #4
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Hi.

2 questions:
Is there a particular reason you need devices to be available very quickly after attachment?
How are you measuring the time it takes between insertion and the device being available?

If you /really/ want to you can abandon udev and use the old static /dev directory. You'd have to create all the device nodes in /dev manually, and stop the udev daemon from starting. There might be some kernel reconfiguration required too.

Dave
 
Old 08-20-2009, 05:28 AM   #5
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
For the third question of your original post, there are other device nodes created. Look in /dev/disk/by-path and /dev/disk/by-id. These are also created by udev. You can have entries in /etc/fstab files that allow you to mount filesystems by UUID or LABEL. This allows you to use particular options like uid,gid,fmask & dmask based on the filesystem and not the mode. Using the same computer, this could allow one user to have exclusive access to a pen drive. The permissions and ownership are determined (for vfat & ntfs) in the mount command. Another user may be able to mount it but can be denied read or write access, depending on the option values given.

Also look at PolicyKit. You can have rules that allow mounting of removable media, restrict it to the user of an active session, or deny mounting removable media all together.

Last edited by jschiwal; 08-20-2009 at 05:31 AM.
 
Old 08-20-2009, 05:34 AM   #6
paldebojyoti
Member
 
Registered: Aug 2009
Posts: 32

Original Poster
Rep: Reputation: 15
Hi Dave,

Yes I need to get the device node should come up very fast. If UDEV will take long then my application will create separate device node, as my application will get the major & minor number form the sysfs.
When a device is inserted, an entry in usbfs has immediately created, also all the USB related information is updated in SYSFS immediately, but the device node is not created that fast, it takes almost 4-5 seconds.
If my application can create the device node apart from the device node created by UDEV, then I don't need to remove the UDEV.

Regards,
Deb
 
Old 08-20-2009, 06:01 AM   #7
paldebojyoti
Member
 
Registered: Aug 2009
Posts: 32

Original Poster
Rep: Reputation: 15
Hi jschiwal,

Yes the entries are created in /dev/disk/by-id and /dev/disk/by-path, but these two are not the separate device nodes, these are the soft links to the device node created in /dev (i.e. sdb, sdc) by UDEV.

Regards,
Deb
 
  


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
detect usb device insert/remove and get device node from "C" program ebinjose Linux - Embedded & Single-board computer 4 04-29-2012 08:26 AM
usb device detection, manual insertion card(smart card) reader problem, zapkhiel Linux - Hardware 4 07-17-2009 08:50 AM
USB device node - where is it? moistTowelette Linux - Hardware 3 08-13-2007 11:44 AM
creation of dynamic device node entry in /dev balalin Linux - Kernel 0 04-10-2007 04:29 AM
Keeping a pointer out of intput/mice and node in place for unplugged usb device AlexiaDeath Linux - Hardware 5 01-13-2006 05:16 AM


All times are GMT -5. The time now is 04:11 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration