From: Kay Sievers Date: Thu, 4 Dec 2008 00:43:33 +0000 (+0100) Subject: rules: add persistent /dev/serial/{by-id,by-path} rules X-Git-Tag: 174~1266 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc4c751802147f1ff21bf52a57a2976754949453;p=systemd rules: add persistent /dev/serial/{by-id,by-path} rules $ 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 --- diff --git a/extras/path_id/path_id b/extras/path_id/path_id index f7b1435d..f45f62ad 100755 --- a/extras/path_id/path_id +++ b/extras/path_id/path_id @@ -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 index 00000000..df10606e --- /dev/null +++ b/rules/rules.d/60-persistent-serial.rules @@ -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"