Commit 9f3e25d0 authored by Ivan Krasin's avatar Ivan Krasin

OpenDir/ReadDir/Lookup/ReleaseDir work (as a hack)

parent b2a58f7a
...@@ -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))
......
...@@ -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
Namelen uint32 NameLen 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
Namelen uint32 NameLen 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
Namelen uint32 NameLen uint32
Padding uint32 Padding uint32
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment