From 54eefbca11ba8214bcfbcd6b18f8ff8f248e8fe1 Mon Sep 17 00:00:00 2001 From: chrfranke <chrfranke@4ea69e1a-61f1-4043-bf83-b5c94c648137> Date: Sun, 22 May 2022 13:08:08 +0000 Subject: [PATCH] ataprint.cpp: Print Master Password ID if set to non-default value. git-svn-id: https://svn.code.sf.net/p/smartmontools/code/trunk@5384 4ea69e1a-61f1-4043-bf83-b5c94c648137 --- smartmontools/ChangeLog | 4 ++++ smartmontools/ataprint.cpp | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/smartmontools/ChangeLog b/smartmontools/ChangeLog index cfd757c6b..5d5ed2c35 100644 --- a/smartmontools/ChangeLog +++ b/smartmontools/ChangeLog @@ -1,5 +1,9 @@ $Id$ +2022-05-22 Christian Franke <franke@computer.org> + + ataprint.cpp: Print Master Password ID if set to non-default value. + 2022-05-22 Eaton Zveare <eaton@eaton-works.com> ataprint.cpp: Add master_password_id to ata_security json output diff --git a/smartmontools/ataprint.cpp b/smartmontools/ataprint.cpp index fc984e84d..d3d480974 100644 --- a/smartmontools/ataprint.cpp +++ b/smartmontools/ataprint.cpp @@ -4,7 +4,7 @@ * Home page of code is: https://www.smartmontools.org * * Copyright (C) 2002-11 Bruce Allen - * Copyright (C) 2008-21 Christian Franke + * Copyright (C) 2008-22 Christian Franke * Copyright (C) 1999-2000 Michael Cornwell <cornwell@acm.org> * * SPDX-License-Identifier: GPL-2.0-or-later @@ -3277,7 +3277,13 @@ static void print_ata_security_status(const char * msg, unsigned short state, un } } - jout("%s%s%s%s%s\n", msg, s1, s2, s3, s4); + // Print Master Password ID if set to non-default value + // (0x0000, 0xffff: unsupported, 0xfffe: default) + char s5[32] = ""; + if (0x0000 < master_password_id && master_password_id < 0xfffe) + snprintf(s5, sizeof(s5), ", Master PW ID: 0x%04x", master_password_id); + + jout("%s%s%s%s%s%s\n", msg, s1, s2, s3, s4, s5); json::ref jref = jglb["ata_security"]; jref["state"] = state; -- GitLab