Signed-off-by: John Howard <jhoward@microsoft.com>
| ... | ... |
@@ -4,7 +4,6 @@ import ( |
| 4 | 4 |
"errors" |
| 5 | 5 |
"fmt" |
| 6 | 6 |
"io" |
| 7 |
- "io/ioutil" |
|
| 8 | 7 |
"os" |
| 9 | 8 |
"path/filepath" |
| 10 | 9 |
"strings" |
| ... | ... |
@@ -143,17 +142,6 @@ func CopyFile(src, dst string) (int64, error) {
|
| 143 | 143 |
return io.Copy(df, sf) |
| 144 | 144 |
} |
| 145 | 145 |
|
| 146 |
-// GetTotalUsedFds Returns the number of used File Descriptors by |
|
| 147 |
-// reading it via /proc filesystem. |
|
| 148 |
-func GetTotalUsedFds() int {
|
|
| 149 |
- if fds, err := ioutil.ReadDir(fmt.Sprintf("/proc/%d/fd", os.Getpid())); err != nil {
|
|
| 150 |
- logrus.Errorf("Error opening /proc/%d/fd: %s", os.Getpid(), err)
|
|
| 151 |
- } else {
|
|
| 152 |
- return len(fds) |
|
| 153 |
- } |
|
| 154 |
- return -1 |
|
| 155 |
-} |
|
| 156 |
- |
|
| 157 | 146 |
// ReadSymlinkedDirectory returns the target directory of a symlink. |
| 158 | 147 |
// The target of the symbolic link may not be a file. |
| 159 | 148 |
func ReadSymlinkedDirectory(path string) (string, error) {
|
| 160 | 149 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,22 @@ |
| 0 |
+// +build linux freebsd |
|
| 1 |
+ |
|
| 2 |
+package fileutils |
|
| 3 |
+ |
|
| 4 |
+import ( |
|
| 5 |
+ "fmt" |
|
| 6 |
+ "io/ioutil" |
|
| 7 |
+ "os" |
|
| 8 |
+ |
|
| 9 |
+ "github.com/Sirupsen/logrus" |
|
| 10 |
+) |
|
| 11 |
+ |
|
| 12 |
+// GetTotalUsedFds Returns the number of used File Descriptors by |
|
| 13 |
+// reading it via /proc filesystem. |
|
| 14 |
+func GetTotalUsedFds() int {
|
|
| 15 |
+ if fds, err := ioutil.ReadDir(fmt.Sprintf("/proc/%d/fd", os.Getpid())); err != nil {
|
|
| 16 |
+ logrus.Errorf("Error opening /proc/%d/fd: %s", os.Getpid(), err)
|
|
| 17 |
+ } else {
|
|
| 18 |
+ return len(fds) |
|
| 19 |
+ } |
|
| 20 |
+ return -1 |
|
| 21 |
+} |