Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-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
jacobsa-fuse
Commits
a4e48c2e
Commit
a4e48c2e
authored
Feb 27, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished AppendDirent.
parent
4f436277
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
3 deletions
+32
-3
fuseutil/dirent.go
fuseutil/dirent.go
+32
-3
No files found.
fuseutil/dirent.go
View file @
a4e48c2e
...
...
@@ -4,6 +4,8 @@
package
fuseutil
import
(
"unsafe"
bazilfuse
"bazil.org/fuse"
"github.com/jacobsa/fuse"
)
...
...
@@ -28,10 +30,11 @@ type Dirent struct {
// Append the supplied directory entry to the given buffer in the format
// expected in fuse.ReadResponse.Data, returning the resulting buffer.
func
AppendDirent
(
buf
[]
byte
,
d
Dirent
)
[]
byte
{
func
AppendDirent
(
input
[]
byte
,
d
Dirent
)
(
output
[]
byte
)
{
// We want to append bytes with the layout of fuse_dirent
// (http://goo.gl/BmFxob) in host order. Its layout is reproduced here for
// documentation purposes:
// (http://goo.gl/BmFxob) in host order. The struct must be aligned according
// to FUSE_DIRENT_ALIGN (http://goo.gl/UziWvH), which dictates 8-byte
// alignment.
type
fuse_dirent
struct
{
ino
uint64
off
uint64
...
...
@@ -39,4 +42,30 @@ func AppendDirent(buf []byte, d Dirent) []byte {
type_
uint32
name
[
0
]
byte
}
const
alignment
=
8
const
nameOffset
=
8
+
8
+
4
+
4
// Write the header into the buffer.
de
:=
fuse_dirent
{
ino
:
uint64
(
d
.
Inode
),
off
:
uint64
(
d
.
Offset
),
namelen
:
uint32
(
len
(
d
.
Name
)),
type_
:
uint32
(
d
.
Type
),
}
output
=
append
(
input
,
(
*
[
nameOffset
]
byte
)(
unsafe
.
Pointer
(
&
de
))[
:
]
...
)
// Write the name afterward.
output
=
append
(
output
,
d
.
Name
...
)
// Add any necessary padding.
if
len
(
d
.
Name
)
%
alignment
!=
0
{
padLen
:=
alignment
-
(
len
(
d
.
Name
)
%
alignment
)
var
padding
[
alignment
]
byte
output
=
append
(
output
,
padding
[
:
padLen
]
...
)
}
return
}
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