# [Permisos/grupos]Problemas con el USB,gtkam, gnomad(abierto)

## Sertinell

hola:

os describo el problema, no puedo acceder a la camara como usuario con gtkam ( mi camara no funciona con usb-storage) ni puedo acceder a mi mp3 Zen micro. En a,mbos casos funciona sin ningun problema como root, os dejo todos los datos qe pueden ser necesarios:

Reglas de udev:

```
# cat /etc/udev/rules.d/50-udev.rules

# /etc/udev/udev.rules:  device naming rules for udev

#

# Gentoo specific rules, based a bit on devfs rules, but much simpler.

#

# There are a number of modifiers that are allowed to be used in some of the

# fields.  See the udev man page for a full description of them.

###########################################################

#

# For devfs similar /dev layout (neater)

#

###########################################################

# all block devices

SUBSYSTEM="block", GROUP="disk"

# cdrom symlinks and other good cdrom naming

BUS="ide",  KERNEL="hd[a-z]", PROGRAM="/etc/udev/scripts/cdsymlinks.sh %k", SYMLINK="%c{1} %c{2} %c{3} %c{4} %c{5} %c{6}"

BUS="scsi", KERNEL="sr[0-9]*", PROGRAM="/etc/udev/scripts/cdsymlinks.sh %k", SYMLINK="%c{1} %c{2} %c{3} %c{4} %c{5} %c{6}"

BUS="scsi", KERNEL="scd[a-z]", PROGRAM="/etc/udev/scripts/cdsymlinks.sh %k", SYMLINK="%c{1} %c{2} %c{3} %c{4} %c{5} %c{6}"

# devfs-names for ide-devices (uncomment only one)

#  /dev/ide/.../{disc,cd} and /dev/{cdroms,discs}/* type names

BUS="ide", KERNEL="hd*", PROGRAM="/etc/udev/scripts/ide-devfs.sh %k %b %n", NAME="%k", SYMLINK="%c{1} %c{2}", GROUP="%c{3}"

# disk devices

KERNEL="sd*",           NAME="%k", GROUP="disk"

KERNEL="dasd*",         NAME="%k", GROUP="disk"

KERNEL="ataraid*",      NAME="%k", GROUP="disk"

# dri devices

KERNEL="card*",         NAME="dri/card%n", GROUP="video"

KERNEL="nvidia*",       NAME="%k", GROUP="video"

KERNEL="3dfx*",         NAME="%k", GROUP="video"

# alsa devices

SUBSYSTEM="sound", GROUP="audio"

KERNEL="controlC[0-9]*",        NAME="snd/%k"

KERNEL="hw[CD0-9]*",            NAME="snd/%k"

KERNEL="pcm[CD0-9cp]*",         NAME="snd/%k"

KERNEL="midiC[D0-9]*",          NAME="snd/%k"

KERNEL="timer",                 NAME="snd/%k"

KERNEL="seq",                   NAME="snd/%k"

# capi devices

KERNEL="capi",          NAME="capi20", SYMLINK="isdn/capi20"

KERNEL="capi*",         NAME="capi/%n"

# cpu devices

KERNEL="cpu[0-9]*",     NAME="cpu/%n/cpuid"

KERNEL="msr[0-9]*",     NAME="cpu/%n/msr"

KERNEL="microcode",     NAME="cpu/microcode"

# dm devices (ignore them)

KERNEL="dm-[0-9]*",     NAME=""

# create a symlink named after the device map name

# note devmap_name comes with extras/multipath

#KERNEL="dm-[0-9]*",    PROGRAM="/sbin/devmap_name %M %m", NAME="%k", SYMLINK="%c"

KERNEL="device-mapper", NAME="mapper/control"

# fb devices

KERNEL="fb[0-9]*",      NAME="fb/%n", SYMLINK="%k", GROUP="video", MODE="0600"

# floppy devices

KERNEL="fd[0-9]*",      NAME="floppy/%n", SYMLINK="%k", GROUP="floppy"

# i2c devices

KERNEL="i2c-[0-9]*",    NAME="i2c/%n", SYMLINK="%k"

# input devices

KERNEL="mice",          NAME="input/%k", MODE="0644"

KERNEL="mouse*",        NAME="input/%k", MODE="0644"

KERNEL="event*",        NAME="input/%k", MODE="0600"

KERNEL="js*",           NAME="input/%k", MODE="664"

KERNEL="ts*",           NAME="input/%k", MODE="0600"

# loop devices

KERNEL="loop[0-9]*",    NAME="loop/%n", SYMLINK="%k", GROUP="disk"

# md block devices

KERNEL="md[0-9]*",      NAME="md/%n", SYMLINK="%k", GROUP="disk"

# aoe char devices,

SUBSYSTEM="aoe", KERNEL="discover",     NAME="etherd/%k", GROUP="disk", MODE="0220"

SUBSYSTEM="aoe", KERNEL="err",          NAME="etherd/%k", GROUP="disk", MODE="0440"

SUBSYSTEM="aoe", KERNEL="interfaces",   NAME="etherd/%k", GROUP="disk", MODE="0220"

# misc devices

KERNEL="agpgart",       NAME="misc/%k", SYMLINK="%k"

KERNEL="psaux",         NAME="misc/%k", SYMLINK="%k"

KERNEL="rtc",           NAME="misc/%k", SYMLINK="%k", MODE="0664"

KERNEL="uinput",        NAME="misc/%k", SYMLINK="%k"

KERNEL="inotify",       NAME="misc/%k", SYMLINK="%k", MODE="0666"

# netlink devices

KERNEL="route",         NAME="netlink/%k"

KERNEL="skip",          NAME="netlink/%k"

KERNEL="usersock",      NAME="netlink/%k"

KERNEL="fwmonitor",     NAME="netlink/%k"

KERNEL="tcpdiag",       NAME="netlink/%k"

KERNEL="nflog",         NAME="netlink/%k"

KERNEL="xfrm",          NAME="netlink/%k"

KERNEL="arpd",          NAME="netlink/%k"

KERNEL="route6",        NAME="netlink/%k"

KERNEL="ip6_fw",        NAME="netlink/%k"

KERNEL="dnrtmsg",       NAME="netlink/%k"

KERNEL="tap*",          NAME="netlink/%k"

# network devices

KERNEL="tun",           NAME="net/%k"

# ramdisk devices

KERNEL="ram[0-9]*",     NAME="rd/%n", SYMLINK="%k"

# raw devices

KERNEL="raw[0-9]*",     NAME="raw/%k", GROUP="disk"

KERNEL="ram*",          NAME="%k", GROUP="disk"

# sound devices

KERNEL="adsp",                  NAME="sound/%k", SYMLINK="%k", GROUP="audio"

KERNEL="adsp[0-9]*",            NAME="sound/%k", SYMLINK="%k", GROUP="audio"

KERNEL="audio",                 NAME="sound/%k", SYMLINK="%k", GROUP="audio"

KERNEL="audio[0-9]*",           NAME="sound/%k", SYMLINK="%k", GROUP="audio"

KERNEL="dsp",                   NAME="sound/%k", SYMLINK="%k", GROUP="audio"

KERNEL="dsp[0-9]*",             NAME="sound/%k", SYMLINK="%k", GROUP="audio"

KERNEL="mixer",                 NAME="sound/%k", SYMLINK="%k", GROUP="audio"

KERNEL="mixer[0-9]*",           NAME="sound/%k", SYMLINK="%k", GROUP="audio"

KERNEL="sequencer",             NAME="sound/%k", SYMLINK="%k", GROUP="audio"

KERNEL="sequencer[0-9]*",       NAME="sound/%k", SYMLINK="%k", GROUP="audio"

# tty devices

KERNEL="console",       NAME="%k", GROUP="tty", MODE="0600"

KERNEL="tty",           NAME="%k", GROUP="tty", MODE="0666"

KERNEL="tty[0-9]*",     NAME="vc/%n",  SYMLINK="%k", GROUP="tty"

KERNEL="ttyS[0-9]*",    NAME="tts/%n", SYMLINK="%k", GROUP="tty"

KERNEL="ttyUSB[0-9]*",  NAME="tts/USB%n", GROUP="tty", MODE="0600"

KERNEL="ippp0",         NAME="%k", GROUP="tty"

KERNEL="isdn*",         NAME="%k", GROUP="tty"

KERNEL="dcbri*",        NAME="%k", GROUP="tty"

KERNEL="ircomm*",       NAME="%k", GROUP="tty"

# pty devices

KERNEL="ptmx",                  NAME="%k", GROUP="tty", MODE="0666"

KERNEL="pty[p-za-e][0-9a-f]*",  NAME="pty/m%n", SYMLINK="%k", GROUP="tty"

KERNEL="tty[p-za-e][0-9a-f]*",  NAME="pty/s%n", SYMLINK="%k", GROUP="tty"

# vc devices

KERNEL="vcs",           NAME="vcc/0",   SYMLINK="%k", GROUP="tty"

KERNEL="vcs[0-9]*",     NAME="vcc/%n",  SYMLINK="%k", GROUP="tty"

KERNEL="vcsa",          NAME="vcc/a0",  SYMLINK="%k", GROUP="tty"

KERNEL="vcsa[0-9]*",    NAME="vcc/a%n", SYMLINK="%k", GROUP="tty"

# memory devices

KERNEL="random",        NAME="%k", MODE="0666"

KERNEL="urandom",       NAME="%k", MODE="0444"

KERNEL="mem",           NAME="%k", MODE="0640"

KERNEL="kmem",          NAME="%k", MODE="0640"

KERNEL="port",          NAME="%k", MODE="0640"

KERNEL="full",          NAME="%k", MODE="0666"

KERNEL="null",          NAME="%k", MODE="0666"

KERNEL="zero",          NAME="%k", MODE="0666"

# usb devices

KERNEL="hiddev*",               NAME="usb/%k"

KERNEL="auer*",                 NAME="usb/%k"

KERNEL="legousbtower*",         NAME="usb/%k", GROUP="usb"

KERNEL="dabusb*",               NAME="usb/%k"

BUS="usb", KERNEL="lp[0-9]*",   NAME="usb/%k", GROUP="lp"

# v4l devices

KERNEL="video[0-9]*",   NAME="v4l/video%n", SYMLINK="video%n", GROUP="video"

KERNEL="radio[0-9]*",   NAME="v4l/radio%n", GROUP="video"

KERNEL="vbi[0-9]*",     NAME="v4l/vbi%n", SYMLINK="vbi%n", GROUP="video"

KERNEL="vtx[0-9]*",     NAME="v4l/vtx%n", GROUP="video"

# dvb devices

KERNEL="dvb*", PROGRAM="/etc/udev/scripts/dvb.sh %k", NAME="%c", GROUP="video", MODE="0660"

# Asterix Zaptel devices

KERNEL="zapctl",        NAME="zap/ctl"

KERNEL="zaptimer",      NAME="zap/timer"

KERNEL="zapchannel",    NAME="zap/channel"

KERNEL="zappseudo",     NAME="zap/pseudo"

KERNEL="zap[0-9]*",     NAME="zap/%n"

# pilot/palm devices

KERNEL="pilot",         NAME="%k", GROUP="uucp"

# jaz devices

KERNEL="jaz*",          NAME="%k", GROUP="disk"

# zip devices

KERNEL="pocketzip*",    NAME="%k", GROUP="disk"

KERNEL="zip*",          NAME="%k", GROUP="disk"

# ls120 devices

KERNEL="ls120",         NAME="%k", GROUP="disk"

# lp devices

KERNEL="lp*",           NAME="%k", GROUP="lp"

KERNEL="irlpt",         NAME="%k", GROUP="lp"

KERNEL="usblp",         NAME="%k", GROUP="lp"

KERNEL="lp*",           NAME="%k", GROUP="lp"

# tape devices

KERNEL="ht*",           NAME="%k", GROUP="tape"

KERNEL="nht*",          NAME="%k", GROUP="tape"

KERNEL="pt*",           NAME="%k", GROUP="tape"

KERNEL="npt*",          NAME="%k", GROUP="tape"

KERNEL="st*",           NAME="%k", GROUP="tape"

KERNEL="nst*",          NAME="%k", GROUP="tape"

KERNEL="osst*",         NAME="%k", GROUP="tape"

KERNEL="nosst*",        NAME="%k", GROUP="tape"

# diskonkey devices

KERNEL="diskonkey*",    NAME="%k", GROUP="disk"

# rem_ide devices

KERNEL="microdrive*",   NAME="%k", GROUP="disk"

# kbd devices

KERNEL="kbd",           NAME="%k", MODE="0664"

# Sony Vaio Jogdial sonypi device

KERNEL="sonypi",        NAME="%k", MODE="0666"

# packet devices

KERNEL="pktcdvd",       NAME="pktcdvd/control", GROUP="cdrw", MODE="0660"

KERNEL="pktcdvd[0-9]*", NAME="pktcdvd/pktcdvd%n", GROUP="cdrw", MODE="0660"

# infiniband devices

KERNEL="umad*", NAME="infiniband/%k"

KERNEL="issm*", NAME="infiniband/%k"

```

