fix(disk): correctly replace /dev in /dev/mapper

Only replace the first instance of /dev in a /dev/mapper string.
Otherwise, if an LVM group is named dev it will replace that as well.

fixes: #1411
pull/1412/head
Josh Powers 2 years ago
parent 0494d7f0b9
commit 7645051510
No known key found for this signature in database
GPG Key ID: A2FA14A470214D78

@ -341,7 +341,7 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro
}
if strings.HasPrefix(d.Device, "/dev/mapper/") {
devpath, err := filepath.EvalSymlinks(common.HostDev(strings.Replace(d.Device, "/dev", "", -1)))
devpath, err := filepath.EvalSymlinks(common.HostDev(strings.Replace(d.Device, "/dev", "", 1)))
if err == nil {
d.Device = devpath
}

Loading…
Cancel
Save