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
Kirill Smelkov
go-fuse
Commits
ec46e594
Commit
ec46e594
authored
May 25, 2012
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gofmt.
parent
bf30f7b8
Changes
39
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
107 additions
and
130 deletions
+107
-130
benchmark/benchmark.go
benchmark/benchmark.go
+0
-1
benchmark/stat_test.go
benchmark/stat_test.go
+1
-1
example/autounionfs/main.go
example/autounionfs/main.go
+1
-1
example/statfs/main.go
example/statfs/main.go
+4
-4
example/zipfs/main.go
example/zipfs/main.go
+4
-4
fuse/api.go
fuse/api.go
+3
-4
fuse/bufferpool.go
fuse/bufferpool.go
+0
-1
fuse/cache_test.go
fuse/cache_test.go
+1
-1
fuse/copy.go
fuse/copy.go
+2
-2
fuse/defaultnode.go
fuse/defaultnode.go
+1
-1
fuse/defaultraw.go
fuse/defaultraw.go
+1
-2
fuse/direntry.go
fuse/direntry.go
+11
-10
fuse/files.go
fuse/files.go
+3
-3
fuse/fsconnector.go
fuse/fsconnector.go
+4
-4
fuse/fsetattr_test.go
fuse/fsetattr_test.go
+1
-1
fuse/fsmount.go
fuse/fsmount.go
+2
-2
fuse/fsops.go
fuse/fsops.go
+4
-5
fuse/handle.go
fuse/handle.go
+1
-1
fuse/lockingfs.go
fuse/lockingfs.go
+1
-1
fuse/loopback_test.go
fuse/loopback_test.go
+1
-1
fuse/memnode_test.go
fuse/memnode_test.go
+1
-1
fuse/misc_test.go
fuse/misc_test.go
+0
-1
fuse/mountstate.go
fuse/mountstate.go
+10
-11
fuse/opcode.go
fuse/opcode.go
+10
-10
fuse/pathfs.go
fuse/pathfs.go
+5
-5
fuse/pressure_test.go
fuse/pressure_test.go
+2
-3
fuse/read.go
fuse/read.go
+1
-1
fuse/request.go
fuse/request.go
+10
-11
fuse/types.go
fuse/types.go
+1
-3
fuse/xattr_test.go
fuse/xattr_test.go
+1
-2
raw/print.go
raw/print.go
+5
-6
raw/types.go
raw/types.go
+1
-6
splice/pool.go
splice/pool.go
+2
-2
splice/splice.go
splice/splice.go
+1
-3
splice/splice_test.go
splice/splice_test.go
+2
-6
unionfs/autounion.go
unionfs/autounion.go
+5
-5
unionfs/cachingfs.go
unionfs/cachingfs.go
+1
-1
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+1
-1
zipfs/memtree.go
zipfs/memtree.go
+2
-2
No files found.
benchmark/benchmark.go
View file @
ec46e594
...
...
@@ -13,7 +13,6 @@ import (
"time"
)
func
ReadLines
(
name
string
)
[]
string
{
f
,
err
:=
os
.
Open
(
name
)
if
err
!=
nil
{
...
...
benchmark/stat_test.go
View file @
ec46e594
...
...
@@ -157,7 +157,7 @@ func BenchmarkCFuseThreadedStat(b *testing.B) {
mountPoint
)
cmd
.
Env
=
append
(
os
.
Environ
(),
fmt
.
Sprintf
(
"STATFS_INPUT=%s"
,
f
.
Name
()),
fmt
.
Sprintf
(
"STATFS_DELAY_USEC=%d"
,
delay
/
time
.
Microsecond
))
fmt
.
Sprintf
(
"STATFS_DELAY_USEC=%d"
,
delay
/
time
.
Microsecond
))
cmd
.
Start
()
bin
,
err
:=
exec
.
LookPath
(
"fusermount"
)
...
...
example/autounionfs/main.go
View file @
ec46e594
...
...
@@ -73,5 +73,5 @@ func main() {
gofs
.
SetFileSystemConnector
(
conn
)
state
.
Loop
()
time
.
Sleep
(
1
*
time
.
Second
)
time
.
Sleep
(
1
*
time
.
Second
)
}
example/statfs/main.go
View file @
ec46e594
...
...
@@ -3,8 +3,8 @@ package main
import
(
"flag"
"fmt"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/benchmark"
"github.com/hanwen/go-fuse/fuse"
"io"
"log"
"os"
...
...
@@ -52,7 +52,7 @@ func main() {
}
nfs
:=
fuse
.
NewPathNodeFs
(
fs
,
nil
)
opts
:=
&
fuse
.
FileSystemOptions
{
AttrTimeout
:
time
.
Duration
(
*
ttl
*
float64
(
time
.
Second
)),
AttrTimeout
:
time
.
Duration
(
*
ttl
*
float64
(
time
.
Second
)),
EntryTimeout
:
time
.
Duration
(
*
ttl
*
float64
(
time
.
Second
)),
}
state
,
_
,
err
:=
fuse
.
MountNodeFileSystem
(
flag
.
Arg
(
0
),
nfs
,
opts
)
...
...
@@ -60,7 +60,7 @@ func main() {
fmt
.
Printf
(
"Mount fail: %v
\n
"
,
err
)
os
.
Exit
(
1
)
}
state
.
SetRecordStatistics
(
*
latencies
)
state
.
Debug
=
*
debug
runtime
.
GC
()
...
...
@@ -75,7 +75,7 @@ func main() {
cmd
.
Stdout
=
os
.
Stdout
cmd
.
Start
()
}
state
.
Loop
()
if
memProfFile
!=
nil
{
pprof
.
WriteHeapProfile
(
memProfFile
)
...
...
example/zipfs/main.go
View file @
ec46e594
...
...
@@ -45,7 +45,7 @@ func main() {
log
.
Fatalf
(
"os.Create: %v"
,
err
)
}
}
var
fs
fuse
.
NodeFileSystem
fs
,
err
=
zipfs
.
NewArchiveFileSystem
(
flag
.
Arg
(
1
))
if
err
!=
nil
{
...
...
@@ -54,7 +54,7 @@ func main() {
}
opts
:=
&
fuse
.
FileSystemOptions
{
AttrTimeout
:
time
.
Duration
(
*
ttl
*
float64
(
time
.
Second
)),
AttrTimeout
:
time
.
Duration
(
*
ttl
*
float64
(
time
.
Second
)),
EntryTimeout
:
time
.
Duration
(
*
ttl
*
float64
(
time
.
Second
)),
}
state
,
_
,
err
:=
fuse
.
MountNodeFileSystem
(
flag
.
Arg
(
0
),
fs
,
opts
)
...
...
@@ -62,7 +62,7 @@ func main() {
fmt
.
Printf
(
"Mount fail: %v
\n
"
,
err
)
os
.
Exit
(
1
)
}
state
.
SetRecordStatistics
(
*
latencies
)
state
.
Debug
=
*
debug
runtime
.
GC
()
...
...
@@ -77,7 +77,7 @@ func main() {
cmd
.
Stdout
=
os
.
Stdout
cmd
.
Start
()
}
state
.
Loop
()
if
memProfFile
!=
nil
{
pprof
.
WriteHeapProfile
(
memProfFile
)
...
...
fuse/api.go
View file @
ec46e594
...
...
@@ -77,7 +77,6 @@ type FsNode interface {
StatFs
()
*
StatfsOut
}
// A filesystem API that uses paths rather than inodes. A minimal
// file system should have at least a functional GetAttr method.
// Typically, each call happens in its own goroutine, so take care to
...
...
@@ -171,7 +170,7 @@ type File interface {
// The methods below may be called on closed files, due to
// concurrency. In that case, you should return EBADF.
Truncate
(
size
uint64
)
Status
GetAttr
(
out
*
Attr
)
(
Status
)
GetAttr
(
out
*
Attr
)
Status
Chown
(
uid
uint32
,
gid
uint32
)
Status
Chmod
(
perms
uint32
)
Status
Utimens
(
atimeNs
int64
,
mtimeNs
int64
)
Status
...
...
@@ -279,7 +278,7 @@ type RawFileSystem interface {
// File handling.
Create
(
out
*
raw
.
CreateOut
,
header
*
raw
.
InHeader
,
input
*
raw
.
CreateIn
,
name
string
)
(
code
Status
)
Open
(
out
*
raw
.
OpenOut
,
header
*
raw
.
InHeader
,
input
*
raw
.
OpenIn
)
(
status
Status
)
Read
(
*
raw
.
InHeader
,
*
ReadIn
,
[]
byte
)
ReadResult
Read
(
*
raw
.
InHeader
,
*
ReadIn
,
[]
byte
)
ReadResult
Release
(
header
*
raw
.
InHeader
,
input
*
raw
.
ReleaseIn
)
Write
(
*
raw
.
InHeader
,
*
WriteIn
,
[]
byte
)
(
written
uint32
,
code
Status
)
...
...
@@ -288,7 +287,7 @@ type RawFileSystem interface {
// Directory handling
OpenDir
(
out
*
raw
.
OpenOut
,
header
*
raw
.
InHeader
,
input
*
raw
.
OpenIn
)
(
status
Status
)
ReadDir
(
out
*
DirEntryList
,
header
*
raw
.
InHeader
,
input
*
ReadIn
)
(
Status
)
ReadDir
(
out
*
DirEntryList
,
header
*
raw
.
InHeader
,
input
*
ReadIn
)
Status
ReleaseDir
(
header
*
raw
.
InHeader
,
input
*
raw
.
ReleaseIn
)
FsyncDir
(
header
*
raw
.
InHeader
,
input
*
raw
.
FsyncIn
)
(
code
Status
)
...
...
fuse/bufferpool.go
View file @
ec46e594
...
...
@@ -122,7 +122,6 @@ func (p *BufferPoolImpl) AllocBuffer(size uint32) []byte {
}
p
.
lock
.
Unlock
()
return
b
}
...
...
fuse/cache_test.go
View file @
ec46e594
...
...
@@ -2,12 +2,12 @@ package fuse
import
(
"bytes"
"github.com/hanwen/go-fuse/raw"
"io/ioutil"
"log"
"os"
"sync"
"testing"
"github.com/hanwen/go-fuse/raw"
)
var
_
=
log
.
Println
...
...
fuse/copy.go
View file @
ec46e594
...
...
@@ -27,7 +27,7 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *Conte
defer
dst
.
Release
()
defer
dst
.
Flush
()
buf
:=
make
([]
byte
,
128
*
(
1
<<
10
))
buf
:=
make
([]
byte
,
128
*
(
1
<<
10
))
off
:=
int64
(
0
)
for
{
res
:=
src
.
Read
(
buf
,
off
)
...
...
@@ -35,7 +35,7 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *Conte
return
res
.
Status
}
res
.
Read
(
buf
)
if
len
(
res
.
Data
)
==
0
{
break
}
...
...
fuse/defaultnode.go
View file @
ec46e594
...
...
@@ -31,7 +31,7 @@ type DefaultFsNode struct {
inode
*
Inode
}
var
_
=
FsNode
((
*
DefaultFsNode
)(
nil
))
var
_
=
FsNode
((
*
DefaultFsNode
)(
nil
))
func
(
n
*
DefaultFsNode
)
StatFs
()
*
StatfsOut
{
return
nil
...
...
fuse/defaultraw.go
View file @
ec46e594
...
...
@@ -6,7 +6,6 @@ import (
var
_
=
RawFileSystem
((
*
DefaultRawFileSystem
)(
nil
))
func
(
fs
*
DefaultRawFileSystem
)
Init
(
init
*
RawFsInit
)
{
}
...
...
@@ -116,7 +115,7 @@ func (fs *DefaultRawFileSystem) Fsync(header *raw.InHeader, input *raw.FsyncIn)
return
ENOSYS
}
func
(
fs
*
DefaultRawFileSystem
)
ReadDir
(
l
*
DirEntryList
,
header
*
raw
.
InHeader
,
input
*
ReadIn
)
(
Status
)
{
func
(
fs
*
DefaultRawFileSystem
)
ReadDir
(
l
*
DirEntryList
,
header
*
raw
.
InHeader
,
input
*
ReadIn
)
Status
{
return
ENOSYS
}
...
...
fuse/direntry.go
View file @
ec46e594
...
...
@@ -11,6 +11,7 @@ import (
var
_
=
log
.
Print
var
eightPadding
[
8
]
byte
const
direntSize
=
int
(
unsafe
.
Sizeof
(
raw
.
Dirent
{}))
// DirEntry is a type for PathFileSystem and NodeFileSystem to return
...
...
@@ -21,13 +22,13 @@ type DirEntry struct {
}
type
DirEntryList
struct
{
buf
[]
byte
offset
uint64
buf
[]
byte
offset
uint64
}
func
NewDirEntryList
(
data
[]
byte
,
off
uint64
)
*
DirEntryList
{
return
&
DirEntryList
{
buf
:
data
[
:
0
],
buf
:
data
[
:
0
],
offset
:
off
,
}
}
...
...
@@ -37,7 +38,7 @@ func (l *DirEntryList) AddDirEntry(e DirEntry) bool {
}
func
(
l
*
DirEntryList
)
Add
(
name
string
,
inode
uint64
,
mode
uint32
)
bool
{
padding
:=
(
8
-
len
(
name
)
&
7
)
&
7
padding
:=
(
8
-
len
(
name
)
&
7
)
&
7
delta
:=
padding
+
direntSize
+
len
(
name
)
oldLen
:=
len
(
l
.
buf
)
newLen
:=
delta
+
oldLen
...
...
@@ -47,18 +48,18 @@ func (l *DirEntryList) Add(name string, inode uint64, mode uint32) bool {
}
l
.
buf
=
l
.
buf
[
:
newLen
]
dirent
:=
(
*
raw
.
Dirent
)(
unsafe
.
Pointer
(
&
l
.
buf
[
oldLen
]))
dirent
.
Off
=
l
.
offset
+
1
dirent
.
Off
=
l
.
offset
+
1
dirent
.
Ino
=
inode
dirent
.
NameLen
=
uint32
(
len
(
name
))
dirent
.
NameLen
=
uint32
(
len
(
name
))
dirent
.
Typ
=
ModeToType
(
mode
)
oldLen
+=
direntSize
copy
(
l
.
buf
[
oldLen
:
],
name
)
oldLen
+=
len
(
name
)
if
padding
>
0
{
copy
(
l
.
buf
[
oldLen
:
],
eightPadding
[
:
padding
])
}
l
.
offset
=
dirent
.
Off
return
true
}
...
...
@@ -70,12 +71,12 @@ func (l *DirEntryList) Bytes() []byte {
////////////////////////////////////////////////////////////////
type
rawDir
interface
{
ReadDir
(
out
*
DirEntryList
,
input
*
ReadIn
)
(
Status
)
ReadDir
(
out
*
DirEntryList
,
input
*
ReadIn
)
Status
Release
()
}
type
connectorDir
struct
{
node
FsNode
node
FsNode
stream
[]
DirEntry
lastOffset
uint64
}
...
...
fuse/files.go
View file @
ec46e594
...
...
@@ -102,9 +102,9 @@ func (f *LoopbackFile) String() string {
func
(
f
*
LoopbackFile
)
Read
(
buf
[]
byte
,
off
int64
)
(
res
ReadResult
)
{
return
ReadResult
{
Fd
:
f
.
File
.
Fd
(),
FdOff
:
off
,
FdSize
:
len
(
buf
),
Fd
:
f
.
File
.
Fd
(),
FdOff
:
off
,
FdSize
:
len
(
buf
),
Status
:
OK
,
}
}
...
...
fuse/fsconnector.go
View file @
ec46e594
...
...
@@ -79,7 +79,7 @@ func (c *FileSystemConnector) verify() {
}
// Generate EntryOut and increase the lookup count for an inode.
func
(
c
*
FileSystemConnector
)
childLookup
(
out
*
raw
.
EntryOut
,
fsi
FsNode
)
{
func
(
c
*
FileSystemConnector
)
childLookup
(
out
*
raw
.
EntryOut
,
fsi
FsNode
)
{
n
:=
fsi
.
Inode
()
fsi
.
GetAttr
((
*
Attr
)(
&
out
.
Attr
),
nil
,
nil
)
n
.
mount
.
fillEntry
(
out
)
...
...
@@ -99,7 +99,7 @@ func (c *FileSystemConnector) findMount(parent *Inode, name string) (mount *file
}
parent
.
treeLock
.
RUnlock
()
return
return
}
func
(
c
*
FileSystemConnector
)
toInode
(
nodeid
uint64
)
*
Inode
{
...
...
@@ -118,7 +118,7 @@ func (c *FileSystemConnector) lookupUpdate(node *Inode) uint64 {
}
node
.
lookupCount
+=
1
node
.
treeLock
.
Unlock
()
return
node
.
nodeId
}
...
...
@@ -173,7 +173,7 @@ func (c *FileSystemConnector) recursiveConsiderDropInode(n *Inode) (drop bool) {
n
.
openFilesMutex
.
Lock
()
ok
:=
len
(
n
.
openFiles
)
==
0
n
.
openFilesMutex
.
Unlock
()
return
ok
}
...
...
fuse/fsetattr_test.go
View file @
ec46e594
...
...
@@ -24,7 +24,7 @@ func (f *MutableDataFile) String() string {
func
(
f
*
MutableDataFile
)
Read
(
buf
[]
byte
,
off
int64
)
(
r
ReadResult
)
{
r
.
Data
=
f
.
data
[
off
:
off
+
int64
(
len
(
buf
))]
return
r
return
r
}
func
(
f
*
MutableDataFile
)
Write
(
d
[]
byte
,
off
int64
)
(
uint32
,
Status
)
{
...
...
fuse/fsmount.go
View file @
ec46e594
...
...
@@ -4,7 +4,7 @@ import (
"log"
"sync"
"unsafe"
"github.com/hanwen/go-fuse/raw"
)
...
...
@@ -65,7 +65,7 @@ func (m *fileSystemMount) fillEntry(out *raw.EntryOut) {
splitDuration
(
m
.
options
.
EntryTimeout
,
&
out
.
EntryValid
,
&
out
.
EntryValidNsec
)
splitDuration
(
m
.
options
.
AttrTimeout
,
&
out
.
AttrValid
,
&
out
.
AttrValidNsec
)
m
.
setOwner
(
&
out
.
Attr
)
if
out
.
Mode
&
S_IFDIR
==
0
&&
out
.
Nlink
==
0
{
if
out
.
Mode
&
S_IFDIR
==
0
&&
out
.
Nlink
==
0
{
out
.
Nlink
=
1
}
}
...
...
fuse/fsops.go
View file @
ec46e594
...
...
@@ -114,7 +114,7 @@ func (c *FileSystemConnector) OpenDir(out *raw.OpenOut, header *raw.InHeader, in
}
stream
=
append
(
stream
,
node
.
getMountDirEntries
()
...
)
de
:=
&
connectorDir
{
node
:
node
.
FsNode
(),
node
:
node
.
FsNode
(),
stream
:
append
(
stream
,
DirEntry
{
S_IFDIR
,
"."
},
DirEntry
{
S_IFDIR
,
".."
}),
}
h
,
opened
:=
node
.
mount
.
registerFileHandle
(
node
,
de
,
nil
,
input
.
Flags
)
...
...
@@ -123,7 +123,7 @@ func (c *FileSystemConnector) OpenDir(out *raw.OpenOut, header *raw.InHeader, in
return
OK
}
func
(
c
*
FileSystemConnector
)
ReadDir
(
l
*
DirEntryList
,
header
*
raw
.
InHeader
,
input
*
ReadIn
)
(
Status
)
{
func
(
c
*
FileSystemConnector
)
ReadDir
(
l
*
DirEntryList
,
header
*
raw
.
InHeader
,
input
*
ReadIn
)
Status
{
node
:=
c
.
toInode
(
header
.
NodeId
)
opened
:=
node
.
mount
.
getOpenedFile
(
input
.
Fh
)
return
opened
.
dir
.
ReadDir
(
l
,
input
)
...
...
@@ -350,10 +350,10 @@ func (c *FileSystemConnector) Write(header *raw.InHeader, input *WriteIn, data [
return
opened
.
WithFlags
.
File
.
Write
(
data
,
int64
(
input
.
Offset
))
}
func
(
c
*
FileSystemConnector
)
Read
(
header
*
raw
.
InHeader
,
input
*
ReadIn
,
buf
[]
byte
)
(
ReadResult
)
{
func
(
c
*
FileSystemConnector
)
Read
(
header
*
raw
.
InHeader
,
input
*
ReadIn
,
buf
[]
byte
)
ReadResult
{
node
:=
c
.
toInode
(
header
.
NodeId
)
opened
:=
node
.
mount
.
getOpenedFile
(
input
.
Fh
)
return
opened
.
WithFlags
.
File
.
Read
(
buf
,
int64
(
input
.
Offset
))
}
...
...
@@ -372,4 +372,3 @@ func (c *FileSystemConnector) Flush(header *raw.InHeader, input *raw.FlushIn) St
opened
:=
node
.
mount
.
getOpenedFile
(
input
.
Fh
)
return
opened
.
WithFlags
.
File
.
Flush
()
}
fuse/handle.go
View file @
ec46e594
...
...
@@ -65,7 +65,7 @@ func (m *portableHandleMap) Register(obj *Handled, asInt interface{}) (handle ui
func
(
m
*
portableHandleMap
)
Count
()
int
{
m
.
RLock
()
c
:=
m
.
used
c
:=
m
.
used
m
.
RUnlock
()
return
c
}
...
...
fuse/lockingfs.go
View file @
ec46e594
...
...
@@ -296,7 +296,7 @@ func (fs *LockingRawFileSystem) Fsync(header *raw.InHeader, input *raw.FsyncIn)
return
fs
.
RawFileSystem
.
Fsync
(
header
,
input
)
}
func
(
fs
*
LockingRawFileSystem
)
ReadDir
(
out
*
DirEntryList
,
header
*
raw
.
InHeader
,
input
*
ReadIn
)
(
Status
)
{
func
(
fs
*
LockingRawFileSystem
)
ReadDir
(
out
*
DirEntryList
,
header
*
raw
.
InHeader
,
input
*
ReadIn
)
Status
{
defer
fs
.
locked
()()
return
fs
.
RawFileSystem
.
ReadDir
(
out
,
header
,
input
)
}
...
...
fuse/loopback_test.go
View file @
ec46e594
...
...
@@ -140,7 +140,7 @@ func TestReadLarge(t *testing.T) {
defer
ts
.
Cleanup
()
// Add a bit more to test the splicing at the end.
content
:=
make
([]
byte
,
1024
*
1024
+
43
)
content
:=
make
([]
byte
,
1024
*
1024
+
43
)
for
i
:=
range
content
{
content
[
i
]
=
byte
(
i
)
}
...
...
fuse/memnode_test.go
View file @
ec46e594
...
...
@@ -48,7 +48,7 @@ func TestMemNodeFsWrite(t *testing.T) {
err
:=
ioutil
.
WriteFile
(
wd
+
"/test"
,
[]
byte
(
want
),
0644
)
CheckSuccess
(
err
)
content
,
err
:=
ioutil
.
ReadFile
(
wd
+
"/test"
)
content
,
err
:=
ioutil
.
ReadFile
(
wd
+
"/test"
)
if
string
(
content
)
!=
want
{
t
.
Fatalf
(
"content mismatch: got %q, want %q"
,
content
,
want
)
}
...
...
fuse/misc_test.go
View file @
ec46e594
...
...
@@ -49,4 +49,3 @@ func TestLinkAt(t *testing.T) {
t
.
Fatal
(
"Ino mismatch"
,
s1
,
s2
)
}
}
fuse/mountstate.go
View file @
ec46e594
...
...
@@ -2,8 +2,8 @@ package fuse
import
(
"fmt"
"log"
"io"
"log"
"os"
"strings"
"sync"
...
...
@@ -40,14 +40,14 @@ type MountState struct {
opts
*
MountOptions
kernelSettings
raw
.
InitIn
reqMu
sync
.
Mutex
reqPool
[]
*
request
readPool
[][]
byte
reqReaders
int
reqMu
sync
.
Mutex
reqPool
[]
*
request
readPool
[][]
byte
reqReaders
int
outstandingReadBufs
int
canSplice
bool
loops
sync
.
WaitGroup
canSplice
bool
loops
sync
.
WaitGroup
}
func
(
ms
*
MountState
)
KernelSettings
()
raw
.
InitIn
{
...
...
@@ -163,7 +163,7 @@ func (ms *MountState) BufferPoolStats() string {
ms
.
reqMu
.
Unlock
()
s
+=
fmt
.
Sprintf
(
" read buffers: %d (sz %d )"
,
r
,
ms
.
opts
.
MaxWrite
/
PAGESIZE
+
1
)
r
,
ms
.
opts
.
MaxWrite
/
PAGESIZE
+
1
)
return
s
}
...
...
@@ -192,7 +192,7 @@ func (ms *MountState) readRequest(exitIdle bool) (req *request, code Status) {
dest
=
ms
.
readPool
[
l
-
1
]
ms
.
readPool
=
ms
.
readPool
[
:
l
-
1
]
}
else
{
dest
=
make
([]
byte
,
ms
.
opts
.
MaxWrite
+
PAGESIZE
)
dest
=
make
([]
byte
,
ms
.
opts
.
MaxWrite
+
PAGESIZE
)
}
ms
.
outstandingReadBufs
++
ms
.
reqReaders
++
...
...
@@ -272,7 +272,7 @@ func (ms *MountState) Loop() {
func
(
ms
*
MountState
)
loop
(
exitIdle
bool
)
{
defer
ms
.
loops
.
Done
()
exit
:
exit
:
for
{
req
,
errNo
:=
ms
.
readRequest
(
exitIdle
)
switch
errNo
{
...
...
@@ -336,7 +336,6 @@ func (ms *MountState) AllocOut(req *request, size uint32) []byte {
return
req
.
bufferPoolOutputBuf
}
func
(
ms
*
MountState
)
write
(
req
*
request
)
Status
{
// Forget does not wait for reply.
if
req
.
inHeader
.
Opcode
==
_OP_FORGET
||
req
.
inHeader
.
Opcode
==
_OP_BATCH_FORGET
{
...
...
fuse/opcode.go
View file @
ec46e594
...
...
@@ -67,9 +67,9 @@ const (
func
doInit
(
state
*
MountState
,
req
*
request
)
{
const
(
FUSE_KERNEL_VERSION
=
7
FUSE_KERNEL_VERSION
=
7
MINIMUM_MINOR_VERSION
=
13
OUR_MINOR_VERSION
=
16
OUR_MINOR_VERSION
=
16
)
input
:=
(
*
raw
.
InitIn
)(
req
.
inData
)
...
...
@@ -93,7 +93,7 @@ func doInit(state *MountState, req *request) {
state
.
opts
.
MaxWrite
=
maxW
}
}
out
:=
&
raw
.
InitOut
{
Major
:
FUSE_KERNEL_VERSION
,
Minor
:
OUR_MINOR_VERSION
,
...
...
@@ -106,7 +106,7 @@ func doInit(state *MountState, req *request) {
if
out
.
Minor
>
input
.
Minor
{
out
.
Minor
=
input
.
Minor
}
req
.
outData
=
unsafe
.
Pointer
(
out
)
req
.
status
=
OK
}
...
...
@@ -130,7 +130,7 @@ func doReadDir(state *MountState, req *request) {
in
:=
(
*
ReadIn
)(
req
.
inData
)
buf
:=
state
.
AllocOut
(
req
,
in
.
Size
)
entries
:=
NewDirEntryList
(
buf
,
uint64
(
in
.
Offset
))
code
:=
state
.
fileSystem
.
ReadDir
(
entries
,
req
.
inHeader
,
in
)
req
.
flatData
.
Data
=
entries
.
Bytes
()
req
.
status
=
code
...
...
@@ -180,8 +180,8 @@ func doGetXAttr(state *MountState, req *request) {
req
.
status
=
code
return
}
req
.
outData
=
nil
req
.
outData
=
nil
var
data
[]
byte
switch
req
.
inHeader
.
Opcode
{
case
_OP_GETXATTR
:
...
...
@@ -216,7 +216,7 @@ func doForget(state *MountState, req *request) {
func
doBatchForget
(
state
*
MountState
,
req
*
request
)
{
in
:=
(
*
raw
.
BatchForgetIn
)(
req
.
inData
)
wantBytes
:=
uintptr
(
in
.
Count
)
*
unsafe
.
Sizeof
(
raw
.
BatchForgetIn
{})
wantBytes
:=
uintptr
(
in
.
Count
)
*
unsafe
.
Sizeof
(
raw
.
BatchForgetIn
{})
if
uintptr
(
len
(
req
.
arg
))
<
wantBytes
{
// We have no return value to complain, so log an error.
log
.
Printf
(
"Too few bytes for batch forget. Got %d bytes, want %d (%d entries)"
,
...
...
@@ -244,7 +244,7 @@ func doLookup(state *MountState, req *request) {
func
doMknod
(
state
*
MountState
,
req
*
request
)
{
out
:=
(
*
raw
.
EntryOut
)(
req
.
outData
)
req
.
status
=
state
.
fileSystem
.
Mknod
(
out
,
req
.
inHeader
,
(
*
raw
.
MknodIn
)(
req
.
inData
),
req
.
filenames
[
0
])
}
...
...
@@ -568,7 +568,7 @@ func init() {
var
r
request
sizeOfOutHeader
:=
unsafe
.
Sizeof
(
raw
.
OutHeader
{})
for
code
,
h
:=
range
operationHandlers
{
if
h
.
OutputSize
+
sizeOfOutHeader
>
unsafe
.
Sizeof
(
r
.
outBuf
)
{
if
h
.
OutputSize
+
sizeOfOutHeader
>
unsafe
.
Sizeof
(
r
.
outBuf
)
{
log
.
Panicf
(
"request output buffer too small: code %v, sz %d + %d %v"
,
code
,
h
.
OutputSize
,
sizeOfOutHeader
,
h
)
}
}
...
...
fuse/pathfs.go
View file @
ec46e594
...
...
@@ -223,30 +223,30 @@ func (n *pathInode) GetPath() string {
if
n
==
n
.
pathFs
.
root
{
return
""
}
pathLen
:=
0
// The simple solution is to collect names, and reverse join
// them, them, but since this is a hot path, we take some
// effort to avoid allocations.
n
.
pathFs
.
pathLock
.
RLock
()
p
:=
n
for
;
p
.
Parent
!=
nil
;
p
=
p
.
Parent
{
pathLen
+=
len
(
p
.
Name
)
+
1
}
pathLen
--
if
p
!=
p
.
pathFs
.
root
{
n
.
pathFs
.
pathLock
.
RUnlock
()
return
".deleted"
}
pathBytes
:=
make
([]
byte
,
pathLen
)
end
:=
len
(
pathBytes
)
for
p
=
n
;
p
.
Parent
!=
nil
;
p
=
p
.
Parent
{
l
:=
len
(
p
.
Name
)
copy
(
pathBytes
[
end
-
l
:
],
p
.
Name
)
copy
(
pathBytes
[
end
-
l
:
],
p
.
Name
)
end
-=
len
(
p
.
Name
)
+
1
if
end
>
0
{
pathBytes
[
end
]
=
'/'
...
...
fuse/pressure_test.go
View file @
ec46e594
...
...
@@ -46,7 +46,7 @@ func TestMemoryPressure(t *testing.T) {
os
.
Lstat
(
dir
)
var
wg
sync
.
WaitGroup
for
i
:=
0
;
i
<
10
*
_MAX_READERS
;
i
++
{
for
i
:=
0
;
i
<
10
*
_MAX_READERS
;
i
++
{
wg
.
Add
(
1
)
go
func
(
x
int
)
{
fn
:=
fmt
.
Sprintf
(
"%s/%ddir/file%d"
,
dir
,
x
,
x
)
...
...
@@ -60,10 +60,9 @@ func TestMemoryPressure(t *testing.T) {
time
.
Sleep
(
100
*
time
.
Millisecond
)
created
:=
state
.
buffers
.
createdBuffers
+
state
.
outstandingReadBufs
t
.
Logf
(
"Have %d read bufs"
,
state
.
outstandingReadBufs
)
if
created
>
2
*
_MAX_READERS
{
if
created
>
2
*
_MAX_READERS
{
t
.
Errorf
(
"created %d buffers, max reader %d"
,
created
,
_MAX_READERS
)
}
wg
.
Wait
()
}
fuse/read.go
View file @
ec46e594
...
...
@@ -11,7 +11,7 @@ type ReadResult struct {
// If Data is nil and Status OK, splice from the following
// file.
Fd
uintptr
Fd
uintptr
// Offset within Fd, or -1 to use current offset.
FdOff
int64
...
...
fuse/request.go
View file @
ec46e594
...
...
@@ -17,17 +17,17 @@ type request struct {
inputBuf
[]
byte
// These split up inputBuf.
inHeader
*
raw
.
InHeader
// generic header
inData
unsafe
.
Pointer
// per op data
arg
[]
byte
// flat data.
filenames
[]
string
// filename arguments
inHeader
*
raw
.
InHeader
// generic header
inData
unsafe
.
Pointer
// per op data
arg
[]
byte
// flat data.
filenames
[]
string
// filename arguments
// Unstructured data, a pointer to the relevant XxxxOut struct.
outData
unsafe
.
Pointer
status
Status
flatData
ReadResult
// Start timestamp for timing info.
startNs
int64
preWriteNs
int64
...
...
@@ -44,8 +44,8 @@ type request struct {
// arrays:
//
// Output header and structured data.
outBuf
[
160
]
byte
outBuf
[
160
]
byte
// Input, if small enough to fit here.
smallInputBuf
[
128
]
byte
}
...
...
@@ -123,10 +123,10 @@ func (r *request) setInput(input []byte) bool {
copy
(
r
.
smallInputBuf
[
:
],
input
)
r
.
inputBuf
=
r
.
smallInputBuf
[
:
len
(
input
)]
return
false
}
}
r
.
inputBuf
=
input
r
.
bufferPoolInputBuf
=
input
return
true
}
...
...
@@ -198,4 +198,3 @@ func (r *request) serializeHeader() (header []byte) {
copy
(
header
[
sizeOfOutHeader
:
],
asSlice
)
return
header
}
fuse/types.go
View file @
ec46e594
package
fuse
import
(
"github.com/hanwen/go-fuse/raw"
"os"
"syscall"
"github.com/hanwen/go-fuse/raw"
)
const
(
...
...
@@ -41,7 +41,6 @@ const (
EROFS
=
Status
(
syscall
.
EROFS
)
)
type
Attr
raw
.
Attr
type
Owner
raw
.
Owner
...
...
@@ -78,4 +77,3 @@ type WriteIn struct {
Flags
uint32
Padding
uint32
}
fuse/xattr_test.go
View file @
ec46e594
...
...
@@ -17,7 +17,6 @@ var xattrGolden = map[string][]byte{
"user.attr2"
:
[]
byte
(
"val2"
)}
var
xattrFilename
=
"filename"
type
XAttrTestFs
struct
{
tester
*
testing
.
T
filename
string
...
...
@@ -118,7 +117,7 @@ func TestXAttrNoExist(t *testing.T) {
nm
:=
xattrFilename
mountPoint
,
clean
:=
xattrTestCase
(
t
,
nm
)
defer
clean
()
mounted
:=
filepath
.
Join
(
mountPoint
,
nm
)
_
,
err
:=
os
.
Lstat
(
mounted
)
if
err
!=
nil
{
...
...
raw/print.go
View file @
ec46e594
package
raw
import
(
"fmt"
"os"
...
...
@@ -24,8 +25,8 @@ func init() {
CAP_SPLICE_WRITE
:
"SPLICE_WRITE"
,
CAP_SPLICE_MOVE
:
"SPLICE_MOVE"
,
CAP_SPLICE_READ
:
"SPLICE_READ"
,
CAP_FLOCK_LOCKS
:
"FLOCK_LOCKS"
,
CAP_IOCTL_DIR
:
"IOCTL_DIR"
,
CAP_FLOCK_LOCKS
:
"FLOCK_LOCKS"
,
CAP_IOCTL_DIR
:
"IOCTL_DIR"
,
}
releaseFlagNames
=
map
[
int
]
string
{
RELEASE_FLUSH
:
"FLUSH"
,
...
...
@@ -58,7 +59,7 @@ func init() {
W_OK
:
"w"
,
R_OK
:
"r"
,
}
}
func
FlagString
(
names
map
[
int
]
string
,
fl
int
,
def
string
)
string
{
...
...
@@ -78,7 +79,7 @@ func FlagString(names map[int]string, fl int, def string) string {
return
strings
.
Join
(
s
,
","
)
}
func
(
me
*
ForgetIn
)
String
()
string
{
return
fmt
.
Sprintf
(
"{%d}"
,
me
.
Nlookup
)
}
...
...
@@ -87,7 +88,6 @@ func (me *BatchForgetIn) String() string {
return
fmt
.
Sprintf
(
"{%d}"
,
me
.
Count
)
}
func
(
me
*
MkdirIn
)
String
()
string
{
return
fmt
.
Sprintf
(
"{0%o (0%o)}"
,
me
.
Mode
,
me
.
Umask
)
}
...
...
@@ -127,7 +127,6 @@ func (me *GetAttrIn) String() string {
return
fmt
.
Sprintf
(
"{Fh %d}"
,
me
.
Fh
)
}
func
(
me
*
ReleaseIn
)
String
()
string
{
return
fmt
.
Sprintf
(
"{Fh %d %s %s L%d}"
,
me
.
Fh
,
FlagString
(
OpenFlagNames
,
int
(
me
.
Flags
),
""
),
...
...
raw/types.go
View file @
ec46e594
...
...
@@ -3,7 +3,6 @@
package
raw
type
ForgetIn
struct
{
Nlookup
uint64
}
...
...
@@ -18,7 +17,6 @@ type BatchForgetIn struct {
Dummy
uint32
}
type
MkdirIn
struct
{
Mode
uint32
Umask
uint32
...
...
@@ -31,7 +29,7 @@ type RenameIn struct {
type
LinkIn
struct
{
Oldnodeid
uint64
}
type
MknodIn
struct
{
Mode
uint32
Rdev
uint32
...
...
@@ -86,7 +84,6 @@ type GetAttrIn struct {
Fh
uint64
}
const
RELEASE_FLUSH
=
(
1
<<
0
)
type
ReleaseIn
struct
{
...
...
@@ -289,7 +286,6 @@ type CreateIn struct {
Padding
uint32
}
type
NotifyInvalInodeOut
struct
{
Ino
uint64
Off
int64
...
...
@@ -370,7 +366,6 @@ type InHeader struct {
Padding
uint32
}
type
Kstatfs
struct
{
Blocks
uint64
Bfree
uint64
...
...
splice/pool.go
View file @
ec46e594
package
splice
import
(
"sync"
)
...
...
@@ -46,7 +47,6 @@ func (me *pairPool) used() int {
return
me
.
usedCount
}
func
(
me
*
pairPool
)
get
()
(
p
*
Pair
,
err
error
)
{
me
.
Lock
()
defer
me
.
Unlock
()
...
...
@@ -58,7 +58,7 @@ func (me *pairPool) get() (p *Pair, err error) {
me
.
unused
=
me
.
unused
[
:
l
-
1
]
return
p
,
nil
}
return
newSplicePair
()
}
...
...
splice/splice.go
View file @
ec46e594
...
...
@@ -12,9 +12,8 @@ import (
var
_
=
log
.
Println
var
maxPipeSize
int
var
resizable
bool
var
resizable
bool
func
Resizable
()
bool
{
return
resizable
...
...
@@ -86,4 +85,3 @@ func newSplicePair() (p *Pair, err error) {
}
return
p
,
nil
}
splice/splice_test.go
View file @
ec46e594
...
...
@@ -9,7 +9,7 @@ func TestPairSize(t *testing.T) {
p
,
_
:=
Get
()
defer
Done
(
p
)
p
.
MaxGrow
()
b
:=
make
([]
byte
,
p
.
Cap
()
+
100
)
b
:=
make
([]
byte
,
p
.
Cap
()
+
100
)
for
i
:=
range
b
{
b
[
i
]
=
byte
(
i
)
}
...
...
@@ -24,9 +24,5 @@ func TestPairSize(t *testing.T) {
if
err
==
nil
{
t
.
Fatalf
(
"should give error on exceeding capacity"
)
}
}
}
unionfs/autounion.go
View file @
ec46e594
...
...
@@ -424,7 +424,7 @@ func (fs *AutoUnionFs) OpenDir(name string, context *fuse.Context) (stream []fus
fs
.
lock
.
RLock
()
defer
fs
.
lock
.
RUnlock
()
stream
=
make
(
[]
fuse
.
DirEntry
,
0
,
len
(
fs
.
knownFileSystems
)
+
5
)
stream
=
make
([]
fuse
.
DirEntry
,
0
,
len
(
fs
.
knownFileSystems
)
+
5
)
if
name
==
_CONFIG
{
for
k
:=
range
fs
.
knownFileSystems
{
stream
=
append
(
stream
,
fuse
.
DirEntry
{
...
...
@@ -439,10 +439,10 @@ func (fs *AutoUnionFs) OpenDir(name string, context *fuse.Context) (stream []fus
Name
:
_CONFIG
,
Mode
:
uint32
(
fuse
.
S_IFDIR
|
0755
),
},
fuse
.
DirEntry
{
Name
:
_STATUS
,
Mode
:
uint32
(
fuse
.
S_IFDIR
|
0755
),
})
fuse
.
DirEntry
{
Name
:
_STATUS
,
Mode
:
uint32
(
fuse
.
S_IFDIR
|
0755
),
})
}
return
stream
,
status
}
...
...
unionfs/cachingfs.go
View file @
ec46e594
...
...
@@ -49,7 +49,7 @@ func readDir(fs fuse.FileSystem, name string) *dirResponse {
if
!
code
.
Ok
()
{
return
r
}
r
.
entries
=
origStream
r
.
entries
=
origStream
return
r
}
...
...
unionfs/unionfs_test.go
View file @
ec46e594
...
...
@@ -11,7 +11,7 @@ import (
"syscall"
"testing"
"time"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/raw"
)
...
...
zipfs/memtree.go
View file @
ec46e594
...
...
@@ -89,9 +89,9 @@ func (n *memNode) Deletable() bool {
return
false
}
func
(
n
*
memNode
)
GetAttr
(
out
*
fuse
.
Attr
,
file
fuse
.
File
,
context
*
fuse
.
Context
)
(
fuse
.
Status
)
{
func
(
n
*
memNode
)
GetAttr
(
out
*
fuse
.
Attr
,
file
fuse
.
File
,
context
*
fuse
.
Context
)
fuse
.
Status
{
if
n
.
Inode
()
.
IsDir
()
{
out
.
Mode
=
fuse
.
S_IFDIR
|
0777
out
.
Mode
=
fuse
.
S_IFDIR
|
0777
return
fuse
.
OK
}
n
.
file
.
Stat
(
out
)
...
...
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