mi /etc/group

```
# cat /etc/group

root:x:0:root

bin:x:1:root,bin,daemon

daemon:x:2:root,bin,daemon

sys:x:3:root,bin,adm

adm:x:4:root,adm,daemon

tty:x:5:

disk:x:6:root,adm

lp:x:7:lp

mem:x:8:

kmem:x:9:

wheel:x:10:root,sergio

floppy:x:11:root

mail:x:12:mail

news:x:13:news

uucp:x:14:uucp

man:x:15:man

cron:x:16:cron

console:x:17:

audio:x:18:sergio

cdrom:x:19:users,sergio

dialout:x:20:root

ftp:x:21:

sshd:x:22:

at:x:25:at

tape:x:26:root

video:x:27:root

squid:x:31:squid

gdm:x:32:gdm

xfs:x:33:xfs

games:x:35:sergio,users

named:x:40:named

mysql:x:60:

postgres:x:70:

cdrw:x:80:users,sergio

apache:x:81:

nut:x:84:

usb:x:85:sergio

vpopmail:x:89:

users:x:100:games,sergio

nofiles:x:200:

qmail:x:201:

postfix:x:207:

postdrop:x:208:

smmsp:x:209:smmsp

slocate:x:245:

portage:x:250:portage

utmp:x:406:

nogroup:x:65533:

nobody:x:65534:

rpc:x:111:

proftpd:x:407:

messagebus:x:408:

haldaemon:x:409:

```

