teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone
Blob Blame History Raw
From af5732176cb192206f555a1c00dd5431a757367f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Wed, 22 Jul 2015 00:23:47 -0400
Subject: [PATCH] ata_id: unreverse WWN identifier

An endianness conversion was lost in 6024a6e302bad6bcf073fa84a41a6123305dc845.
Restore it. Now ata_id and scsi_id output match.

https://bugzilla.redhat.com/show_bug.cgi?id=1227503

Cherry-picked from: 01f61d331bb5038f0c877ac03c54333328b6ea28
Resolves: #1308795
---
 src/udev/ata_id/ata_id.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c
index b6f28c6..4adec44 100644
--- a/src/udev/ata_id/ata_id.c
+++ b/src/udev/ata_id/ata_id.c
@@ -638,10 +638,20 @@ int main(int argc, char *argv[])
                  * All other values are reserved.
                  */
                 word = identify.wyde[108];
-                if ((word & 0xf000) == 0x5000)
+                if ((word & 0xf000) == 0x5000) {
+                        uint64_t wwwn;
+
+                        wwwn   = identify.wyde[108];
+                        wwwn <<= 16;
+                        wwwn  |= identify.wyde[109];
+                        wwwn <<= 16;
+                        wwwn  |= identify.wyde[110];
+                        wwwn <<= 16;
+                        wwwn  |= identify.wyde[111];
                         printf("ID_WWN=0x%1$" PRIx64 "\n"
                                "ID_WWN_WITH_EXTENSION=0x%1$" PRIx64 "\n",
-                               identify.octa[108/4]);
+                               wwwn);
+                }
 
                 /* from Linux's include/linux/ata.h */
                 if (identify.wyde[0] == 0x848a ||