devd and da* devices

manefesto

Member


Messages: 40

I want to run action if inserted flash drive
Edit devd.conf:
Code:
 58 attach 0 {
 59     device-name "da[0-9]+";
 60     action "/home/sh/da.sh $device-name" ;
 61
 62 };
My simple script
Code:
#!/bin/sh
echo $1 >> /home/sh/out.txt

But nothing happens. Where's the bug?

PS: with umass worked fine.
 
OP
M

manefesto

Member


Messages: 40

yes
Code:
chmod 777 da.sh
If change da to umass then fine worked,but need worked with da device
 

wblock@

Beastie Himself
Developer

Reaction score: 3,717
Messages: 13,851

Please don't use 777 as permissions. That will come back to haunt you. Or maybe someone else.

It seems that da devices don't trigger an attach event. Maybe because they're not attached, but created. You can detect them with a notify event from the devfs system:
Code:
# WB
notify 20 {
        match "system" "DEVFS";
        #match "subsystem" "CDEV";
        match "type" "CREATE";
        match "cdev" "da[0-9]$";
        action "/home/sampleuser/da.sh cdev=$cdev device attached!";
};

There's a corresponding destroy event on detach. Because there may be multiple new devices created, da0 and da0s1 in my case, the pattern on the cdev line restricts that to just the um, base device.

The action script is run as root. You can use su sampleuser -c '/home/sampleuser/da.sh ...' to run it as a less-dangerous user.

Thanks for asking this; it gave me a chance to find out some new things about devd(8).
 
Top