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 4, 2024
1 parent 9bbce07 commit 07581f5
Show file tree
Hide file tree
Showing 2 changed files with 27 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 @@ -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)
}
Expand Down
18 changes: 18 additions & 0 deletions utils/nvme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 07581f5

Please sign in to comment.