From 07581f55bfa959fcb15ec7d72cf4ddbce06f33d8 Mon Sep 17 00:00:00 2001 From: Manuel Mendez Date: Mon, 3 Jun 2024 14:53:13 -0400 Subject: [PATCH] nvme: Store discovered capabilities in common.Capabilities Needed so we can figure out the correct wipe functions later on. --- utils/nvme.go | 19 +++++++++---------- utils/nvme_test.go | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/utils/nvme.go b/utils/nvme.go index 02008339..10787e92 100644 --- a/utils/nvme.go +++ b/utils/nvme.go @@ -108,16 +108,15 @@ func (n *Nvme) Drives(ctx context.Context) ([]*model.Drive, error) { drives[i] = model.NewDrive(&common.Drive{ Common: common.Common{ - LogicalName: d.DevicePath, - Serial: d.SerialNumber, - Vendor: vendor, - Model: dModel, - ProductName: d.ProductName, - Description: d.ModelNumber, - Firmware: &common.Firmware{ - Installed: d.Firmware, - }, - Metadata: metadata, + LogicalName: d.DevicePath, + Serial: d.SerialNumber, + Vendor: vendor, + Model: dModel, + ProductName: d.ProductName, + Description: d.ModelNumber, + Firmware: &common.Firmware{Installed: d.Firmware}, + Capabilities: capabilitiesFound, + Metadata: metadata, }, }, nil) } diff --git a/utils/nvme_test.go b/utils/nvme_test.go index 0dafc0e0..21822263 100644 --- a/utils/nvme_test.go +++ b/utils/nvme_test.go @@ -19,6 +19,15 @@ func Test_NvmeComponents(t *testing.T) { expected := []*model.Drive{ {Drive: common.Drive{Common: common.Common{ LogicalName: "/dev/nvme0n1", Serial: "Z9DF70I8FY3L", Vendor: "TOSHIBA", Model: "KXG60ZNV256G TOSHIBA", Description: "KXG60ZNV256G TOSHIBA", Firmware: &common.Firmware{Installed: "AGGA4104"}, ProductName: "NULL", + Capabilities: []*common.Capability{ + {Name: "fmns", Description: "Format Applies to All/Single Namespace(s) (t:All, f:Single)", Enabled: false}, + {Name: "cens", Description: "Crypto Erase Applies to All/Single Namespace(s) (t:All, f:Single)", Enabled: false}, + {Name: "cese", Description: "Crypto Erase Supported as part of Secure Erase", Enabled: true}, + {Name: "cer", Description: "Crypto Erase Sanitize Operation Supported", Enabled: false}, + {Name: "ber", Description: "Block Erase Sanitize Operation Supported", Enabled: false}, + {Name: "owr", Description: "Overwrite Sanitize Operation Supported", Enabled: false}, + {Name: "ndi", Description: "No-Deallocate After Sanitize bit in Sanitize command Supported", Enabled: false}, + }, Metadata: map[string]string{ "Block Erase Sanitize Operation Supported": "false", "Crypto Erase Applies to All/Single Namespace(s) (t:All, f:Single)": "false", @@ -31,6 +40,15 @@ func Test_NvmeComponents(t *testing.T) { }}}, {Drive: common.Drive{Common: common.Common{ LogicalName: "/dev/nvme1n1", Serial: "Z9DF70I9FY3L", Vendor: "TOSHIBA", Model: "KXG60ZNV256G TOSHIBA", Description: "KXG60ZNV256G TOSHIBA", Firmware: &common.Firmware{Installed: "AGGA4104"}, ProductName: "NULL", + Capabilities: []*common.Capability{ + {Name: "fmns", Description: "Format Applies to All/Single Namespace(s) (t:All, f:Single)", Enabled: false}, + {Name: "cens", Description: "Crypto Erase Applies to All/Single Namespace(s) (t:All, f:Single)", Enabled: false}, + {Name: "cese", Description: "Crypto Erase Supported as part of Secure Erase", Enabled: true}, + {Name: "cer", Description: "Crypto Erase Sanitize Operation Supported", Enabled: false}, + {Name: "ber", Description: "Block Erase Sanitize Operation Supported", Enabled: false}, + {Name: "owr", Description: "Overwrite Sanitize Operation Supported", Enabled: false}, + {Name: "ndi", Description: "No-Deallocate After Sanitize bit in Sanitize command Supported", Enabled: false}, + }, Metadata: map[string]string{ "Block Erase Sanitize Operation Supported": "false", "Crypto Erase Applies to All/Single Namespace(s) (t:All, f:Single)": "false",