Linux - Distributions This forum is for Distribution specific questions.
Red Hat, Slackware, Debian, Novell, LFS, Mandriva, Ubuntu, Fedora - the list goes on and on... |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
08-19-2009, 09:46 AM
|
#1
|
|
Member
Registered: Aug 2009
Posts: 32
Rep:
|
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
|
|
|
|
08-19-2009, 11:14 AM
|
#2
|
|
Senior Member
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109
Rep:
|
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
|
|
|
|
08-19-2009, 11:54 PM
|
#3
|
|
Member
Registered: Aug 2009
Posts: 32
Original Poster
Rep:
|
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
|
|
|
|
08-20-2009, 05:14 AM
|
#4
|
|
Senior Member
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109
Rep:
|
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
|
|
|
|
08-20-2009, 05:28 AM
|
#5
|
|
Moderator
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
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.
|
|
|
|
08-20-2009, 05:34 AM
|
#6
|
|
Member
Registered: Aug 2009
Posts: 32
Original Poster
Rep:
|
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
|
|
|
|
08-20-2009, 06:01 AM
|
#7
|
|
Member
Registered: Aug 2009
Posts: 32
Original Poster
Rep:
|
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
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 05:06 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|