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
dd5992bb
Commit
dd5992bb
authored
Apr 21, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix overwriting renames in PathFileSystemConnector.
parent
201f145d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
11 deletions
+76
-11
fuse/loopback_test.go
fuse/loopback_test.go
+64
-8
fuse/pathfilesystem.go
fuse/pathfilesystem.go
+12
-3
No files found.
fuse/loopback_test.go
View file @
dd5992bb
...
@@ -3,13 +3,14 @@ package fuse
...
@@ -3,13 +3,14 @@ package fuse
import
(
import
(
"bytes"
"bytes"
"fmt"
"fmt"
"io/ioutil"
"log"
"log"
"os"
"os"
"path/filepath"
"path/filepath"
"rand"
"strings"
"strings"
"testing"
"syscall"
"syscall"
"
rand
"
"
testing
"
"time"
"time"
)
)
...
@@ -277,22 +278,68 @@ func (me *testCase) testSymlink() {
...
@@ -277,22 +278,68 @@ func (me *testCase) testSymlink() {
func
(
me
*
testCase
)
testRename
()
{
func
(
me
*
testCase
)
testRename
()
{
me
.
tester
.
Log
(
"Testing rename."
)
me
.
tester
.
Log
(
"Testing rename."
)
me
.
writeOrigFile
()
me
.
writeOrigFile
()
me
.
makeOrigSubdir
()
sd
:=
me
.
mountPoint
+
"/testRename"
err
:=
os
.
MkdirAll
(
sd
,
0777
)
defer
os
.
RemoveAll
(
sd
)
err
:=
os
.
Rename
(
me
.
mountFile
,
me
.
mountSubfile
)
subFile
:=
sd
+
"/subfile"
err
=
os
.
Rename
(
me
.
mountFile
,
subFile
)
CheckSuccess
(
err
)
CheckSuccess
(
err
)
f
,
_
:=
os
.
Lstat
(
me
.
origFile
)
f
,
_
:=
os
.
Lstat
(
me
.
origFile
)
if
f
!=
nil
{
if
f
!=
nil
{
me
.
tester
.
Errorf
(
"original %v still exists."
,
me
.
origFile
)
me
.
tester
.
Errorf
(
"original %v still exists."
,
me
.
origFile
)
}
}
f
,
_
=
os
.
Lstat
(
me
.
origSubf
ile
)
f
,
_
=
os
.
Lstat
(
subF
ile
)
if
f
==
nil
{
if
f
==
nil
{
me
.
tester
.
Errorf
(
"destination %v does not exist."
,
me
.
origSubfile
)
me
.
tester
.
Errorf
(
"destination %v does not exist."
,
me
.
origSubfile
)
}
}
}
me
.
removeMountSubdir
()
func
(
me
*
testCase
)
testDelRename
()
{
me
.
tester
.
Log
(
"Testing del+rename."
)
sd
:=
me
.
mountPoint
+
"/testDelRename"
err
:=
os
.
MkdirAll
(
sd
,
0755
)
CheckSuccess
(
err
)
d
:=
sd
+
"/dest"
err
=
ioutil
.
WriteFile
(
d
,
[]
byte
(
"blabla"
),
0644
)
CheckSuccess
(
err
)
f
,
err
:=
os
.
Open
(
d
)
CheckSuccess
(
err
)
err
=
os
.
Remove
(
d
)
CheckSuccess
(
err
)
s
:=
sd
+
"/src"
err
=
ioutil
.
WriteFile
(
s
,
[]
byte
(
"blabla"
),
0644
)
CheckSuccess
(
err
)
err
=
os
.
Rename
(
s
,
d
)
CheckSuccess
(
err
)
f
.
Close
()
}
}
func
(
me
*
testCase
)
testOverwriteRename
()
{
me
.
tester
.
Log
(
"Testing rename overwrite."
)
sd
:=
me
.
mountPoint
+
"/testOverwriteRename"
err
:=
os
.
MkdirAll
(
sd
,
0755
)
CheckSuccess
(
err
)
d
:=
sd
+
"/dest"
err
=
ioutil
.
WriteFile
(
d
,
[]
byte
(
"blabla"
),
0644
)
CheckSuccess
(
err
)
s
:=
sd
+
"/src"
err
=
ioutil
.
WriteFile
(
s
,
[]
byte
(
"blabla"
),
0644
)
CheckSuccess
(
err
)
err
=
os
.
Rename
(
s
,
d
)
CheckSuccess
(
err
)
}
func
(
me
*
testCase
)
testAccess
()
{
func
(
me
*
testCase
)
testAccess
()
{
me
.
writeOrigFile
()
me
.
writeOrigFile
()
...
@@ -513,7 +560,10 @@ func (me *testCase) testLargeDirRead() {
...
@@ -513,7 +560,10 @@ func (me *testCase) testLargeDirRead() {
func
TestMount
(
t
*
testing
.
T
)
{
func
TestMount
(
t
*
testing
.
T
)
{
ts
:=
new
(
testCase
)
ts
:=
new
(
testCase
)
ts
.
Setup
(
t
)
ts
.
Setup
(
t
)
defer
ts
.
Cleanup
()
ts
.
testOverwriteRename
()
ts
.
testDelRename
()
ts
.
testOpenUnreadable
()
ts
.
testOpenUnreadable
()
ts
.
testReadThroughFuse
()
ts
.
testReadThroughFuse
()
ts
.
testRemove
()
ts
.
testRemove
()
...
@@ -523,11 +573,17 @@ func TestMount(t *testing.T) {
...
@@ -523,11 +573,17 @@ func TestMount(t *testing.T) {
ts
.
testRename
()
ts
.
testRename
()
ts
.
testAccess
()
ts
.
testAccess
()
ts
.
testMknod
()
ts
.
testMknod
()
ts
.
testReaddir
()
ts
.
testFSync
()
ts
.
testFSync
()
ts
.
testLargeRead
()
ts
.
testLargeRead
()
ts
.
testLargeDirRead
()
ts
.
testLargeDirRead
()
ts
.
Cleanup
()
}
func
TestReadOnly
(
t
*
testing
.
T
)
{
ts
:=
new
(
testCase
)
ts
.
Setup
(
t
)
defer
ts
.
Cleanup
()
ts
.
testReaddir
()
}
}
func
TestRecursiveMount
(
t
*
testing
.
T
)
{
func
TestRecursiveMount
(
t
*
testing
.
T
)
{
...
...
fuse/pathfilesystem.go
View file @
dd5992bb
...
@@ -228,19 +228,24 @@ func (me *PathFileSystemConnector) verify() {
...
@@ -228,19 +228,24 @@ func (me *PathFileSystemConnector) verify() {
me
.
fileLock
.
Lock
()
me
.
fileLock
.
Lock
()
defer
me
.
fileLock
.
Unlock
()
defer
me
.
fileLock
.
Unlock
()
hiddenOpen
:=
0
for
k
,
v
:=
range
me
.
inodeMap
{
for
k
,
v
:=
range
me
.
inodeMap
{
if
v
.
NodeId
!=
k
{
if
v
.
NodeId
!=
k
{
panic
(
fmt
.
Sprintf
(
"nodeid mismatch %v %v"
,
v
,
k
))
panic
(
fmt
.
Sprintf
(
"nodeid mismatch %v %v"
,
v
,
k
))
}
}
if
v
.
Parent
==
nil
&&
v
.
NodeId
!=
FUSE_ROOT_ID
{
hiddenOpen
+=
v
.
OpenCount
}
}
}
root
:=
me
.
inodeMap
[
FUSE_ROOT_ID
]
root
:=
me
.
inodeMap
[
FUSE_ROOT_ID
]
root
.
verify
()
root
.
verify
()
open
:=
root
.
totalOpenCount
()
open
:=
root
.
totalOpenCount
()
openFiles
:=
len
(
me
.
openFiles
)
openFiles
:=
len
(
me
.
openFiles
)
mounted
:=
root
.
totalMountCount
()
mounted
:=
root
.
totalMountCount
()
if
open
!=
openFiles
+
mounted
{
if
open
+
hiddenOpen
!=
openFiles
+
mounted
{
panic
(
fmt
.
Sprintf
(
"opencount mismatch
%v %v %v"
,
open
,
openFiles
,
mounted
))
panic
(
fmt
.
Sprintf
(
"opencount mismatch
totalOpen=%v openFiles=%v mounted=%v hidden=%v"
,
open
,
openFiles
,
mounted
,
hiddenOpen
))
}
}
}
}
...
@@ -320,6 +325,10 @@ func (me *PathFileSystemConnector) renameUpdate(oldParent *inode, oldName string
...
@@ -320,6 +325,10 @@ func (me *PathFileSystemConnector) renameUpdate(oldParent *inode, oldName string
panic
(
"Source of rename does not exist"
)
panic
(
"Source of rename does not exist"
)
}
}
dest
:=
newParent
.
Children
[
newName
]
if
dest
!=
nil
{
dest
.
setParent
(
nil
)
}
node
.
setParent
(
nil
)
node
.
setParent
(
nil
)
node
.
Name
=
newName
node
.
Name
=
newName
node
.
setParent
(
newParent
)
node
.
setParent
(
newParent
)
...
...
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