From 546e73f82306f73163ce47e675da3e6e8dc751c7 Mon Sep 17 00:00:00 2001
From: chrfranke <chrfranke@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Sun, 22 May 2022 12:54:20 +0000
Subject: [PATCH] ataprint.cpp: Add master_password_id to ata_security json
 output.

Patch by Eaton Zveare (GH pull/134).

git-svn-id: https://svn.code.sf.net/p/smartmontools/code/trunk@5383 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 smartmontools/ChangeLog    | 5 +++++
 smartmontools/ataprint.cpp | 5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/smartmontools/ChangeLog b/smartmontools/ChangeLog
index 1690c4848..cfd757c6b 100644
--- a/smartmontools/ChangeLog
+++ b/smartmontools/ChangeLog
@@ -1,5 +1,10 @@
 $Id$
 
+2022-05-22  Eaton Zveare  <eaton@eaton-works.com>
+
+	ataprint.cpp: Add master_password_id to ata_security json output
+	(GH pull/134).
+
 2022-05-08  Gabriele Pohl  <contact@dipohl.de>
 
 	drivedb.h:
diff --git a/smartmontools/ataprint.cpp b/smartmontools/ataprint.cpp
index 3a64c8b30..fc984e84d 100644
--- a/smartmontools/ataprint.cpp
+++ b/smartmontools/ataprint.cpp
@@ -3237,7 +3237,7 @@ static void print_apm_level(const char * msg, int level)
   }
 }
 
-static void print_ata_security_status(const char * msg, unsigned short state)
+static void print_ata_security_status(const char * msg, unsigned short state, unsigned short master_password_id)
 {
   // Table 6 of T13/2015-D (ACS-2) Revision 7, June 22, 2011
   if (!(state & 0x0001)) {
@@ -3291,6 +3291,7 @@ static void print_ata_security_status(const char * msg, unsigned short state)
     if (locked)
       jref["pw_attempts_exceeded"] = !!(state & 0x0010);
   }
+  jref["master_password_id"] = master_password_id;
 }
 
 static void print_standby_timer(const char * msg, int timer, const ata_identify_device & drive)
@@ -3653,7 +3654,7 @@ int ataPrintMain (ata_device * device, const ata_print_options & options)
 
   // Print ATA Security status
   if (options.get_security)
-    print_ata_security_status("ATA Security is:  ", word128);
+    print_ata_security_status("ATA Security is:  ", word128, drive.words088_255[92-88]);
 
   // Print write cache reordering status
   if (options.sct_wcache_reorder_get) {
-- 
GitLab