Set perms on attach of USB umass disk
Vince
jhary at unsane.co.uk
Thu Nov 1 12:55:10 PDT 2007
Darren Spruell wrote:
> I've been trying (and failing) to figure out how to adjust ownership
> or permissions of a USB memory stick on device attach.
>
>
> umass0: SanDisk Corporation Cruzer Mini, rev 2.00/0.20, addr 5
> da0 at umass-sim0 bus 0 target 0 lun 0
> da0: <SanDisk Cruzer Mini 0.4> Removable Direct Access SCSI-2 device
> da0: 1.000MB/s transfers
> da0: 977MB (2001888 512 byte sectors: 64H 32S/T 977C)
>
> $ usbdevs -v
> Controller /dev/usb0:
> addr 1: full speed, self powered, config 1, UHCI root hub(0x0000),
> Intel(0x0000), rev 1.00
> port 1 addr 2: full speed, power 100 mA, config 1, Dell USB Keyboard
> Hub(0x1004), Dell(0x413c), rev 48.01
> port 1 addr 3: low speed, power 90 mA, config 1, Dell USB Keyboard
> Hub(0x2006), Dell(0x413c), rev 48.00
> port 2 addr 5: full speed, power 100 mA, config 1, Cruzer
> Mini(0x5150), SanDisk Corporation(0x0781), rev 0.20
>
>
> I've tried altering devfs.conf but this appears to only work for
> devices that are attached at startup of devfs. I've tried configuring
> devd(8):
>
> attach 100 {
> device-name "da[0-9]+s1";
> action "/bin/chmod 0660 $device-name";
> };
>
> attach 100 {
> device-name "da[0-9]+";
> action "/bin/chmod 0660 $device-name";
> };
>
> Neither of these seem to result in the permission change I'm after
> (making device writable by my user which is in the operator group):
>
> $ ls -l /dev/da0*
> crw-r----- 1 root operator 0, 165 Oct 21 13:08 /dev/da0
> crw-r----- 1 root operator 0, 166 Oct 21 13:08 /dev/da0s1
>
> What's the right way to handle this?
>
create a new file /etc/devfs.rules with contents
[system=10]
add path 'da*' mode 660 group operator
Then in /etc/rc.conf add
devfs_system_ruleset="system"
and restart devfs (/etc/rc.d/devfs restart)
This should do the job, for futher reading devfs.rules has a manpage.
Vince
More information about the freebsd-questions
mailing list