dmesg cuando conecto una de las 2 cosas

```
usb 1-2: new full speed USB device using uhci_hcd and address N
```

N va subiendo segun los vaya conectando ...

en mi /dev no veo nada qe tenga qe ver con algo parecido al usb

Si es necesario algun archivo mas decidmelo por favor,

Gracias

----------

## Sertinell

os suelto lo qe se qeja gphoto2, de forma prograsiva, hasta qe falla  :Sad: 

```
$ gphoto2 --list-ports

Dispositivos encontrados: 1

Ruta                             Descripción

--------------------------------------------------------------

usb:                             Universal Serial Bus

sergio@gentoo ~ $ gphoto2 --auto-detect

Modelo                         Puerto

----------------------------------------------------------

sergio@gentoo ~ $ gphoto2 --auto-detect

Modelo                         Puerto

----------------------------------------------------------

Kodak CX6330                   usb:

sergio@gentoo ~ $ gphoto2 --summary

*** Error ***

Se ha producido un error en la biblioteca de entrada-salida ('No se pudo reclamar el dispositivo USB'): Could not claim interface 0 (Operación no permitida). Make sure no other program or kernel module (such as sdc2xx, stv680, spca50x) is using the device and you have read/write access to the device.

*** Error (-53: «No se pudo reclamar el dispositivo USB») ***

Por favor, utilice la opción --debug para obtener los mensajes de depuración.

Estos mensajes pueden ayudar a encontrar una solución a su problema.

Si piensa enviar cualquier mensaje de error o de depuración a la lista

de distribución de desarrolladores de gPhoto <gphoto-devel@lists.sourceforge.net>,

por favor ejecute gphoto2 como sigue:

    env LANG=C gphoto2 --debug --summary

Please make sure there is sufficient quoting around the arguments.

```

