Skip to content

exposing cntlid #731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion sysfs/class_nvme.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type NVMeDevice struct {
Model string // /sys/class/nvme/<Name>/model
State string // /sys/class/nvme/<Name>/state
FirmwareRevision string // /sys/class/nvme/<Name>/firmware_rev
ControllerID string // /sys/class/nvme/<Name>/cntlid
}

// NVMeClass is a collection of every NVMe device in /sys/class/nvme.
Expand Down Expand Up @@ -67,7 +68,7 @@ func (fs FS) parseNVMeDevice(name string) (*NVMeDevice, error) {
path := fs.sys.Path(nvmeClassPath, name)
device := NVMeDevice{Name: name}

for _, f := range [...]string{"firmware_rev", "model", "serial", "state"} {
for _, f := range [...]string{"firmware_rev", "model", "serial", "state", "cntlid"} {
name := filepath.Join(path, f)
value, err := util.SysReadFile(name)
if err != nil {
Expand All @@ -83,6 +84,8 @@ func (fs FS) parseNVMeDevice(name string) (*NVMeDevice, error) {
device.Serial = value
case "state":
device.State = value
case "cntlid":
device.ControllerID = value
}
}

Expand Down
1 change: 1 addition & 0 deletions sysfs/class_nvme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func TestNVMeClass(t *testing.T) {
Model: "Samsung SSD 970 PRO 512GB",
Serial: "S680HF8N190894I",
State: "live",
ControllerID: "1997",
},
}

Expand Down
5 changes: 5 additions & 0 deletions testdata/fixtures.ttar
Original file line number Diff line number Diff line change
Expand Up @@ -6412,6 +6412,11 @@ Mode: 755
Directory: fixtures/sys/class/nvme/nvme0
Mode: 755
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: fixtures/sys/class/nvme/nvme0/cntlid
Lines: 1
1997
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: fixtures/sys/class/nvme/nvme0/firmware_rev
Lines: 1
1B2QEXP7
Expand Down