Skip to content

Commit

Permalink
nvme: Store discovered capabilities in common.Capabilities
Browse files Browse the repository at this point in the history
Needed so we can figure out the correct wipe functions later on.
  • Loading branch information
mmlb committed Jun 3, 2024
1 parent 7022b5b commit 80a3162
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
19 changes: 9 additions & 10 deletions utils/nvme.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,15 @@ func (n *Nvme) Drives(ctx context.Context) ([]*drive.Drive, error) {

drives[i] = drive.New(&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)
}
Expand Down
19 changes: 19 additions & 0 deletions utils/nvme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,19 @@ import (
)

func Test_NvmeComponents(t *testing.T) {
// nolint:dupl
expected := []*drive.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",
Expand All @@ -30,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",
Expand Down

0 comments on commit 80a3162

Please sign in to comment.