Folks,
Thanks very much to all who helped with this. The key hints were from
Guy Jennings about the case sensitivity of the udev rule for the
vendorID, and from Lewis Muir about setting the USB_DEVFS_PATH
environment variable.
Once I fixed the case-sensitivity problem udev was doing what it was
supposed to do, setting the permissions to 666 on the USB device, for
example /dev/bus/usb/005/021. However, this was not having the desired
affect because on some Linux kernels libusb uses /proc/bus/usb rather
than /dev/bus/usb by default. However, this default can be overridden
with the USB_DEVFS_PATH environment variable. Setting USB_DEVFS_PATH to
/dev/bus/usb forces libusb to use the /dev/bus/usb, and then the
permissions set by udev have the desired affect and my EPICS IOC runs
without root privilege.
This is from the help page I just wrote for the USB device (XIA Saturn
module)
http://cars9.uchicago.edu/software/epics/dxpDoc.html#Installing%20the%20
Saturn%20on%20Linux:
******************************************************************
USB devices on Linux are automatically created with read-only permission
for non-root users by default. In order to run the dxpApp application
without root privilege it is necessary to change the device permissions.
Because these devices are created dynamically when the Saturn is
connected, this cannot just be done once statically. Rather it requires
using the "udev" utility on Linux to have the device permissions set
correctly each time the Saturn connects.
Here is a recipe for doing this.
Create a file in /etc/udev/rules.d called, for example,
"80-saturn.rules". Put the following 2 lines in this file.
SUBSYSTEM=="usb_device",ACTION=="add",SYSFS{idVendor}=="10e9",SYSFS{idPr
oduct}=="0700",MODE="0666"
SUBSYSTEM=="usb_device",ACTION=="add",SYSFS{idVendor}=="10e9",SYSFS{idPr
oduct}=="0701",MODE="0666"
These rules instruct the udev facility to set the permissions on the USB
device to 666 (owner, group and world read/write) for the Saturn
whenever it is added to the system. 10e9 is the vendor ID for the
Saturn, and 0700 and 0701 are the product IDs for the USB 1.1 and USB
2.0 versions of the Saturn. Note that the 10e9 ID is case sensitive!
Force the udevd daemon to reload its rules:
$ /sbin/udevcontrol reload_rules
These changes for udev should cause the Saturn USB device to have the
correct permissions:
baja:/etc/udev/rules.d>ls -lt /dev/bus/usb/005/021
crw-rw-rw- 1 root root 189, 532 2008-01-07 16:08
/dev/bus/usb/005/021
However, on some Linux versions libusb uses /proc/bus/usb by default,
rather than /dev/bus/usb, so the permissions set by udev will not have
the desired affect. This can be fixed by defining the environment
variable USB_DEVFS_PATH to be /dev/bus/usb. In fact I now add the
following command to the EPICS IOC startup script (st.cmd) on Linux when
using USB, just before the xiaInit command:
# On Linux execute the following command so that libusb uses
/dev/bus/usb
# as the file system for the USB device.
# On some Linux systems it uses /proc/bus/usb instead, but udev
# sets the permissions on /dev, not /proc.
epicsEnvSet USB_DEVFS_PATH /dev/bus/usb
This could obviously be done in the shell startup script instead if
desired.
********************************************************************
Mark
> -----Original Message-----
> From: J. Lewis Muir [mailto:[email protected]]
> Sent: Wednesday, January 02, 2008 10:23 AM
> To: [email protected]
> Cc: Mark Rivers; [email protected]; Denison, PN (Peter);
> [email protected]; Scott D. Davilla
> Subject: Re: Help with udev
>
> On 12/21/07 2:15 PM, Mark Rivers wrote:
> > That is the good news. The bad news is that setting the permissions
> > on that device, /dev/bus/usb/005/018 does not allow a
> non-privileged
> > user to access the device. In order for a non-privileged use to
> > access the device, I find that I need to set the permissions to 666
> > on /proc/bus/usb/005/018 i.e. the /proc filesystem, not the /dev
> > filesystem. If I change the permissions on the /proc filesystem
> > manually then I can run the IOC in a non-privileged account.
> >
> > I am not a Linux expert by any means. What is the
> difference between
> > the /dev and /proc filesystems? Peter also mentioned the /sys file
> > system. How is that related?
> >
> > I am using the libusb library to access the device. With
> that API one
> > simply calls usb_find_busses and usb_find_devices to
> locate the device
> > you are interested in. You don't specify the file system anywhere.
> >
> > Any ideas how to get the permissions I need set on the device?
> >
> > Thanks, Mark
>
> Hi, Mark.
>
> Maybe the libusb library is using /proc/bus/usb as the virtual file
> system instead of /dev/bus/usb. What happens if you set the
> USB_DEVFS_PATH environment variable to "/dev/bus/usb" in the process
> environment of your IOC?
>
> -lewis
>
- References:
- Re: Help with udev J. Lewis Muir
- Navigate by Date:
- Prev:
Re: edm troubles John Sinclair
- Next:
Alarm Handler on 64-bit Peter Medvescek
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
<2008>
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: Help with udev Emmanuel Mayssat
- Next:
RE: Ca error Jeff Hill
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
<2008>
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|