]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: even if a device is a zac device, scsi-$ID_SERIAL will be reserved for it ...
author我超厉害 <524413304@qq.com>
Tue, 16 Jan 2024 05:57:07 +0000 (13:57 +0800)
committerGitHub <noreply@github.com>
Tue, 16 Jan 2024 05:57:07 +0000 (14:57 +0900)
Co-authored-by: wangyuhang <wangyuhang27@huawei.com>
rules.d/60-persistent-storage.rules.in
src/udev/ata_id/ata_id.c

index 96b888fdffbff2e150bdcdfac82d9ac677a7f7c5..390c6e00343dbc87ba1b78284af97386981295c9 100644 (file)
@@ -59,6 +59,8 @@ KERNEL=="vd*", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="di
 
 # ATA
 KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", IMPORT{program}="ata_id --export $devnode"
+KERNEL=="sd*[!0-9]|sr*", ENV{ID_BUS}=="ata", ENV{ID_ATA_PERIPHERAL_DEVICE_TYPE}=="20", PROGRAM="scsi_id -u -g $devnode", \
+  SYMLINK+="disk/by-id/scsi-$result$env{.PART_SUFFIX}"
 
 # ATAPI devices (SPC-3 or later)
 KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{type}=="5", ATTRS{scsi_level}=="[6-9]*", IMPORT{program}="ata_id --export $devnode"
index 0b1f0b7157df4fe6861746c0ad0b4cc96886a9fc..4dd7e54973ab11c247448a87cffd1ec4a09d6718 100644 (file)
@@ -298,7 +298,8 @@ static void disk_identify_fixup_uint16(uint8_t identify[512], unsigned offset_wo
  * non-zero with errno set.
  */
 static int disk_identify(int fd,
-                         uint8_t out_identify[512]) {
+                         uint8_t out_identify[512],
+                         int *ret_peripheral_device_type) {
         uint8_t inquiry_buf[36];
         int peripheral_device_type, r;
 
@@ -358,6 +359,9 @@ static int disk_identify(int fd,
         if (all_nul_bytes)
                 return log_debug_errno(SYNTHETIC_ERRNO(EIO), "IDENTIFY data is all zeroes.");
 
+        if (ret_peripheral_device_type)
+                *ret_peripheral_device_type = peripheral_device_type;
+
         return 0;
 }
 
@@ -407,7 +411,7 @@ static int run(int argc, char *argv[]) {
         char model[41], model_enc[256], serial[21], revision[9];
         _cleanup_close_ int fd = -EBADF;
         uint16_t word;
-        int r;
+        int r, peripheral_device_type = -1;
 
         log_set_target(LOG_TARGET_AUTO);
         udev_parse_config();
@@ -422,7 +426,7 @@ static int run(int argc, char *argv[]) {
         if (fd < 0)
                 return log_error_errno(errno, "Cannot open %s: %m", arg_device);
 
-        if (disk_identify(fd, identify.byte) >= 0) {
+        if (disk_identify(fd, identify.byte, &peripheral_device_type) >= 0) {
                 /*
                  * fix up only the fields from the IDENTIFY data that we are going to
                  * use and copy it into the hd_driveid struct for convenience
@@ -615,6 +619,9 @@ static int run(int argc, char *argv[]) {
                 if (IN_SET(identify.wyde[0], 0x848a, 0x844a) ||
                     (identify.wyde[83] & 0xc004) == 0x4004)
                         printf("ID_ATA_CFA=1\n");
+
+                if (peripheral_device_type >= 0)
+                        printf("ID_ATA_PERIPHERAL_DEVICE_TYPE=%d\n", peripheral_device_type);
         } else {
                 if (serial[0] != '\0')
                         printf("%s_%s\n", model, serial);