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
fb412460
Commit
fb412460
authored
Jun 30, 2013
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fuse: cleanup DirEntryList.
* document methods * hide Offset * hide Bytes method.
parent
a7349e99
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
23 deletions
+27
-23
fuse/direntry.go
fuse/direntry.go
+19
-17
fuse/nodefs/dir.go
fuse/nodefs/dir.go
+6
-4
fuse/opcode.go
fuse/opcode.go
+2
-2
No files found.
fuse/direntry.go
View file @
fb412460
...
...
@@ -25,40 +25,41 @@ func (d DirEntry) String() string {
}
type
DirEntryList
struct
{
buf
[]
byte
size
int
// TODO - hide this again.
Offset
uint64
buf
[]
byte
size
int
offset
uint64
}
func
NewDirEntryList
(
data
[]
byte
,
off
uint64
)
*
DirEntryList
{
return
&
DirEntryList
{
buf
:
data
[
:
0
],
size
:
len
(
data
),
O
ffset
:
off
,
o
ffset
:
off
,
}
}
// AddDirEntry tries to add an entry.
func
(
l
*
DirEntryList
)
AddDirEntry
(
e
DirEntry
)
bool
{
// AddDirEntry tries to add an entry, and reports whether it
// succeeded.
func
(
l
*
DirEntryList
)
AddDirEntry
(
e
DirEntry
)
(
bool
,
uint64
)
{
return
l
.
Add
(
nil
,
e
.
Name
,
uint64
(
raw
.
FUSE_UNKNOWN_INO
),
e
.
Mode
)
}
func
(
l
*
DirEntryList
)
Add
(
prefix
[]
byte
,
name
string
,
inode
uint64
,
mode
uint32
)
bool
{
// Add adds a direntry to the DirEntryList, returning whether it
// succeeded.
func
(
l
*
DirEntryList
)
Add
(
prefix
[]
byte
,
name
string
,
inode
uint64
,
mode
uint32
)
(
bool
,
uint64
)
{
padding
:=
(
8
-
len
(
name
)
&
7
)
&
7
delta
:=
padding
+
direntSize
+
len
(
name
)
+
len
(
prefix
)
oldLen
:=
len
(
l
.
buf
)
newLen
:=
delta
+
oldLen
if
newLen
>
l
.
size
{
return
false
return
false
,
l
.
offset
}
l
.
buf
=
l
.
buf
[
:
newLen
]
copy
(
l
.
buf
[
oldLen
:
],
prefix
)
oldLen
+=
len
(
prefix
)
dirent
:=
(
*
raw
.
Dirent
)(
unsafe
.
Pointer
(
&
l
.
buf
[
oldLen
]))
dirent
.
Off
=
l
.
O
ffset
+
1
dirent
.
Off
=
l
.
o
ffset
+
1
dirent
.
Ino
=
inode
dirent
.
NameLen
=
uint32
(
len
(
name
))
dirent
.
Typ
=
ModeToType
(
mode
)
...
...
@@ -70,18 +71,19 @@ func (l *DirEntryList) Add(prefix []byte, name string, inode uint64, mode uint32
copy
(
l
.
buf
[
oldLen
:
],
eightPadding
[
:
padding
])
}
l
.
O
ffset
=
dirent
.
Off
return
true
l
.
o
ffset
=
dirent
.
Off
return
true
,
l
.
offset
}
func
(
l
*
DirEntryList
)
AddDirLookupEntry
(
e
DirEntry
,
entryOut
*
raw
.
EntryOut
)
bool
{
// AddDirLookupEntry is used for ReadDirPlus. It serializes a DirEntry
// and its corresponding lookup. Pass a null EntryOut if the lookup
// data should be ignored.
func
(
l
*
DirEntryList
)
AddDirLookupEntry
(
e
DirEntry
,
entryOut
*
raw
.
EntryOut
)
(
bool
,
uint64
)
{
var
lookup
[]
byte
toSlice
(
&
lookup
,
unsafe
.
Pointer
(
entryOut
),
unsafe
.
Sizeof
(
raw
.
EntryOut
{}))
return
l
.
Add
(
lookup
,
e
.
Name
,
uint64
(
raw
.
FUSE_UNKNOWN_INO
),
e
.
Mode
)
}
func
(
l
*
DirEntryList
)
B
ytes
()
[]
byte
{
func
(
l
*
DirEntryList
)
b
ytes
()
[]
byte
{
return
l
.
buf
}
////////////////////////////////////////////////////////////////
fuse/nodefs/dir.go
View file @
fb412460
...
...
@@ -34,11 +34,12 @@ func (d *connectorDir) ReadDir(list *fuse.DirEntryList, input *raw.ReadIn, conte
log
.
Printf
(
"got emtpy directory entry, mode %o."
,
e
.
Mode
)
continue
}
if
!
list
.
AddDirEntry
(
e
)
{
ok
,
off
:=
list
.
AddDirEntry
(
e
)
d
.
lastOffset
=
off
if
!
ok
{
break
}
}
d
.
lastOffset
=
list
.
Offset
return
fuse
.
OK
}
...
...
@@ -76,11 +77,12 @@ func (d *connectorDir) ReadDirPlus(list *fuse.DirEntryList, input *raw.ReadIn, c
log
.
Printf
(
"got empty directory entry, mode %o."
,
e
.
Mode
)
continue
}
if
!
list
.
AddDirLookupEntry
(
e
,
&
d
.
lookups
[
input
.
Offset
+
uint64
(
i
)])
{
ok
,
off
:=
list
.
AddDirLookupEntry
(
e
,
&
d
.
lookups
[
input
.
Offset
+
uint64
(
i
)])
d
.
lastOffset
=
off
if
!
ok
{
break
}
}
d
.
lastOffset
=
list
.
Offset
return
fuse
.
OK
}
...
...
fuse/opcode.go
View file @
fb412460
...
...
@@ -128,7 +128,7 @@ func doReadDir(state *Server, req *request) {
entries
:=
NewDirEntryList
(
buf
,
uint64
(
in
.
Offset
))
code
:=
state
.
fileSystem
.
ReadDir
(
entries
,
&
req
.
context
,
in
)
req
.
flatData
=
entries
.
B
ytes
()
req
.
flatData
=
entries
.
b
ytes
()
req
.
status
=
code
}
...
...
@@ -138,7 +138,7 @@ func doReadDirPlus(server *Server, req *request) {
entries
:=
NewDirEntryList
(
buf
,
uint64
(
in
.
Offset
))
code
:=
server
.
fileSystem
.
ReadDirPlus
(
entries
,
&
req
.
context
,
in
)
req
.
flatData
=
entries
.
B
ytes
()
req
.
flatData
=
entries
.
b
ytes
()
req
.
status
=
code
}
...
...
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