Si lo hago ocmo root todo va bien

```
gentoo ~ # gphoto2 --summary

Camera summary:

Model: CX6330 Zoom Digital Camera

  device version: 01.0300

  serial number:  KCKCL35104202

Vendor extension ID: 0x00000001

Vendor extension description: Eastman Kodak PTP Extensions

Battery Level(0x5001):(read only) (type=0x2) Enumeration [0,10,100] value: 10

Date Time(0x5011):(readwrite) (type=0xffff) '20050305T233629'

UI Language(0xd006):(read only) (type=0x4) Enumeration [1,3,4,5,6,7,8] value: 5

Property 0xd007:(read only) (type=0x4) Enumeration [1,2] value: 1

Property 0xd008:(read only) (type=0x4) Range [5 - 60, step 1] value: 5

Property 0xd009:(read only) (type=0x4) Enumeration [1,2] value: 1

```

Alguna idea ?¿

----------

## Sertinell

Empiezo a pensar q puede se cosa de hotplug:

```
# cat /etc/hotplug/usb/usbcam

#!/bin/bash

# $Id: usbcam.console,v 1.4 2002/09/12 16:50:18 hun Exp $

#

# /etc/hotplug/usb/usbcam

#

# Sets up newly plugged in USB camera so that the user who owns

# the console according to pam_console can access it from user space

#

# Note that for this script to work, you'll need all of the following:

# a) a line in the file /etc/hotplug/usermap that corresponds to the

#    camera you are using. You can get the correct lines for all cameras

#    supported by libgphoto2 by running "print-usb-usermap".

# b) a setup using pam_console creates the respective lock files

#    containing the name of the respective user. You can check for that

#    by executing "echo `cat /var/{run,lock}/console.lock`" and

#    verifying the appropriate user is mentioned somewhere there.

# c) a Linux kernel supporting hotplug and usbdevfs

# d) the hotplug package (http://linux-hotplug.sourceforge.net/)

#

# In the usermap file, the first field "usb module" should be named

# "usbcam" like this script.

#

if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]

then

    # New code, using lock files instead of copying /dev/console permissions

    # This also works with non-gdm logins (e.g. on a virtual terminal)

    # Idea and code from Nalin Dahyabhai <nalin@redhat.com>

    if [ -f /var/run/console.lock ]

    then

        CONSOLEOWNER=`cat /var/run/console.lock`

    elif [ -f /var/lock/console.lock ]

    then

        CONSOLEOWNER=`cat /var/lock/console.lock`

    else

        CONSOLEOWNER=

    fi

    if [ -n "$CONSOLEOWNER" ]

    then

        chmod 0000 "${DEVICE}"

        chown "$CONSOLEOWNER" "${DEVICE}"

        chmod 0600 "${DEVICE}"

    fi

fi

```

```
# cat /etc/hotplug/usb/nomadjukebox

#!/bin/sh

# Lifts a plugged in nomad jukebox to user space and

# optionally runs a client program.

# Written by Linus Walleij 2004, based on the "usbcam"

# script by Nalin Dahyabhai.

DEVICEOWNER=CONSOLE

DEVICEPERMS=0600

PROGRAM="cd ~; gnomad2 --display=localhost:0"

if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]

then

    # New code, using lock files instead of copying /dev/console permissions

    # This also works with non-gdm logins (e.g. on a virtual terminal)

    # Idea and code from Nalin Dahyabhai <nalin@redhat.com>

    if [ "x$DEVICEOWNER" = "xCONSOLE" ]

    then

        if [ -f /var/run/console.lock ]

        then

            DEVICEOWNER=`cat /var/run/console.lock`

        elif [ -f /var/lock/console.lock ]

        then

            DEVICEOWNER=`cat /var/lock/console.lock`

        else

            DEVICEOWNER=

        fi

    fi

    if [ -n "$DEVICEOWNER" ]

    then

        chmod 0000 "${DEVICE}"

        chown "${DEVICEOWNER}" "${DEVICE}"

        chmod "${DEVICEPERMS}" "${DEVICE}"

        # Then run an optional program - this does not work yet.

        # su "${CONSOLEOWNER}" -c "${PROGRAM}"

    fi

fi

```

```
# cat /etc/hotplug/usb.usermap

# usb module         match_flags idVendor idProduct bcdDevice_lo bcdDevice_hi bDeviceClass bDeviceSubClass bDeviceProtocol bInterfaceClass bInterfaceSubClass bInterfaceProtocol driver_info

# Creative Nomad Jukebox

nomadjukebox    0x0000  0x0471  0x0222  0x0000  0x0000  0x00    0x00    0x00   0x00     0x00    0x00    0x00000000

# Creative Nomad Jukebox 2

nomadjukebox    0x0000  0x041e  0x4100  0x0000  0x0000  0x00    0x00    0x00   0x00     0x00    0x00    0x00000000

# Creative Nomad Jukebox 3

nomadjukebox    0x0000  0x041e  0x4101  0x0000  0x0000  0x00    0x00    0x00   0x00     0x00    0x00    0x00000000

# Creative Nomad Jukebox Zen

nomadjukebox    0x0000  0x041e  0x4108  0x0000  0x0000  0x00    0x00    0x00   0x00     0x00    0x00    0x00000000

# Creative Nomad Jukebox Zen USB 2.0

nomadjukebox    0x0000  0x041e  0x410b  0x0000  0x0000  0x00    0x00    0x00   0x00     0x00    0x00    0x00000000

# Creative Nomad Jukebox Zen NX

nomadjukebox    0x0000  0x041e  0x4109  0x0000  0x0000  0x00    0x00    0x00   0x00     0x00    0x00    0x00000000

# Creative Nomad Jukebox Zen Xtra

nomadjukebox    0x0000  0x041e  0x4110  0x0000  0x0000  0x00    0x00    0x00   0x00     0x00    0x00    0x00000000

# Dell Digital Jukebox

nomadjukebox    0x0000  0x041e  0x4111  0x0000  0x0000  0x00    0x00    0x00   0x00     0x00    0x00    0x00000000

# Creative Nomad Jukebox Zen Touch

nomadjukebox    0x0000  0x041e  0x411b  0x0000  0x0000  0x00    0x00    0x00   0x00     0x00    0x00    0x00000000

# Creative Nomad Jukebox Zen Micro

nomadjukebox    0x0000  0x041e  0x411e  0x0000  0x0000  0x00    0x00    0x00   0x00     0x00    0x00    0x00000000

# Second Generation Dell Digital Jukebox

nomadjukebox    0x0000  0x041e  0x4126  0x0000  0x0000  0x00    0x00    0x00   0x00     0x00    0x00    0x00000000

# Dell Pocket DJ

nomadjukebox    0x0000  0x041e  0x4127  0x0000  0x0000  0x00    0x00    0x00   0x00     0x00    0x00    0x00000000

```

