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
9dd4fe7f
Commit
9dd4fe7f
authored
May 11, 2012
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify open directory seeking.
Fix bug in MemNodeFs.
parent
2c972a0a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
29 deletions
+15
-29
fuse/defaultnode.go
fuse/defaultnode.go
+1
-1
fuse/direntry.go
fuse/direntry.go
+14
-24
fuse/fsops.go
fuse/fsops.go
+0
-4
No files found.
fuse/defaultnode.go
View file @
9dd4fe7f
...
...
@@ -106,7 +106,7 @@ func (n *DefaultFsNode) Flush(file File, openFlags uint32, context *Context) (co
func
(
n
*
DefaultFsNode
)
OpenDir
(
context
*
Context
)
([]
DirEntry
,
Status
)
{
ch
:=
n
.
Inode
()
.
Children
()
s
:=
make
([]
DirEntry
,
len
(
ch
))
s
:=
make
([]
DirEntry
,
0
,
len
(
ch
))
for
name
,
child
:=
range
ch
{
fi
,
code
:=
child
.
FsNode
()
.
GetAttr
(
nil
,
context
)
if
code
.
Ok
()
{
...
...
fuse/direntry.go
View file @
9dd4fe7f
...
...
@@ -4,13 +4,13 @@ package fuse
import
(
"bytes"
"
fmt
"
"
log
"
"unsafe"
"github.com/hanwen/go-fuse/raw"
)
var
_
=
fmt
.
Print
var
_
=
log
.
Print
// DirEntry is a type for PathFileSystem and NodeFileSystem to return
// directory contents in.
...
...
@@ -21,11 +21,11 @@ type DirEntry struct {
type
DirEntryList
struct
{
buf
bytes
.
Buffer
offset
*
uint64
offset
uint64
maxSize
int
}
func
NewDirEntryList
(
max
int
,
off
*
uint64
)
*
DirEntryList
{
func
NewDirEntryList
(
max
int
,
off
uint64
)
*
DirEntryList
{
return
&
DirEntryList
{
maxSize
:
max
,
offset
:
off
}
}
...
...
@@ -39,10 +39,10 @@ func (l *DirEntryList) AddDirEntry(e DirEntry) bool {
func
(
l
*
DirEntryList
)
Add
(
name
[]
byte
,
inode
uint64
,
mode
uint32
)
bool
{
lastLen
:=
l
.
buf
.
Len
()
(
*
l
.
offset
)
++
l
.
offset
++
dirent
:=
raw
.
Dirent
{
Off
:
*
l
.
offset
,
Off
:
l
.
offset
,
Ino
:
inode
,
NameLen
:
uint32
(
len
(
name
)),
Typ
:
ModeToType
(
mode
),
...
...
@@ -61,7 +61,7 @@ func (l *DirEntryList) Add(name []byte, inode uint64, mode uint32) bool {
if
l
.
buf
.
Len
()
>
l
.
maxSize
{
l
.
buf
.
Truncate
(
lastLen
)
(
*
l
.
offset
)
--
l
.
offset
--
return
false
}
return
true
...
...
@@ -80,31 +80,21 @@ type rawDir interface {
type
connectorDir
struct
{
stream
[]
DirEntry
leftOver
DirEntry
lastOffset
uint64
}
// TODO - use index into []stream for seeking correctly.
func
(
d
*
connectorDir
)
ReadDir
(
input
*
ReadIn
)
(
*
DirEntryList
,
Status
)
{
if
d
.
stream
==
nil
{
return
nil
,
OK
}
list
:=
NewDirEntryList
(
int
(
input
.
Size
),
&
d
.
lastOffset
)
if
d
.
leftOver
.
Name
!=
""
{
success
:=
list
.
AddDirEntry
(
d
.
leftOver
)
if
!
success
{
panic
(
"No space for single entry."
)
}
d
.
leftOver
.
Name
=
""
}
for
len
(
d
.
stream
)
>
0
{
e
:=
d
.
stream
[
len
(
d
.
stream
)
-
1
]
success
:=
list
.
AddDirEntry
(
e
)
if
!
success
{
return
list
,
OK
off
:=
input
.
Offset
list
:=
NewDirEntryList
(
int
(
input
.
Size
),
off
)
todo
:=
d
.
stream
[
off
:
]
for
_
,
e
:=
range
todo
{
if
!
list
.
AddDirEntry
(
e
)
{
break
}
d
.
stream
=
d
.
stream
[
:
len
(
d
.
stream
)
-
1
]
}
return
list
,
OK
}
...
...
fuse/fsops.go
View file @
9dd4fe7f
...
...
@@ -112,15 +112,11 @@ func (c *FileSystemConnector) OpenDir(header *raw.InHeader, input *raw.OpenIn) (
if
err
!=
OK
{
return
0
,
0
,
err
}
stream
=
append
(
stream
,
node
.
getMountDirEntries
()
...
)
de
:=
&
connectorDir
{
stream
:
append
(
stream
,
DirEntry
{
S_IFDIR
,
"."
},
DirEntry
{
S_IFDIR
,
".."
}),
}
h
,
opened
:=
node
.
mount
.
registerFileHandle
(
node
,
de
,
nil
,
input
.
Flags
)
// TODO - implement seekable directories
opened
.
FuseFlags
|=
raw
.
FOPEN_NONSEEKABLE
return
opened
.
FuseFlags
,
h
,
OK
}
...
...
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