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
fee1de79
Commit
fee1de79
authored
Feb 11, 2013
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compiles on Darwin (does not work.)
parent
6305de53
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
187 additions
and
23 deletions
+187
-23
fuse/mountstate.go
fuse/mountstate.go
+2
-23
fuse/mountstate_darwin.go
fuse/mountstate_darwin.go
+21
-0
fuse/mountstate_linux.go
fuse/mountstate_linux.go
+29
-0
fuse/syscall_darwin.go
fuse/syscall_darwin.go
+135
-0
No files found.
fuse/mountstate.go
View file @
fee1de79
...
...
@@ -348,6 +348,7 @@ func (ms *MountState) handleRequest(req *request) {
ms
.
returnRequest
(
req
)
}
func
(
ms
*
MountState
)
AllocOut
(
req
*
request
,
size
uint32
)
[]
byte
{
if
cap
(
req
.
bufferPoolOutputBuf
)
>=
int
(
size
)
{
req
.
bufferPoolOutputBuf
=
req
.
bufferPoolOutputBuf
[
:
size
]
...
...
@@ -375,29 +376,7 @@ func (ms *MountState) write(req *request) Status {
return
OK
}
if
req
.
flatDataSize
()
==
0
{
_
,
err
:=
ms
.
mountFile
.
Write
(
header
)
return
ToStatus
(
err
)
}
if
req
.
fdData
!=
nil
{
if
err
:=
ms
.
trySplice
(
header
,
req
,
req
.
fdData
);
err
==
nil
{
req
.
readResult
.
Done
()
return
OK
}
else
{
log
.
Println
(
"trySplice:"
,
err
)
sz
:=
req
.
flatDataSize
()
buf
:=
ms
.
AllocOut
(
req
,
uint32
(
sz
))
req
.
flatData
,
req
.
status
=
req
.
fdData
.
Bytes
(
buf
)
header
=
req
.
serializeHeader
(
len
(
req
.
flatData
))
}
}
_
,
err
:=
Writev
(
int
(
ms
.
mountFile
.
Fd
()),
[][]
byte
{
header
,
req
.
flatData
})
if
req
.
readResult
!=
nil
{
req
.
readResult
.
Done
()
}
return
ToStatus
(
err
)
return
ms
.
systemWrite
(
req
,
header
)
}
func
(
ms
*
MountState
)
writeInodeNotify
(
entry
*
raw
.
NotifyInvalInodeOut
)
Status
{
...
...
fuse/mountstate_darwin.go
0 → 100644
View file @
fee1de79
package
fuse
func
(
ms
*
MountState
)
systemWrite
(
req
*
request
,
header
[]
byte
)
Status
{
if
req
.
flatDataSize
()
==
0
{
_
,
err
:=
ms
.
mountFile
.
Write
(
header
)
return
ToStatus
(
err
)
}
if
req
.
fdData
!=
nil
{
sz
:=
req
.
flatDataSize
()
buf
:=
ms
.
AllocOut
(
req
,
uint32
(
sz
))
req
.
flatData
,
req
.
status
=
req
.
fdData
.
Bytes
(
buf
)
header
=
req
.
serializeHeader
(
len
(
req
.
flatData
))
}
_
,
err
:=
Writev
(
int
(
ms
.
mountFile
.
Fd
()),
[][]
byte
{
header
,
req
.
flatData
})
if
req
.
readResult
!=
nil
{
req
.
readResult
.
Done
()
}
return
ToStatus
(
err
)
}
fuse/mountstate_linux.go
0 → 100644
View file @
fee1de79
package
fuse
import
(
"log"
)
func
(
ms
*
MountState
)
systemWrite
(
req
*
request
,
header
[]
byte
)
Status
{
if
req
.
flatDataSize
()
==
0
{
_
,
err
:=
ms
.
mountFile
.
Write
(
header
)
return
ToStatus
(
err
)
}
if
req
.
fdData
!=
nil
{
if
err
:=
ms
.
trySplice
(
header
,
req
,
req
.
fdData
);
err
==
nil
{
req
.
readResult
.
Done
()
return
OK
}
else
{
log
.
Println
(
"trySplice:"
,
err
)
sz
:=
req
.
flatDataSize
()
buf
:=
ms
.
AllocOut
(
req
,
uint32
(
sz
))
req
.
flatData
,
req
.
status
=
req
.
fdData
.
Bytes
(
buf
)
header
=
req
.
serializeHeader
(
len
(
req
.
flatData
))
}
}
_
,
err
:=
Writev
(
int
(
ms
.
mountFile
.
Fd
()),
[][]
byte
{
header
,
req
.
flatData
})
if
req
.
readResult
!=
nil
{
req
.
readResult
.
Done
()
}
return
ToStatus
(
err
)
}
fuse/syscall_darwin.go
0 → 100644
View file @
fee1de79
package
fuse
import
(
"bytes"
"os"
"syscall"
"unsafe"
)
// TODO - move these into Go's syscall package.
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
))
return
int
(
n1
),
int
(
e1
)
}
func
Writev
(
fd
int
,
packet
[][]
byte
)
(
n
int
,
err
error
)
{
iovecs
:=
make
([]
syscall
.
Iovec
,
0
,
len
(
packet
))
for
_
,
v
:=
range
packet
{
if
len
(
v
)
==
0
{
continue
}
vec
:=
syscall
.
Iovec
{
Base
:
&
v
[
0
],
}
vec
.
SetLen
(
len
(
v
))
iovecs
=
append
(
iovecs
,
vec
)
}
n
,
errno
:=
writev
(
fd
,
&
iovecs
[
0
],
len
(
iovecs
))
if
errno
!=
0
{
err
=
os
.
NewSyscallError
(
"writev"
,
syscall
.
Errno
(
errno
))
}
return
n
,
err
}
func
getxattr
(
path
string
,
attr
string
,
dest
[]
byte
)
(
sz
int
,
errno
int
)
{
pathBs
:=
syscall
.
StringBytePtr
(
path
)
attrBs
:=
syscall
.
StringBytePtr
(
attr
)
size
,
_
,
errNo
:=
syscall
.
Syscall6
(
syscall
.
SYS_GETXATTR
,
uintptr
(
unsafe
.
Pointer
(
pathBs
)),
uintptr
(
unsafe
.
Pointer
(
attrBs
)),
uintptr
(
unsafe
.
Pointer
(
&
dest
[
0
])),
uintptr
(
len
(
dest
)),
0
,
0
)
return
int
(
size
),
int
(
errNo
)
}
func
GetXAttr
(
path
string
,
attr
string
,
dest
[]
byte
)
(
value
[]
byte
,
errno
int
)
{
sz
,
errno
:=
getxattr
(
path
,
attr
,
dest
)
for
sz
>
cap
(
dest
)
&&
errno
==
0
{
dest
=
make
([]
byte
,
sz
)
sz
,
errno
=
getxattr
(
path
,
attr
,
dest
)
}
if
errno
!=
0
{
return
nil
,
errno
}
return
dest
[
:
sz
],
errno
}
func
listxattr
(
path
string
,
dest
[]
byte
)
(
sz
int
,
errno
int
)
{
pathbs
:=
syscall
.
StringBytePtr
(
path
)
var
destPointer
unsafe
.
Pointer
if
len
(
dest
)
>
0
{
destPointer
=
unsafe
.
Pointer
(
&
dest
[
0
])
}
size
,
_
,
errNo
:=
syscall
.
Syscall
(
syscall
.
SYS_LISTXATTR
,
uintptr
(
unsafe
.
Pointer
(
pathbs
)),
uintptr
(
destPointer
),
uintptr
(
len
(
dest
)))
return
int
(
size
),
int
(
errNo
)
}
func
ListXAttr
(
path
string
)
(
attributes
[]
string
,
errno
int
)
{
dest
:=
make
([]
byte
,
0
)
sz
,
errno
:=
listxattr
(
path
,
dest
)
if
errno
!=
0
{
return
nil
,
errno
}
for
sz
>
cap
(
dest
)
&&
errno
==
0
{
dest
=
make
([]
byte
,
sz
)
sz
,
errno
=
listxattr
(
path
,
dest
)
}
// -1 to drop the final empty slice.
dest
=
dest
[
:
sz
-
1
]
attributesBytes
:=
bytes
.
Split
(
dest
,
[]
byte
{
0
})
attributes
=
make
([]
string
,
len
(
attributesBytes
))
for
i
,
v
:=
range
attributesBytes
{
attributes
[
i
]
=
string
(
v
)
}
return
attributes
,
errno
}
func
Setxattr
(
path
string
,
attr
string
,
data
[]
byte
,
flags
int
)
(
errno
int
)
{
pathbs
:=
syscall
.
StringBytePtr
(
path
)
attrbs
:=
syscall
.
StringBytePtr
(
attr
)
_
,
_
,
errNo
:=
syscall
.
Syscall6
(
syscall
.
SYS_SETXATTR
,
uintptr
(
unsafe
.
Pointer
(
pathbs
)),
uintptr
(
unsafe
.
Pointer
(
attrbs
)),
uintptr
(
unsafe
.
Pointer
(
&
data
[
0
])),
uintptr
(
len
(
data
)),
uintptr
(
flags
),
0
)
return
int
(
errNo
)
}
func
Removexattr
(
path
string
,
attr
string
)
(
errno
int
)
{
pathbs
:=
syscall
.
StringBytePtr
(
path
)
attrbs
:=
syscall
.
StringBytePtr
(
attr
)
_
,
_
,
errNo
:=
syscall
.
Syscall
(
syscall
.
SYS_REMOVEXATTR
,
uintptr
(
unsafe
.
Pointer
(
pathbs
)),
uintptr
(
unsafe
.
Pointer
(
attrbs
)),
0
)
return
int
(
errNo
)
}
func
ioctl
(
fd
int
,
cmd
int
,
arg
uintptr
)
(
int
,
int
)
{
r0
,
_
,
e1
:=
syscall
.
Syscall
(
syscall
.
SYS_IOCTL
,
uintptr
(
fd
),
uintptr
(
cmd
),
uintptr
(
arg
))
val
:=
int
(
r0
)
errno
:=
int
(
e1
)
return
val
,
errno
}
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