```
# cat /etc/hotplug/usb.rc

#!/bin/sh

# vim: syntax=sh

#

# usb.rc        This brings the USB subsystem up and down safely.

#

# $Id: usb.rc,v 1.28 2004/09/20 22:30:35 kroah Exp $

#

# Best invoked via /etc/init.d/hotplug or equivalent, with

# writable /tmp, /usr mounted, and syslogging active.

#

# Bus management is basically unrelated to runlevel changes; it

# relates to physical topology, including possibly hotpluggable

# busses (USB, Cardbus) or controllers.  If a bus is physically

# present, it should normally be available.

#

# USB-dependant systems (iMacs, "legacy free" x86 systems, and so on)

# should statically link USB keyboard support into the kernel (USB core,

# EHCI/OHCI/UHCI/..., hid, input, keybdev; and likely mousedev) so the

# system console can't be removed by accident.

PATH=/sbin:/bin:/usr/sbin:/usr/bin

unset I_WANT_A_BROKEN_PS

PS_PERSONALITY=linux

STATIC_MODULE_LIST=

X11_USBMICE_HACK=false

# override any of the defaults above?

if [ -f /etc/sysconfig/usb ]; then

    . /etc/sysconfig/usb

fi

if [ -f /etc/conf.d/usb ]; then

    . /etc/conf.d/usb

fi

MOUSE_MODULES="mousedev input"

# In its currently-recommended configuration, XFree86 3.3.6 always opens

# /dev/input/mice; so mousedev and input must be loaded before X11 starts.

if [ $X11_USBMICE_HACK = true ]; then

    STATIC_MODULE_LIST="$MOUSE_MODULES $STATIC_MODULE_LIST"

fi

#

# "COLD PLUG" ... recovery from partial USB init that may have happened

# before the OS could really handle hotplug, perhaps because /sbin or

# $HOTPLUG_DIR wasn't available or /tmp wasn't writable.  When/if the

# /sbin/hotplug program is invoked then, hotplug event notifications

# get dropped.  To make up for such "cold boot" errors, we synthesize

# all the hotplug events we expect to have seen already.  They can be

# out of order, and some might be duplicates.

#

# Note that on 2.5 the init filesystem may have loaded some of the more

# essential usb drivers (maybe usb-storage for a boot disk, and hid),

# but we may still need to load less important ones or invoke setup

# scripts that couldn't run earlier.

#

usb_boot_events ()

{

        #

        # FIXME on 2.5, /sys/bus/usb/devices/* gives all of the

        # info we need.  Interface hotplug events come from the

        # "*:*" files, and device events (do them first) come

        # from the others.

        #

        # don't expect usbmodules to exist!!  and remove the

        # dependency (below) on usbfs to decide whether we should

        # be synthesizing coldplug events.

        #

        # synthesize hotplug events if we can

        # make sure the usb agent will run

        ACTION=add

        PRODUCT=0/0/0

        TYPE=

        INTERFACE=

        DEVPATH=

        DEVFS=/proc/bus/usb

        DEVICE=

        export ACTION PRODUCT TYPE INTERFACE DEVPATH DEVFS DEVICE

        if [ -d /sys/bus ]; then

            if [ -d /sys/bus/usb/devices ]; then

                cd /sys/bus/usb/devices

                for device in /sys/bus/usb/devices/[0-9]*; do

                    devlink=$( readlink -f $device )

                    DEVPATH=${devlink#/sys}

                    if [ -f $devlink/../idVendor ]; then

                        PRODUCT="$(cat $devlink/../idVendor)/$(cat $devlink/../idProduct)/$(cat $devlink/../bcdDevice)"

                        if [ -f $devlink/../../devnum ]

                        then

                            devbus=$( ( echo -n 000 ; cat $devlink/../../devnum ) | grep -o ...\$ )

                            devdev=$( ( echo -n 000 ; cat $devlink/../devnum ) | grep -o ...\$ )

                            DEVICE="/proc/bus/usb/$devbus/$devdev"

                        else

                            DEVICE=

                        fi

                        /etc/hotplug/usb.agent

                    fi

                done

            fi

        else

            # we need (non-bash) programs to parse descriptors.

            LISTER=`which usbmodules`

            if [ "$LISTER" = "" ] || [ ! -f /proc/bus/usb/devices ]; then

                echo $"** can't synthesize root hub events"

                return

            fi

            for DEVICE in /proc/bus/usb/*/*; do

                /etc/hotplug/usb.agent

            done

        fi

}

maybe_start_usb ()

{

    COUNT=0

    # if USB is partially initted then synthesize "cold plug" events. the

    # kernel probably dropped many "hot plug" events, and those it didn't

    # drop likely couldn't trigger all the setup actions (kicking daemons,

    # dropping config records, and so on).

    # if it's not initted at all (no hcds loaded) no synthesized events

    # will be needed, we'll see real ones.  knowing that there are no

    # hcds available through version-portable logic is a nightmare, so

    # assume we synthesize unless "usbfs" is clearly not initted (which

    # we currently need when synthesizing, anyway).

    SYNTHESIZE=true

    if [ ! -d /proc/bus/usb ]; then

        SYNTHESIZE=false

    fi

    # if distro hasn't already done part of this ... load core,

    # and mount usbfs before the first hotplug agent fires

    # (so it'll be available to the agents).

    modprobe -q usbcore >/dev/null 2>&1

    if [ -d /proc/bus/usb ]; then

        # if it's not mounted, try to mount it

        if [ -z "`grep " /proc/bus/usb " /proc/mounts`" ]; then

            if grep -q -E "^[^#][^[:space:]]+[[:space:]]+/proc/bus/usb/?[[:space:]]" /etc/fstab; then

                mount /proc/bus/usb

            else

                if grep -q usbfs /proc/filesystems; then

                    mount -t usbfs usbfs /proc/bus/usb

                else

                    mount -t usbdevfs usbdevfs /proc/bus/usb

                fi

            fi

        fi

    fi

    # Load Host Controller Drivers (HCDs) ... this automatically handles

    # systems with multiple controllers (EHCI, OHCI, UHCI) without needing

    # /proc or tools (lspci -v|grep USB, etc) to do so.  If hotplugging

    # is enabled on this system, initting a root hub will cause hotplug

    # events to fire for every device on the tree at that root.

    # FIXME: some of this should be driven by PCI hotplugging, and have

    # the blacklist control which uhci driver gets used (before 2.5).

    # "new style" HCDs ... more common code

    modprobe -q ehci-hcd >/dev/null 2>&1

    modprobe -q ohci-hcd >/dev/null 2>&1

    modprobe -q uhci-hcd >/dev/null 2>&1

    # "old style" HCDs ... more driver-specific bugs

    modprobe -q usb-ohci >/dev/null 2>&1

    # NOTE: this prefers "uhci"; you may prefer "usb-uhci".

    # modprobe -q usb-uhci >/dev/null 2>&1 || modprobe -q uhci >/dev/null 2>&1

    modprobe -q uhci >/dev/null 2>&1 || modprobe -q usb-uhci >/dev/null 2>&1

    # ... add any non-PCI HCDS here.  Examples include the

    # CRIS usb-host, Philips ISP-1161, Symlogic 811HS, and so on.

    # ohci-hcd can handle some non-pci variants.

    if [ -d /proc/bus/usb ]; then

        # If we see there are no busses, we "failed" and

        # can report so even if we're partially nonmodular.

        #

        # NOTE: this fails on older kernels, where usbdevfs had two files

        # ('devices' and 'drivers') with no hcds registered, but works on

        # newer kernels where usbfs has zero files until hcds register,

        # and might not have the 'drivers' file.

        COUNT=`ls /proc/bus/usb | wc -l`

        if [ $COUNT -lt 2 ]; then

            umount /proc/bus/usb

            rmmod usbcore >/dev/null 2>&1

            return 1

        fi

    # if USB is fully modular and yet can clean up,

    # we know init failed without needing usbfs

    elif rmmod usbcore >/dev/null 2>&1; then

        return 1

    fi

    # hotplug events didn't fire during booting;

    # cope with devices that enumerated earlier

    # and may not have been fully configured.

    if [ $SYNTHESIZE = true ]; then

        sleep 1

        usb_boot_events

    fi

    # Some modules are statically loaded, perhaps because they are

    # needed to activate filesystem device nodes.

    for MODULE in $STATIC_MODULE_LIST; do

        modprobe $MODULE

    done

    # we did everything we could ...

    return 0

}

maybe_stop_usb ()

{

    # call this multiple times if you had to take down components of the

    # USB subsystem by hand; it cleans up whatever can

    # be cleaned up, letting the system quiesce further.

    # NOTE:  this list of "all USB modules" is unfortunate, but it seems

    # inevitable until modutils supports the notion of drivers with use

    # counts of zero that shouldn't be removed until after their device

    # gets removed.  Maybe in 2.5 ... of necessity, the list is partial.

    # disconnect all controllers we can, and kernel drivers

    # HCDs first, so most drivers reduce their use counts.

    rmmod ehci-hcd >/dev/null 2>&1

    rmmod ohci-hcd >/dev/null 2>&1

    rmmod uhci-hcd >/dev/null 2>&1

    rmmod usb-ohci >/dev/null 2>&1

    rmmod usb-uhci >/dev/null 2>&1

    rmmod     uhci >/dev/null 2>&1

    # user mode code may keep usbfs busy for a while yet ...

    # OK, usbcore won't actually be removed unless there happen to be

    # no USB drivers loaded, and usbfs isn't mounted.  let's force

    # removal of autocleanable modules before trying to rmmod usbcore

    rmmod -as

# note: module-init-tools 0.8a doesn't handle "-as" flags

    # Now let's workaround the fact that some USB modules never increase

    # their module use counts, so that "rmmod -a" won't unload them.

    # (And we can't use "modprobe --autoclean" anyway.)

    rmmod acm              >/dev/null 2>&1

    rmmod audio            >/dev/null 2>&1

    rmmod auerswald        >/dev/null 2>&1

    rmmod belkin_sa        >/dev/null 2>&1

    rmmod bluetooth        >/dev/null 2>&1

    rmmod catc             >/dev/null 2>&1

    rmmod CDCEther         >/dev/null 2>&1

    rmmod cpia_usb         >/dev/null 2>&1

    rmmod cyberjack        >/dev/null 2>&1

    rmmod dabusb           >/dev/null 2>&1

    rmmod dc2xx            >/dev/null 2>&1

    rmmod digi_acceleport  >/dev/null 2>&1

    rmmod dsbr100          >/dev/null 2>&1

    rmmod emi26            >/dev/null 2>&1

    rmmod empeg            >/dev/null 2>&1

    rmmod ftdi_sio         >/dev/null 2>&1

    rmmod hci_usb          >/dev/null 2>&1

    rmmod hid              >/dev/null 2>&1

    rmmod hpusbscsi        >/dev/null 2>&1

    rmmod ibmcam           >/dev/null 2>&1

    rmmod iforce           >/dev/null 2>&1

    rmmod io_edgeport      >/dev/null 2>&1

    rmmod ipaq             >/dev/null 2>&1

    rmmod ir-usb           >/dev/null 2>&1

    rmmod irda-usb         >/dev/null 2>&1

    rmmod kaweth           >/dev/null 2>&1

    rmmod keyspan          >/dev/null 2>&1

    rmmod keyspan_pda      >/dev/null 2>&1

    rmmod kl5kusb105       >/dev/null 2>&1

    rmmod mct_u232         >/dev/null 2>&1

    rmmod mdc800           >/dev/null 2>&1

    rmmod microtek         >/dev/null 2>&1

    rmmod omninet          >/dev/null 2>&1

    rmmod ov511            >/dev/null 2>&1

    rmmod pegasus          >/dev/null 2>&1

    rmmod pl2303           >/dev/null 2>&1

    rmmod printer          >/dev/null 2>&1

    rmmod pwc pwcx         >/dev/null 2>&1

    rmmod rio500           >/dev/null 2>&1

    rmmod rtl8150          >/dev/null 2>&1

    rmmod scanner          >/dev/null 2>&1

    rmmod se401            >/dev/null 2>&1

    rmmod stv680           >/dev/null 2>&1

    rmmod usbhid           >/dev/null 2>&1

    rmmod usbkbd           >/dev/null 2>&1

    rmmod usbmouse         >/dev/null 2>&1

    rmmod usbnet           >/dev/null 2>&1

    rmmod usbtest          >/dev/null 2>&1

    rmmod usb-storage      >/dev/null 2>&1

    rmmod uss720           >/dev/null 2>&1

    rmmod vicam            >/dev/null 2>&1

    rmmod visor            >/dev/null 2>&1

    rmmod wacom            >/dev/null 2>&1

    rmmod whiteheat        >/dev/null 2>&1

    if [ "$STATIC_MODULE_LIST" != "" ]; then

        rmmod $STATIC_MODULE_LIST >/dev/null 2>&1

    fi

    # remove the helper modules that some usb modules need

    rmmod usbserial        >/dev/null 2>&1

    rmmod usbvideo         >/dev/null 2>&1

    # ok, hope that user mode drivers/managers closed their fds.

    umount /proc/bus/usb >/dev/null 2>&1

    rmmod usbcore >/dev/null 2>&1

    # we did everything we could ...

    return 0;

}

# See how we were called.

case "$1" in

  start)

        maybe_start_usb

        ;;

  stop)

        maybe_stop_usb

        ;;

  status)

        echo $"USB Status for kernel: " `uname -srm`

        echo ''

        if [ -f /proc/bus/usb/devices ]; then

            # as noted above:  this fails on older kernels,

            # where usbfs created files differently.

            COUNT=`ls /proc/bus/usb | wc -l`

            if [ $COUNT -ge 2 ]; then

                COUNT=`expr $COUNT - 2`

                echo $"USB up; bus count is $COUNT"

                grep "^[TPSI]:" /proc/bus/usb/devices

            else

                echo $"usbfs partially up; no busses"

            fi

            echo ''

            echo $"USB Drivers Loaded: "

            if [ -f /proc/bus/usb/drivers ]; then

                cat /proc/bus/usb/drivers

            fi

            if [ -d /sys/bus/usb ]; then

                ls -1 /sys/bus/usb/drivers

            fi

        else

            echo $"usbfs is unavailable. "

            if [ -f /proc/modules ] && grep -F -q usbcore /proc/modules; then

                echo $"USB module is loaded. "

            else

                echo $"USB may be statically linked. "

            fi

            echo $"If khubd is running, that shows USB is available."

        fi

        echo ''

        if [ -f /proc/sys/kernel/hotplug ]; then

            echo $"khubd/hotplug thread: "

        else

            echo $"khubd thread:"

        fi

        ps -l | head -n 1

        ps -Al | grep 'khubd' | grep -v grep

        echo ''

        lsmod

        echo ''

        # /proc/devices too? "usb", "input", and others ...

        ;;

  restart)

        # always invoke by absolute path, else PATH=$PATH:

        $0 stop && $0 start

        ;;

  *)

        echo $"Usage: $0 {start|stop|status|restart}"

        exit 1

esac

```

