Re: A question about 'lsusb'

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

 



On Thu, Aug 30, 2018 at 05:10:53PM -0400, Alan Stern wrote:
> On Thu, 30 Aug 2018, Faisal Mehmood wrote:
> 
> > Based on my (limited) understanding if I were to disable udev, the
> > userspace should not be able to enumerate/interact with any newly
> > connected device since udev handles uevents generated by kernel.
> > (right?)
> 
> That's not quite right.  Yes, udev does handle uevents.  But a newly
> connected device may be usable from userspace, to some extent, without
> any handling of uevents.
> 
> > So as a test, I disabled systemd-udevd and then plugged in a flash
> > drive. I disabled support for usb mass storage in the kernel. So 'lsblk'
> > didn't show the device, just as expected. However, 'lsusb' still 
> > dynamically updates the list as I repeatedly plugin and remove a flash
> > drive.
> 
> An example of what I described above.
> 
> > Then I studied libusb/lsusb code for a bit. It seems that lsusb makes use
> > of 'libusb_get_device_list()' to find the connected usb devices. But I
> > couldn't find any detail regarding implementation of
> > libusb_get_device_list.
> 
> That's an internal aspect of libusb, so it might not be described in 
> the documentation.  You can always check the source code if you really 
> want to know how it works.  I think it may look at the files under 
> /sys/bus/usb/devices/ -- that's certainly one possibility which would 
> always work even without udev.
> 
> > I am sure I'm missing something. Could someone please help me understand
> > what is happening behind the scenes?
> 
> udev does things like loading drivers into the kernel (modprobe'ing 
> them) and creating nodes under /dev.  But a driver that is already 
> present in the kernel doesn't need to be modprobe'd, and the files 
> under /sys are created automatically by the kernel rather than by udev.  

Also, udev has not created /dev nodes for probably a decade now.  That's
what devtmpfs does.  udev can create symlinks to existing dev nodes, and
some "special-case" device nodes where the kernel name is not what
userspace wants to use.

But really, why would anyone _want_ to remove udev, it's such a nice
program and solves so many problems :)

thanks,

greg k-h



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux