1 | #! /bin/sh
|
---|
2 | # $Id: VBoxCreateUSBNode.sh 34572 2010-12-01 14:23:21Z vboxsync $ */
|
---|
3 | ## @file
|
---|
4 | # VirtualBox USB Proxy Service, Linux Specialization.
|
---|
5 | # udev helper for creating and removing device nodes for VirtualBox USB devices
|
---|
6 | #
|
---|
7 |
|
---|
8 | #
|
---|
9 | # Copyright (C) 2010 Oracle Corporation
|
---|
10 | #
|
---|
11 | # Oracle Corporation confidential
|
---|
12 | # All rights reserved
|
---|
13 | #
|
---|
14 |
|
---|
15 | do_remove=0
|
---|
16 | case "$1" in "--remove")
|
---|
17 | do_remove=1; shift;;
|
---|
18 | esac
|
---|
19 | bus=`expr "$2" '/' 128 + 1`
|
---|
20 | device=`expr "$2" '%' 128 + 1`
|
---|
21 | class="$3"
|
---|
22 | group="$4"
|
---|
23 | if test "$class" -eq 9; then
|
---|
24 | exit 0
|
---|
25 | fi
|
---|
26 | devdir="`printf "/dev/vboxusb/%.3d" $bus`"
|
---|
27 | devpath="`printf "/dev/vboxusb/%.3d/%.3d" $bus $device`"
|
---|
28 | if test "$do_remove" -eq 0; then
|
---|
29 | if test -z "$group"; then
|
---|
30 | group="vboxusers"
|
---|
31 | fi
|
---|
32 | mkdir /dev/vboxusb -m 0750 2>/dev/null
|
---|
33 | chown root:$group /dev/vboxusb 2>/dev/null
|
---|
34 | mkdir "$devdir" -m 0750 2>/dev/null
|
---|
35 | chown root:$group "$devdir" 2>/dev/null
|
---|
36 | mknod "$devpath" c $1 $2 -m 0660 2>/dev/null
|
---|
37 | chown root:$group "$devpath" 2>/dev/null
|
---|
38 | else
|
---|
39 | rm -f "$devpath"
|
---|
40 | fi
|
---|
41 |
|
---|