Skip to content

Commit 450188e

Browse files
authored
update wwnToDevicePath for nvme (dell#42)
1 parent cda8402 commit 450188e

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

gofsutil_mount_unix.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,18 @@ func (fs *FS) wwnToDevicePath(
205205
symlinkPath := fmt.Sprintf("%s%s", MultipathDevDiskByIDPrefix, wwn)
206206
devPath, err := os.Readlink(symlinkPath)
207207

208-
// Look for regular path device.
208+
// Look for nvme path device.
209209
if err != nil || devPath == "" {
210-
symlinkPath = fmt.Sprintf("/dev/disk/by-id/wwn-0x%s", wwn)
210+
symlinkPath = fmt.Sprintf("/dev/disk/by-id/nvme-eui.%s", wwn)
211211
devPath, err = os.Readlink(symlinkPath)
212-
if err != nil {
213-
log.Printf("Check for disk path %s not found", symlinkPath)
214-
return "", "", err
212+
if err != nil || devPath == "" {
213+
// Look for normal path device
214+
symlinkPath = fmt.Sprintf("/dev/disk/by-id/wwn-0x%s", wwn)
215+
devPath, err = os.Readlink(symlinkPath)
216+
if err != nil {
217+
log.Printf("Check for disk path %s not found", symlinkPath)
218+
return "", "", err
219+
}
215220
}
216221
}
217222
components := strings.Split(devPath, "/")

gofsutil_unix_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ func TestWWNToDevicePath(t *testing.T) {
147147
wwn: "60570970000197900046533030394146",
148148
result: "/dev/mydevb",
149149
},
150+
{
151+
src: "/dev/disk/by-id/nvme-eui.12635330303134340000976000012000",
152+
tgt: "../../mydevb",
153+
wwn: "12635330303134340000976000012000",
154+
result: "/dev/mydevb",
155+
},
150156
}
151157
for _, tt := range tests {
152158
t.Run("", func(_ *testing.T) {

0 commit comments

Comments
 (0)