aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/osutil
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-09-22 11:09:53 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-09-22 13:10:55 +0200
commit913d592f973a0155647473eaa032711fe956f8a5 (patch)
tree29b1b2083c00d199cf4d9a30917411d923b49ef4 /pkg/osutil
parentc26ea367cfa790e86800ac025638ad50f95b8287 (diff)
all: more assorted fuchsia support
Diffstat (limited to 'pkg/osutil')
-rw-r--r--pkg/osutil/osutil.go20
-rw-r--r--pkg/osutil/osutil_fuchsia.go17
-rw-r--r--pkg/osutil/osutil_unix.go20
3 files changed, 37 insertions, 20 deletions
diff --git a/pkg/osutil/osutil.go b/pkg/osutil/osutil.go
index 4fbd04506..79cd455c2 100644
--- a/pkg/osutil/osutil.go
+++ b/pkg/osutil/osutil.go
@@ -55,26 +55,6 @@ func runCmd(timeout time.Duration, env []string, dir, bin string, args ...string
return output.Bytes(), nil
}
-var wd string
-
-func init() {
- var err error
- wd, err = os.Getwd()
- if err != nil {
- panic(fmt.Sprintf("failed to get wd: %v", err))
- }
-}
-
-func Abs(path string) string {
- if wd1, err := os.Getwd(); err == nil && wd1 != wd {
- panic("don't mess with wd in a concurrent program")
- }
- if path == "" || filepath.IsAbs(path) {
- return path
- }
- return filepath.Join(wd, path)
-}
-
// IsExist returns true if the file name exists.
func IsExist(name string) bool {
_, err := os.Stat(name)
diff --git a/pkg/osutil/osutil_fuchsia.go b/pkg/osutil/osutil_fuchsia.go
new file mode 100644
index 000000000..75cdad843
--- /dev/null
+++ b/pkg/osutil/osutil_fuchsia.go
@@ -0,0 +1,17 @@
+// 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.
+
+// +build fuchsia
+
+package osutil
+
+func HandleInterrupts(shutdown chan struct{}) {
+}
+
+func Abs(path string) string {
+ // Getwd is not implemented. Let's hope for best.
+ if path == "" {
+ return ""
+ }
+ return "./" + path
+}
diff --git a/pkg/osutil/osutil_unix.go b/pkg/osutil/osutil_unix.go
index 01eabc15b..27482b99a 100644
--- a/pkg/osutil/osutil_unix.go
+++ b/pkg/osutil/osutil_unix.go
@@ -90,3 +90,23 @@ func LongPipe() (io.ReadCloser, io.WriteCloser, error) {
prolongPipe(r, w)
return r, w, err
}
+
+var wd string
+
+func init() {
+ var err error
+ wd, err = os.Getwd()
+ if err != nil {
+ panic(fmt.Sprintf("failed to get wd: %v", err))
+ }
+}
+
+func Abs(path string) string {
+ if wd1, err := os.Getwd(); err == nil && wd1 != wd {
+ panic("don't mess with wd in a concurrent program")
+ }
+ if path == "" || filepath.IsAbs(path) {
+ return path
+ }
+ return filepath.Join(wd, path)
+}