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
1989e683
Commit
1989e683
authored
Dec 28, 2010
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug with dirent padding.
Add test case with random filename lengths.
parent
a9d18e32
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
25 deletions
+56
-25
fuse/fuse.go
fuse/fuse.go
+9
-10
fuse/passthrough_test.go
fuse/passthrough_test.go
+47
-15
No files found.
fuse/fuse.go
View file @
1989e683
...
...
@@ -542,7 +542,6 @@ func (de *DEntryList) AddString(name string, inode uint64, mode uint32) {
func
(
de
*
DEntryList
)
Add
(
name
[]
byte
,
inode
uint64
,
mode
uint32
)
{
de
.
offset
++
dirent
:=
new
(
Dirent
)
dirent
.
Off
=
de
.
offset
dirent
.
Ino
=
inode
...
...
@@ -553,11 +552,11 @@ func (de *DEntryList) Add(name []byte, inode uint64, mode uint32) {
if
err
!=
nil
{
panic
(
"Serialization of Dirent failed"
)
}
de
.
buf
.
Write
(
[]
byte
(
name
)
)
de
.
buf
.
WriteByte
(
0
)
n
:=
(
len
(
name
)
+
1
)
%
8
// padding
if
n
!=
0
{
de
.
buf
.
Write
(
make
([]
byte
,
8
-
n
))
de
.
buf
.
Write
(
name
)
padding
:=
8
-
len
(
name
)
&
7
if
padding
<
8
{
de
.
buf
.
Write
(
make
([]
byte
,
padding
))
}
}
...
...
fuse/passthrough_test.go
View file @
1989e683
...
...
@@ -9,6 +9,7 @@ import (
"strings"
"testing"
"syscall"
"rand"
)
var
_
=
strings
.
Join
...
...
@@ -505,18 +506,37 @@ func (self *testCase) testLargeRead() {
os
.
Remove
(
name
)
}
func
randomLengthString
(
length
int
)
string
{
r
:=
rand
.
Intn
(
length
)
j
:=
0
b
:=
make
([]
byte
,
r
)
for
i
:=
0
;
i
<
r
;
i
++
{
j
=
(
j
+
1
)
%
10
b
[
i
]
=
byte
(
j
)
+
byte
(
'0'
)
}
return
string
(
b
)
}
func
(
self
*
testCase
)
testLargeDirRead
()
{
c
ount
:=
100
c
reated
:=
100
names
:=
make
([]
string
,
c
ount
)
names
:=
make
([]
string
,
c
reated
)
subdir
:=
path
.
Join
(
self
.
origDir
,
"readdirSubdir"
)
os
.
Mkdir
(
subdir
,
0700
)
longname
:=
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
for
i
:=
0
;
i
<
count
;
i
++
{
nameSet
:=
make
(
map
[
string
]
bool
)
for
i
:=
0
;
i
<
created
;
i
++
{
// Should vary file name length.
name
:=
path
.
Join
(
subdir
,
fmt
.
Sprintf
(
"file%d"
,
i
))
base
:=
fmt
.
Sprintf
(
"file%d%s"
,
i
,
randomLengthString
(
len
(
longname
)))
name
:=
path
.
Join
(
subdir
,
base
)
nameSet
[
base
]
=
true
f
,
err
:=
os
.
Open
(
name
,
os
.
O_WRONLY
|
os
.
O_CREATE
,
0777
)
if
err
!=
nil
{
self
.
tester
.
Errorf
(
"open write err %v"
,
err
)
...
...
@@ -534,6 +554,7 @@ func (self *testCase) testLargeDirRead() {
}
// Chunked read.
total
:=
0
readSet
:=
make
(
map
[
string
]
bool
)
for
{
namesRead
,
err
:=
dir
.
Readdirnames
(
20
)
if
err
!=
nil
{
...
...
@@ -543,13 +564,24 @@ func (self *testCase) testLargeDirRead() {
if
len
(
namesRead
)
==
0
{
break
}
for
_
,
v
:=
range
(
namesRead
)
{
readSet
[
v
]
=
true
}
total
+=
len
(
namesRead
)
}
if
total
!=
count
{
self
.
tester
.
Errorf
(
"readdir mismatch %v %v"
,
total
,
count
)
if
total
!=
created
{
self
.
tester
.
Errorf
(
"readdir mismatch got %v wanted %v"
,
total
,
created
)
}
for
k
,
_
:=
range
(
nameSet
)
{
_
,
ok
:=
readSet
[
k
]
if
!
ok
{
self
.
tester
.
Errorf
(
"Name %v not found"
,
k
)
}
}
dir
.
Close
()
os
.
RemoveAll
(
subdir
)
...
...
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