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
3e137f8a
Commit
3e137f8a
authored
Feb 18, 2016
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fuse: support handleless read/write that skips the OPEN opcode.
parent
24519377
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
43 deletions
+88
-43
fuse/nodefs/fileless_test.go
fuse/nodefs/fileless_test.go
+50
-5
fuse/opcode.go
fuse/opcode.go
+1
-1
fuse/print.go
fuse/print.go
+18
-18
fuse/request_linux.go
fuse/request_linux.go
+1
-1
fuse/types.go
fuse/types.go
+18
-18
No files found.
fuse/nodefs/fileless_test.go
View file @
3e137f8a
...
...
@@ -9,14 +9,22 @@ import (
type
nodeReadNode
struct
{
Node
noOpen
bool
data
[]
byte
}
func
newNodeReadNode
(
d
[]
byte
)
*
nodeReadNode
{
return
&
nodeReadNode
{
NewDefaultNode
(),
d
}
func
newNodeReadNode
(
noOpen
bool
,
d
[]
byte
)
*
nodeReadNode
{
return
&
nodeReadNode
{
Node
:
NewDefaultNode
(),
noOpen
:
noOpen
,
data
:
d
,
}
}
func
(
n
*
nodeReadNode
)
Open
(
flags
uint32
,
context
*
fuse
.
Context
)
(
file
File
,
code
fuse
.
Status
)
{
if
n
.
noOpen
{
return
nil
,
fuse
.
ENOSYS
}
return
nil
,
fuse
.
OK
}
...
...
@@ -31,17 +39,53 @@ func (n *nodeReadNode) Read(file File, dest []byte, off int64, context *fuse.Con
func
(
n
*
nodeReadNode
)
Lookup
(
out
*
fuse
.
Attr
,
name
string
,
context
*
fuse
.
Context
)
(
*
Inode
,
fuse
.
Status
)
{
out
.
Mode
=
fuse
.
S_IFREG
|
0644
out
.
Size
=
uint64
(
len
(
name
))
ch
:=
n
.
Inode
()
.
NewChild
(
name
,
false
,
newNodeReadNode
([]
byte
(
name
)))
ch
:=
n
.
Inode
()
.
NewChild
(
name
,
false
,
newNodeReadNode
(
n
.
noOpen
,
[]
byte
(
name
)))
return
ch
,
fuse
.
OK
}
func
TestNoOpen
(
t
*
testing
.
T
)
{
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"nodefs"
)
if
err
!=
nil
{
t
.
Fatalf
(
"TempDir: %v"
,
err
)
}
root
:=
newNodeReadNode
(
true
,
nil
)
root
.
noOpen
=
true
s
,
_
,
err
:=
MountRoot
(
dir
,
root
,
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"MountRoot: %v"
,
err
)
}
s
.
SetDebug
(
VerboseTest
())
defer
s
.
Unmount
()
go
s
.
Serve
()
content
,
err
:=
ioutil
.
ReadFile
(
dir
+
"/file"
)
if
err
!=
nil
{
t
.
Fatalf
(
"ReadFile: %v"
,
err
)
}
want
:=
"file"
if
string
(
content
)
!=
want
{
t
.
Fatalf
(
"got %q, want %q"
,
content
,
want
)
}
content
,
err
=
ioutil
.
ReadFile
(
dir
+
"/file2"
)
if
err
!=
nil
{
t
.
Fatalf
(
"ReadFile: %v"
,
err
)
}
want
=
"file2"
if
string
(
content
)
!=
want
{
t
.
Fatalf
(
"got %q, want %q"
,
content
,
want
)
}
}
func
TestNodeRead
(
t
*
testing
.
T
)
{
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"nodefs"
)
if
err
!=
nil
{
t
.
Fatalf
(
"TempDir: %v"
,
err
)
}
root
:=
newNodeReadNode
(
nil
)
root
:=
newNodeReadNode
(
false
,
nil
)
s
,
_
,
err
:=
MountRoot
(
dir
,
root
,
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"MountRoot: %v"
,
err
)
...
...
@@ -56,4 +100,5 @@ func TestNodeRead(t *testing.T) {
if
string
(
content
)
!=
want
{
t
.
Fatalf
(
"got %q, want %q"
,
content
,
want
)
}
}
fuse/opcode.go
View file @
3e137f8a
...
...
@@ -79,7 +79,7 @@ func doInit(server *Server, req *request) {
server
.
reqMu
.
Lock
()
server
.
kernelSettings
=
*
input
server
.
kernelSettings
.
Flags
=
input
.
Flags
&
(
CAP_ASYNC_READ
|
CAP_BIG_WRITES
|
CAP_FILE_OPS
|
CAP_AUTO_INVAL_DATA
|
CAP_READDIRPLUS
)
CAP_AUTO_INVAL_DATA
|
CAP_READDIRPLUS
|
CAP_NO_OPEN_SUPPORT
)
if
input
.
Minor
>=
13
{
server
.
setSplice
()
...
...
fuse/print.go
View file @
3e137f8a
...
...
@@ -39,9 +39,9 @@ func init() {
CAP_AUTO_INVAL_DATA
:
"AUTO_INVAL_DATA"
,
CAP_READDIRPLUS
:
"READDIRPLUS"
,
CAP_READDIRPLUS_AUTO
:
"READDIRPLUS_AUTO"
,
CAP_
FUSE_ASYNC_DIO
:
"ASYNC_DIO"
,
CAP_
FUSE_WRITEBACK_CACHE
:
"WRITEBACK_CACHE"
,
CAP_
FUSE_NO_OPEN_SUPPORT
:
"NO_OPEN_SUPPORT"
,
CAP_
ASYNC_DIO
:
"ASYNC_DIO"
,
CAP_
WRITEBACK_CACHE
:
"WRITEBACK_CACHE"
,
CAP_
NO_OPEN_SUPPORT
:
"NO_OPEN_SUPPORT"
,
}
releaseFlagNames
=
map
[
int64
]
string
{
RELEASE_FLUSH
:
"FLUSH"
,
...
...
fuse/request_linux.go
View file @
3e137f8a
...
...
@@ -5,5 +5,5 @@ const outputHeaderSize = 160
const
(
_FUSE_KERNEL_VERSION
=
7
_MINIMUM_MINOR_VERSION
=
12
_OUR_MINOR_VERSION
=
2
1
_OUR_MINOR_VERSION
=
2
3
)
fuse/types.go
View file @
3e137f8a
...
...
@@ -158,9 +158,9 @@ const (
CAP_AUTO_INVAL_DATA
=
(
1
<<
12
)
CAP_READDIRPLUS
=
(
1
<<
13
)
CAP_READDIRPLUS_AUTO
=
(
1
<<
14
)
CAP_
FUSE_ASYNC_DIO
=
(
1
<<
15
)
CAP_
FUSE_WRITEBACK_CACHE
=
(
1
<<
16
)
CAP_
FUSE_NO_OPEN_SUPPORT
=
(
1
<<
17
)
CAP_
ASYNC_DIO
=
(
1
<<
15
)
CAP_
WRITEBACK_CACHE
=
(
1
<<
16
)
CAP_
NO_OPEN_SUPPORT
=
(
1
<<
17
)
)
type
InitIn
struct
{
...
...
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