Commit Graph

82 Commits (fec0b2fcc641a9a7cb490800be088566fc18b2c0)

Author SHA1 Message Date
shirou bc060cc227 add SPDX License, remove old build tag, and replace import
shirou ce11e9ca5f [linux][disk]: fix Rdev cast
Ville Skyttä adaeba09d9 feat(disk): look for filesystem labels from udev on Linux
shirou 0665cafa1b chore: replace deprecated ioutil package to os and io
Greg Dallavalle 0a23dc690f comment cleanup
Greg Dallavalle b2d1f05f08 update comment
Greg aa4c84c6b3
Update disk/disk_linux.go
Co-authored-by: shirou <shirou.faw@gmail.com>
Greg Dallavalle 0ca6266393 fix IOCounters() SerialNumber enumeration
Antoine Toulme 38b94668ea allow to pass context values to override environment variables
Matthieu MOREL 1fb1e3e3e6 ci(lint): correct gci linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Josh Powers 7645051510
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
arstercz f6dc96c30e follow the psutil principles, do nothing if can not find root device
arstercz d52b97cd25 fix disk readlink error which system boot by nfs mount
Jamie Strandboge 9e6e627ec8 [disk][linux] add HOST_PROC_MOUNTINFO, closes #1271
The changes to gopsutil for reading /proc/1/mountinfo affected
applications running under restricted environments that disallows access
to /proc/1/mountinfo. #1159 was filed for android but other restricted
environments are also affected (eg, snaps)). The fix for #1159 addressed
the application behavior to work under confinement for non-android as
well. However, depending on the system, the attempt to read
/proc/1/mountinfo could cause a sandbox denial in the logs which can be
quite noisy if using gopsutil as part of a monitoring solution that
polls often.

This introduces HOST_PROC_MOUNTINFO to force reading from the parent dir
of the specified path instead of first trying /proc/1. When unset,
retain the current behavior with fallback. This allows people, for
example, to set HOST_PROC_MOUNTINFO=/proc/self/mountinfo when gopsutil
is running under these restricted environments.

This change updates the private readMountFile() to use a root path
instead of a root subpath, and adjusts PartitionsWithContext() to set
the root path to /proc/1 initially and falling back to /proc/self. When
HOST_PROC_MOUNTINFO is not empty, set the root path to the parent
directory of HOST_PROC_MOUNTINFO.
Ville Skyttä 5095c3f51e [disk][linux] recognize more file systems
shirou 49037dd0d8 [disk][linux] add fallback to /proc/self
Matthieu MOREL 4671e649aa
enable revive linter
mmorel-35 1e6b445a8a gofumpt
Matthieu MOREL b673968d5d
enable errorlint linter
shirou d2e27c1712 fix dependabot v2 deletion.
shirou 0969c9436b delete v2 directory, move v3 to top #1078
shirou b39f8bb90e
[v2][disk][linux] apply DiskPartiton change to v2
shirou 1f733a99dc [disk] move without context functions to disk.go.
Aman Karmani 23d63601d1 [disk][linux] flag bind mounts
Ilya Prudnikov 256e00319e implement proposed solution
Ilya Prudnikov 7277cdf050 Fix for track disk stats when running in container
Lomanic e4ec7b275a [disk][linux] Fix #555 for kernels >=2.6.26
Aman Gupta 74d3cea10f Proper fix for unavailable /proc/filesystems
John Floren 93e08ea089 Fixes a problem when using Docker on a host with an encrypted LLVM root. A docker container with a volume mounted from the host will see /dev/mapper in its mount info file, but will not be able to read it.
eshimizu 91b1c81467
Update disk_linux.go
Aman Gupta 34b030b41c
Ignore getFileSystems errors when requesting all partitions
Aman Gupta ea0f864aef ignore /proc/filesystems errors on android
Tony Lambiris 80ceab90aa
Add support for hfsplus file system
Lomanic d7405fd873 [disk][linux] Follow symlinks with filepath.EvalSymlinks for LVM volumes
See #686
Tony Lambiris 8037dc42c8
Add a check for logical volume paths
Lomanic 368a865910 [disk][linux] Fix comment in PartitionsWithContext
Lomanic 0d3a2ac515
[disk][linux] Fix comment in PartitionsWithContext
JHE a08b926ce6 It could be another error than the "self/mountinfo" missing
JHE 06a21ae66a Fix some issue.
JHE a5cb715e64 if mountinfo not found, use mounts
JHE d141349619 if mountinfo not found, use mounts
JHE a45f6d8a03 if mountinfo not found, use mounts
Nico Vinzens 1a7a39a789
Merge branch 'master' into master
Remy Mathieu fda98ebc34 disk: trim the device mapper name.
While reading the value of the file with `ioutil.ReadFile`,
the name is suffixed with a `\n`

Tested on Ubuntu 18.10
Lomanic 8888537497 [disk][linux] Fix #555 Unescape escaped sequences in fstab path in disk.Partitions
Nico Vinzens 1079f31626 change the way we handle the mountinfo lines
Nico Vinzens 23dfe98621 use HostSys to construct device path
Nico Vinzens 813c630e9c replace self/mounts with self/mountinfo
Jaime Soriano Pastor 61902bc2a5 Use HOST_* environment variables for getting disk serial number in Linux
shirou d813235a11 disk[linux]: cast uint64 for build on MIPS
related: #533