fixed name in /dev for USB devices

Stuff that plugs in via USB, FireWire, eSATA, PS/2, etc.

fixed name in /dev for USB devices

Postby pashap » 21 Nov 2012, 14:18

Hi,
How I can assign permanent device in /dev for USB device? I have some 3g modem and usb2com. After reboot from time to time devices mixed but need fixed name in /dev.
thanks!
pashap
Junior Member
 
Posts: 5
Joined: 11 Aug 2009, 14:26

Postby wblock@ » 21 Nov 2012, 16:27

Use devd.conf(5) to detect the device on attach and create a link to it. Warning: I have not tried these recently, and there have been some changes to dev(8), so consider these untested. Worked months ago, though.

I put my own additions in /etc/devd/wb.conf to avoid having to add them to /etc/devd.conf every time that is updated.
Code: Select all
# WB
# link Epson R200 printer to /dev/ulpt-r200 and unlpt-r200
attach 20 {
        device-name "ulpt[0-9]";
        match "vendor" "0x04b8";
        match "product" "0x0005";
        action "ln -sf /dev/$device-name /dev/ulpt-r200";
        action "ln -sf /dev/`echo $device-name \
                | sed -e 's/ulpt/unlpt/'` /dev/unlpt-r200";
        action "chmod g+w /dev/ulpt-r200 /dev/unlpt-r200";
};

# WB
detach 20 {
        device-name "ugen[0-9].[0-9]";
        match "vendor" "0x04b8";
        match "product" "0x0005";
        action "rm -f /dev/ulpt-r200 /dev/unlpt-r200";
};
User avatar
wblock@
Old Fart
 
Posts: 10227
Joined: 07 Sep 2009, 23:23
Location: Milky Way galaxy

Postby fonz » 21 Nov 2012, 17:56

That looks quite interesting. I had also observed the ever changing USB attachments as described by the OP (e.g. now the external HDD is /dev/foo but next time I boot it may be assigned /dev/bar) but it never annoyed me enough to really look into it. It seems like I have found something to do ;)
ΔS>0 ⇒ Entropy is here to stay.

"Lawyer" is just "liar" pronounced in a regional accent.
User avatar
fonz
Giant Locked
 
Posts: 2236
Joined: 16 Nov 2008, 16:32
Location: in dreamland, swooning over a woman I can't have

Postby wblock@ » 21 Nov 2012, 18:31

I really think there should be a system file, possibly an addition to /etc/devfs.conf, that would let the user associate USB vendor and product IDs with links in /dev.

Code: Select all
link    usb:0x04b8:0x0005    ulpt-r200


I'm sure this can be done, but have not given any thought to implementation.
User avatar
wblock@
Old Fart
 
Posts: 10227
Joined: 07 Sep 2009, 23:23
Location: Milky Way galaxy

Postby pashap » 23 Nov 2012, 09:12

I want to fixed name for 3g modem (example /dev/cuaU99) but I don't understand what is make.
When I attached usb 3g modem:

Code: Select all
kernel: u3g0: <HUAWEI Technology HUAWEI Mobile, class 0/0, rev 2.00/0.00, addr 2> on usbus0
kernel: u3g0: Found 4 ports.
kernel: umass1: <HUAWEI Technology HUAWEI Mobile, class 0/0, rev 2.00/0.00, addr 2> on usbus0
kernel: umass1:  SCSI over Bulk-Only; quirks = 0x0000
kernel: umass1:5:1:-1: Attached to scbus5
kernel: (probe0:umass-sim1:1:0:0): TEST UNIT READY. CDB: 0 0 0 0 0 0
kernel: (probe0:umass-sim1:1:0:0): CAM status: SCSI Status Error
kernel: (probe0:umass-sim1:1:0:0): SCSI status: Check Condition
kernel: (probe0:umass-sim1:1:0:0): SCSI sense: UNIT ATTENTION asc:28,0 (Not ready to ready change, medium may have changed)
kernel: cd1 at umass-sim1 bus 1 scbus5 target 0 lun 0
kernel: cd1: <HUAWEI Mass Storage 2.31> Removable CD-ROM SCSI-2 device
kernel: cd1: 1.000MB/s transfers
kernel: cd1: cd present [41280 x 2048 byte records]


As I understand the u3g driver assign devices to /dev/cuaU?, /dev/ttyU? via ucom driver. What rule must specify in this case for a devd?
pashap
Junior Member
 
Posts: 5
Joined: 11 Aug 2009, 14:26


Return to Peripheral Hardware

Who is online

Users browsing this forum: No registered users and 0 guests