我正在开发一款具有 ARM cortex-a53 的嵌入式主板。为了在此主板上添加对“udevadm”的支持,我下载了“buildroot-2022.02”(https://buildroot.org/downloads/buildroot-2022.02.tar.gz) 并为我的平台进行交叉编译。
当我跑步时乌德瓦德命令我得到了以下输出。
root@root:~$ udevadm info /dev/sda
P: /devices/platform/2f0b80000.sata/ata1/host0/target0:0:0/0:0:0:0/block/sda
N: sda
E: DEVNAME=/dev/sda
E: DEVPATH=/devices/platform/2f0b80000.sata/ata1/host0/target0:0:0/0:0:0:0/block/sda
E: DEVTYPE=disk
E: ID_PART_TABLE_TYPE=gpt
E: ID_PART_TABLE_UUID=c3723b53-1411-48bc-8eb4-7481fb489854
E: MAJOR=8
E: MINOR=0
E: SUBSYSTEM=block
E: USEC_INITIALIZED=6485105
我没有得到“ID总线“ 范围。
当我运行“udevadm 测试 /sys/class/block/sda“命令我得到以下 o/p
root@root:~$ udevadm test /sys/class/block/sda
calling: test
version 3.2.11
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.
/etc/udev/hwdb.bin does not exist, please run udevadm hwdb --update
Load module index
timestamp of '/etc/udev/rules.d' changed
timestamp of '/run/udev/rules.d' changed
Reading rules file: /lib/udev/rules.d/50-udev-default.rules
specified group 'tty' unknown
specified group 'dialout' unknown
specified group 'kmem' unknown
specified group 'input' unknown
specified group 'video' unknown
specified group 'audio' unknown
specified group 'lp' unknown
specified group 'disk' unknown
specified group 'cdrom' unknown
specified group 'tape' unknown
specified group 'kvm' unknown
Reading rules file: /lib/udev/rules.d/60-block.rules
Reading rules file: /lib/udev/rules.d/60-cdrom_id.rules
Reading rules file: /lib/udev/rules.d/60-drm.rules
Reading rules file: /lib/udev/rules.d/60-evdev.rules
Reading rules file: /lib/udev/rules.d/60-input-id.rules
Reading rules file: /lib/udev/rules.d/60-persistent-alsa.rules
Reading rules file: /lib/udev/rules.d/60-persistent-input.rules
Reading rules file: /lib/udev/rules.d/60-persistent-storage-tape.rules
Reading rules file: /lib/udev/rules.d/60-persistent-storage.rules
Reading rules file: /lib/udev/rules.d/60-persistent-v4l.rules
Reading rules file: /lib/udev/rules.d/60-sensor.rules
Reading rules file: /lib/udev/rules.d/60-serial.rules
Reading rules file: /lib/udev/rules.d/64-btrfs.rules
Reading rules file: /lib/udev/rules.d/70-joystick.rules
Reading rules file: /lib/udev/rules.d/70-mouse.rules
Reading rules file: /lib/udev/rules.d/70-touchpad.rules
Reading rules file: /lib/udev/rules.d/75-net-description.rules
Reading rules file: /lib/udev/rules.d/75-probe_mtd.rules
Reading rules file: /lib/udev/rules.d/78-sound-card.rules
Reading rules file: /lib/udev/rules.d/80-drivers.rules
Reading rules file: /lib/udev/rules.d/80-net-name-slot.rules
Reading rules file: /etc/udev/rules.d/udev.rules
rules contain 24576 bytes tokens (2048 * 12 bytes), 8335 bytes strings
1096 strings (14316 bytes), 690 de-duplicated (6388 bytes), 407 trie nodes used
GROUP 0 /lib/udev/rules.d/50-udev-default.rules:59
IMPORT 'ata_id --export /dev/sda' /lib/udev/rules.d/60-persistent-storage.rules:38
starting 'ata_id --export /dev/sda'
'ata_id --export /dev/sda'(err) '/lib/udev/ata_id: error while loading shared libraries: libblkid.so.1: cannot open shared object file: No such file or directory'
'ata_id --export /dev/sda' [1728] exit with return code 127
IMPORT 'scsi_id --export --whitelisted -d /dev/sda' /lib/udev/rules.d/60-persistent-storage.rules:50
starting 'scsi_id --export --whitelisted -d /dev/sda'
'scsi_id --export --whitelisted -d /dev/sda'(err) '/lib/udev/scsi_id: error while loading shared libraries: libblkid.so.1: cannot open shared object file: No such file or direc
tory'
'scsi_id --export --whitelisted -d /dev/sda' [1729] exit with return code 127
IMPORT builtin 'path_id' /lib/udev/rules.d/60-persistent-storage.rules:73
IMPORT builtin 'path_id' returned non-zero
IMPORT builtin 'blkid' /lib/udev/rules.d/60-persistent-storage.rules:90
probe /dev/sda raid offset=0
handling device node '/dev/sda', devnum=b8:0, mode=0600, uid=0, gid=0
preserve permissions /dev/sda, 060600, uid=0, gid=0
preserve already existing symlink '/dev/block/8:0' to '../sda'
created db file '/run/udev/data/b8:0' for '/devices/platform/2f0b90000.sata/ata2/host1/target1:0:0/1:0:0:0/block/sda'
ACTION=add
DEVNAME=/dev/sda
DEVPATH=/devices/platform/2f0b90000.sata/ata2/host1/target1:0:0/1:0:0:0/block/sda
DEVTYPE=disk
ID_PART_TABLE_TYPE=gpt
ID_PART_TABLE_UUID=c54841fb-8cb1-424c-a579-900948226b73
MAJOR=8
MINOR=0
SUBSYSTEM=block
USEC_INITIALIZED=6649798
Unload module index
root@root:~$
上述 o/p 的总结是,以下规则写在“/lib/udev/rules.d/60-persistent-storage.rules“文件正在尝试执行”ata_id --导出 /dev/sda“命令并出现错误。
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", IMPORT{program}="ata_id --export $devnode"
我得到的错误是
starting 'ata_id --export /dev/sda'
'ata_id --export /dev/sda'(err) '/lib/udev/ata_id: error while loading shared libraries: libblkid.so.1: cannot open shared object file: No such file or directory'
'ata_id --export /dev/sda' [1728] exit with return code 127
但当我运行“ata_id --导出 /dev/sda“命令从终端我得到了以下 o/p。它没有显示错误
root@root:~$ ata_id --export /dev/sda
ID_ATA=1
ID_TYPE=disk
ID_BUS=ata
ID_MODEL=ST1000NM0011
ID_MODEL_ENC=ST1000NM0011\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2 0\x20\x20\x20\x20\x20\x20\x20\x20\x20
ID_REVISION=PA07
ID_SERIAL=ST1000NM0011_Z1N2YF10
ID_SERIAL_SHORT=Z1N2YF10
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=150
ID_ATA_FEATURE_SET_SECURITY_ENHANCED_ERASE_UNIT_MIN=150
ID_ATA_FEATURE_SET_SMART=1
ID_ATA_FEATURE_SET_SMART_ENABLED=1
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=0x5000c5004ecabf57
ID_WWN_WITH_EXTENSION=0x5000c5004ecabf57
root@root:~$
当我在 ata_id 上运行 ldd 命令时,它不知道任何链接问题。
root@root:~$ ldd /lib/udev/ata_id
linux-vdso.so.1 (0x0000007fbd357000)
libblkid.so.1 => /lib/libblkid.so.1 (0x0000007fbd2a5000)
libkmod.so.2 => /lib/libkmod.so.2 (0x0000007fbd281000)
libc.so.6 => /lib/libc.so.6 (0x0000007fbd117000)
/lib/ld-linux-aarch64.so.1 (0x0000007fbd329000)
root@root:~$ ls -l /lib/libblkid.so.1*
lrwxrwxrwx 1 root root 17 Sep 30 05:19 /lib/libblkid.so.1 -> libblkid.so.1.1.0
-rwxr-xr-x 1 root root 316112 Nov 29 12:01 /lib/libblkid.so.1.1.0
root@root:~$
所以我的问题是,为什么 udev 规则会引发错误?