Commit 5d8ba04f authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Simplify socketpair function.

parent 53e99700
......@@ -77,6 +77,7 @@ func CopyFileInfo(fi *os.FileInfo, attr *Attr) {
attr.Blksize = uint32(fi.Blksize)
}
// TODO - expose in Go's syscall package.
func writev(fd int, iovecs *syscall.Iovec, cnt int) (n int, errno int) {
n1, _, e1 := syscall.Syscall(
syscall.SYS_WRITEV,
......
package fuse
// Written with a look to http://ptspts.blogspot.com/2009/11/fuse-protocol-tutorial-for-linux-26.html
import (
"fmt"
"log"
......@@ -14,20 +13,8 @@ import (
var fusermountBinary string
var umountBinary string
func Socketpair(network string) (l, r *os.File, err error) {
var domain int
var typ int
switch network {
case "unix":
domain = syscall.AF_UNIX
typ = syscall.SOCK_STREAM
case "unixgram":
domain = syscall.AF_UNIX
typ = syscall.SOCK_SEQPACKET
default:
log.Panicf("unknown network %q", network)
}
fd, err := syscall.Socketpair(domain, typ, 0)
func unixgramSocketpair() (l, r *os.File, err error) {
fd, err := syscall.Socketpair(syscall.AF_UNIX, syscall.SOCK_SEQPACKET, 0)
if err != nil {
return nil, nil, os.NewSyscallError("socketpair",
err.(syscall.Errno))
......@@ -40,7 +27,7 @@ func Socketpair(network string) (l, r *os.File, err error) {
// Create a FUSE FS on the specified mount point. The returned
// mount point is always absolute.
func mount(mountPoint string, options string) (f *os.File, finalMountPoint string, err error) {
local, remote, err := Socketpair("unixgram")
local, remote, err := unixgramSocketpair()
if err != nil {
return
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment