Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Levin Zimmermann
go-fuse
Commits
1d3f8250
Commit
1d3f8250
authored
Dec 21, 2010
by
Ivan Krasin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Apply patch"
This reverts commit
a25a48d9
.
parent
a25a48d9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
54 deletions
+43
-54
fuse/fuse.go
fuse/fuse.go
+1
-2
fuse/fuse_test.go
fuse/fuse_test.go
+3
-5
fuse/mount.go
fuse/mount.go
+39
-47
No files found.
fuse/fuse.go
View file @
1d3f8250
...
...
@@ -155,8 +155,7 @@ func serialize(h *InHeader, res Status, out interface{}) (data [][]byte) {
panic
(
fmt
.
Sprintf
(
"Can't serialize out: %v, err: %v"
,
out
,
err
))
}
}
fmt
.
Printf
(
"out_data: %v, len(out_data): %d, SizeOfOutHeader: %d
\n
"
,
out_data
,
len
(
out_data
),
SizeOfOutHeader
)
fmt
.
Printf
(
"out_data: %v, len(out_data): %d, SizeOfOutHeader: %d
\n
"
,
out_data
,
len
(
out_data
),
SizeOfOutHeader
)
var
hout
OutHeader
hout
.
Unique
=
h
.
Unique
hout
.
Status
=
res
...
...
fuse/fuse_test.go
View file @
1d3f8250
package
fuse
import
(
"fmt"
"log"
"os"
"strings"
...
...
@@ -60,13 +59,14 @@ func (f *testFile) Close() (status Status) {
func
errorHandler
(
errors
chan
os
.
Error
)
{
for
err
:=
range
errors
{
log
.
Println
(
"MountPoint.errorHandler: "
,
err
)
log
.
Stderr
(
"MountPoint.errorHandler: "
,
err
)
if
err
==
os
.
EOF
{
break
}
}
}
func
TestMount
(
t
*
testing
.
T
)
{
fs
:=
new
(
testFuse
)
...
...
@@ -85,9 +85,7 @@ func TestMount(t *testing.T) {
t
.
Fatalf
(
"Can't unmount a dir, err: %v"
,
err
)
}
}()
// ugh - error handling should be method of testfuse instead?
go
errorHandler
(
errors
)
errorHandler
(
errors
)
f
,
err
:=
os
.
Open
(
tempMountDir
,
os
.
O_RDONLY
,
0
)
if
err
!=
nil
{
t
.
Fatalf
(
"Can't open a dir: %s, err: %v"
,
tempMountDir
,
err
)
...
...
fuse/mount.go
View file @
1d3f8250
...
...
@@ -4,41 +4,18 @@ package fuse
import
(
"fmt"
"net"
"os"
"path"
"syscall"
"unsafe"
)
// Make a type to attach the Unmount method.
type
mounted
string
func
Socketpair
(
network
string
)
(
l
,
r
*
os
.
File
,
err
os
.
Error
)
{
var
domain
int
var
typ
int
switch
network
{
default
:
panic
(
"unknown network "
+
network
)
case
"unix"
:
domain
=
syscall
.
AF_UNIX
typ
=
syscall
.
SOCK_STREAM
case
"unixgram"
:
domain
=
syscall
.
AF_UNIX
typ
=
syscall
.
SOCK_SEQPACKET
}
fd
,
errno
:=
syscall
.
Socketpair
(
domain
,
typ
,
0
)
if
errno
!=
0
{
return
nil
,
nil
,
os
.
NewSyscallError
(
"socketpair"
,
errno
)
}
l
=
os
.
NewFile
(
fd
[
0
],
"socketpair-half1"
)
r
=
os
.
NewFile
(
fd
[
1
],
"socketpair-half2"
)
return
}
// Mount create a fuse fs on the specified mount point.
func
mount
(
mountPoint
string
)
(
f
*
os
.
File
,
m
mounted
,
err
os
.
Error
)
{
local
,
remote
,
err
:=
Socketpair
(
"unixgram"
)
local
,
remote
,
err
:=
net
.
Socketpair
(
"unixgram"
)
if
err
!=
nil
{
return
}
...
...
@@ -58,7 +35,7 @@ func mount(mountPoint string) (f *os.File, m mounted, err os.Error) {
[]
string
{
"/bin/fusermount"
,
mountPoint
},
[]
string
{
"_FUSE_COMMFD=3"
},
""
,
[]
*
os
.
File
{
nil
,
nil
,
nil
,
remote
})
[]
*
os
.
File
{
nil
,
nil
,
nil
,
remote
.
File
()
})
if
err
!=
nil
{
return
}
...
...
@@ -96,6 +73,24 @@ func (m mounted) Unmount() (err os.Error) {
return
}
func
recvmsg
(
fd
int
,
msg
*
syscall
.
Msghdr
,
flags
int
)
(
n
int
,
errno
int
)
{
n1
,
_
,
e1
:=
syscall
.
Syscall
(
syscall
.
SYS_RECVMSG
,
uintptr
(
fd
),
uintptr
(
unsafe
.
Pointer
(
msg
)),
uintptr
(
flags
))
n
=
int
(
n1
)
errno
=
int
(
e1
)
return
}
func
Recvmsg
(
fd
int
,
msg
*
syscall
.
Msghdr
,
flags
int
)
(
n
int
,
err
os
.
Error
)
{
n
,
errno
:=
recvmsg
(
fd
,
msg
,
flags
)
if
n
==
0
&&
errno
==
0
{
return
0
,
os
.
EOF
}
if
errno
!=
0
{
err
=
os
.
NewSyscallError
(
"recvmsg"
,
errno
)
}
return
}
func
writev
(
fd
int
,
iovecs
*
syscall
.
Iovec
,
cnt
int
)
(
n
int
,
errno
int
)
{
n1
,
_
,
e1
:=
syscall
.
Syscall
(
syscall
.
SYS_WRITEV
,
uintptr
(
fd
),
uintptr
(
unsafe
.
Pointer
(
iovecs
)),
uintptr
(
cnt
))
n
=
int
(
n1
)
...
...
@@ -113,7 +108,7 @@ func Writev(fd int, packet [][]byte) (n int, err os.Error) {
continue
}
iovecs
[
i
]
.
Base
=
(
*
byte
)(
unsafe
.
Pointer
(
&
packet
[
i
][
0
]))
iovecs
[
i
]
.
SetLen
(
len
(
packet
[
i
]))
iovecs
[
i
]
.
Len
=
uint64
(
len
(
packet
[
i
]))
}
n
,
errno
:=
writev
(
fd
,
(
*
syscall
.
Iovec
)(
unsafe
.
Pointer
(
&
iovecs
[
0
])),
len
(
iovecs
))
...
...
@@ -124,35 +119,32 @@ func Writev(fd int, packet [][]byte) (n int, err os.Error) {
return
}
func
get
Int32
(
b
[]
byte
,
idx
int
)
int32
{
ptr
:=
(
*
int32
)(
unsafe
.
Pointer
(
&
b
[
idx
*
4
]))
return
*
ptr
}
func
get
FuseConn
(
local
net
.
Conn
)
(
f
*
os
.
File
,
err
os
.
Error
)
{
var
msg
syscall
.
Msghdr
var
iov
syscall
.
Iovec
base
:=
make
([]
int32
,
256
)
control
:=
make
([]
int32
,
256
)
func
getFuseConn
(
local
*
os
.
File
)
(
f
*
os
.
File
,
err
os
.
Error
)
{
var
data
[
4
]
byte
control
:=
make
([]
byte
,
4
*
256
)
iov
.
Base
=
(
*
byte
)(
unsafe
.
Pointer
(
&
base
[
0
]))
iov
.
Len
=
uint64
(
len
(
base
)
*
4
)
msg
.
Iov
=
(
*
syscall
.
Iovec
)(
unsafe
.
Pointer
(
&
iov
))
msg
.
Iovlen
=
1
msg
.
Control
=
(
*
byte
)(
unsafe
.
Pointer
(
&
control
[
0
]))
msg
.
Controllen
=
uint64
(
len
(
control
)
*
4
)
// n, oobn, recvflags - todo: error checking.
_
,
oobn
,
_
,
errno
:=
syscall
.
Recvmsg
(
local
.
Fd
(),
data
[
:
],
control
[
:
],
0
)
if
errno
!=
0
{
_
,
err
=
Recvmsg
(
local
.
File
()
.
Fd
(),
&
msg
,
0
)
if
err
!=
nil
{
return
}
length
:=
getInt32
(
control
,
0
)
// 1 = level.
typ
:=
getInt32
(
control
,
2
)
// syscall.Cmsghdr.Type
// Ugh - is this 64-bit proof?
fd
:=
getInt32
(
control
,
3
)
length
:=
control
[
0
]
typ
:=
control
[
2
]
// syscall.Cmsghdr.Type
fd
:=
control
[
4
]
if
typ
!=
1
{
err
=
os
.
NewError
(
fmt
.
Sprintf
(
"getFuseConn: recvmsg returned wrong control type: %d"
,
typ
))
return
}
if
oobn
<
16
{
if
length
<
20
{
err
=
os
.
NewError
(
fmt
.
Sprintf
(
"getFuseConn: too short control message. Length: %d"
,
length
))
return
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment