Skip to content

Commit

Permalink
update wwnToDevicePath for nvme (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
delldubey authored Jun 19, 2024
1 parent cda8402 commit 450188e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
15 changes: 10 additions & 5 deletions gofsutil_mount_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,18 @@ func (fs *FS) wwnToDevicePath(
symlinkPath := fmt.Sprintf("%s%s", MultipathDevDiskByIDPrefix, wwn)
devPath, err := os.Readlink(symlinkPath)

// Look for regular path device.
// Look for nvme path device.
if err != nil || devPath == "" {
symlinkPath = fmt.Sprintf("/dev/disk/by-id/wwn-0x%s", wwn)
symlinkPath = fmt.Sprintf("/dev/disk/by-id/nvme-eui.%s", wwn)
devPath, err = os.Readlink(symlinkPath)
if err != nil {
log.Printf("Check for disk path %s not found", symlinkPath)
return "", "", err
if err != nil || devPath == "" {
// Look for normal path device
symlinkPath = fmt.Sprintf("/dev/disk/by-id/wwn-0x%s", wwn)
devPath, err = os.Readlink(symlinkPath)
if err != nil {
log.Printf("Check for disk path %s not found", symlinkPath)
return "", "", err
}
}
}
components := strings.Split(devPath, "/")
Expand Down
6 changes: 6 additions & 0 deletions gofsutil_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ func TestWWNToDevicePath(t *testing.T) {
wwn: "60570970000197900046533030394146",
result: "/dev/mydevb",
},
{
src: "/dev/disk/by-id/nvme-eui.12635330303134340000976000012000",
tgt: "../../mydevb",
wwn: "12635330303134340000976000012000",
result: "/dev/mydevb",
},
}
for _, tt := range tests {
t.Run("", func(_ *testing.T) {
Expand Down

0 comments on commit 450188e

Please sign in to comment.