syscall: relax locks on root and working dirs

The locks are protecting the references, but surround the operations that are
called on those references. In an implementaiton of an rio server, the tests
for the rio server contained an open call that delegated to another open call
on a different filesystem - leading to deadlock.

Change-Id: I44a6f9c78650e4217b05096a4a8e9751db6d7d9d
diff --git a/src/syscall/syscall_fuchsia.go b/src/syscall/syscall_fuchsia.go
index ec0ddcc..b54d37d 100644
--- a/src/syscall/syscall_fuchsia.go
+++ b/src/syscall/syscall_fuchsia.go
@@ -287,17 +287,17 @@
 
 	rootMu.Lock()
 	root, err = rio.New([]mx.Handle{mx.RootHandle})
+	rootMu.Unlock()
 	if err != nil {
 		println("syscall: failed to create mxio root: ", err.Error())
 	}
-	rootMu.Unlock()
 
 	cwdMu.Lock()
 	cwd, err = rio.New([]mx.Handle{mx.CwdHandle})
+	cwdMu.Unlock()
 	if err != nil {
 		println("syscall: failed to create mxio cwd: ", err.Error())
 	}
-	cwdMu.Unlock()
 
 	initStdio := func(i int) (mxio.MXIO, error) {
 		switch mx.StdioHandleTypes[i] {
@@ -382,12 +382,14 @@
 		return nil, EINVAL
 	} else if path[0] != '/' {
 		cwdMu.Lock()
-		f, err = cwd.Open(path, int32(mode), perm)
+		c := cwd
 		cwdMu.Unlock()
+		f, err = c.Open(path, int32(mode), perm)
 	} else {
 		rootMu.Lock()
-		f, err = root.Open(path, int32(mode), perm)
+		r := root
 		rootMu.Unlock()
+		f, err = r.Open(path, int32(mode), perm)
 	}
 	return f, err
 }