Skip to content

Commit

Permalink
fix(disk): correctly replace /dev in /dev/mapper
Browse files Browse the repository at this point in the history
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: shirou#1411
  • Loading branch information
powersj committed Feb 1, 2023
1 parent 0494d7f commit 7645051
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion disk/disk_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 7645051

Please sign in to comment.