
This pulls in and uses github.com/docker/docker/pkg/chrootarchive for the actual copy up which is some battle hardened code to unpack avoiding things like symlink traversal security issues. However it does pull in a pretty huge pile of vendoring, including github.com/docker/docker/pkg/reexec which we must then call at startup. It's not immediately clear that this tradeoff is the correct one. Signed-off-by: Ian Campbell <ijc@docker.com>
23 lines
441 B
Go
23 lines
441 B
Go
// +build linux freebsd
|
|
|
|
package fileutils
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"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 := ioutil.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
|
|
}
|