Re: Disabling USB
Alan Stern <[email protected]>
| Newsgroups | gmane.linux.usb.devel |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 4 Dec 2007, Przemyslaw Lopaciuk wrote: > > Thank you for your reply... I think that you misunderstood my > question... I want to write function let's say... disableUSB() that > would disable USB when invoked... > As I understand you can pass kernel command line parameters while > booting. Can you do that also when the kernel is running? > If yes than how? You can unbind the host controller drivers from the controller devices. This can be done using sysfs. You would have to iterate through these directories: /sys/bus/usb/devices/usb*/../driver In each of those directories, iterate through all the symbolic links (you can omit the link named "module" if it's present) and write the name of the link to the "unbind" file. For example on my system: $ cd /sys/bus/usb/devices/usb1/../driver/ $ ls -l total 0 lrwxrwxrwx 1 root root 0 Dec 4 10:30 0000:00:1d.0 -> ../../../../devices/pci0000:00/0000:00:1d.0/ lrwxrwxrwx 1 root root 0 Dec 4 10:30 0000:00:1d.1 -> ../../../../devices/pci0000:00/0000:00:1d.1/ lrwxrwxrwx 1 root root 0 Dec 4 10:30 0000:00:1d.2 -> ../../../../devices/pci0000:00/0000:00:1d.2/ lrwxrwxrwx 1 root root 0 Dec 4 10:30 0000:01:01.0 -> ../../../../devices/pci0000:00/0000:00:1e.0/0000:01:01.0/ lrwxrwxrwx 1 root root 0 Dec 4 10:30 0000:01:01.1 -> ../../../../devices/pci0000:00/0000:00:1e.0/0000:01:01.1/ --w------- 1 root root 4096 Dec 4 10:30 bind lrwxrwxrwx 1 root root 0 Dec 4 10:30 module -> ../../../../module/uhci_hcd/ --w------- 1 root root 4096 Dec 4 10:30 new_id --w------- 1 root root 4096 Dec 4 10:30 unbind So I would then have to do the equivalent of: echo -n 0000:00:1d.0 >unbind echo -n 0000:00:1d.1 >unbind echo -n 0000:00:1d.2 >unbind echo -n 0000:01:01.0 >unbind echo -n 0000:01:01.1 >unbind Then do the same thing for /sys/bus/usb/devices/usb2/../driver, and so on, until no more of these directories are left. Alan Stern ------------------------------------------------------------------------- SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ [email protected] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel