Commit Graph

11021 Commits

Author SHA1 Message Date
Boian Bonev
1e007fb1ee
sparse: avoid clash with __bitwise and __force from 4.10 linux/types.h (#5061)
It also used __bitwise and __force. It seems easier to rename
our versions since they are local to this one single header.

Also, undefine them afteerwards, so that we don't pollute the
preprocessor macro namespace.

systemd-commit: dc66f33a16596c2886a24da12e56ec096214e124
Author: Lubomir Rintel <lkundrak@v3.sk>
Date:   Wed Jan 11 10:50:25 2017 +0100
2021-10-10 03:48:51 +03:00
Boian Bonev
d7f91539ea
mtd: some basic code cleanups
While looking at our exit() invocations I noticed that the mtd_probe
stuff uses 'exit(-1)' at various places, which is not really a good
idea, as exit codes of processes on Linux are supposed to be in the
range of 0…255.

This patch cleans that up a bit, and fixes a number of other things:

1. Let's always let main() exit, nothing intermediary. We generally
   don't like code that invokes exit() on its own.

2. Close the file descriptors opened.

3. Some logging for errors is added, mostly on debug level.

Please review this with extra care. As I don't have the right hardware
to test this patch I only did superficial testing.

systemd-commit: 41b9d436b2739cbe8bf9482b665d85d59d06bc0e
Author: Lennart Poettering <lennart@poettering.net>
Date:   Tue Apr 24 17:50:01 2018 +0200
2021-10-10 03:47:55 +03:00
Boian Bonev
3871924512
Fix whitespace and other non-semantic changes 2021-10-10 03:46:52 +03:00
Boian Bonev
d527ee593c
udev/scsi_id: fix incorrect page length when get device identification VPD page
The length of device identification VPD page is filled with two bytes,
but scsi_id only gets the low byte. Fix it.

Signed-off-by: Zhang Xianwei <zhang.xianwei8@zte.com.cn>

systemd-commit: 1f7b6872dbe8ccae1f3bda9aa6aeb87c9b42e01e
Author: Zhang Xianwei <zhang.xianwei8@zte.com.cn>
Date:   Mon May 13 18:41:55 2019 +0800
2021-10-10 03:46:47 +03:00
Boian Bonev
21b7edeffc
scsi_id: Fixup prefix for pre-SPC inquiry reply
The prefix for EMC Symmetrix pre-SPC VPD inquiry reply
is always SCSI_ID_NAA, so we need to hardcode it to
avoid false values here.

Signed-off-by: Hannes Reinecke <hare@suse.com>

systemd-commit: c0373eb019db70017878ee64d042de902e4c98ee
Author: Hannes Reinecke <hare@suse.de>
Date:   Wed Sep 13 09:08:28 2017 +0200
2021-10-10 03:46:39 +03:00
Boian Bonev
9da0df4417
scsi_serial: replace some crazy strncpy() calls by strnlen()
gcc was warning about strncpy() leaving an unterminated string.
In this case, it was correct.

The code was doing strncpy()+strncat()+strlen() essentially to determine
if the strings have expected length. If the length was correct, a buffer
overread was performed (or at least some garbage bytes were used from the
uninitialized part of the buffer). Let's do the length check first and then
only copy stuff if everything agrees.

For some reason the function was called "prepend", when it obviously does
an "append".

systemd-commit: 099c77fd5ff835614dea8dc11c57f6d44f77d9ee
Author: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Date:   Tue May 7 15:58:29 2019 +0200
2021-10-10 03:46:30 +03:00
Boian Bonev
8c9571be6a
Fix whitespace and other non-semantic changes 2021-10-10 03:46:25 +03:00
Boian Bonev
acbd248f14
udev/scsi: use the scsi device type number directly
Previously, the value is once stringified, and later again parsed,
that is completely redundant.

Follow-up for 1001167ca5e4cfdc6230562e4fb9029e5f624d53.

Replaces #20013.

systemd-commit: 4dce1b9f059733ed9a263fba7cfa12704e96794a
Author: Yu Watanabe <watanabe.yu+github@gmail.com>
Date:   Fri Jun 25 15:04:12 2021 +0900
2021-10-10 03:46:08 +03:00
Boian Bonev
73080ea4f0
Fix whitespace and other non-semantic changes 2021-10-10 03:45:02 +03:00
Boian Bonev
dd850edec3
scsi_id: add missing options to getopt_long() (#6501)
systemd-commit: ebc6f34a0b2359ac0da41037a1122d3abe02caee
Author: Jan Synacek <jan.synacek@gmail.com>
Date:   Wed Aug 2 10:12:33 2017 +0200
2021-10-10 03:44:26 +03:00
Boian Bonev
c18d88dc6a
v4l_id: use device_caps if available
According to the specification[1] the 'capabilities' describe the physical
device as a whole and the 'device_caps' describe the current device node.
The existence of 'device_caps' is indicated by the V4L2_CAP_DEVICE_CAPS
capability flag.
Use the 'device_caps' if available to generate the correct
ID_V4L_CAPABILITIES for the current device node.

This is relevant for UVC devices with current kernels: Two /dev/videoX
devices exist for those. One for video and one for metadata. The
 V4L2_CAP_VIDEO_CAPTURE flag is present in the 'capabilities' for both
device nodes but only in the 'device_caps' of the video device node.

Without this, the ID_V4L_CAPABILITIES of the metadata device node
incorrectly contains 'capture'.

[1] https://www.linuxtv.org/downloads/v4l-dvb-apis-new/uapi/v4l/vidioc-querycap.html

systemd-commit: 646876105fe1799355715839477958adf1d096fd
Author: Michael Olbrich <m.olbrich@pengutronix.de>
Date:   Sun Feb 3 10:52:02 2019 +0100
2021-10-10 03:39:31 +03:00
Boian Bonev
ee626856ca
ata_id: Add check for fixed format sense codes (#13654)
Original revisions of the SAT (SCSI-ATA Translation) specification
required that all sense data be reported in Descriptor Format (72h).

Later revisions specifcally allow and account for sense data being
reported in Fixed Format (70h).

The current code checks for a Descriptor Format sense structure (0x72),
then looks specifically at the first byte of the first descriptor for the
ATA specific code 0x9, cross referencing it with the first byte which is
just a length field 0x0c (as a sanity check).

In the Fixed Format case(0x70), we can fall back to using the top-level
SCSI Sense data for the Additional Sense code (0x0) and then the
Additional Sense Code Qualifier (0x1d),

That identifies that the sense data is of the format associated with:
`ATA PASS THROUGH INFORMATION AVAILABLE`.

This fallback mechanism retains support for SATLs compliant with ANSI
INCITS 431-2007, and enables support for Fixed Format Sense data
enabled by SATLs with later revisions.

Glad to do so. This patch allows ata_id to export attributes correctly. I believe that any drive can potentially return information in this format on
any SATL using the libata-scsi (the Linux builtin SATL), but in this particular case, it appears it is the SATL itself. Attaching the disk to the AHCI con
troller changes the behavior impacted here. (Not entirely surprisingly, SATLs are are pretty inconsistent).

Test:
This case specifically is an LSI SATL. I'll illustrate that without the patch, ata_id does not return
any output for a valid SATA drive but after the patch does.

1. Verify the device is ATA, by looking at the vpd page specific to ATA drives

```
root@machine:~# sg_vpd -p ai /dev/sdn
ATA information VPD page:
  SAT Vendor identification: LSI
  SAT Product identification: LSI SATL
  SAT Product revision level: 0008
  Device signature indicates SATA transport
  ATA command IDENTIFY DEVICE response summary:
	model: HGST HUH728080ALE604
	serial number: ZZZZH3VX
	firmware revision: A4GNW7J0
```

2. Look at what udev thinks of the disk, it says ID_BUS=scsi
ATA information says ID_MODEL should be HGST_HUH728080ALE604
udev says it is HGST_HUH728080AL (Missing E604, 4 bytes), and no ATA attributes are
populated.

```
root@machine:~# udevadm info -q all /dev/sdn
P: /devices/pci0000:00/0000:00:03.0/0000:05:00.0/host2/port-2:0/expander-2:0/port-2:0:11/end_device-2:0:11/target2:0:11/2:0:11:0/block/sdn
N: sdn
S: disk/by-id/scsi-35000cca23be1dc3c
S: disk/by-id/wwn-0x5000cca23be1dc3c
S: disk/by-path/pci-0000:05:00.0-sas-exp0x500605b0000272bf-phy11-lun-0
E: DEVLINKS=/dev/disk/by-id/wwn-0x5000cca23be1dc3c /dev/disk/by-id/scsi-35000cca23be1dc3c /dev/disk/by-path/pci-0000:05:00.0-sas-exp0x500605b0000272bf-phy11-lun-0
E: DEVNAME=/dev/sdn
E: DEVPATH=/devices/pci0000:00/0000:00:03.0/0000:05:00.0/host2/port-2:0/expander-2:0/port-2:0:11/end_device-2:0:11/target2:0:11/2:0:11:0/block/sdn
E: DEVTYPE=disk
E: ID_BUS=scsi
E: ID_MODEL=HGST_HUH728080AL
E: ID_MODEL_ENC=HGST\x20HUH728080AL
E: ID_PATH=pci-0000:05:00.0-sas-exp0x500605b0000272bf-phy11-lun-0
E: ID_PATH_TAG=pci-0000_05_00_0-sas-exp0x500605b0000272bf-phy11-lun-0
E: ID_REVISION=W7J0
E: ID_SCSI=1
E: ID_SCSI_SERIAL=ZZZZH3VX
E: ID_SERIAL=35000cca23be1dc3c
E: ID_SERIAL_SHORT=5000cca23be1dc3c
E: ID_TYPE=disk
E: ID_VENDOR=ATA
E: ID_VENDOR_ENC=ATA\x20\x20\x20\x20\x20
E: ID_WWN=0x5000cca23be1dc3c
E: ID_WWN_WITH_EXTENSION=0x5000cca23be1dc3c
E: MAJOR=8
E: MINOR=208
E: SUBSYSTEM=block
E: TAGS=:systemd:
```

3. Run ata_id (unpatched) (Outputs nothing, RC=2)

```
root@machine:~# strace -e ioctl /lib/udev/ata_id /dev/sdn -x
ioctl(3, SG_IO, {'Q', BSG_PROTOCOL_SCSI, BSG_SUB_PROTOCOL_SCSI_CMD, request[6]=[12, 00, 00, 00, 24, 00], request_tag=0, request_attr=0, request_priority=0, request_extra=0, max_response_len=32, dout_iovec_count=0, dout_xfer_len=0, din_iovec_count=0, din_xfer_len=36, timeout=30000, flags=0, usr_ptr=0, spare_in=0, dout[0]=NULL}) = -1 EINVAL (Invalid argument)
ioctl(3, SG_IO, {'S', SG_DXFER_FROM_DEV, cmd[6]=[12, 00, 00, 00, 24, 00], mx_sb_len=32, iovec_count=0, dxfer_len=36, timeout=30000, flags=0, data[36]=[00, 00, 06, 12, 45, 00, 00, 02, 41, 54, 41, 20, 20, 20, 20, 20, 48, 47, 53, 54, 20, 48, 55, 48, 37, 32, 38, 30, 38, 30, 41, 4c, ...], status=00, masked_status=00, sb[0]=[], host_status=0, driver_status=0, resid=0, duration=1, info=0}) = 0
ioctl(3, SG_IO, {'Q', BSG_PROTOCOL_SCSI, BSG_SUB_PROTOCOL_SCSI_CMD, request[12]=[a1, 08, 2e, 00, 01, 00, 00, 00, 00, ec, 00, 00], request_tag=0, request_attr=0, request_priority=0, request_extra=0, max_response_len=32, dout_iovec_count=0, dout_xfer_len=0, din_iovec_count=0, din_xfer_len=512, timeout=30000, flags=0, usr_ptr=0, spare_in=0, dout[0]=NULL}) = -1 EINVAL (Invalid argument)
ioctl(3, SG_IO, {'S', SG_DXFER_FROM_DEV, cmd[12]=[a1, 08, 2e, 00, 01, 00, 00, 00, 00, ec, 00, 00], mx_sb_len=32, iovec_count=0, dxfer_len=512, timeout=30000, flags=0, data[0]=[], status=02, masked_status=01, sb[18]=[70, 00, 01, 00, 00, 00, 00, 0a, 00, 00, 00, 00, 00, 1d, 00, 00, 00, 00], host_status=0, driver_status=0x8, resid=512, duration=0, info=0x1}) = 0
ioctl(3, HDIO_GET_IDENTITY, 0x7ffe408f7590) = -1 EINVAL (Invalid argument)
+++ exited with 2 +++
```
Sense buffers visible with the strace:
`sb[18]=[70, 00, 01, 00, 00, 00, 00, 0a, 00, 00, 00, 00, 00, 1d, 00, 00, 00, 00]` is the important bit, see 70, 0a and 1d bytes

4. Run patched version: model is HGST_HUH728080ALE604 as expected, ATA attributes are
correctly populated.
```
root@machine:~# ./ata_id /dev/sdn -x
ID_ATA=1
ID_TYPE=disk
ID_BUS=ata
ID_MODEL=HGST_HUH728080ALE604
ID_MODEL_ENC=HGST\x20HUH728080ALE604\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
ID_REVISION=A4GNW7J0
ID_SERIAL=HGST_HUH728080ALE604_ZZZZH3VX
ID_SERIAL_SHORT=ZZZZH3VX
ID_ATA_WRITE_CACHE=1
ID_ATA_WRITE_CACHE_ENABLED=1
ID_ATA_FEATURE_SET_HPA=1
ID_ATA_FEATURE_SET_HPA_ENABLED=1
ID_ATA_FEATURE_SET_PM=1
ID_ATA_FEATURE_SET_PM_ENABLED=1
ID_ATA_FEATURE_SET_SECURITY=1
ID_ATA_FEATURE_SET_SECURITY_ENABLED=0
ID_ATA_FEATURE_SET_SECURITY_ERASE_UNIT_MIN=66522
ID_ATA_FEATURE_SET_SMART=1
ID_ATA_FEATURE_SET_SMART_ENABLED=1
ID_ATA_FEATURE_SET_PUIS=1
ID_ATA_FEATURE_SET_PUIS_ENABLED=0
ID_ATA_FEATURE_SET_APM=1
ID_ATA_FEATURE_SET_APM_ENABLED=1
ID_ATA_FEATURE_SET_APM_CURRENT_VALUE=254
ID_ATA_DOWNLOAD_MICROCODE=1
ID_ATA_SATA=1
ID_ATA_SATA_SIGNAL_RATE_GEN2=1
ID_ATA_SATA_SIGNAL_RATE_GEN1=1
ID_ATA_ROTATION_RATE_RPM=7200
ID_WWN=0x5000cca23be1dc3c
ID_WWN_WITH_EXTENSION=0x5000cca23be1dc3c
```

5. Drop it in place and verify: we see that ata_id does work.
```
root@hw1-b01left-2212a:~# udevadm test /block/sdn
<truncated>
GROUP 6 /lib/udev/rules.d/50-udev-default.rules:55
IMPORT 'ata_id --export /dev/sdn' /lib/udev/rules.d/60-persistent-storage.rules:33
starting 'ata_id --export /dev/sdn'
'ata_id --export /dev/sdn'(out) 'ID_ATA=1'
'ata_id --export /dev/sdn'(out) 'ID_TYPE=disk'
'ata_id --export /dev/sdn'(out) 'ID_BUS=ata'
'ata_id --export /dev/sdn'(out) 'ID_MODEL=HGST_HUH728080ALE604'
'ata_id --export /dev/sdn'(out) 'ID_MODEL_ENC=HGST\x20HUH728080ALE604\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'
'ata_id --export /dev/sdn'(out) 'ID_REVISION=A4GNW7J0'
'ata_id --export /dev/sdn'(out) 'ID_SERIAL=HGST_HUH728080ALE604_ZZZZH3VX'
'ata_id --export /dev/sdn'(out) 'ID_SERIAL_SHORT=ZZZZH3VX'
'ata_id --export /dev/sdn'(out) 'ID_ATA_WRITE_CACHE=1'
'ata_id --export /dev/sdn'(out) 'ID_ATA_WRITE_CACHE_ENABLED=1'
'ata_id --export /dev/sdn'(out) 'ID_ATA_FEATURE_SET_HPA=1'
'ata_id --export /dev/sdn'(out) 'ID_ATA_FEATURE_SET_HPA_ENABLED=1'
'ata_id --export /dev/sdn'(out) 'ID_ATA_FEATURE_SET_PM=1'
'ata_id --export /dev/sdn'(out) 'ID_ATA_FEATURE_SET_PM_ENABLED=1'
'ata_id --export /dev/sdn'(out) 'ID_ATA_FEATURE_SET_SECURITY=1'
'ata_id --export /dev/sdn'(out) 'ID_ATA_FEATURE_SET_SECURITY_ENABLED=0'
'ata_id --export /dev/sdn'(out) 'ID_ATA_FEATURE_SET_SECURITY_ERASE_UNIT_MIN=66522'
'ata_id --export /dev/sdn'(out) 'ID_ATA_FEATURE_SET_SMART=1'
'ata_id --export /dev/sdn'(out) 'ID_ATA_FEATURE_SET_SMART_ENABLED=1'
'ata_id --export /dev/sdn'(out) 'ID_ATA_FEATURE_SET_PUIS=1'
'ata_id --export /dev/sdn'(out) 'ID_ATA_FEATURE_SET_PUIS_ENABLED=0'
'ata_id --export /dev/sdn'(out) 'ID_ATA_FEATURE_SET_APM=1'
'ata_id --export /dev/sdn'(out) 'ID_ATA_FEATURE_SET_APM_ENABLED=1'
'ata_id --export /dev/sdn'(out) 'ID_ATA_FEATURE_SET_APM_CURRENT_VALUE=254'
'ata_id --export /dev/sdn'(out) 'ID_ATA_DOWNLOAD_MICROCODE=1'
'ata_id --export /dev/sdn'(out) 'ID_ATA_SATA=1'
'ata_id --export /dev/sdn'(out) 'ID_ATA_SATA_SIGNAL_RATE_GEN2=1'
'ata_id --export /dev/sdn'(out) 'ID_ATA_SATA_SIGNAL_RATE_GEN1=1'
'ata_id --export /dev/sdn'(out) 'ID_ATA_ROTATION_RATE_RPM=7200'
'ata_id --export /dev/sdn'(out) 'ID_WWN=0x5000cca23be1dc3c'
'ata_id --export /dev/sdn'(out) 'ID_WWN_WITH_EXTENSION=0x5000cca23be1dc3c'
Process 'ata_id --export /dev/sdn' succeeded.
LINK 'disk/by-id/ata-HGST_HUH728080ALE604_ZZZZH3VX' /lib/udev/rules.d/60-persistent-storage.rules:47
IMPORT builtin 'path_id' /lib/udev/rules.d/60-persistent-storage.rules:65
LINK 'disk/by-path/pci-0000:05:00.0-sas-exp0x500605b0000272bf-phy11-lun-0' /lib/udev/rules.d/60-persistent-storage.rules:66
IMPORT builtin 'blkid' /lib/udev/rules.d/60-persistent-storage.rules:81
probe /dev/sdn raid offset=0
LINK 'disk/by-id/wwn-0x5000cca23be1dc3c' /lib/udev/rules.d/60-persistent-storage.rules:88
RUN '/usr/lib/python-dsnet-appliance/hotplug disk udev-disk-add' /etc/udev/rules.d/99-appliance-hotplug.rules:1
update old name, '/dev/disk/by-id/scsi-35000cca23be1dc3c' no longer belonging to '/devices/pci0000:00/0000:00:03.0/0000:05:00.0/host2/port-2:0/expander-2:0/port-2:0:11/end_device-2:0:11/target2:0:11/2:0:11:0/block/sdn'
no reference left, remove '/dev/disk/by-id/scsi-35000cca23be1dc3c'
handling device node '/dev/sdn', devnum=b8:208, mode=0660, uid=0, gid=6
preserve permissions /dev/sdn, 060660, uid=0, gid=6
preserve already existing symlink '/dev/block/8:208' to '../sdn'
creating link '/dev/disk/by-id/ata-HGST_HUH728080ALE604_ZZZZH3VX' to '/dev/sdn'
creating symlink '/dev/disk/by-id/ata-HGST_HUH728080ALE604_ZZZZH3VX' to '../../sdn'
found 'b8:208' claiming '/run/udev/links/\x2fdisk\x2fby-id\x2fwwn-0x5000cca23be1dc3c'
creating link '/dev/disk/by-id/wwn-0x5000cca23be1dc3c' to '/dev/sdn'
preserve already existing symlink '/dev/disk/by-id/wwn-0x5000cca23be1dc3c' to '../../sdn'
found 'b8:208' claiming '/run/udev/links/\x2fdisk\x2fby-path\x2fpci-0000:05:00.0-sas-exp0x500605b0000272bf-phy11-lun-0'
creating link '/dev/disk/by-path/pci-0000:05:00.0-sas-exp0x500605b0000272bf-phy11-lun-0' to '/dev/sdn'
preserve already existing symlink '/dev/disk/by-path/pci-0000:05:00.0-sas-exp0x500605b0000272bf-phy11-lun-0' to '../../sdn'
created db file '/run/udev/data/b8:208' for '/devices/pci0000:00/0000:00:03.0/0000:05:00.0/host2/port-2:0/expander-2:0/port-2:0:11/end_device-2:0:11/target2:0:11/2:0:11:0/block/sdn'
ACTION=add
DEVLINKS=/dev/disk/by-path/pci-0000:05:00.0-sas-exp0x500605b0000272bf-phy11-lun-0 /dev/disk/by-id/ata-HGST_HUH728080ALE604_ZZZZH3VX /dev/disk/by-id/wwn-0x5000cca23be1dc3c
DEVNAME=/dev/sdn
DEVPATH=/devices/pci0000:00/0000:00:03.0/0000:05:00.0/host2/port-2:0/expander-2:0/port-2:0:11/end_device-2:0:11/target2:0:11/2:0:11:0/block/sdn
DEVTYPE=disk
ID_ATA=1
ID_ATA_DOWNLOAD_MICROCODE=1
ID_ATA_FEATURE_SET_APM=1
ID_ATA_FEATURE_SET_APM_CURRENT_VALUE=254
ID_ATA_FEATURE_SET_APM_ENABLED=1
ID_ATA_FEATURE_SET_HPA=1
ID_ATA_FEATURE_SET_HPA_ENABLED=1
ID_ATA_FEATURE_SET_PM=1
ID_ATA_FEATURE_SET_PM_ENABLED=1
ID_ATA_FEATURE_SET_PUIS=1
ID_ATA_FEATURE_SET_PUIS_ENABLED=0
ID_ATA_FEATURE_SET_SECURITY=1
ID_ATA_FEATURE_SET_SECURITY_ENABLED=0
ID_ATA_FEATURE_SET_SECURITY_ERASE_UNIT_MIN=66522
ID_ATA_FEATURE_SET_SMART=1
ID_ATA_FEATURE_SET_SMART_ENABLED=1
ID_ATA_ROTATION_RATE_RPM=7200
ID_ATA_SATA=1
ID_ATA_SATA_SIGNAL_RATE_GEN1=1
ID_ATA_SATA_SIGNAL_RATE_GEN2=1
ID_ATA_WRITE_CACHE=1
ID_ATA_WRITE_CACHE_ENABLED=1
ID_BUS=ata
ID_MODEL=HGST_HUH728080ALE604
ID_MODEL_ENC=HGST\x20HUH728080ALE604\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
ID_PATH=pci-0000:05:00.0-sas-exp0x500605b0000272bf-phy11-lun-0
ID_PATH_TAG=pci-0000_05_00_0-sas-exp0x500605b0000272bf-phy11-lun-0
ID_REVISION=A4GNW7J0
ID_SERIAL=HGST_HUH728080ALE604_ZZZZH3VX
ID_SERIAL_SHORT=ZZZZH3VX
ID_TYPE=disk
ID_WWN=0x5000cca23be1dc3c
ID_WWN_WITH_EXTENSION=0x5000cca23be1dc3c
MAJOR=8
MINOR=208
SUBSYSTEM=block
TAGS=:systemd:
USEC_INITIALIZED=6055690
run: '/usr/lib/python-dsnet-appliance/hotplug disk udev-disk-add'
Unload module index
Unloaded link configuration context.
```

6. Query just to double check: (ID_BUS=ata, model correct, etc).
```
root@machine:~# udevadm info /dev/sdn
P: /devices/pci0000:00/0000:00:03.0/0000:05:00.0/host2/port-2:0/expander-2:0/port-2:0:11/end_device-2:0:11/target2:0:11/2:0:11:0/block/sdn
N: sdn
S: disk/by-id/ata-HGST_HUH728080ALE604_ZZZZH3VX
S: disk/by-id/wwn-0x5000cca23be1dc3c
S: disk/by-path/pci-0000:05:00.0-sas-exp0x500605b0000272bf-phy11-lun-0
E: DEVLINKS=/dev/disk/by-id/wwn-0x5000cca23be1dc3c /dev/disk/by-path/pci-0000:05:00.0-sas-exp0x500605b0000272bf-phy11-lun-0 /dev/disk/by-id/ata-HGST_HUH728080ALE604_ZZZZH3VX
E: DEVNAME=/dev/sdn
E: DEVPATH=/devices/pci0000:00/0000:00:03.0/0000:05:00.0/host2/port-2:0/expander-2:0/port-2:0:11/end_device-2:0:11/target2:0:11/2:0:11:0/block/sdn
E: DEVTYPE=disk
E: ID_ATA=1
E: ID_ATA_DOWNLOAD_MICROCODE=1
E: ID_ATA_FEATURE_SET_APM=1
E: ID_ATA_FEATURE_SET_APM_CURRENT_VALUE=254
E: ID_ATA_FEATURE_SET_APM_ENABLED=1
E: ID_ATA_FEATURE_SET_HPA=1
E: ID_ATA_FEATURE_SET_HPA_ENABLED=1
E: ID_ATA_FEATURE_SET_PM=1
E: ID_ATA_FEATURE_SET_PM_ENABLED=1
E: ID_ATA_FEATURE_SET_PUIS=1
E: ID_ATA_FEATURE_SET_PUIS_ENABLED=0
E: ID_ATA_FEATURE_SET_SECURITY=1
E: ID_ATA_FEATURE_SET_SECURITY_ENABLED=0
E: ID_ATA_FEATURE_SET_SECURITY_ERASE_UNIT_MIN=66522
E: ID_ATA_FEATURE_SET_SMART=1
E: ID_ATA_FEATURE_SET_SMART_ENABLED=1
E: ID_ATA_ROTATION_RATE_RPM=7200
E: ID_ATA_SATA=1
E: ID_ATA_SATA_SIGNAL_RATE_GEN1=1
E: ID_ATA_SATA_SIGNAL_RATE_GEN2=1
E: ID_ATA_WRITE_CACHE=1
E: ID_ATA_WRITE_CACHE_ENABLED=1
E: ID_BUS=ata
E: ID_MODEL=HGST_HUH728080ALE604
E: ID_MODEL_ENC=HGST\x20HUH728080ALE604\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
E: ID_PATH=pci-0000:05:00.0-sas-exp0x500605b0000272bf-phy11-lun-0
E: ID_PATH_TAG=pci-0000_05_00_0-sas-exp0x500605b0000272bf-phy11-lun-0
E: ID_REVISION=A4GNW7J0
E: ID_SERIAL=HGST_HUH728080ALE604_ZZZZH3VX
E: ID_SERIAL_SHORT=ZZZZH3VX
E: ID_TYPE=disk
E: ID_WWN=0x5000cca23be1dc3c
E: ID_WWN_WITH_EXTENSION=0x5000cca23be1dc3c
E: MAJOR=8
E: MINOR=208
E: SUBSYSTEM=block
E: TAGS=:systemd:
E: USEC_INITIALIZED=6055690
```

If I install the same disk into a machine using an ATA driver, this behavior changes:
```
root@machine2:~# sg_vpd -p ai /dev/sdb
ATA information VPD page:
  SAT Vendor identification: linux
  SAT Product identification: libata
  SAT Product revision level: 3.00
  Device signature indicates SATA transport
  ATA command IDENTIFY DEVICE response summary:
	model: HGST HUH728080ALE604
	serial number: ZZZZH3VX
	firmware revision: A4GNW7J0
root@machine-2:~# /lib/udev/ata_id -x /dev/sdb
ID_ATA=1
ID_TYPE=disk
ID_BUS=ata
ID_MODEL=HGST_HUH728080ALE604
ID_MODEL_ENC=HGST\x20HUH728080ALE604\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
ID_REVISION=A4GNW7J0
<truncated>
```

systemd-commit: 402fecff19d42bb06caed1a3a32262c18087b7f1
Author: Ryan Attard <frontrunner4000@gmail.com>
Date:   Fri Oct 4 07:52:49 2019 -0500
2021-10-10 03:35:18 +03:00
Boian Bonev
35e9881bb4
Install tree as a dependency for make check 2021-10-10 03:11:53 +03:00
Boian Bonev
07528ca2ce
Make testing more verbose, 3rd try 2021-10-10 02:32:47 +03:00
Boian Bonev
66703bbee7
Make testing more verbose, 2nd try 2021-10-10 02:26:35 +03:00
Boian Bonev
782a9425e9
Make testing more verbose 2021-10-10 02:13:19 +03:00
Boian Bonev
af4be561f7
Use AC_PROG_CC instead of obsoleted AC_PROG_CC_C99 2021-10-10 01:53:23 +03:00
Boian Bonev
3b1286f970
Merge pull request #198 from xfan1024/master
src/libudev/conf-files.c: fix bug of using basename
2021-10-07 01:29:07 +03:00
Jesse Smith
d16f9d5ff5 Permit eudev to work with rules which include escaped double-quotes
- Adjust parsing function to understand escaped double-quotes in rules.
- Added new test to udev-test.pl to confirm escaped quotes work.
- Bring eudev up to date with systemd pull request $6890.

This commit resolves GitHub issue #187.

This is a slightly adjusted patch/commit from systemd's udev.
Original upstream commit: 8a247d50abb5315adcc64daea10bc836c9d4c6e0
Provided by Franck Bui (GitHub user fbuihuu)
2021-10-06 08:27:54 -03:00
xfan1024
56bc3ebcbc src/libudev/conf-files.c: fix bug of using basename
BASENAME(3) Linux Programmer's Manual say:
> These functions may return pointers to statically allocated memory
> which may be overwritten by subsequent calls.

Using basename return value as key of hashmap is not safe, it may
cause that hashmap_put always return -EEXIST if hash collision happen.

Using basename return value as strcmp first and second parameters may
always return 0.

Signed-off-by: xiaofan <xiaofan@iscas.ac.cn>
2021-10-06 16:30:00 +08:00
Boian Bonev
74e8d28165
Add make check 2021-10-05 08:29:43 +03:00
Boian Bonev
c3aef5c323
Shorten action name 2021-10-05 08:20:36 +03:00
Boian Bonev
c14f496206
Change the CI icon 2021-10-05 08:08:32 +03:00
Boian Bonev
169de7af52
Add instructions for Alpine/Arch 2021-10-04 23:00:21 +03:00
Boian Bonev
36f1d6c388
Wrap all text to 80 columns
Remove instructions how to install git (assuming that is obvious)
Reword the text about git clone
Add a warning in the install section
2021-10-04 22:20:57 +03:00
Boian Bonev
4fd30d1a01
Add libtool to build dependencies 2021-10-04 22:09:36 +03:00
Boian Bonev
6a4cbd3546
Remove trailing whitespace 2021-10-04 22:08:46 +03:00
Boian Bonev
9e73a75128
Merge remote-tracking branch 'upstream/master' 2021-10-04 22:06:32 +03:00
Boian Bonev
a8a0eb73f5
Print the commands in verbose builds 2021-10-04 22:04:20 +03:00
Boian Bonev
3274500a96
Merge pull request #207 from slicer69/doc
Add build instructions
2021-10-04 01:20:13 +03:00
Jesse Smith
5e875ffa56 Remove build instructions from README
Back out build instructiosn from README as thy are now in BUILD.
2021-10-03 12:05:21 -03:00
Jesse Smith
258e2777b1 Add build instructions
- document how to install all dependencies
- document how to get source via tarball or git
- document how to build eudev
2021-10-03 12:04:12 -03:00
Boian Bonev
ea6124b724
Merge pull request #206 from ArsenArsen/master
add actions workflows to check compilation on glibc and musl (devuan, alpine)
2021-09-30 23:55:34 +03:00
Arsen Arsenović
3cd39b4113
ci: add workflow to build eudev 2021-09-30 22:37:07 +02:00
Jesse Smith
f4171bc0a8 Added clarification to build instructions.
Updated intro to build intructions to clarify build
process differs on non-Debian distros.
2021-09-30 15:19:45 -03:00
Jesse Smith
75857c0846 Adjusted instructions for installing dependencies to look nicer. 2021-09-30 13:20:54 -03:00
Jesse Smith
3c21322d12 Added new file (BUILD) with intructions for getting dependencies, configuring
eudev, and building the code.

Added blurb to README with simplified build instructions.
2021-09-30 11:20:31 -03:00
Arsen Arsenović
4b7f66ba72
autotools: make autogen.sh exit on failure 2021-09-30 01:13:25 +02:00
Boian Bonev
8b4177dc60
Update README.md 2021-09-16 15:00:44 +03:00
Boian Bonev
1d093c25fb
Update README.md 2021-09-15 00:51:52 +03:00
Boian Bonev
4aeeabe313
Update README.md 2021-09-14 23:58:49 +03:00
Anthony G. Basile
226a9f4ded src/udev/udev-event.c: clean up whitespaces
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2021-08-23 12:06:49 -04:00
Andoni Zarate
841cd0ce3f On collision rename my name to a temporal one letting others got my name...
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2021-08-23 12:03:05 -04:00
Issam E. Maghni
61d3f39975 Makefile: flag -n of ln is not POSIX
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2021-08-23 11:55:44 -04:00
Anthony G. Basile
f559dc96f4 README.md: Add deprecation notice
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2021-08-20 17:31:36 -04:00
Anthony G. Basile
be7068512c configure.ac: bump to version 3.2.10, version 243
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2021-02-09 14:12:04 -05:00
Thomas Deutschmann
9d4010a362 udevadm: hwdb: allow empty properties
Backport of afe87974dd.

Will address shown error

> Error, empty key or value ' XKB_FIXED_VARIANT' in '/usr/lib/udev/hwdb.d/60-keyboard.hwdb'

caued by recent changes in sys-apps/hwids-20201207 [Link 1].

Link 1: f30071bbeb (diff-7b9ba9c30888b1b5b1fa008f185e4efaff34eaff2c13f35c38b2ae0416cd891eR1840)
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2021-02-09 14:07:34 -05:00
Thomas Deutschmann
14748acf5e udevadm: hwdb: sync with systemd
Backports some changes from 6a34639e76.

Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2021-02-09 14:07:34 -05:00
Yann Dirson
9a240b197b
Revert bad 78-sound-card.rules update causing path_id skip
The following device properly got assigned ID_PATH with eudev 3.2.1,
but does not get it any more with recent versions:

P: /devices/platform/rt5651-sound/sound/card0
E: DEVPATH=/devices/platform/rt5651-sound/sound/card0
E: SOUND_FORM_FACTOR=internal
E: SOUND_INITIALIZED=1
E: SUBSYSTEM=sound
E: USEC_INITIALIZED=507638688065

This results in pulseaudio giving a non-stable card name by using a
device number.

I tracked the problem to commit
47367bc4df, which changed (without
explaining why it does so) the rules for "internal" sound cards,
notably preventing `IMPORT{builtin}="path_id"` from being reached.

Signed-off-by: Yann Dirson <yann@blade-group.com>
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2021-01-14 12:52:26 -05:00
Issam E. Maghni
fa0ea89c14
configure: test -a|o is not POSIX
Fixes `test: too many arguments` when building Linux-PAM using sbase.
This is due to a non-POSIX syntax test ... -a ... and test ... -o ....

> The XSI extensions specifying the -a and -o binary primaries and the
> '(' and ')' operators have been marked obsolescent.

See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2020-12-22 09:58:51 -05:00