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
3d9d5c3f
Commit
3d9d5c3f
authored
Jun 23, 2013
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide pathfs.DefaultFileSystem to reduce API clutter.
parent
f2ebdfe7
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
68 additions
and
53 deletions
+68
-53
fuse/pathfs/api.go
fuse/pathfs/api.go
+2
-2
fuse/pathfs/default.go
fuse/pathfs/default.go
+34
-30
fuse/pathfs/loopback.go
fuse/pathfs/loopback.go
+6
-3
fuse/pathfs/owner_test.go
fuse/pathfs/owner_test.go
+2
-2
fuse/pathfs/pathfs.go
fuse/pathfs/pathfs.go
+1
-1
fuse/pathfs/xattr_test.go
fuse/pathfs/xattr_test.go
+7
-4
fuse/test/cache_test.go
fuse/test/cache_test.go
+2
-2
fuse/test/defaultread_test.go
fuse/test/defaultread_test.go
+5
-4
fuse/test/fsetattr_test.go
fuse/test/fsetattr_test.go
+7
-3
fuse/test/notify_test.go
fuse/test/notify_test.go
+2
-2
No files found.
fuse/pathfs/api.go
View file @
3d9d5c3f
...
...
@@ -11,8 +11,8 @@ import (
// Typically, each call happens in its own goroutine, so take care to
// make the file system thread-safe.
//
//
Include DefaultFileSystem to provide a default null implementation of
//
required
methods.
//
NewDefaultFileSystem provides a null implementation of required
// methods.
type
FileSystem
interface
{
// Used for pretty printing.
String
()
string
...
...
fuse/pathfs/default.go
View file @
3d9d5c3f
...
...
@@ -6,106 +6,110 @@ import (
"github.com/hanwen/go-fuse/fuse"
)
var
_
=
FileSystem
((
*
DefaultFileSystem
)(
nil
))
// NewDefaultFileSystem creates a filesystem that responds ENOSYS for
// all methods
func
NewDefaultFileSystem
()
FileSystem
{
return
(
*
defaultFileSystem
)(
nil
)
}
//
D
efaultFileSystem implements a FileSystem that returns ENOSYS for every operation.
type
D
efaultFileSystem
struct
{}
//
d
efaultFileSystem implements a FileSystem that returns ENOSYS for every operation.
type
d
efaultFileSystem
struct
{}
//
D
efaultFileSystem
func
(
fs
*
D
efaultFileSystem
)
GetAttr
(
name
string
,
context
*
fuse
.
Context
)
(
*
fuse
.
Attr
,
fuse
.
Status
)
{
//
d
efaultFileSystem
func
(
fs
*
d
efaultFileSystem
)
GetAttr
(
name
string
,
context
*
fuse
.
Context
)
(
*
fuse
.
Attr
,
fuse
.
Status
)
{
return
nil
,
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
GetXAttr
(
name
string
,
attr
string
,
context
*
fuse
.
Context
)
([]
byte
,
fuse
.
Status
)
{
func
(
fs
*
d
efaultFileSystem
)
GetXAttr
(
name
string
,
attr
string
,
context
*
fuse
.
Context
)
([]
byte
,
fuse
.
Status
)
{
return
nil
,
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
,
context
*
fuse
.
Context
)
fuse
.
Status
{
func
(
fs
*
d
efaultFileSystem
)
SetXAttr
(
name
string
,
attr
string
,
data
[]
byte
,
flags
int
,
context
*
fuse
.
Context
)
fuse
.
Status
{
return
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
ListXAttr
(
name
string
,
context
*
fuse
.
Context
)
([]
string
,
fuse
.
Status
)
{
func
(
fs
*
d
efaultFileSystem
)
ListXAttr
(
name
string
,
context
*
fuse
.
Context
)
([]
string
,
fuse
.
Status
)
{
return
nil
,
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
RemoveXAttr
(
name
string
,
attr
string
,
context
*
fuse
.
Context
)
fuse
.
Status
{
func
(
fs
*
d
efaultFileSystem
)
RemoveXAttr
(
name
string
,
attr
string
,
context
*
fuse
.
Context
)
fuse
.
Status
{
return
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
Readlink
(
name
string
,
context
*
fuse
.
Context
)
(
string
,
fuse
.
Status
)
{
func
(
fs
*
d
efaultFileSystem
)
Readlink
(
name
string
,
context
*
fuse
.
Context
)
(
string
,
fuse
.
Status
)
{
return
""
,
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
,
context
*
fuse
.
Context
)
fuse
.
Status
{
func
(
fs
*
d
efaultFileSystem
)
Mknod
(
name
string
,
mode
uint32
,
dev
uint32
,
context
*
fuse
.
Context
)
fuse
.
Status
{
return
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
Mkdir
(
name
string
,
mode
uint32
,
context
*
fuse
.
Context
)
fuse
.
Status
{
func
(
fs
*
d
efaultFileSystem
)
Mkdir
(
name
string
,
mode
uint32
,
context
*
fuse
.
Context
)
fuse
.
Status
{
return
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
Unlink
(
name
string
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
func
(
fs
*
d
efaultFileSystem
)
Unlink
(
name
string
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
Rmdir
(
name
string
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
func
(
fs
*
d
efaultFileSystem
)
Rmdir
(
name
string
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
Symlink
(
value
string
,
linkName
string
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
func
(
fs
*
d
efaultFileSystem
)
Symlink
(
value
string
,
linkName
string
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
Rename
(
oldName
string
,
newName
string
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
func
(
fs
*
d
efaultFileSystem
)
Rename
(
oldName
string
,
newName
string
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
Link
(
oldName
string
,
newName
string
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
func
(
fs
*
d
efaultFileSystem
)
Link
(
oldName
string
,
newName
string
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
Chmod
(
name
string
,
mode
uint32
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
func
(
fs
*
d
efaultFileSystem
)
Chmod
(
name
string
,
mode
uint32
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
func
(
fs
*
d
efaultFileSystem
)
Chown
(
name
string
,
uid
uint32
,
gid
uint32
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
Truncate
(
name
string
,
offset
uint64
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
func
(
fs
*
d
efaultFileSystem
)
Truncate
(
name
string
,
offset
uint64
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
Open
(
name
string
,
flags
uint32
,
context
*
fuse
.
Context
)
(
file
fuse
.
File
,
code
fuse
.
Status
)
{
func
(
fs
*
d
efaultFileSystem
)
Open
(
name
string
,
flags
uint32
,
context
*
fuse
.
Context
)
(
file
fuse
.
File
,
code
fuse
.
Status
)
{
return
nil
,
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
OpenDir
(
name
string
,
context
*
fuse
.
Context
)
(
stream
[]
fuse
.
DirEntry
,
status
fuse
.
Status
)
{
func
(
fs
*
d
efaultFileSystem
)
OpenDir
(
name
string
,
context
*
fuse
.
Context
)
(
stream
[]
fuse
.
DirEntry
,
status
fuse
.
Status
)
{
return
nil
,
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
OnMount
(
nodeFs
*
PathNodeFs
)
{
func
(
fs
*
d
efaultFileSystem
)
OnMount
(
nodeFs
*
PathNodeFs
)
{
}
func
(
fs
*
D
efaultFileSystem
)
OnUnmount
()
{
func
(
fs
*
d
efaultFileSystem
)
OnUnmount
()
{
}
func
(
fs
*
D
efaultFileSystem
)
Access
(
name
string
,
mode
uint32
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
func
(
fs
*
d
efaultFileSystem
)
Access
(
name
string
,
mode
uint32
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
,
context
*
fuse
.
Context
)
(
file
fuse
.
File
,
code
fuse
.
Status
)
{
func
(
fs
*
d
efaultFileSystem
)
Create
(
name
string
,
flags
uint32
,
mode
uint32
,
context
*
fuse
.
Context
)
(
file
fuse
.
File
,
code
fuse
.
Status
)
{
return
nil
,
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
Utimens
(
name
string
,
Atime
*
time
.
Time
,
Mtime
*
time
.
Time
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
func
(
fs
*
d
efaultFileSystem
)
Utimens
(
name
string
,
Atime
*
time
.
Time
,
Mtime
*
time
.
Time
,
context
*
fuse
.
Context
)
(
code
fuse
.
Status
)
{
return
fuse
.
ENOSYS
}
func
(
fs
*
D
efaultFileSystem
)
String
()
string
{
return
"
D
efaultFileSystem"
func
(
fs
*
d
efaultFileSystem
)
String
()
string
{
return
"
d
efaultFileSystem"
}
func
(
fs
*
D
efaultFileSystem
)
StatFs
(
name
string
)
*
fuse
.
StatfsOut
{
func
(
fs
*
d
efaultFileSystem
)
StatFs
(
name
string
)
*
fuse
.
StatfsOut
{
return
nil
}
fuse/pathfs/loopback.go
View file @
3d9d5c3f
...
...
@@ -17,15 +17,18 @@ var _ = log.Println
type
loopbackFileSystem
struct
{
Root
string
DefaultFileSystem
FileSystem
}
// A FUSE filesystem that shunts all request to an underlying file
// system. Its main purpose is to provide test coverage without
// having to build a synthetic filesystem.
func
NewLoopbackFileSystem
(
root
string
)
(
out
*
loopbackFileSystem
)
{
out
=
new
(
loopbackFileSystem
)
out
.
Root
=
root
out
=
&
loopbackFileSystem
{
FileSystem
:
NewDefaultFileSystem
(),
Root
:
root
,
}
return
out
}
...
...
fuse/pathfs/owner_test.go
View file @
3d9d5c3f
...
...
@@ -10,7 +10,7 @@ import (
)
type
ownerFs
struct
{
Default
FileSystem
FileSystem
}
const
_RANDOM_OWNER
=
31415265
...
...
@@ -32,7 +32,7 @@ func (fs *ownerFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse
func
setupOwnerTest
(
t
*
testing
.
T
,
opts
*
fuse
.
FileSystemOptions
)
(
workdir
string
,
cleanup
func
())
{
wd
,
err
:=
ioutil
.
TempDir
(
""
,
"go-fuse-owner_test"
)
fs
:=
&
ownerFs
{}
fs
:=
&
ownerFs
{
NewDefaultFileSystem
()
}
nfs
:=
NewPathNodeFs
(
fs
,
nil
)
state
,
_
,
err
:=
fuse
.
MountNodeFileSystem
(
wd
,
nfs
,
opts
)
if
err
!=
nil
{
...
...
fuse/pathfs/pathfs.go
View file @
3d9d5c3f
...
...
@@ -97,7 +97,7 @@ func (fs *PathNodeFs) OnUnmount() {
func
(
fs
*
PathNodeFs
)
String
()
string
{
name
:=
fs
.
fs
.
String
()
if
name
==
"
D
efaultFileSystem"
{
if
name
==
"
d
efaultFileSystem"
{
name
=
fmt
.
Sprintf
(
"%T"
,
fs
.
fs
)
name
=
strings
.
TrimLeft
(
name
,
"*"
)
}
...
...
fuse/pathfs/xattr_test.go
View file @
3d9d5c3f
...
...
@@ -24,13 +24,16 @@ type XAttrTestFs struct {
filename
string
attrs
map
[
string
][]
byte
Default
FileSystem
FileSystem
}
func
NewXAttrFs
(
nm
string
,
m
map
[
string
][]
byte
)
*
XAttrTestFs
{
x
:=
new
(
XAttrTestFs
)
x
.
filename
=
nm
x
.
attrs
=
make
(
map
[
string
][]
byte
,
len
(
m
))
x
:=
&
XAttrTestFs
{
filename
:
nm
,
attrs
:
make
(
map
[
string
][]
byte
,
len
(
m
)),
FileSystem
:
NewDefaultFileSystem
(),
}
for
k
,
v
:=
range
m
{
x
.
attrs
[
k
]
=
v
}
...
...
fuse/test/cache_test.go
View file @
3d9d5c3f
...
...
@@ -109,7 +109,7 @@ func TestCacheFs(t *testing.T) {
}
type
nonseekFs
struct
{
pathfs
.
Default
FileSystem
pathfs
.
FileSystem
Length
int
}
...
...
@@ -134,7 +134,7 @@ func (fs *nonseekFs) Open(name string, flags uint32, context *fuse.Context) (fus
}
func
TestNonseekable
(
t
*
testing
.
T
)
{
fs
:=
&
nonseekFs
{}
fs
:=
&
nonseekFs
{
FileSystem
:
pathfs
.
NewDefaultFileSystem
()
}
fs
.
Length
=
200
*
1024
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"go-fuse-cache_test"
)
...
...
fuse/test/defaultread_test.go
View file @
3d9d5c3f
...
...
@@ -2,7 +2,6 @@ package test
import
(
"io/ioutil"
"log"
"os"
"testing"
...
...
@@ -10,10 +9,9 @@ import (
"github.com/hanwen/go-fuse/fuse/pathfs"
)
var
_
=
log
.
Println
type
DefaultReadFS
struct
{
pathfs
.
Default
FileSystem
pathfs
.
FileSystem
size
uint64
exist
bool
}
...
...
@@ -33,7 +31,10 @@ func (fs *DefaultReadFS) Open(name string, f uint32, context *fuse.Context) (fus
}
func
defaultReadTest
(
t
*
testing
.
T
)
(
root
string
,
cleanup
func
())
{
fs
:=
&
DefaultReadFS
{}
fs
:=
&
DefaultReadFS
{
FileSystem
:
pathfs
.
NewDefaultFileSystem
(),
}
var
err
error
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"go-fuse"
)
if
err
!=
nil
{
...
...
fuse/test/fsetattr_test.go
View file @
3d9d5c3f
...
...
@@ -90,7 +90,7 @@ func (f *MutableDataFile) Chmod(perms uint32) fuse.Status {
// This FS only supports a single r/w file called "/file".
type
FSetAttrFs
struct
{
pathfs
.
Default
FileSystem
pathfs
.
FileSystem
file
*
MutableDataFile
}
...
...
@@ -162,7 +162,9 @@ func setupFAttrTest(t *testing.T, fs pathfs.FileSystem) (dir string, clean func(
}
func
TestDataReadLarge
(
t
*
testing
.
T
)
{
fs
:=
&
FSetAttrFs
{}
fs
:=
&
FSetAttrFs
{
FileSystem
:
pathfs
.
NewDefaultFileSystem
(),
}
dir
,
clean
,
_
:=
setupFAttrTest
(
t
,
fs
)
defer
clean
()
...
...
@@ -181,7 +183,9 @@ func TestDataReadLarge(t *testing.T) {
}
func
TestFSetAttr
(
t
*
testing
.
T
)
{
fs
:=
&
FSetAttrFs
{}
fs
:=
&
FSetAttrFs
{
FileSystem
:
pathfs
.
NewDefaultFileSystem
(),
}
dir
,
clean
,
sync
:=
setupFAttrTest
(
t
,
fs
)
defer
clean
()
...
...
fuse/test/notify_test.go
View file @
3d9d5c3f
...
...
@@ -14,7 +14,7 @@ import (
var
_
=
log
.
Println
type
NotifyFs
struct
{
pathfs
.
Default
FileSystem
pathfs
.
FileSystem
size
uint64
exist
bool
}
...
...
@@ -46,7 +46,7 @@ type NotifyTest struct {
func
NewNotifyTest
(
t
*
testing
.
T
)
*
NotifyTest
{
me
:=
&
NotifyTest
{}
me
.
fs
=
&
NotifyFs
{}
me
.
fs
=
&
NotifyFs
{
FileSystem
:
pathfs
.
NewDefaultFileSystem
()
}
var
err
error
me
.
dir
,
err
=
ioutil
.
TempDir
(
""
,
"go-fuse-notify_test"
)
if
err
!=
nil
{
...
...
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