Sigo investigando  :Twisted Evil: 

----------

## Sertinell

Mirando por google encuentro esto

http://lists.eslack.org/pipermail/eslack/2004-April/004443.html

Parece qe tiene el mismo problema qe yo, he probado a cambiar los permisos al /proc/bus/usb/001y todo sigue igual como user na de na...

Edito: Ya he conseguido qe me funcione la camara (con las faq's de gphoto). Con el reproductor mp3 no hay manera

----------

## Hefistion

y comcretamente como lo sulucionaste?

----------

## Sertinell

 *Hefistion wrote:*   

> y comcretamente como lo sulucionaste?

 

Con un

```
cp /usr/share/doc/libgphoto2-2.1.5/linux-hotplug/usbcam.group /etc/hotplug/usb/usbcam

```

y editando ese mismo archivo, para el reproductor deberia ser algo parecido ... Creo qe tendre qe editar este archivo

```
# cat /etc/hotplug/usb/nomadjukebox

#!/bin/sh

# Lifts a plugged in nomad jukebox to user space and

# optionally runs a client program.

# Written by Linus Walleij 2004, based on the "usbcam"

# script by Nalin Dahyabhai.

DEVICEOWNER=CONSOLE

DEVICEPERMS=0600

PROGRAM="cd ~; gnomad2 --display=localhost:0"

if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]

then

    # New code, using lock files instead of copying /dev/console permissions

    # This also works with non-gdm logins (e.g. on a virtual terminal)

    # Idea and code from Nalin Dahyabhai <nalin@redhat.com>

    if [ "x$DEVICEOWNER" = "xCONSOLE" ]

    then

        if [ -f /var/run/console.lock ]

        then

            DEVICEOWNER=`cat /var/run/console.lock`

        elif [ -f /var/lock/console.lock ]

        then

            DEVICEOWNER=`cat /var/lock/console.lock`

        else

            DEVICEOWNER=

        fi

    fi

    if [ -n "$DEVICEOWNER" ]

    then

        chmod 0000 "${DEVICE}"

        chown "${DEVICEOWNER}" "${DEVICE}"

        chmod "${DEVICEPERMS}" "${DEVICE}"

        # Then run an optional program - this does not work yet.

        # su "${CONSOLEOWNER}" -c "${PROGRAM}"

    fi

fi

```

Pero es la primera vezq e me tengo qe pelear con hotplug, asi qe no tengo muxa idea

----------

