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
dd926abd
Commit
dd926abd
authored
Feb 26, 2013
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use file descriptor in mounstate.
parent
675a48a2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
21 deletions
+21
-21
fuse/mount_darwin.go
fuse/mount_darwin.go
+2
-2
fuse/mount_linux.go
fuse/mount_linux.go
+7
-11
fuse/mountstate.go
fuse/mountstate.go
+6
-5
fuse/mountstate_linux.go
fuse/mountstate_linux.go
+5
-2
fuse/splice_linux.go
fuse/splice_linux.go
+1
-1
No files found.
fuse/mount_darwin.go
View file @
dd926abd
...
...
@@ -114,7 +114,7 @@ import (
"unsafe"
)
func
mount
(
dir
string
,
options
string
)
(
connection
*
os
.
File
,
err
error
)
{
func
mount
(
dir
string
,
options
string
)
(
int
,
error
)
{
errp
:=
(
**
C
.
char
)(
C
.
malloc
(
16
))
*
errp
=
nil
defer
C
.
free
(
unsafe
.
Pointer
(
errp
))
...
...
@@ -124,7 +124,7 @@ func mount(dir string, options string) (connection *os.File, err error) {
if
*
errp
!=
nil
{
return
nil
,
mountError
(
C
.
GoString
(
*
errp
))
}
return
os
.
NewFile
(
uintptr
(
fd
),
"<fuseConnection>"
)
,
nil
return
fd
,
nil
}
...
...
fuse/mount_linux.go
View file @
dd926abd
...
...
@@ -26,7 +26,7 @@ func unixgramSocketpair() (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
,
err
error
)
{
func
mount
(
mountPoint
string
,
options
string
)
(
f
d
int
,
err
error
)
{
local
,
remote
,
err
:=
unixgramSocketpair
()
if
err
!=
nil
{
return
...
...
@@ -98,7 +98,7 @@ func unmount(mountPoint string) (err error) {
return
}
func
getConnection
(
local
*
os
.
File
)
(
f
*
os
.
File
,
err
error
)
{
func
getConnection
(
local
*
os
.
File
)
(
int
,
error
)
{
var
data
[
4
]
byte
control
:=
make
([]
byte
,
4
*
256
)
...
...
@@ -107,26 +107,22 @@ func getConnection(local *os.File) (f *os.File, err error) {
err
:=
syscall
.
Recvmsg
(
int
(
local
.
Fd
()),
data
[
:
],
control
[
:
],
0
)
if
err
!=
nil
{
return
return
0
,
err
}
message
:=
*
(
*
syscall
.
Cmsghdr
)(
unsafe
.
Pointer
(
&
control
[
0
]))
fd
:=
*
(
*
int32
)(
unsafe
.
Pointer
(
uintptr
(
unsafe
.
Pointer
(
&
control
[
0
]))
+
syscall
.
SizeofCmsghdr
))
if
message
.
Type
!=
1
{
err
=
fmt
.
Errorf
(
"getConnection: recvmsg returned wrong control type: %d"
,
message
.
Type
)
return
return
0
,
fmt
.
Errorf
(
"getConnection: recvmsg returned wrong control type: %d"
,
message
.
Type
)
}
if
oobn
<=
syscall
.
SizeofCmsghdr
{
err
=
fmt
.
Errorf
(
"getConnection: too short control message. Length: %d"
,
oobn
)
return
return
0
,
fmt
.
Errorf
(
"getConnection: too short control message. Length: %d"
,
oobn
)
}
if
fd
<
0
{
err
=
fmt
.
Errorf
(
"getConnection: fd < 0: %d"
,
fd
)
return
return
0
,
fmt
.
Errorf
(
"getConnection: fd < 0: %d"
,
fd
)
}
f
=
os
.
NewFile
(
uintptr
(
fd
),
"<fuseConnection>"
)
return
return
int
(
fd
),
nil
}
func
init
()
{
...
...
fuse/mountstate.go
View file @
dd926abd
...
...
@@ -7,6 +7,7 @@ import (
"path/filepath"
"strings"
"sync"
"syscall"
"time"
"unsafe"
...
...
@@ -26,7 +27,7 @@ type MountState struct {
fileSystem
RawFileSystem
// I/O with kernel and daemon.
mountF
ile
*
os
.
File
mountF
d
int
// Dump debug info onto stdout.
Debug
bool
...
...
@@ -127,7 +128,7 @@ func (ms *MountState) Mount(mountPoint string, opts *MountOptions) error {
}
mountPoint
=
filepath
.
Clean
(
filepath
.
Join
(
cwd
,
mountPoint
))
}
f
ile
,
err
:=
mount
(
mountPoint
,
strings
.
Join
(
optStrs
,
","
))
f
d
,
err
:=
mount
(
mountPoint
,
strings
.
Join
(
optStrs
,
","
))
if
err
!=
nil
{
return
err
}
...
...
@@ -144,7 +145,7 @@ func (ms *MountState) Mount(mountPoint string, opts *MountOptions) error {
}
ms
.
fileSystem
.
Init
(
&
initParams
)
ms
.
mountPoint
=
mountPoint
ms
.
mountF
ile
=
file
ms
.
mountF
d
=
fd
return
nil
}
...
...
@@ -236,7 +237,7 @@ func (ms *MountState) readRequest(exitIdle bool) (req *request, code Status) {
ms
.
reqReaders
++
ms
.
reqMu
.
Unlock
()
n
,
err
:=
ms
.
mountFile
.
Read
(
dest
)
n
,
err
:=
syscall
.
Read
(
ms
.
mountFd
,
dest
)
if
err
!=
nil
{
code
=
ToStatus
(
err
)
ms
.
reqMu
.
Lock
()
...
...
@@ -305,7 +306,7 @@ func (ms *MountState) Loop() {
ms
.
loops
.
Wait
()
ms
.
reqMu
.
Lock
()
ms
.
mountFile
.
Close
(
)
syscall
.
Close
(
ms
.
mountFd
)
ms
.
reqMu
.
Unlock
()
}
...
...
fuse/mountstate_linux.go
View file @
dd926abd
package
fuse
import
(
"log"
"syscall"
)
func
(
ms
*
MountState
)
systemWrite
(
req
*
request
,
header
[]
byte
)
Status
{
if
req
.
flatDataSize
()
==
0
{
_
,
err
:=
ms
.
mountFile
.
Write
(
header
)
_
,
err
:=
syscall
.
Write
(
ms
.
mountFd
,
header
)
return
ToStatus
(
err
)
}
...
...
@@ -24,7 +27,7 @@ func (ms *MountState) systemWrite(req *request, header []byte) Status {
header
=
req
.
serializeHeader
(
len
(
req
.
flatData
))
}
_
,
err
:=
Writev
(
int
(
ms
.
mountFile
.
Fd
())
,
[][]
byte
{
header
,
req
.
flatData
})
_
,
err
:=
Writev
(
ms
.
mountFd
,
[][]
byte
{
header
,
req
.
flatData
})
if
req
.
readResult
!=
nil
{
req
.
readResult
.
Done
()
}
...
...
fuse/splice_linux.go
View file @
dd926abd
...
...
@@ -61,7 +61,7 @@ func (ms *MountState) trySplice(header []byte, req *request, fdData *ReadResultF
return
fmt
.
Errorf
(
"wrote %d, want %d"
,
n
,
fdData
.
Size
())
}
_
,
err
=
pair
.
WriteTo
(
ms
.
mountFile
.
Fd
(
),
total
)
_
,
err
=
pair
.
WriteTo
(
uintptr
(
ms
.
mountFd
),
total
)
if
err
!=
nil
{
return
err
}
...
...
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