Systemd/src/udev
Lidong Zhong 9b3278d907 udev: rename the persistent link for ATA devices
ATA devices should use the ATA ids like port number and (possibly)
master/slave or multiplier id, not the generic SCSI ID.
Currently only port number is included in the link. With this patch
the link would be able to support more cases, which are a) when the
device is behind a port multiplexer b) the distinction between master
and slave (distinguished by target id).

I tried to verify scenario a) with this patch, but I failed to find a
machine with PMP SATA devices attached. But the link below
https://github.com/systemd/systemd/issues/3943
could show what's the difference. Here is my test for scenario b)

Current version:
linux-ql21:~ # ll /sys/class/block/sd[ab]
lrwxrwxrwx 1 root root 0 May  8 20:46 /sys/class/block/sda ->
../../devices/pci0000:00/0000:00:01.1/ata4/host3/target3:0:0/3:0:0:0/block/sda
lrwxrwxrwx 1 root root 0 May  8 20:46 /sys/class/block/sdb ->
../../devices/pci0000:00/0000:00:01.1/ata4/host3/target3:0:1/3:0:1:0/block/sdb
linux-ql21:~ # ll /dev/disk/by-path/pci-0000\:00\:01.1-ata-1
lrwxrwxrwx 1 root root 9 May  8 20:44
/dev/disk/by-path/pci-0000:00:01.1-ata-1 -> ../../sdb
linux-ql21:~ # udevadm info /sys/class/block/sda |grep by-path
S: disk/by-path/pci-0000:00:01.1-ata-1
E: DEVLINKS=/dev/disk/by-id/ata-VBOX_HARDDISK_VB3649e885-3e0cdd64
/dev/disk/by-id/scsi-0ATA_VBOX_HARDDISK_VB3649e885-3e0cdd64
/dev/disk/by-id/scsi-1ATA_VBOX_HARDDISK_VB3649e885-3e0cdd64
/dev/disk/by-path/pci-0000:00:01.1-ata-1
/dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VB3649e885-3e0cdd64
linux-ql21:~ # udevadm info /sys/class/block/sdb |grep by-path
S: disk/by-path/pci-0000:00:01.1-ata-1
E: DEVLINKS=/dev/disk/by-id/ata-VBOX_HARDDISK_VBc53b2498-d84ae8de
/dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VBc53b2498-d84ae8de
/dev/disk/by-id/scsi-1ATA_VBOX_HARDDISK_VBc53b2498-d84ae8de
/dev/disk/by-id/scsi-0ATA_VBOX_HARDDISK_VBc53b2498-d84ae8de
/dev/disk/by-path/pci-0000:00:01.1-ata-1

After patch applied:
linux-ql21:~ # ll /sys/class/block/sd[ab]
lrwxrwxrwx 1 root root 0 May  8 21:07 /sys/class/block/sda ->
../../devices/pci0000:00/0000:00:01.1/ata4/host3/target3:0:0/3:0:0:0/block/sda
lrwxrwxrwx 1 root root 0 May  8 21:07 /sys/class/block/sdb ->
../../devices/pci0000:00/0000:00:01.1/ata4/host3/target3:0:1/3:0:1:0/block/sdb
linux-ql21:~ # ll /dev/disk/by-path/pci-0000\:00\:01.1-ata-*
lrwxrwxrwx 1 root root  9 May  8 21:07
/dev/disk/by-path/pci-0000:00:01.1-ata-1.0 -> ../../sda
lrwxrwxrwx 1 root root  9 May  8 21:07
/dev/disk/by-path/pci-0000:00:01.1-ata-1.1 -> ../../sdb
linux-ql21:~ # udevadm info /sys/class/block/sda |grep by-path
S: disk/by-path/pci-0000:00:01.1-ata-1.0
E: DEVLINKS=/dev/disk/by-id/scsi-1ATA_VBOX_HARDDISK_VB3649e885-3e0cdd64
/dev/disk/by-id/scsi-0ATA_VBOX_HARDDISK_VB3649e885-3e0cdd64
/dev/disk/by-id/ata-VBOX_HARDDISK_VB3649e885-3e0cdd64
/dev/disk/by-path/pci-0000:00:01.1-ata-1.0
/dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VB3649e885-3e0cdd64
linux-ql21:~ # udevadm info /sys/class/block/sdb |grep by-path
S: disk/by-path/pci-0000:00:01.1-ata-1.1
E: DEVLINKS=/dev/disk/by-id/scsi-0ATA_VBOX_HARDDISK_VBc53b2498-d84ae8de
/dev/disk/by-id/ata-VBOX_HARDDISK_VBc53b2498-d84ae8de
/dev/disk/by-id/scsi-1ATA_VBOX_HARDDISK_VBc53b2498-d84ae8de
/dev/disk/by-id/scsi-SATA_VBOX_HARDDISK_VBc53b2498-d84ae8de
/dev/disk/by-path/pci-0000:00:01.1-ata-1.1

Changelog:
v5: add another parameter compat_link in handle_scsi()
v4: comment for ID_PATH_ATA_COMPAT
    get string length with pointer difference
    (suggested by Franck Bui<fbui@suse.com>)
v3: creating compatible link from env
    variables type change
v2: remove udev rules modification for compatible link
    setup a test scenario of master/slave ATA devices
v1: initial patch
2020-05-21 09:58:06 +02:00
..
ata_id Remove unneded {}s 2020-04-13 09:31:49 +02:00
cdrom_id udev/cdrom_id: Do not open CD-rom in exclusive mode. 2019-10-24 00:09:18 +02:00
fido_id test: move {test,fuzz}-fido-id-desc.c into src/udev/fido_id 2019-10-31 10:37:42 +09:00
mtd_probe coccinelle: make use of SYNTHETIC_ERRNO 2018-11-22 10:54:38 +01:00
net udev: when random MACs are requested, generate them with genuine randomness 2020-05-20 08:25:18 +02:00
scsi_id Remove unneded {}s 2020-04-13 09:31:49 +02:00
v4l_id tree-wide: replace explicit NULL checks with their shorter variants 2019-04-28 14:28:49 +02:00
.vimrc
generate-keyboard-keys-gperf.sh scripts: use 4 space indentation 2019-04-12 08:30:31 +02:00
generate-keyboard-keys-list.sh scripts: use 4 space indentation 2019-04-12 08:30:31 +02:00
meson.build udev: move naming-scheme.[ch] into src/shared/ 2020-01-02 19:34:00 +01:00
udev-builtin-blkid.c libblkid: open device in nonblock mode. 2019-11-08 12:11:32 +01:00
udev-builtin-btrfs.c udev: modernize udev-rules.c 2019-06-02 14:15:26 +09:00
udev-builtin-hwdb.c tree-wide: fix spelling of lookup and setup verbs 2020-03-03 15:02:53 +01:00
udev-builtin-input_id.c Remove unneded {}s 2020-04-13 09:31:49 +02:00
udev-builtin-keyboard.c tree-wide: drop stdio.h when stdio-util.h is included 2019-11-04 00:30:32 +09:00
udev-builtin-kmod.c tree-wide: drop libkmod.h when module-util.h is included 2019-11-04 00:30:32 +09:00
udev-builtin-net_id.c udev: use dot_or_dot_dot() where appropriate 2020-01-07 18:02:53 +01:00
udev-builtin-net_setup_link.c udev: modernize udev-rules.c 2019-06-02 14:15:26 +09:00
udev-builtin-path_id.c udev: rename the persistent link for ATA devices 2020-05-21 09:58:06 +02:00
udev-builtin-uaccess.c udev: modernize udev-rules.c 2019-06-02 14:15:26 +09:00
udev-builtin-usb_id.c tree-wide: drop string.h when string-util.h or friends are included 2019-11-04 00:30:32 +09:00
udev-builtin.c tree-wide: drop string.h when string-util.h or friends are included 2019-11-04 00:30:32 +09:00
udev-builtin.h udev: modernize udev-rules.c 2019-06-02 14:15:26 +09:00
udev-ctrl.c tree-wide: make sure our control buffers are properly aligned 2020-05-07 14:39:44 +02:00
udev-ctrl.h udev-ctrl: split out logic of waiting for reply to udev_ctrl_wait() 2019-02-20 06:17:42 +09:00
udev-event.c udev: Ensure udev_event_spawn reads stdout 2019-12-04 10:31:37 +01:00
udev-event.h udev-rules: add precise information to rule failure logs 2019-06-28 16:20:48 +02:00
udev-node.c udev: ignore error caused by device disconnection 2019-11-12 14:58:53 +09:00
udev-node.h udev: run programs in the specified order 2019-03-05 09:27:29 +01:00
udev-rules.c proc-cmdline: make checking of EFI options variable optional 2020-05-20 19:22:09 +02:00
udev-rules.h udev: move rule structure definitions into the .c file 2019-06-28 16:20:48 +02:00
udev-watch.c coccinelle: also mark previous synthetic errnos as such 2018-11-22 10:54:38 +01:00
udev-watch.h udev-watch: replace udev_device by sd_device and modernize code a bit 2018-10-11 04:21:14 +09:00
udev.conf udev: also allow resolve_names= to be specified in udev.conf 2018-11-13 14:35:36 +01:00
udev.pc.in {systemd,udev}.pc: add names with underscores, deprecate the old ones 2020-03-27 20:12:44 +01:00
udevadm-control.c udevadm: drop pointless must_be_root() checks 2019-05-08 11:51:51 +02:00
udevadm-hwdb.c coccinelle: make use of SYNTHETIC_ERRNO 2018-11-22 10:54:38 +01:00
udevadm-info.c udevadm: show more error message during exporting database 2020-02-27 22:27:16 +09:00
udevadm-monitor.c tree-wide: drop signal.h when signal-util.h is included 2019-11-04 00:30:32 +09:00
udevadm-settle.c tree-wide: drop string.h when string-util.h or friends are included 2019-11-04 00:30:32 +09:00
udevadm-test-builtin.c udev: modernize udev-rules.c 2019-06-02 14:15:26 +09:00
udevadm-test.c udevadm: support special value 'help' for --action option 2019-06-29 04:10:14 +09:00
udevadm-trigger.c basic/set: let set_put_strdup() create the set with string hash ops 2020-05-06 16:54:06 +02:00
udevadm-util.c udevadm: allow a .device unit to be specified for query and trigger 2018-12-11 09:24:31 +01:00
udevadm-util.h udevadm-info,trigger: replace udev_device by sd_device 2018-10-17 03:31:20 +09:00
udevadm.c tree-wide: constify a few static string tables 2019-03-25 14:04:34 +01:00
udevadm.h udevadm: add a workaround for dracut 2019-01-02 10:26:16 +01:00
udevd.c tree-wide: make sure our control buffers are properly aligned 2020-05-07 14:39:44 +02:00