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
8278f60e
Commit
8278f60e
authored
Sep 29, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run gofmt.
parent
336fe3bc
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
60 additions
and
63 deletions
+60
-63
example/unionfs/main.go
example/unionfs/main.go
+1
-1
fuse/files.go
fuse/files.go
+0
-1
fuse/fsconnector.go
fuse/fsconnector.go
+1
-1
fuse/fsops.go
fuse/fsops.go
+1
-1
fuse/loopback_test.go
fuse/loopback_test.go
+3
-3
fuse/memnode.go
fuse/memnode.go
+1
-1
fuse/opcode.go
fuse/opcode.go
+9
-9
fuse/prefixfs.go
fuse/prefixfs.go
+1
-1
unionfs/memunionfs.go
unionfs/memunionfs.go
+8
-9
unionfs/memunionfs_test.go
unionfs/memunionfs_test.go
+15
-15
unionfs/unionfs.go
unionfs/unionfs.go
+3
-4
unionfs/unionfs_test.go
unionfs/unionfs_test.go
+17
-17
No files found.
example/unionfs/main.go
View file @
8278f60e
...
@@ -30,7 +30,7 @@ func main() {
...
@@ -30,7 +30,7 @@ func main() {
var
nodeFs
fuse
.
NodeFileSystem
var
nodeFs
fuse
.
NodeFileSystem
if
*
mem
{
if
*
mem
{
nodeFs
=
unionfs
.
NewMemUnionFs
(
nodeFs
=
unionfs
.
NewMemUnionFs
(
flag
.
Arg
(
1
)
+
"/"
,
&
fuse
.
LoopbackFileSystem
{
Root
:
flag
.
Arg
(
2
)})
flag
.
Arg
(
1
)
+
"/"
,
&
fuse
.
LoopbackFileSystem
{
Root
:
flag
.
Arg
(
2
)})
}
else
{
}
else
{
ufsOptions
:=
unionfs
.
UnionFsOptions
{
ufsOptions
:=
unionfs
.
UnionFsOptions
{
DeletionCacheTTLSecs
:
*
delcache_ttl
,
DeletionCacheTTLSecs
:
*
delcache_ttl
,
...
...
fuse/files.go
View file @
8278f60e
...
@@ -59,7 +59,6 @@ func (me *DevNullFile) String() string {
...
@@ -59,7 +59,6 @@ func (me *DevNullFile) String() string {
return
"DevNullFile"
return
"DevNullFile"
}
}
func
(
me
*
DevNullFile
)
Read
(
input
*
ReadIn
,
bp
BufferPool
)
([]
byte
,
Status
)
{
func
(
me
*
DevNullFile
)
Read
(
input
*
ReadIn
,
bp
BufferPool
)
([]
byte
,
Status
)
{
return
[]
byte
{},
OK
return
[]
byte
{},
OK
}
}
...
...
fuse/fsconnector.go
View file @
8278f60e
...
@@ -192,7 +192,7 @@ func (me *FileSystemConnector) Node(parent *Inode, fullPath string) (*Inode, []s
...
@@ -192,7 +192,7 @@ func (me *FileSystemConnector) Node(parent *Inode, fullPath string) (*Inode, []s
node
.
treeLock
.
RLock
()
node
.
treeLock
.
RLock
()
defer
node
.
treeLock
.
RUnlock
()
defer
node
.
treeLock
.
RUnlock
()
}
}
for
i
,
component
:=
range
comps
{
for
i
,
component
:=
range
comps
{
if
len
(
component
)
==
0
{
if
len
(
component
)
==
0
{
continue
continue
...
...
fuse/fsops.go
View file @
8278f60e
...
@@ -66,7 +66,7 @@ func (me *FileSystemConnector) Lookup(header *InHeader, name string) (out *Entry
...
@@ -66,7 +66,7 @@ func (me *FileSystemConnector) Lookup(header *InHeader, name string) (out *Entry
out
.
NodeId
=
me
.
lookupUpdate
(
child
)
out
.
NodeId
=
me
.
lookupUpdate
(
child
)
out
.
Generation
=
1
out
.
Generation
=
1
out
.
Ino
=
out
.
NodeId
out
.
Ino
=
out
.
NodeId
return
out
,
OK
return
out
,
OK
}
}
...
...
fuse/loopback_test.go
View file @
8278f60e
...
@@ -714,14 +714,14 @@ func TestFStatFs(t *testing.T) {
...
@@ -714,14 +714,14 @@ func TestFStatFs(t *testing.T) {
fOrig
,
err
:=
os
.
OpenFile
(
ts
.
orig
+
"/file"
,
os
.
O_CREATE
|
os
.
O_TRUNC
|
os
.
O_RDWR
,
0644
)
fOrig
,
err
:=
os
.
OpenFile
(
ts
.
orig
+
"/file"
,
os
.
O_CREATE
|
os
.
O_TRUNC
|
os
.
O_RDWR
,
0644
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
defer
fOrig
.
Close
()
defer
fOrig
.
Close
()
empty
:=
syscall
.
Statfs_t
{}
empty
:=
syscall
.
Statfs_t
{}
s1
:=
empty
s1
:=
empty
errno
:=
syscall
.
Fstatfs
(
fOrig
.
Fd
(),
&
s1
)
errno
:=
syscall
.
Fstatfs
(
fOrig
.
Fd
(),
&
s1
)
if
errno
!=
0
{
if
errno
!=
0
{
t
.
Fatal
(
"statfs orig"
,
err
)
t
.
Fatal
(
"statfs orig"
,
err
)
}
}
fMnt
,
err
:=
os
.
OpenFile
(
ts
.
mnt
+
"/file"
,
os
.
O_RDWR
,
0644
)
fMnt
,
err
:=
os
.
OpenFile
(
ts
.
mnt
+
"/file"
,
os
.
O_RDWR
,
0644
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
defer
fMnt
.
Close
()
defer
fMnt
.
Close
()
...
@@ -731,7 +731,7 @@ func TestFStatFs(t *testing.T) {
...
@@ -731,7 +731,7 @@ func TestFStatFs(t *testing.T) {
if
errno
!=
0
{
if
errno
!=
0
{
t
.
Fatal
(
"statfs mnt"
,
err
)
t
.
Fatal
(
"statfs mnt"
,
err
)
}
}
clearStatfs
(
&
s1
)
clearStatfs
(
&
s1
)
clearStatfs
(
&
s2
)
clearStatfs
(
&
s2
)
if
fmt
.
Sprintf
(
"%v"
,
s2
)
!=
fmt
.
Sprintf
(
"%v"
,
s1
)
{
if
fmt
.
Sprintf
(
"%v"
,
s2
)
!=
fmt
.
Sprintf
(
"%v"
,
s1
)
{
...
...
fuse/memnode.go
View file @
8278f60e
...
@@ -13,7 +13,7 @@ var _ = log.Println
...
@@ -13,7 +13,7 @@ var _ = log.Println
type
MemNodeFs
struct
{
type
MemNodeFs
struct
{
DefaultNodeFileSystem
DefaultNodeFileSystem
backingStorePrefix
string
backingStorePrefix
string
root
*
memNode
root
*
memNode
mutex
sync
.
Mutex
mutex
sync
.
Mutex
nextFree
int
nextFree
int
...
...
fuse/opcode.go
View file @
8278f60e
...
@@ -302,13 +302,13 @@ type operationFunc func(*MountState, *request)
...
@@ -302,13 +302,13 @@ type operationFunc func(*MountState, *request)
type
castPointerFunc
func
(
unsafe
.
Pointer
)
interface
{}
type
castPointerFunc
func
(
unsafe
.
Pointer
)
interface
{}
type
operationHandler
struct
{
type
operationHandler
struct
{
Name
string
Name
string
Func
operationFunc
Func
operationFunc
InputSize
uintptr
InputSize
uintptr
OutputSize
uintptr
OutputSize
uintptr
DecodeIn
castPointerFunc
DecodeIn
castPointerFunc
DecodeOut
castPointerFunc
DecodeOut
castPointerFunc
FileNames
int
FileNames
int
FileNameOut
bool
FileNameOut
bool
}
}
...
@@ -339,11 +339,11 @@ func init() {
...
@@ -339,11 +339,11 @@ func init() {
operationHandlers
[
i
]
=
&
operationHandler
{
Name
:
"UNKNOWN"
}
operationHandlers
[
i
]
=
&
operationHandler
{
Name
:
"UNKNOWN"
}
}
}
fileOps
:=
[]
opcode
{
_OP_READLINK
,
_OP_NOTIFY_ENTRY
}
fileOps
:=
[]
opcode
{
_OP_READLINK
,
_OP_NOTIFY_ENTRY
}
for
_
,
op
:=
range
fileOps
{
for
_
,
op
:=
range
fileOps
{
operationHandlers
[
op
]
.
FileNameOut
=
true
operationHandlers
[
op
]
.
FileNameOut
=
true
}
}
for
op
,
sz
:=
range
map
[
opcode
]
uintptr
{
for
op
,
sz
:=
range
map
[
opcode
]
uintptr
{
_OP_FORGET
:
unsafe
.
Sizeof
(
ForgetIn
{}),
_OP_FORGET
:
unsafe
.
Sizeof
(
ForgetIn
{}),
_OP_GETATTR
:
unsafe
.
Sizeof
(
GetAttrIn
{}),
_OP_GETATTR
:
unsafe
.
Sizeof
(
GetAttrIn
{}),
...
...
fuse/prefixfs.go
View file @
8278f60e
...
@@ -14,7 +14,7 @@ type PrefixFileSystem struct {
...
@@ -14,7 +14,7 @@ type PrefixFileSystem struct {
func
(
me
*
PrefixFileSystem
)
prefixed
(
n
string
)
string
{
func
(
me
*
PrefixFileSystem
)
prefixed
(
n
string
)
string
{
return
filepath
.
Join
(
me
.
Prefix
,
n
)
return
filepath
.
Join
(
me
.
Prefix
,
n
)
}
}
func
(
me
*
PrefixFileSystem
)
GetAttr
(
name
string
,
context
*
Context
)
(
*
os
.
FileInfo
,
Status
)
{
func
(
me
*
PrefixFileSystem
)
GetAttr
(
name
string
,
context
*
Context
)
(
*
os
.
FileInfo
,
Status
)
{
return
me
.
FileSystem
.
GetAttr
(
me
.
prefixed
(
name
),
context
)
return
me
.
FileSystem
.
GetAttr
(
me
.
prefixed
(
name
),
context
)
...
...
unionfs/memunionfs.go
View file @
8278f60e
...
@@ -20,9 +20,9 @@ type MemUnionFs struct {
...
@@ -20,9 +20,9 @@ type MemUnionFs struct {
backingStore
string
backingStore
string
root
*
memNode
root
*
memNode
connector
*
fuse
.
FileSystemConnector
connector
*
fuse
.
FileSystemConnector
mutex
sync
.
RWMutex
mutex
sync
.
RWMutex
cond
*
sync
.
Cond
cond
*
sync
.
Cond
nextFree
int
nextFree
int
readonly
fuse
.
FileSystem
readonly
fuse
.
FileSystem
...
@@ -31,7 +31,7 @@ type MemUnionFs struct {
...
@@ -31,7 +31,7 @@ type MemUnionFs struct {
// All paths that have been renamed or deleted will be marked
// All paths that have been renamed or deleted will be marked
// here. After deletion, entries may be recreated, but they
// here. After deletion, entries may be recreated, but they
// will be treated as new.
// will be treated as new.
deleted
map
[
string
]
bool
deleted
map
[
string
]
bool
}
}
type
memNode
struct
{
type
memNode
struct
{
...
@@ -87,7 +87,7 @@ func (me *MemUnionFs) Reap() map[string]*Result {
...
@@ -87,7 +87,7 @@ func (me *MemUnionFs) Reap() map[string]*Result {
todo
:=
[]
string
{
name
}
todo
:=
[]
string
{
name
}
for
len
(
todo
)
>
0
{
for
len
(
todo
)
>
0
{
l
:=
len
(
todo
)
-
1
l
:=
len
(
todo
)
-
1
n
:=
todo
[
l
]
n
:=
todo
[
l
]
todo
=
todo
[
:
l
]
todo
=
todo
[
:
l
]
...
@@ -95,7 +95,7 @@ func (me *MemUnionFs) Reap() map[string]*Result {
...
@@ -95,7 +95,7 @@ func (me *MemUnionFs) Reap() map[string]*Result {
for
e
:=
range
s
{
for
e
:=
range
s
{
full
:=
filepath
.
Join
(
n
,
e
.
Name
)
full
:=
filepath
.
Join
(
n
,
e
.
Name
)
m
[
full
]
=
&
Result
{}
m
[
full
]
=
&
Result
{}
if
e
.
Mode
&
fuse
.
S_IFDIR
!=
0
{
if
e
.
Mode
&
fuse
.
S_IFDIR
!=
0
{
todo
=
append
(
todo
,
full
)
todo
=
append
(
todo
,
full
)
}
}
}
}
...
@@ -137,7 +137,7 @@ func (me *MemUnionFs) Update(results map[string]*Result) {
...
@@ -137,7 +137,7 @@ func (me *MemUnionFs) Update(results map[string]*Result) {
}
}
sort
.
Strings
(
del
)
sort
.
Strings
(
del
)
for
i
:=
len
(
del
)
-
1
;
i
>=
0
;
i
--
{
for
i
:=
len
(
del
)
-
1
;
i
>=
0
;
i
--
{
n
:=
del
[
i
]
n
:=
del
[
i
]
dir
,
base
:=
filepath
.
Split
(
n
)
dir
,
base
:=
filepath
.
Split
(
n
)
dir
=
strings
.
TrimRight
(
dir
,
"/"
)
dir
=
strings
.
TrimRight
(
dir
,
"/"
)
...
@@ -600,7 +600,7 @@ func (me *memNode) Reap(path string, results map[string]*Result) {
...
@@ -600,7 +600,7 @@ func (me *memNode) Reap(path string, results map[string]*Result) {
if
me
.
changed
{
if
me
.
changed
{
info
:=
me
.
info
info
:=
me
.
info
results
[
path
]
=
&
Result
{
results
[
path
]
=
&
Result
{
FileInfo
:
&
info
,
FileInfo
:
&
info
,
Link
:
me
.
link
,
Link
:
me
.
link
,
Backing
:
me
.
backing
,
Backing
:
me
.
backing
,
Original
:
me
.
original
,
Original
:
me
.
original
,
...
@@ -633,4 +633,3 @@ func (me *memNode) Clear(path string) {
...
@@ -633,4 +633,3 @@ func (me *memNode) Clear(path string) {
mn
.
Clear
(
p
)
mn
.
Clear
(
p
)
}
}
}
}
unionfs/memunionfs_test.go
View file @
8278f60e
...
@@ -32,7 +32,7 @@ func setupMemUfs(t *testing.T) (workdir string, ufs *MemUnionFs, cleanup func())
...
@@ -32,7 +32,7 @@ func setupMemUfs(t *testing.T) (workdir string, ufs *MemUnionFs, cleanup func())
os
.
Mkdir
(
wd
+
"/ro"
,
0700
)
os
.
Mkdir
(
wd
+
"/ro"
,
0700
)
fuse
.
CheckSuccess
(
err
)
fuse
.
CheckSuccess
(
err
)
roFs
:=
fuse
.
NewLoopbackFileSystem
(
wd
+
"/ro"
)
roFs
:=
fuse
.
NewLoopbackFileSystem
(
wd
+
"/ro"
)
memFs
:=
NewMemUnionFs
(
wd
+
"/backing"
,
roFs
)
memFs
:=
NewMemUnionFs
(
wd
+
"/backing"
,
roFs
)
// We configure timeouts are smaller, so we can check for
// We configure timeouts are smaller, so we can check for
...
@@ -84,7 +84,7 @@ func TestMemUnionFsSymlinkPromote(t *testing.T) {
...
@@ -84,7 +84,7 @@ func TestMemUnionFsSymlinkPromote(t *testing.T) {
err
=
os
.
Symlink
(
"/foobar"
,
wd
+
"/mount/subdir/link"
)
err
=
os
.
Symlink
(
"/foobar"
,
wd
+
"/mount/subdir/link"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
r
:=
ufs
.
Reap
()
r
:=
ufs
.
Reap
()
if
len
(
r
)
!=
2
||
r
[
"subdir"
]
==
nil
||
r
[
"subdir/link"
]
==
nil
||
r
[
"subdir/link"
]
.
Link
!=
"/foobar"
{
if
len
(
r
)
!=
2
||
r
[
"subdir"
]
==
nil
||
r
[
"subdir/link"
]
==
nil
||
r
[
"subdir/link"
]
.
Link
!=
"/foobar"
{
t
.
Errorf
(
"expect 1 symlink reap result: %v"
,
r
)
t
.
Errorf
(
"expect 1 symlink reap result: %v"
,
r
)
...
@@ -231,7 +231,7 @@ func TestMemUnionFsSubdirCreate(t *testing.T) {
...
@@ -231,7 +231,7 @@ func TestMemUnionFsSubdirCreate(t *testing.T) {
writeToFile
(
wd
+
"/mount/subdir/sub2/file"
,
"other-content"
)
writeToFile
(
wd
+
"/mount/subdir/sub2/file"
,
"other-content"
)
_
,
err
=
os
.
Lstat
(
wd
+
"/mount/subdir/sub2/file"
)
_
,
err
=
os
.
Lstat
(
wd
+
"/mount/subdir/sub2/file"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
r
:=
ufs
.
Reap
()
r
:=
ufs
.
Reap
()
if
r
[
"subdir/sub2/file"
]
==
nil
||
r
[
"subdir/sub2/file"
]
.
Backing
==
""
{
if
r
[
"subdir/sub2/file"
]
==
nil
||
r
[
"subdir/sub2/file"
]
.
Backing
==
""
{
t
.
Errorf
(
"expect 1 file reap result: %v"
,
r
)
t
.
Errorf
(
"expect 1 file reap result: %v"
,
r
)
...
@@ -245,7 +245,7 @@ func TestMemUnionFsCreate(t *testing.T) {
...
@@ -245,7 +245,7 @@ func TestMemUnionFsCreate(t *testing.T) {
writeToFile
(
wd
+
"/mount/file.txt"
,
"hello"
)
writeToFile
(
wd
+
"/mount/file.txt"
,
"hello"
)
_
,
err
:=
os
.
Lstat
(
wd
+
"/mount/file.txt"
)
_
,
err
:=
os
.
Lstat
(
wd
+
"/mount/file.txt"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
r
:=
ufs
.
Reap
()
r
:=
ufs
.
Reap
()
if
r
[
"file.txt"
]
==
nil
||
r
[
"file.txt"
]
.
Backing
==
""
{
if
r
[
"file.txt"
]
==
nil
||
r
[
"file.txt"
]
.
Backing
==
""
{
t
.
Errorf
(
"expect 1 file reap result: %v"
,
r
)
t
.
Errorf
(
"expect 1 file reap result: %v"
,
r
)
...
@@ -292,7 +292,7 @@ func TestMemUnionFsMkdirPromote(t *testing.T) {
...
@@ -292,7 +292,7 @@ func TestMemUnionFsMkdirPromote(t *testing.T) {
CheckSuccess
(
err
)
CheckSuccess
(
err
)
r
:=
ufs
.
Reap
()
r
:=
ufs
.
Reap
()
if
r
[
"subdir/subdir2/dir3"
]
==
nil
||
r
[
"subdir/subdir2/dir3"
]
.
FileInfo
.
Mode
&
fuse
.
S_IFDIR
==
0
{
if
r
[
"subdir/subdir2/dir3"
]
==
nil
||
r
[
"subdir/subdir2/dir3"
]
.
FileInfo
.
Mode
&
fuse
.
S_IFDIR
==
0
{
t
.
Errorf
(
"expect 1 file reap result: %v"
,
r
)
t
.
Errorf
(
"expect 1 file reap result: %v"
,
r
)
}
}
}
}
...
@@ -504,7 +504,7 @@ func TestMemUnionFsDoubleOpen(t *testing.T) {
...
@@ -504,7 +504,7 @@ func TestMemUnionFsDoubleOpen(t *testing.T) {
func
TestMemUnionFsUpdate
(
t
*
testing
.
T
)
{
func
TestMemUnionFsUpdate
(
t
*
testing
.
T
)
{
wd
,
ufs
,
clean
:=
setupMemUfs
(
t
)
wd
,
ufs
,
clean
:=
setupMemUfs
(
t
)
defer
clean
()
defer
clean
()
err
:=
ioutil
.
WriteFile
(
wd
+
"/ro/file1"
,
[]
byte
(
"blablabla"
),
0644
)
err
:=
ioutil
.
WriteFile
(
wd
+
"/ro/file1"
,
[]
byte
(
"blablabla"
),
0644
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
...
@@ -516,14 +516,14 @@ func TestMemUnionFsUpdate(t *testing.T) {
...
@@ -516,14 +516,14 @@ func TestMemUnionFsUpdate(t *testing.T) {
if
fi
,
_
:=
os
.
Lstat
(
wd
+
"/mount/symlink"
);
fi
!=
nil
{
if
fi
,
_
:=
os
.
Lstat
(
wd
+
"/mount/symlink"
);
fi
!=
nil
{
t
.
Fatal
(
"symlink should not exist"
,
fi
)
t
.
Fatal
(
"symlink should not exist"
,
fi
)
}
}
err
=
os
.
Remove
(
wd
+
"/ro/file1"
)
err
=
os
.
Remove
(
wd
+
"/ro/file1"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/file2"
,
[]
byte
(
"foobar"
),
0644
)
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/file2"
,
[]
byte
(
"foobar"
),
0644
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
err
=
os
.
Symlink
(
"target"
,
wd
+
"/ro/symlink"
)
err
=
os
.
Symlink
(
"target"
,
wd
+
"/ro/symlink"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
// Still have cached attributes.
// Still have cached attributes.
fi
,
err
:=
os
.
Lstat
(
wd
+
"/mount/file1"
)
fi
,
err
:=
os
.
Lstat
(
wd
+
"/mount/file1"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
...
@@ -538,7 +538,7 @@ func TestMemUnionFsUpdate(t *testing.T) {
...
@@ -538,7 +538,7 @@ func TestMemUnionFsUpdate(t *testing.T) {
CheckSuccess
(
err
)
CheckSuccess
(
err
)
roSymlinkFi
,
err
:=
os
.
Lstat
(
wd
+
"/ro/symlink"
)
roSymlinkFi
,
err
:=
os
.
Lstat
(
wd
+
"/ro/symlink"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
updates
:=
map
[
string
]
*
Result
{
updates
:=
map
[
string
]
*
Result
{
"file1"
:
&
Result
{
"file1"
:
&
Result
{
nil
,
""
,
""
,
""
,
nil
,
""
,
""
,
""
,
...
@@ -702,7 +702,7 @@ func TestMemUnionFsRenameDirBasic(t *testing.T) {
...
@@ -702,7 +702,7 @@ func TestMemUnionFsRenameDirBasic(t *testing.T) {
if
r
[
"dir"
]
==
nil
||
r
[
"dir"
]
.
FileInfo
!=
nil
||
r
[
"renamed/subdir"
]
==
nil
||
!
r
[
"renamed/subdir"
]
.
FileInfo
.
IsDirectory
()
{
if
r
[
"dir"
]
==
nil
||
r
[
"dir"
]
.
FileInfo
!=
nil
||
r
[
"renamed/subdir"
]
==
nil
||
!
r
[
"renamed/subdir"
]
.
FileInfo
.
IsDirectory
()
{
t
.
Errorf
(
"Reap should del dir, and add renamed/subdir: %v"
,
r
)
t
.
Errorf
(
"Reap should del dir, and add renamed/subdir: %v"
,
r
)
}
}
if
err
=
os
.
Mkdir
(
wd
+
"/mount/dir"
,
0755
);
err
!=
nil
{
if
err
=
os
.
Mkdir
(
wd
+
"/mount/dir"
,
0755
);
err
!=
nil
{
t
.
Errorf
(
"mkdir should succeed %v"
,
err
)
t
.
Errorf
(
"mkdir should succeed %v"
,
err
)
}
}
...
@@ -782,11 +782,11 @@ func TestMemUnionGc(t *testing.T) {
...
@@ -782,11 +782,11 @@ func TestMemUnionGc(t *testing.T) {
writeToFile
(
wd
+
"/mount/file1"
,
"other-content"
)
writeToFile
(
wd
+
"/mount/file1"
,
"other-content"
)
writeToFile
(
wd
+
"/mount/file2"
,
"other-content"
)
writeToFile
(
wd
+
"/mount/file2"
,
"other-content"
)
err
:=
os
.
Remove
(
wd
+
"/mount/file1"
)
err
:=
os
.
Remove
(
wd
+
"/mount/file1"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
ufs
.
Clear
()
ufs
.
Clear
()
entries
,
err
:=
ioutil
.
ReadDir
(
wd
+
"/backing"
)
entries
,
err
:=
ioutil
.
ReadDir
(
wd
+
"/backing"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
if
len
(
entries
)
!=
0
{
if
len
(
entries
)
!=
0
{
t
.
Fatalf
(
"should have 1 file after backing store gc: %v"
,
entries
)
t
.
Fatalf
(
"should have 1 file after backing store gc: %v"
,
entries
)
...
...
unionfs/unionfs.go
View file @
8278f60e
...
@@ -280,7 +280,7 @@ func (me *UnionFs) Promote(name string, srcResult branchResult, context *fuse.Co
...
@@ -280,7 +280,7 @@ func (me *UnionFs) Promote(name string, srcResult branchResult, context *fuse.Co
code
=
fuse
.
CopyFile
(
sourceFs
,
writable
,
name
,
name
,
context
)
code
=
fuse
.
CopyFile
(
sourceFs
,
writable
,
name
,
name
,
context
)
if
code
.
Ok
()
{
if
code
.
Ok
()
{
code
=
writable
.
Chmod
(
name
,
srcResult
.
attr
.
Mode
&
07777
|
0200
,
context
)
code
=
writable
.
Chmod
(
name
,
srcResult
.
attr
.
Mode
&
07777
|
0200
,
context
)
}
}
if
code
.
Ok
()
{
if
code
.
Ok
()
{
code
=
writable
.
Utimens
(
name
,
uint64
(
srcResult
.
attr
.
Atime_ns
),
code
=
writable
.
Utimens
(
name
,
uint64
(
srcResult
.
attr
.
Atime_ns
),
...
@@ -321,13 +321,12 @@ func (me *UnionFs) Promote(name string, srcResult branchResult, context *fuse.Co
...
@@ -321,13 +321,12 @@ func (me *UnionFs) Promote(name string, srcResult branchResult, context *fuse.Co
code
=
writable
.
Symlink
(
link
,
name
,
context
)
code
=
writable
.
Symlink
(
link
,
name
,
context
)
}
}
}
else
if
srcResult
.
attr
.
IsDirectory
()
{
}
else
if
srcResult
.
attr
.
IsDirectory
()
{
code
=
writable
.
Mkdir
(
name
,
srcResult
.
attr
.
Mode
&
07777
|
0200
,
context
)
code
=
writable
.
Mkdir
(
name
,
srcResult
.
attr
.
Mode
&
07777
|
0200
,
context
)
}
else
{
}
else
{
log
.
Println
(
"Unknown file type:"
,
srcResult
.
attr
)
log
.
Println
(
"Unknown file type:"
,
srcResult
.
attr
)
return
fuse
.
ENOSYS
return
fuse
.
ENOSYS
}
}
if
!
code
.
Ok
()
{
if
!
code
.
Ok
()
{
me
.
branchCache
.
GetFresh
(
name
)
me
.
branchCache
.
GetFresh
(
name
)
return
code
return
code
...
@@ -635,7 +634,7 @@ func (me *UnionFs) promoteDirsTo(filename string) fuse.Status {
...
@@ -635,7 +634,7 @@ func (me *UnionFs) promoteDirsTo(filename string) fuse.Status {
j
:=
len
(
todo
)
-
i
-
1
j
:=
len
(
todo
)
-
i
-
1
d
:=
todo
[
j
]
d
:=
todo
[
j
]
r
:=
results
[
j
]
r
:=
results
[
j
]
code
:=
me
.
fileSystems
[
0
]
.
Mkdir
(
d
,
r
.
attr
.
Mode
&
07777
|
0200
,
nil
)
code
:=
me
.
fileSystems
[
0
]
.
Mkdir
(
d
,
r
.
attr
.
Mode
&
07777
|
0200
,
nil
)
if
code
!=
fuse
.
OK
{
if
code
!=
fuse
.
OK
{
log
.
Println
(
"Error creating dir leading to path"
,
d
,
code
,
me
.
fileSystems
[
0
])
log
.
Println
(
"Error creating dir leading to path"
,
d
,
code
,
me
.
fileSystems
[
0
])
return
fuse
.
EPERM
return
fuse
.
EPERM
...
...
unionfs/unionfs_test.go
View file @
8278f60e
...
@@ -31,8 +31,8 @@ func freezeRo(dir string) {
...
@@ -31,8 +31,8 @@ func freezeRo(dir string) {
err
:=
filepath
.
Walk
(
err
:=
filepath
.
Walk
(
dir
,
dir
,
func
(
path
string
,
fi
*
os
.
FileInfo
,
err
os
.
Error
)
os
.
Error
{
func
(
path
string
,
fi
*
os
.
FileInfo
,
err
os
.
Error
)
os
.
Error
{
return
os
.
Chmod
(
path
,
(
fi
.
Mode
&
0777
)
&^
0222
)
return
os
.
Chmod
(
path
,
(
fi
.
Mode
&
0777
)
&^
0222
)
})
})
CheckSuccess
(
err
)
CheckSuccess
(
err
)
}
}
...
@@ -493,7 +493,7 @@ func TestUnionFsRenameDirAllSourcesGone(t *testing.T) {
...
@@ -493,7 +493,7 @@ func TestUnionFsRenameDirAllSourcesGone(t *testing.T) {
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/dir/file.txt"
,
[]
byte
{
42
},
0644
)
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/dir/file.txt"
,
[]
byte
{
42
},
0644
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
err
=
os
.
Rename
(
wd
+
"/mount/dir"
,
wd
+
"/mount/renamed"
)
err
=
os
.
Rename
(
wd
+
"/mount/dir"
,
wd
+
"/mount/renamed"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
...
@@ -515,7 +515,7 @@ func TestUnionFsRenameDirWithDeletions(t *testing.T) {
...
@@ -515,7 +515,7 @@ func TestUnionFsRenameDirWithDeletions(t *testing.T) {
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/dir/subdir/file.txt"
,
[]
byte
{
42
},
0644
)
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/dir/subdir/file.txt"
,
[]
byte
{
42
},
0644
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
if
fi
,
_
:=
os
.
Lstat
(
wd
+
"/mount/dir/subdir/file.txt"
);
fi
==
nil
||
!
fi
.
IsRegular
()
{
if
fi
,
_
:=
os
.
Lstat
(
wd
+
"/mount/dir/subdir/file.txt"
);
fi
==
nil
||
!
fi
.
IsRegular
()
{
t
.
Fatalf
(
"%s/mount/dir/subdir/file.txt should be file: %v"
,
wd
,
fi
)
t
.
Fatalf
(
"%s/mount/dir/subdir/file.txt should be file: %v"
,
wd
,
fi
)
...
@@ -582,7 +582,7 @@ func TestUnionFsWritableDir(t *testing.T) {
...
@@ -582,7 +582,7 @@ func TestUnionFsWritableDir(t *testing.T) {
dirname
:=
wd
+
"/ro/subdir"
dirname
:=
wd
+
"/ro/subdir"
err
:=
os
.
Mkdir
(
dirname
,
0555
)
err
:=
os
.
Mkdir
(
dirname
,
0555
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
fi
,
err
:=
os
.
Lstat
(
wd
+
"/mount/subdir"
)
fi
,
err
:=
os
.
Lstat
(
wd
+
"/mount/subdir"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
...
@@ -599,7 +599,7 @@ func TestUnionFsWriteAccess(t *testing.T) {
...
@@ -599,7 +599,7 @@ func TestUnionFsWriteAccess(t *testing.T) {
// No write perms.
// No write perms.
err
:=
ioutil
.
WriteFile
(
fn
,
[]
byte
(
"foo"
),
0444
)
err
:=
ioutil
.
WriteFile
(
fn
,
[]
byte
(
"foo"
),
0444
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
errno
:=
syscall
.
Access
(
wd
+
"/mount/file"
,
fuse
.
W_OK
)
errno
:=
syscall
.
Access
(
wd
+
"/mount/file"
,
fuse
.
W_OK
)
if
errno
!=
0
{
if
errno
!=
0
{
...
@@ -616,7 +616,7 @@ func TestUnionFsLink(t *testing.T) {
...
@@ -616,7 +616,7 @@ func TestUnionFsLink(t *testing.T) {
fn
:=
wd
+
"/ro/file"
fn
:=
wd
+
"/ro/file"
err
:=
ioutil
.
WriteFile
(
fn
,
[]
byte
(
content
),
0666
)
err
:=
ioutil
.
WriteFile
(
fn
,
[]
byte
(
content
),
0666
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
err
=
os
.
Link
(
wd
+
"/mount/file"
,
wd
+
"/mount/linked"
)
err
=
os
.
Link
(
wd
+
"/mount/file"
,
wd
+
"/mount/linked"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
...
@@ -640,7 +640,7 @@ func TestUnionFsTruncate(t *testing.T) {
...
@@ -640,7 +640,7 @@ func TestUnionFsTruncate(t *testing.T) {
defer
clean
()
defer
clean
()
writeToFile
(
wd
+
"/ro/file"
,
"hello"
)
writeToFile
(
wd
+
"/ro/file"
,
"hello"
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
os
.
Truncate
(
wd
+
"/mount/file"
,
2
)
os
.
Truncate
(
wd
+
"/mount/file"
,
2
)
content
:=
readFromFile
(
wd
+
"/mount/file"
)
content
:=
readFromFile
(
wd
+
"/mount/file"
)
...
@@ -718,7 +718,7 @@ func TestUnionFsRemoveAll(t *testing.T) {
...
@@ -718,7 +718,7 @@ func TestUnionFsRemoveAll(t *testing.T) {
fn
:=
wd
+
"/ro/dir/subdir/y"
fn
:=
wd
+
"/ro/dir/subdir/y"
err
=
ioutil
.
WriteFile
(
fn
,
[]
byte
(
contents
),
0644
)
err
=
ioutil
.
WriteFile
(
fn
,
[]
byte
(
contents
),
0644
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
err
=
os
.
RemoveAll
(
wd
+
"/mount/dir"
)
err
=
os
.
RemoveAll
(
wd
+
"/mount/dir"
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -749,7 +749,7 @@ func TestUnionFsRmRf(t *testing.T) {
...
@@ -749,7 +749,7 @@ func TestUnionFsRmRf(t *testing.T) {
fn
:=
wd
+
"/ro/dir/subdir/y"
fn
:=
wd
+
"/ro/dir/subdir/y"
err
=
ioutil
.
WriteFile
(
fn
,
[]
byte
(
contents
),
0644
)
err
=
ioutil
.
WriteFile
(
fn
,
[]
byte
(
contents
),
0644
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
bin
,
err
:=
exec
.
LookPath
(
"rm"
)
bin
,
err
:=
exec
.
LookPath
(
"rm"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
...
@@ -788,7 +788,7 @@ func TestUnionFsDropDeletionCache(t *testing.T) {
...
@@ -788,7 +788,7 @@ func TestUnionFsDropDeletionCache(t *testing.T) {
err
:=
ioutil
.
WriteFile
(
wd
+
"/ro/file"
,
[]
byte
(
"bla"
),
0644
)
err
:=
ioutil
.
WriteFile
(
wd
+
"/ro/file"
,
[]
byte
(
"bla"
),
0644
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
_
,
err
=
os
.
Lstat
(
wd
+
"/mount/file"
)
_
,
err
=
os
.
Lstat
(
wd
+
"/mount/file"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
...
@@ -887,7 +887,7 @@ func TestUnionFsDisappearing(t *testing.T) {
...
@@ -887,7 +887,7 @@ func TestUnionFsDisappearing(t *testing.T) {
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/file"
,
[]
byte
(
"blabla"
),
0644
)
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/file"
,
[]
byte
(
"blabla"
),
0644
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
err
=
os
.
Remove
(
wd
+
"/mount/file"
)
err
=
os
.
Remove
(
wd
+
"/mount/file"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
...
@@ -928,7 +928,7 @@ func TestUnionFsDeletedGetAttr(t *testing.T) {
...
@@ -928,7 +928,7 @@ func TestUnionFsDeletedGetAttr(t *testing.T) {
err
:=
ioutil
.
WriteFile
(
wd
+
"/ro/file"
,
[]
byte
(
"blabla"
),
0644
)
err
:=
ioutil
.
WriteFile
(
wd
+
"/ro/file"
,
[]
byte
(
"blabla"
),
0644
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
f
,
err
:=
os
.
Open
(
wd
+
"/mount/file"
)
f
,
err
:=
os
.
Open
(
wd
+
"/mount/file"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
...
@@ -947,7 +947,7 @@ func TestUnionFsDoubleOpen(t *testing.T) {
...
@@ -947,7 +947,7 @@ func TestUnionFsDoubleOpen(t *testing.T) {
defer
clean
()
defer
clean
()
err
:=
ioutil
.
WriteFile
(
wd
+
"/ro/file"
,
[]
byte
(
"blablabla"
),
0644
)
err
:=
ioutil
.
WriteFile
(
wd
+
"/ro/file"
,
[]
byte
(
"blablabla"
),
0644
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
roFile
,
err
:=
os
.
Open
(
wd
+
"/mount/file"
)
roFile
,
err
:=
os
.
Open
(
wd
+
"/mount/file"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
...
@@ -985,7 +985,7 @@ func TestUnionFsFdLeak(t *testing.T) {
...
@@ -985,7 +985,7 @@ func TestUnionFsFdLeak(t *testing.T) {
wd
,
clean
:=
setupUfs
(
t
)
wd
,
clean
:=
setupUfs
(
t
)
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/file"
,
[]
byte
(
"blablabla"
),
0644
)
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/file"
,
[]
byte
(
"blablabla"
),
0644
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
contents
,
err
:=
ioutil
.
ReadFile
(
wd
+
"/mount/file"
)
contents
,
err
:=
ioutil
.
ReadFile
(
wd
+
"/mount/file"
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
...
@@ -1091,7 +1091,7 @@ func TestUnionFsPromoteDirTimeStamp(t *testing.T) {
...
@@ -1091,7 +1091,7 @@ func TestUnionFsPromoteDirTimeStamp(t *testing.T) {
CheckSuccess
(
err
)
CheckSuccess
(
err
)
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/subdir/file"
,
[]
byte
(
"hello"
),
0644
)
err
=
ioutil
.
WriteFile
(
wd
+
"/ro/subdir/file"
,
[]
byte
(
"hello"
),
0644
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
freezeRo
(
wd
+
"/ro"
)
freezeRo
(
wd
+
"/ro"
)
err
=
os
.
Chmod
(
wd
+
"/mount/subdir/file"
,
0060
)
err
=
os
.
Chmod
(
wd
+
"/mount/subdir/file"
,
0060
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
...
@@ -1107,7 +1107,7 @@ func TestUnionFsPromoteDirTimeStamp(t *testing.T) {
...
@@ -1107,7 +1107,7 @@ func TestUnionFsPromoteDirTimeStamp(t *testing.T) {
t
.
Errorf
(
"Changed timestamps on promoted subdir: ro %d rw %d"
,
fRo
.
Mtime_ns
,
fRw
.
Mtime_ns
)
t
.
Errorf
(
"Changed timestamps on promoted subdir: ro %d rw %d"
,
fRo
.
Mtime_ns
,
fRw
.
Mtime_ns
)
}
}
if
fRo
.
Mode
|
0200
!=
fRw
.
Mode
{
if
fRo
.
Mode
|
0200
!=
fRw
.
Mode
{
t
.
Errorf
(
"Changed mode ro: %o, rw: %o"
,
fRo
.
Mode
,
fRw
.
Mode
)
t
.
Errorf
(
"Changed mode ro: %o, rw: %o"
,
fRo
.
Mode
,
fRw
.
Mode
)
}
}
}
}
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