#!/bin/bash

# Copyright (C) 2006 Tony Tsui <tsui.tony@gmail.com>
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2.

if [ "$UDI" == "" ] ; then
        echo "Missing or empty environment variable(s)." >&2
        echo "This script should be started by hald." >&2
        exit 1
fi

BUS_NUMBER=`hal-get-property --udi $UDI --key usb.bus_number`
DEVICE_NUMBER=`hal-get-property --udi $UDI --key usb.linux.device_number`

PROC_FILE=`printf /proc/bus/usb/%03i/%03i $BUS_NUMBER $DEVICE_NUMBER`

chmod 666 $PROC_FILE

exit 0
