[24.0] pkg/fileutils: switch to use containerd log pkg

(very) partial backport of 74da6a6363
and ab35df454d

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-06-30 18:28:55 +02:00
parent 2435d75b89
commit cd44aba8db
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -1,20 +1,20 @@
//go:build linux || freebsd
// +build linux freebsd
package fileutils // import "github.com/docker/docker/pkg/fileutils"
import (
"context"
"fmt"
"os"
"github.com/sirupsen/logrus"
"github.com/containerd/containerd/log"
)
// 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)
log.G(context.TODO()).Errorf("Error opening /proc/%d/fd: %s", os.Getpid(), err)
} else {
return len(fds)
}