Set perms on attach of USB umass disk

2007-11-01 Thread Darren Spruell
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(0x),
Intel(0x), 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  operator0, 165 Oct 21 13:08 /dev/da0
crw-r-  1 root  operator0, 166 Oct 21 13:08 /dev/da0s1

What's the right way to handle this?

-- 
Darren Spruell
[EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Set perms on attach of USB umass disk

2007-11-01 Thread Vince

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(0x),
Intel(0x), 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  operator0, 165 Oct 21 13:08 /dev/da0
crw-r-  1 root  operator0, 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
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Set perms on attach of USB umass disk

2007-11-01 Thread Roland Smith
On Thu, Nov 01, 2007 at 10:53:00AM -0700, 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.

[snip]
 I've tried altering devfs.conf but this appears to only work for
 devices that are attached at startup of devfs.
[snip]

As a matter of fact, this is documented in the devfs.conf manual page.
This will also tell you where to look;

 What's the right way to handle this?

You'll have to use devfs.rules. See 'man devfs.rules'

The fact that there are two configuration files is a bit confusing. But
that is because of the way removable devices are handled.

Roland
-- 
R.F.Smith   http://www.xs4all.nl/~rsmith/
[plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated]
pgp: 1A2B 477F 9970 BA3C 2914  B7CE 1277 EFB0 C321 A725 (KeyID: C321A725)


pgpVKJDhKsvLT.pgp
Description: PGP signature


Re: Set perms on attach of USB umass disk

2007-11-01 Thread Darren Spruell
  I've tried altering devfs.conf but this appears to only work for
  devices that are attached at startup of devfs.
 [snip]

 As a matter of fact, this is documented in the devfs.conf manual page.
 This will also tell you where to look;

Yep:

It does not work for devices plugged in and out after the system is up
and running, e.g. USB devices.  See devfs.rules(5) for setting ownership
and permissions for all device nodes, and usbd.conf(5) for actions to be
taken when USB devices are attached or detached.

I overlooked that for some reason. :(

 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)

Works great, thanks.

-- 
Darren Spruell
[EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]