[fdio] Migrate to fdio_fd_create

The fdio_fd_create function replaces the fdio_create_fd function.

Change-Id: Ic8ffe689d53a3a40ba7c0fc3ac68629339afa8f7
diff --git a/src/os/exec_fuchsia_cgo.go b/src/os/exec_fuchsia_cgo.go
index 468448b1..a8cd4da 100644
--- a/src/os/exec_fuchsia_cgo.go
+++ b/src/os/exec_fuchsia_cgo.go
@@ -9,11 +9,12 @@
 // #cgo fuchsia CFLAGS: -I${SRCDIR}/../../../../../zircon/system/ulib/fdio/include
 // #cgo fuchsia LDFLAGS: -lfdio
 //
+// #include <lib/fdio/fd.h>
+// #include <lib/fdio/spawn.h>
+// #include <stdlib.h>
+// #include <unistd.h>
 // #include <zircon/syscalls/object.h>
 // #include <zircon/types.h>
-// #include <lib/fdio/spawn.h>
-// #include <lib/fdio/util.h>
-// #include <stdlib.h>
 //
 // static int fsa_get_local_fd(fdio_spawn_action_t *fsa) { return fsa->fd.local_fd; }
 // static int fsa_get_target_fd(fdio_spawn_action_t *fsa) { return fsa->fd.target_fd; }
@@ -27,7 +28,6 @@
 	"strings"
 	"syscall"
 	"syscall/zx"
-	"syscall/zx/fdio"
 	"syscall/zx/zxwait"
 	"unsafe"
 )
@@ -56,36 +56,16 @@
 		return -1, ErrInvalid
 	}
 
-	var fdioType C.uint32_t
-	switch m.(type) {
-	case *fdio.Node, *fdio.File, *fdio.Directory:
-		fdioType = fdio.HandleTypeRemote
-	case *fdio.Pipe:
-		fdioType = fdio.HandleTypeSocket
-	case *fdio.Logger:
-		fdioType = fdio.HandleTypeLogger
-	default:
-		return -1, ErrInvalid
-	}
-
 	mCopy, err := m.Clone()
 	if err != nil {
 		return -1, err
 	}
 	handles := mCopy.Handles()
 
-	var handlesC [fdio.MaxUnderlyingHandles]C.zx_handle_t
-	var typesC [fdio.MaxUnderlyingHandles]C.uint32_t
-	for i, h := range handles {
-		handlesC[i] = C.zx_handle_t(h)
-		typesC[i] = C.uint32_t(fdioType)
-	}
-
 	var fd C.int
-	status := zx.Status(C.fdio_create_fd(&handlesC[0], &typesC[0], C.size_t(len(handles)), &fd))
+	status := zx.Status(C.fdio_fd_create(C.zx_handle_t(handles[0]), &fd))
 	if status != zx.ErrOk {
-		mCopy.Close()
-		return -1, errors.New("fdio_create_fd failed")
+		return -1, errors.New("fdio_fd_create failed")
 	}
 	return int(fd), nil
 }
diff --git a/src/syscall/zx/fdio/fdio.go b/src/syscall/zx/fdio/fdio.go
index ce98f6b..050ee50 100644
--- a/src/syscall/zx/fdio/fdio.go
+++ b/src/syscall/zx/fdio/fdio.go
@@ -12,10 +12,6 @@
 	"syscall/zx/io"
 )
 
-// MaxUnderlyingHandles is the maximum number of handles which are
-// necessary to implement any FDIO object.
-const MaxUnderlyingHandles = 2
-
 // FDIO provides classic unix-style IO over various transports
 type FDIO interface {
 	Handles() []zx.Handle