aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-06-26 13:42:52 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-06-26 13:42:52 +0200
commit8ebb2147d9eff47da10054ede27c5e399617bc0b (patch)
tree5537aa4ba5f7373fdc3cf865d80630ccfb74adbc /pkg
parent9630a49ef9625a108cd7b6e2249f1e0756f9a603 (diff)
pkg/fileutil: port to darwin
Diffstat (limited to 'pkg')
-rw-r--r--pkg/fileutil/fileutil.go14
-rw-r--r--pkg/fileutil/fileutil_linux.go24
2 files changed, 24 insertions, 14 deletions
diff --git a/pkg/fileutil/fileutil.go b/pkg/fileutil/fileutil.go
index dbc9366de..056eee50f 100644
--- a/pkg/fileutil/fileutil.go
+++ b/pkg/fileutil/fileutil.go
@@ -11,7 +11,6 @@ import (
"path/filepath"
"strconv"
"syscall"
- "unsafe"
)
// CopyFile atomically copies oldFile to newFile preserving permissions and modification time.
@@ -106,16 +105,3 @@ func ProcessTempDir(where string) (string, error) {
}
return "", fmt.Errorf("too many live instances")
}
-
-// UmountAll recurusively unmounts all mounts in dir.
-func UmountAll(dir string) {
- files, _ := ioutil.ReadDir(dir)
- for _, f := range files {
- name := filepath.Join(dir, f.Name())
- if f.IsDir() {
- UmountAll(name)
- }
- fn := []byte(name + "\x00")
- syscall.Syscall(syscall.SYS_UMOUNT2, uintptr(unsafe.Pointer(&fn[0])), syscall.MNT_FORCE, 0)
- }
-}
diff --git a/pkg/fileutil/fileutil_linux.go b/pkg/fileutil/fileutil_linux.go
new file mode 100644
index 000000000..217036256
--- /dev/null
+++ b/pkg/fileutil/fileutil_linux.go
@@ -0,0 +1,24 @@
+// Copyright 2017 syzkaller project authors. All rights reserved.
+// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+package fileutil
+
+import (
+ "io/ioutil"
+ "path/filepath"
+ "syscall"
+ "unsafe"
+)
+
+// UmountAll recurusively unmounts all mounts in dir.
+func UmountAll(dir string) {
+ files, _ := ioutil.ReadDir(dir)
+ for _, f := range files {
+ name := filepath.Join(dir, f.Name())
+ if f.IsDir() {
+ UmountAll(name)
+ }
+ fn := []byte(name + "\x00")
+ syscall.Syscall(syscall.SYS_UMOUNT2, uintptr(unsafe.Pointer(&fn[0])), syscall.MNT_FORCE, 0)
+ }
+}