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
Hide 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
import
(
"bytes"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"rand"
"strings"
"testing"
"syscall"
"
rand
"
"
testing
"
"time"
)
...
...
@@ -277,22 +278,68 @@ func (me *testCase) testSymlink() {
func
(
me
*
testCase
)
testRename
()
{
me
.
tester
.
Log
(
"Testing rename."
)
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
)
f
,
_
:=
os
.
Lstat
(
me
.
origFile
)
if
f
!=
nil
{
me
.
tester
.
Errorf
(
"original %v still exists."
,
me
.
origFile
)
}
f
,
_
=
os
.
Lstat
(
me
.
origSubf
ile
)
f
,
_
=
os
.
Lstat
(
subF
ile
)
if
f
==
nil
{
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
()
{
me
.
writeOrigFile
()
...
...
@@ -513,7 +560,10 @@ func (me *testCase) testLargeDirRead() {
func
TestMount
(
t
*
testing
.
T
)
{
ts
:=
new
(
testCase
)
ts
.
Setup
(
t
)
defer
ts
.
Cleanup
()
ts
.
testOverwriteRename
()
ts
.
testDelRename
()
ts
.
testOpenUnreadable
()
ts
.
testReadThroughFuse
()
ts
.
testRemove
()
...
...
@@ -523,11 +573,17 @@ func TestMount(t *testing.T) {
ts
.
testRename
()
ts
.
testAccess
()
ts
.
testMknod
()
ts
.
testReaddir
()
ts
.
testFSync
()
ts
.
testLargeRead
()
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
)
{
...
...
fuse/pathfilesystem.go
View file @
dd5992bb
...
...
@@ -227,20 +227,25 @@ func (me *PathFileSystemConnector) verify() {
defer
me
.
lock
.
Unlock
()
me
.
fileLock
.
Lock
()
defer
me
.
fileLock
.
Unlock
()
hiddenOpen
:=
0
for
k
,
v
:=
range
me
.
inodeMap
{
if
v
.
NodeId
!=
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
.
verify
()
open
:=
root
.
totalOpenCount
()
openFiles
:=
len
(
me
.
openFiles
)
mounted
:=
root
.
totalMountCount
()
if
open
!=
openFiles
+
mounted
{
panic
(
fmt
.
Sprintf
(
"opencount mismatch
%v %v %v"
,
open
,
openFiles
,
mounted
))
if
open
+
hiddenOpen
!=
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
panic
(
"Source of rename does not exist"
)
}
dest
:=
newParent
.
Children
[
newName
]
if
dest
!=
nil
{
dest
.
setParent
(
nil
)
}
node
.
setParent
(
nil
)
node
.
Name
=
newName
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