diff --git a/patches/gopsutil/v3/disk/disk.go b/patches/gopsutil/v3/disk/disk.go index 5f172b11f37ea..4eb8d99889831 100644 --- a/patches/gopsutil/v3/disk/disk.go +++ b/patches/gopsutil/v3/disk/disk.go @@ -3,7 +3,6 @@ package disk import ( "context" "encoding/json" - "modernc.org/cc/v3" "github.com/shirou/gopsutil/v3/internal/common" ) @@ -25,6 +24,7 @@ type UsageStat struct { type PartitionStat struct { Device string `json:"device"` + Source string `json:"source,omitempty"` Mountpoint string `json:"mountpoint"` Fstype string `json:"fstype"` Opts []string `json:"opts"` diff --git a/patches/gopsutil/v3/disk/disk_linux.go b/patches/gopsutil/v3/disk/disk_linux.go index 7accc8f3ae92c..cf87ed5bd4efd 100644 --- a/patches/gopsutil/v3/disk/disk_linux.go +++ b/patches/gopsutil/v3/disk/disk_linux.go @@ -330,6 +330,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))) if err == nil { + d.Source = d.Device d.Device = devpath } } diff --git a/patches/gopsutil/v3/disk/disk_test.go b/patches/gopsutil/v3/disk/disk_test.go index 5adae5ca3df3c..d8b6ff77f2c06 100644 --- a/patches/gopsutil/v3/disk/disk_test.go +++ b/patches/gopsutil/v3/disk/disk_test.go @@ -114,6 +114,17 @@ func TestDiskPartitionStat_String(t *testing.T) { if e != fmt.Sprintf("%v", v) { t.Errorf("DiskUsageStat string is invalid: %v", v) } + v = PartitionStat{ + Device: "dm-1", + Source: "vg0--lv0", + Mountpoint: "/", + Fstype: "ext4", + Opts: []string{"ro"}, + } + e = `{"device":"dm-1","source":"vg0--lv0","mountpoint":"/","fstype":"ext4","opts":"ro"}` + if e != fmt.Sprintf("%v", v) { + t.Errorf("DiskUsageStat string is invalid: %v", v) + } } func TestDiskIOCountersStat_String(t *testing.T) {