mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
c55a4ac779
The io/ioutil package has been deprecated in Go 1.16. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
22 lines
503 B
Go
22 lines
503 B
Go
//go:build linux || freebsd
|
|
// +build linux freebsd
|
|
|
|
package fileutils // import "github.com/docker/docker/pkg/fileutils"
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// GetTotalUsedFds Returns the number of used File Descriptors by
|
|
// reading it via /proc filesystem.
|
|
func GetTotalUsedFds() int {
|
|
if fds, err := os.ReadDir(fmt.Sprintf("/proc/%d/fd", os.Getpid())); err != nil {
|
|
logrus.Errorf("Error opening /proc/%d/fd: %s", os.Getpid(), err)
|
|
} else {
|
|
return len(fds)
|
|
}
|
|
return -1
|
|
}
|