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
9f3e25d0
Commit
9f3e25d0
authored
Aug 13, 2010
by
Ivan Krasin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OpenDir/ReadDir/Lookup/ReleaseDir work (as a hack)
parent
b2a58f7a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
7 deletions
+36
-7
fuse/fuse.go
fuse/fuse.go
+32
-3
fuse/types.go
fuse/types.go
+4
-4
No files found.
fuse/fuse.go
View file @
9f3e25d0
...
@@ -28,6 +28,8 @@ type MountPoint struct {
...
@@ -28,6 +28,8 @@ type MountPoint struct {
fs
FileSystem
fs
FileSystem
}
}
var
was
bool
// Mount create a fuse fs on the specified mount point.
// Mount create a fuse fs on the specified mount point.
func
Mount
(
mountPoint
string
,
fs
FileSystem
)
(
m
*
MountPoint
,
err
os
.
Error
,
errors
chan
os
.
Error
)
{
func
Mount
(
mountPoint
string
,
fs
FileSystem
)
(
m
*
MountPoint
,
err
os
.
Error
,
errors
chan
os
.
Error
)
{
local
,
remote
,
err
:=
net
.
Socketpair
(
"unixgram"
)
local
,
remote
,
err
:=
net
.
Socketpair
(
"unixgram"
)
...
@@ -108,7 +110,7 @@ func handle(fs FileSystem, in_data []byte, toW chan [][]byte, errors chan os.Err
...
@@ -108,7 +110,7 @@ func handle(fs FileSystem, in_data []byte, toW chan [][]byte, errors chan os.Err
}
}
var
out
interface
{}
var
out
interface
{}
var
result
Error
=
OK
var
result
Error
=
OK
fmt
.
Printf
(
"Opcode: %v
\n
"
,
h
.
Opcode
)
fmt
.
Printf
(
"Opcode: %v
, NodeId: %v, h: %v
\n
"
,
h
.
Opcode
,
h
.
NodeId
,
h
)
switch
h
.
Opcode
{
switch
h
.
Opcode
{
case
FUSE_INIT
:
case
FUSE_INIT
:
in
:=
new
(
InitIn
)
in
:=
new
(
InitIn
)
...
@@ -152,16 +154,43 @@ func handle(fs FileSystem, in_data []byte, toW chan [][]byte, errors chan os.Err
...
@@ -152,16 +154,43 @@ func handle(fs FileSystem, in_data []byte, toW chan [][]byte, errors chan os.Err
open_out
=
new
(
OpenOut
)
open_out
=
new
(
OpenOut
)
open_out
.
Fh
=
1
open_out
.
Fh
=
1
out
=
open_out
out
=
open_out
was
=
false
case
FUSE_READDIR
:
case
FUSE_READDIR
:
if
was
{
break
}
in
:=
new
(
ReadIn
)
in
:=
new
(
ReadIn
)
err
=
binary
.
Read
(
r
,
binary
.
LittleEndian
,
in
)
err
=
binary
.
Read
(
r
,
binary
.
LittleEndian
,
in
)
if
err
!=
nil
{
if
err
!=
nil
{
break
break
}
}
fmt
.
Printf
(
"FUSE_READDIR: %v
\n
"
,
in
)
fmt
.
Printf
(
"FUSE_READDIR: %v
\n
"
,
in
)
// Here I need to stop and to think a bit.
dirent
:=
new
(
Dirent
)
dirent
.
Off
=
1
dirent
.
Ino
=
h
.
NodeId
dirent
.
NameLen
=
7
dirent
.
Typ
=
(
S_IFDIR
&
0170000
)
>>
12
;
buf
:=
new
(
bytes
.
Buffer
)
err
=
binary
.
Write
(
buf
,
binary
.
LittleEndian
,
dirent
)
if
err
!=
nil
{
fmt
.
Printf
(
"AAA!!! binary.Write failed
\n
"
)
os
.
Exit
(
1
)
os
.
Exit
(
1
)
}
buf
.
Write
([]
byte
(
"hello12"
))
buf
.
WriteByte
(
0
)
out
=
buf
.
Bytes
()
was
=
true
case
FUSE_LOOKUP
:
filename
:=
string
(
r
.
Bytes
())
fmt
.
Printf
(
"filename: %s
\n
"
,
filename
)
entry_out
:=
new
(
EntryOut
)
entry_out
.
NodeId
=
h
.
NodeId
+
1
entry_out
.
Mode
=
S_IFDIR
out
=
entry_out
case
FUSE_RELEASEDIR
:
return
default
:
default
:
errors
<-
os
.
NewError
(
fmt
.
Sprintf
(
"Unsupported OpCode: %d"
,
h
.
Opcode
))
errors
<-
os
.
NewError
(
fmt
.
Sprintf
(
"Unsupported OpCode: %d"
,
h
.
Opcode
))
...
...
fuse/types.go
View file @
9f3e25d0
...
@@ -223,7 +223,7 @@ type Kstatfs struct {
...
@@ -223,7 +223,7 @@ type Kstatfs struct {
Files
uint64
Files
uint64
Ffree
uint64
Ffree
uint64
Bsize
uint32
Bsize
uint32
Name
l
en
uint32
Name
L
en
uint32
Frsize
uint32
Frsize
uint32
Padding
uint32
Padding
uint32
Spare
[
6
]
uint32
Spare
[
6
]
uint32
...
@@ -244,7 +244,7 @@ type EntryOut struct {
...
@@ -244,7 +244,7 @@ type EntryOut struct {
AttrValid
uint64
/* Cache timeout for the attributes */
AttrValid
uint64
/* Cache timeout for the attributes */
EntryValidNsec
uint32
EntryValidNsec
uint32
AttrValidNsec
uint32
AttrValidNsec
uint32
Attr
Attr
Attr
}
}
type
ForgetIn
struct
{
type
ForgetIn
struct
{
...
@@ -508,7 +508,7 @@ type OutHeader struct {
...
@@ -508,7 +508,7 @@ type OutHeader struct {
type
Dirent
struct
{
type
Dirent
struct
{
Ino
uint64
Ino
uint64
Off
uint64
Off
uint64
Name
l
en
uint32
Name
L
en
uint32
Typ
uint32
Typ
uint32
// name []byte // char name[0] -- looks like the name is right after this struct.
// name []byte // char name[0] -- looks like the name is right after this struct.
}
}
...
@@ -521,6 +521,6 @@ type NotifyInvalInodeOut struct {
...
@@ -521,6 +521,6 @@ type NotifyInvalInodeOut struct {
type
NotifyInvalEntryOut
struct
{
type
NotifyInvalEntryOut
struct
{
Parent
uint64
Parent
uint64
Name
l
en
uint32
Name
L
en
uint32
Padding
uint32
Padding
uint32
}
}
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