]> err.no Git - systemd/commitdiff
rules: add persistent /dev/serial/{by-id,by-path} rules
authorKay Sievers <kay.sievers@vrfy.org>
Thu, 4 Dec 2008 00:43:33 +0000 (01:43 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Thu, 4 Dec 2008 00:43:33 +0000 (01:43 +0100)
 $ tree /dev/serial/
 /dev/serial/
 |-- by-id
 |   |-- usb-067b_2303-if00-port0 -> ../../ttyUSB0
 |   |-- usb-FTDI_FT232R_USB_UART_A7005uBP-if00-port0 -> ../../ttyUSB3
 |   |-- usb-HUAWEI_Technology_HUAWEI_Mobile-if00-port0 -> ../../ttyUSB1
 |   `-- usb-HUAWEI_Technology_HUAWEI_Mobile-if01-port0 -> ../../ttyUSB2
 `-- by-path
     |-- pci-0000:00:1d.0-usb-0:1:1.0-port0 -> ../../ttyUSB3
     |-- pci-0000:00:1d.7-usb-0:2.2.2:1.0-port0 -> ../../ttyUSB0
     |-- pci-0000:00:1d.7-usb-0:2.3:1.0-port0 -> ../../ttyUSB1
     `-- pci-0000:00:1d.7-usb-0:2.3:1.1-port0 -> ../../ttyUSB2

 $ tree /dev/serial/
 /dev/serial/
 |-- by-id
 |   |-- usb-Inside_Out_Networks_Edgeport_4_04-01-006467-if00-port0 -> ../../ttyUSB0
 |   |-- usb-Inside_Out_Networks_Edgeport_4_04-01-006467-if00-port1 -> ../../ttyUSB1
 |   |-- usb-Inside_Out_Networks_Edgeport_4_04-01-006467-if00-port2 -> ../../ttyUSB2
 |   |-- usb-Inside_Out_Networks_Edgeport_4_04-01-006467-if00-port3 -> ../../ttyUSB3
 |   |-- usb-Keyspan__a_division_of_InnoSys_Inc._USB_4-port_Serial_Adapter-if00-port0 -> ../../ttyUSB8
 |   |-- usb-Keyspan__a_division_of_InnoSys_Inc._USB_4-port_Serial_Adapter-if00-port1 -> ../../ttyUSB9
 |   |-- usb-Keyspan__a_division_of_InnoSys_Inc._USB_4-port_Serial_Adapter-if00-port2 -> ../../ttyUSB10
 |   |-- usb-Keyspan__a_division_of_InnoSys_Inc._USB_4-port_Serial_Adapter-if00-port3 -> ../../ttyUSB11
 |   `-- usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0 -> ../../ttyUSB7
 `-- by-path
     |-- pci-0000:00:1d.2-usb-0:1.3:1.0-port0 -> ../../ttyUSB7
     |-- pci-0000:00:1d.7-usb-0:6.1.4.1:1.0-port0 -> ../../ttyUSB4
     |-- pci-0000:00:1d.7-usb-0:6.1.4.1:1.0-port1 -> ../../ttyUSB5
     |-- pci-0000:00:1d.7-usb-0:6.1.4.1:1.0-port2 -> ../../ttyUSB6
     |-- pci-0000:00:1d.7-usb-0:6.1.4.4:1.0-port0 -> ../../ttyUSB0
     |-- pci-0000:00:1d.7-usb-0:6.1.4.4:1.0-port1 -> ../../ttyUSB1
     |-- pci-0000:00:1d.7-usb-0:6.1.4.4:1.0-port2 -> ../../ttyUSB2
     |-- pci-0000:00:1d.7-usb-0:6.1.4.4:1.0-port3 -> ../../ttyUSB3
     |-- pci-0000:00:1d.7-usb-0:6.3:1.0-port0 -> ../../ttyUSB8
     |-- pci-0000:00:1d.7-usb-0:6.3:1.0-port1 -> ../../ttyUSB9
     |-- pci-0000:00:1d.7-usb-0:6.3:1.0-port2 -> ../../ttyUSB10
     `-- pci-0000:00:1d.7-usb-0:6.3:1.0-port3 -> ../../ttyUSB11

extras/path_id/path_id
rules/rules.d/60-persistent-serial.rules [new file with mode: 0644]

index f7b1435d3d7a0b8ce27c17130dc14951e9089fd7..f45f62ad32eb1cf0a57e96e1ff1b895d357c0dd8 100755 (executable)
@@ -515,6 +515,9 @@ handle_device () {
                        */host[0-9]*/[0-9]*:[0-9]*:[0-9]*:[0-9]*)
                                handle_scsi "$D"
                                ;;
+                       */ttyUSB*)
+                               D=${D%/ttyUSB*}
+                               ;;
                        */usb[0-9]*/[0-9]*/*)
                                handle_usb "$D"
                                ;;
diff --git a/rules/rules.d/60-persistent-serial.rules b/rules/rules.d/60-persistent-serial.rules
new file mode 100644 (file)
index 0000000..df10606
--- /dev/null
@@ -0,0 +1,19 @@
+# do not edit this file, it will be overwritten on update
+
+ACTION!="add|change", GOTO="persistent_serial_end"
+SUBSYSTEM!="tty", GOTO="persistent_serial_end"
+KERNEL!="ttyUSB[0-9]*", GOTO="persistent_serial_end"
+
+SUBSYSTEMS=="usb-serial", ENV{ID_PORT}="$attr{port_number}"
+ENV{ID_PORT}=="", GOTO="persistent_serial_end"
+
+IMPORT="path_id"
+ENV{ID_PATH}=="?*", SYMLINK+="serial/by-path/$env{ID_PATH}-port$env{ID_PORT}"
+
+IMPORT="usb_id --export"
+ENV{ID_SERIAL}=="", GOTO="persistent_serial_end"
+SUBSYSTEMS=="usb", ENV{ID_IFACE}="$attr{bInterfaceNumber}"
+ENV{ID_IFACE}=="", GOTO="persistent_serial_end"
+SYMLINK+="serial/by-id/$env{ID_BUS}-$env{ID_SERIAL}-if$env{ID_IFACE}-port$env{ID_PORT}"
+
+LABEL="persistent_serial_end"