1 | <sect2>
|
---|
2 | <title>Configuring <application>libusb</application></title>
|
---|
3 |
|
---|
4 | <!-- To be reviewed when hotplug enters the LFS book -->
|
---|
5 |
|
---|
6 | <para>libusb requires the usbfs kernel filesystem to be mounted on
|
---|
7 | <filename class="directory">/proc/bus/usb</filename>. Applications
|
---|
8 | require the files in this directory to be accessible to the user,
|
---|
9 | sometimes for both reading and writing.</para>
|
---|
10 |
|
---|
11 | <para>To restrict access to <acronym>USB</acronym> devices, create the
|
---|
12 | usb group:</para>
|
---|
13 |
|
---|
14 | <screen><userinput><command>groupadd -g 15 usb</command></userinput></screen>
|
---|
15 |
|
---|
16 | <para>To get usbfs mounted on boot, we will create a special init script,
|
---|
17 | because just putting an extra line into
|
---|
18 | <filename>/etc/fstab</filename> does not work for those who compiled
|
---|
19 | "USB device filesystem" as a kernel module. To do this,
|
---|
20 | execute the following command:</para>
|
---|
21 |
|
---|
22 | <screen><userinput><command>cat >/etc/rc.d/init.d/usb <<"EOF"</command>
|
---|
23 | #!/bin/sh
|
---|
24 | # Begin $rc_base/init.d/usb
|
---|
25 |
|
---|
26 | . /etc/sysconfig/rc
|
---|
27 | . $rc_functions
|
---|
28 |
|
---|
29 | modprobe usbcore 2>/dev/null || true
|
---|
30 | # insert a modprobe command for your USB host adapter here, e.g.
|
---|
31 | # modprobe ehci-hcd 2>/dev/null
|
---|
32 | # Other host adapters are uhci-hcd and ohci-hcd
|
---|
33 | # 2.4.x kernels have usb-ehci, usb-uhci, and usb-ohci modules
|
---|
34 | if ( grep -q usbfs /proc/filesystems )
|
---|
35 | then
|
---|
36 | echo "Mounting USB filesystem"
|
---|
37 | mount -o devgid=15,devmode=0660 -t usbfs usbfs /proc/bus/usb
|
---|
38 | evaluate_retval
|
---|
39 | fi
|
---|
40 | # End $rc_base/init.d/usb
|
---|
41 | <command>EOF</command></userinput></screen>
|
---|
42 |
|
---|
43 | <para>Give this script the appropriate permissions and
|
---|
44 | make a symlink to run it at startup:</para>
|
---|
45 | <screen><userinput><command>chmod 755 /etc/rc.d/init.d/usb &&
|
---|
46 | ln -s ../init.d/usb /etc/rc.d/rcsysinit.d/S90usb</command></userinput></screen>
|
---|
47 |
|
---|
48 | </sect2>
|
---|