mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-12-28 23:19:46 -08:00
Fix memory corruption when number of filesystems > 16 (#900)
Signed-off-by: Juergen Hoetzel <juergen@archlinux.org>
This commit is contained in:
parent
6025dc207d
commit
de0632c2e9
|
@ -41,17 +41,14 @@ func gostring(b []int8) string {
|
||||||
|
|
||||||
// Expose filesystem fullness.
|
// Expose filesystem fullness.
|
||||||
func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
|
func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
|
||||||
buf := make([]unix.Statfs_t, 16)
|
n, err := unix.Getfsstat(nil, noWait)
|
||||||
for {
|
|
||||||
n, err := unix.Getfsstat(buf, noWait)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if n < len(buf) {
|
buf := make([]unix.Statfs_t, n)
|
||||||
buf = buf[:n]
|
_, err = unix.Getfsstat(buf, noWait)
|
||||||
break
|
if err != nil {
|
||||||
}
|
return nil, err
|
||||||
buf = make([]unix.Statfs_t, len(buf)*2)
|
|
||||||
}
|
}
|
||||||
stats := []filesystemStats{}
|
stats := []filesystemStats{}
|
||||||
for _, fs := range buf {
|
for _, fs := range buf {
|
||||||
|
|
Loading…
Reference in a new issue