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
b8e3280d
Commit
b8e3280d
authored
Jul 29, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a Name function to the FileSystem.
parent
5f46e065
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
40 additions
and
11 deletions
+40
-11
fuse/api.go
fuse/api.go
+3
-0
fuse/default.go
fuse/default.go
+4
-0
fuse/loopback.go
fuse/loopback.go
+5
-0
unionfs/autounion.go
unionfs/autounion.go
+6
-0
unionfs/cachingfs.go
unionfs/cachingfs.go
+4
-0
unionfs/create.go
unionfs/create.go
+1
-3
unionfs/unionfs.go
unionfs/unionfs.go
+7
-6
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+2
-2
zipfs/memtree.go
zipfs/memtree.go
+4
-0
zipfs/multizip.go
zipfs/multizip.go
+4
-0
No files found.
fuse/api.go
View file @
b8e3280d
...
@@ -16,6 +16,9 @@ import (
...
@@ -16,6 +16,9 @@ import (
// Include DefaultFileSystem to provide a default null implementation of
// Include DefaultFileSystem to provide a default null implementation of
// required methods.
// required methods.
type
FileSystem
interface
{
type
FileSystem
interface
{
// Used for pretty printing.
Name
()
string
// Attributes
// Attributes
GetAttr
(
name
string
)
(
*
os
.
FileInfo
,
Status
)
GetAttr
(
name
string
)
(
*
os
.
FileInfo
,
Status
)
...
...
fuse/default.go
View file @
b8e3280d
...
@@ -276,3 +276,7 @@ func (me *DefaultFileSystem) Create(name string, flags uint32, mode uint32) (fil
...
@@ -276,3 +276,7 @@ func (me *DefaultFileSystem) Create(name string, flags uint32, mode uint32) (fil
func
(
me
*
DefaultFileSystem
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
{
func
(
me
*
DefaultFileSystem
)
Utimens
(
name
string
,
AtimeNs
uint64
,
CtimeNs
uint64
)
(
code
Status
)
{
return
ENOSYS
return
ENOSYS
}
}
func
(
me
*
DefaultFileSystem
)
Name
()
string
{
return
"DefaultFileSystem"
}
fuse/loopback.go
View file @
b8e3280d
...
@@ -158,3 +158,8 @@ func (me *LoopbackFileSystem) ListXAttr(name string) ([]string, Status) {
...
@@ -158,3 +158,8 @@ func (me *LoopbackFileSystem) ListXAttr(name string) ([]string, Status) {
func
(
me
*
LoopbackFileSystem
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
{
func
(
me
*
LoopbackFileSystem
)
RemoveXAttr
(
name
string
,
attr
string
)
Status
{
return
Status
(
Removexattr
(
me
.
GetPath
(
name
),
attr
))
return
Status
(
Removexattr
(
me
.
GetPath
(
name
),
attr
))
}
}
func
(
me
*
LoopbackFileSystem
)
Name
()
string
{
return
fmt
.
Sprintf
(
"LoopbackFileSystem(%s)"
,
me
.
Root
)
}
unionfs/autounion.go
View file @
b8e3280d
package
unionfs
package
unionfs
import
(
import
(
"fmt"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse"
"log"
"log"
"os"
"os"
...
@@ -59,6 +60,10 @@ func NewAutoUnionFs(directory string, options AutoUnionFsOptions) *AutoUnionFs {
...
@@ -59,6 +60,10 @@ func NewAutoUnionFs(directory string, options AutoUnionFsOptions) *AutoUnionFs {
return
a
return
a
}
}
func
(
me
*
AutoUnionFs
)
Name
()
string
{
return
fmt
.
Sprintf
(
"AutoUnionFs(%s)"
,
me
.
root
)
}
func
(
me
*
AutoUnionFs
)
Mount
(
connector
*
fuse
.
FileSystemConnector
)
{
func
(
me
*
AutoUnionFs
)
Mount
(
connector
*
fuse
.
FileSystemConnector
)
{
me
.
connector
=
connector
me
.
connector
=
connector
if
me
.
options
.
UpdateOnMount
{
if
me
.
options
.
UpdateOnMount
{
...
@@ -356,3 +361,4 @@ func (me *AutoUnionFs) OpenDir(name string) (stream chan fuse.DirEntry, status f
...
@@ -356,3 +361,4 @@ func (me *AutoUnionFs) OpenDir(name string) (stream chan fuse.DirEntry, status f
close
(
stream
)
close
(
stream
)
return
stream
,
status
return
stream
,
status
}
}
unionfs/cachingfs.go
View file @
b8e3280d
...
@@ -139,6 +139,10 @@ func (me *CachingFileSystem) OpenDir(name string) (stream chan fuse.DirEntry, st
...
@@ -139,6 +139,10 @@ func (me *CachingFileSystem) OpenDir(name string) (stream chan fuse.DirEntry, st
return
nil
,
r
.
Status
return
nil
,
r
.
Status
}
}
func
(
me
*
CachingFileSystem
)
Name
()
string
{
return
fmt
.
Sprintf
(
"CachingFileSystem(%s)"
,
me
.
FileSystem
.
Name
())
}
func
(
me
*
CachingFileSystem
)
Open
(
name
string
,
flags
uint32
)
(
f
fuse
.
File
,
status
fuse
.
Status
)
{
func
(
me
*
CachingFileSystem
)
Open
(
name
string
,
flags
uint32
)
(
f
fuse
.
File
,
status
fuse
.
Status
)
{
if
flags
&
fuse
.
O_ANYWRITE
!=
0
&&
name
==
_DROP_CACHE
{
if
flags
&
fuse
.
O_ANYWRITE
!=
0
&&
name
==
_DROP_CACHE
{
me
.
DropCache
()
me
.
DropCache
()
...
...
unionfs/create.go
View file @
b8e3280d
package
unionfs
package
unionfs
import
(
import
(
"fmt"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/zipfs"
"github.com/hanwen/go-fuse/zipfs"
"os"
"os"
...
@@ -32,6 +31,5 @@ func NewUnionFsFromRoots(roots []string, opts *UnionFsOptions, roCaching bool) (
...
@@ -32,6 +31,5 @@ func NewUnionFsFromRoots(roots []string, opts *UnionFsOptions, roCaching bool) (
fses
=
append
(
fses
,
fs
)
fses
=
append
(
fses
,
fs
)
}
}
identifier
:=
fmt
.
Sprintf
(
"%v"
,
roots
)
return
NewUnionFs
(
fses
,
*
opts
),
nil
return
NewUnionFs
(
identifier
,
fses
,
*
opts
),
nil
}
}
unionfs/unionfs.go
View file @
b8e3280d
...
@@ -60,8 +60,6 @@ func filePathHash(path string) string {
...
@@ -60,8 +60,6 @@ func filePathHash(path string) string {
type
UnionFs
struct
{
type
UnionFs
struct
{
fuse
.
DefaultFileSystem
fuse
.
DefaultFileSystem
name
string
// The same, but as interfaces.
// The same, but as interfaces.
fileSystems
[]
fuse
.
FileSystem
fileSystems
[]
fuse
.
FileSystem
...
@@ -84,9 +82,8 @@ const (
...
@@ -84,9 +82,8 @@ const (
_DROP_CACHE
=
".drop_cache"
_DROP_CACHE
=
".drop_cache"
)
)
func
NewUnionFs
(
name
string
,
fileSystems
[]
fuse
.
FileSystem
,
options
UnionFsOptions
)
*
UnionFs
{
func
NewUnionFs
(
fileSystems
[]
fuse
.
FileSystem
,
options
UnionFsOptions
)
*
UnionFs
{
g
:=
new
(
UnionFs
)
g
:=
new
(
UnionFs
)
g
.
name
=
name
g
.
options
=
&
options
g
.
options
=
&
options
g
.
fileSystems
=
fileSystems
g
.
fileSystems
=
fileSystems
...
@@ -745,7 +742,7 @@ func (me *UnionFs) DropSubFsCaches() {
...
@@ -745,7 +742,7 @@ func (me *UnionFs) DropSubFsCaches() {
func
(
me
*
UnionFs
)
Open
(
name
string
,
flags
uint32
)
(
fuseFile
fuse
.
File
,
status
fuse
.
Status
)
{
func
(
me
*
UnionFs
)
Open
(
name
string
,
flags
uint32
)
(
fuseFile
fuse
.
File
,
status
fuse
.
Status
)
{
if
name
==
_DROP_CACHE
{
if
name
==
_DROP_CACHE
{
if
flags
&
fuse
.
O_ANYWRITE
!=
0
{
if
flags
&
fuse
.
O_ANYWRITE
!=
0
{
log
.
Println
(
"Forced cache drop on"
,
me
.
name
)
log
.
Println
(
"Forced cache drop on"
,
me
.
Name
()
)
me
.
DropBranchCache
()
me
.
DropBranchCache
()
me
.
DropDeletionCache
()
me
.
DropDeletionCache
()
me
.
DropSubFsCaches
()
me
.
DropSubFsCaches
()
...
@@ -778,5 +775,9 @@ func (me *UnionFs) Flush(name string) fuse.Status {
...
@@ -778,5 +775,9 @@ func (me *UnionFs) Flush(name string) fuse.Status {
}
}
func
(
me
*
UnionFs
)
Name
()
string
{
func
(
me
*
UnionFs
)
Name
()
string
{
return
me
.
name
names
:=
[]
string
{}
for
_
,
fs
:=
range
me
.
fileSystems
{
names
=
append
(
names
,
fs
.
Name
())
}
return
fmt
.
Sprintf
(
"%v"
,
names
)
}
}
unionfs/unionfs_test.go
View file @
b8e3280d
...
@@ -42,7 +42,7 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) {
...
@@ -42,7 +42,7 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) {
fses
=
append
(
fses
,
fuse
.
NewLoopbackFileSystem
(
wd
+
"/rw"
))
fses
=
append
(
fses
,
fuse
.
NewLoopbackFileSystem
(
wd
+
"/rw"
))
fses
=
append
(
fses
,
fses
=
append
(
fses
,
NewCachingFileSystem
(
fuse
.
NewLoopbackFileSystem
(
wd
+
"/ro"
),
0
))
NewCachingFileSystem
(
fuse
.
NewLoopbackFileSystem
(
wd
+
"/ro"
),
0
))
ufs
:=
NewUnionFs
(
"testFs"
,
fses
,
testOpts
)
ufs
:=
NewUnionFs
(
fses
,
testOpts
)
// We configure timeouts are smaller, so we can check for
// We configure timeouts are smaller, so we can check for
// UnionFs's cache consistency.
// UnionFs's cache consistency.
...
@@ -630,7 +630,7 @@ func TestDisappearing(t *testing.T) {
...
@@ -630,7 +630,7 @@ func TestDisappearing(t *testing.T) {
var
fses
[]
fuse
.
FileSystem
var
fses
[]
fuse
.
FileSystem
fses
=
append
(
fses
,
wrFs
)
fses
=
append
(
fses
,
wrFs
)
fses
=
append
(
fses
,
fuse
.
NewLoopbackFileSystem
(
wd
+
"/ro"
))
fses
=
append
(
fses
,
fuse
.
NewLoopbackFileSystem
(
wd
+
"/ro"
))
ufs
:=
NewUnionFs
(
"testFs"
,
fses
,
testOpts
)
ufs
:=
NewUnionFs
(
fses
,
testOpts
)
opts
:=
&
fuse
.
FileSystemOptions
{
opts
:=
&
fuse
.
FileSystemOptions
{
EntryTimeout
:
entryTtl
,
EntryTimeout
:
entryTtl
,
...
...
zipfs/memtree.go
View file @
b8e3280d
...
@@ -89,6 +89,10 @@ func NewMemTreeFileSystem(t *MemTree) *MemTreeFileSystem {
...
@@ -89,6 +89,10 @@ func NewMemTreeFileSystem(t *MemTree) *MemTreeFileSystem {
const
mem_DIRMODE
uint32
=
fuse
.
S_IFDIR
|
0500
const
mem_DIRMODE
uint32
=
fuse
.
S_IFDIR
|
0500
const
mem_FILEMODE
uint32
=
fuse
.
S_IFREG
|
0400
const
mem_FILEMODE
uint32
=
fuse
.
S_IFREG
|
0400
func
(
me
*
MemTreeFileSystem
)
Name
()
string
{
return
"MemTreeFileSystem"
}
func
(
me
*
MemTreeFileSystem
)
GetAttr
(
name
string
)
(
*
os
.
FileInfo
,
fuse
.
Status
)
{
func
(
me
*
MemTreeFileSystem
)
GetAttr
(
name
string
)
(
*
os
.
FileInfo
,
fuse
.
Status
)
{
dir
,
file
:=
me
.
tree
.
Lookup
(
name
)
dir
,
file
:=
me
.
tree
.
Lookup
(
name
)
if
dir
==
nil
{
if
dir
==
nil
{
...
...
zipfs/multizip.go
View file @
b8e3280d
...
@@ -46,6 +46,10 @@ func NewMultiZipFs() *MultiZipFs {
...
@@ -46,6 +46,10 @@ func NewMultiZipFs() *MultiZipFs {
return
m
return
m
}
}
func
(
me
*
MultiZipFs
)
Name
()
string
{
return
"MultiZipFs"
}
func
(
me
*
MultiZipFs
)
Mount
(
connector
*
fuse
.
FileSystemConnector
)
{
func
(
me
*
MultiZipFs
)
Mount
(
connector
*
fuse
.
FileSystemConnector
)
{
me
.
Connector
=
connector
me
.
Connector
=
connector
}
}
...
...
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