gopsutil icon indicating copy to clipboard operation
gopsutil copied to clipboard

Different file system types from Partitions() and Usage()

Open sebstyle opened this issue 3 years ago • 1 comments

Describe the bug On my Linux machine Partitions() reports ext4 correctly but Usage() reports ext2/ext3 incorrectly To Reproduce

// Loop devices (snap) filtered out

disk.Partitions(false): [{"device":"/dev/nvme0n1p2","mountpoint":"/","fstype":"ext4","opts":["rw","relatime"]} {"device":"/dev/nvme0n1p1","mountpoint":"/boot/efi","fstype":"vfat","opts":["rw","relatime"]} {"device":"/dev/nvme0n1p3","mountpoint":"/mnt/storage","fstype":"ext4","opts":["rw","relatime"]}]

// Paths obtained from disk.Partitions()

disk.Usage(/): {"path":"/","fstype":"ext2/ext3","total":97891741696,"free":32866172928,"used":60008792064,"usedPercent":64.6124518799754,"inodesTotal":6111232,"inodesUsed":364489,"inodesFree":5746743,"inodesUsedPercent":5.964247470886394}
disk.Usage(/boot/efi): {"path":"/boot/efi","fstype":"msdos","total":535805952,"free":527626240,"used":8179712,"usedPercent":1.5266183530562945,"inodesTotal":0,"inodesUsed":0,"inodesFree":0,"inodesUsedPercent":0}
disk.Usage(/mnt/storage): {"path":"/mnt/storage","fstype":"ext2/ext3","total":368039882752,"free":262375129088,"used":86898024448,"usedPercent":24.87967470968058,"inodesTotal":22888448,"inodesUsed":53410,"inodesFree":22835038,"inodesUsedPercent":0.23334915499731568}


Expected behavior I would expect them to be the same

Environment (please complete the following information):

Ubuntu 20.04.2 LTS (Focal Fossa)
5.8.0-44-generic #50~20.04.1-Ubuntu SMP
go1.13.8 linux/amd64
github.com/shirou/gopsutil/v3/disk

sebstyle avatar Mar 15 '21 21:03 sebstyle

This looks like a known limitation of statfs: https://unix.stackexchange.com/a/274030

bt90 avatar Sep 25 '21 06:09 bt90