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 {
fs FileSystem
}
var was bool
// 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) {
local, remote, err := net.Socketpair("unixgram")
......@@ -108,7 +110,7 @@ func handle(fs FileSystem, in_data []byte, toW chan [][]byte, errors chan os.Err
}
var out interface{}
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 {
case FUSE_INIT:
in := new(InitIn)
......@@ -152,16 +154,43 @@ func handle(fs FileSystem, in_data []byte, toW chan [][]byte, errors chan os.Err
open_out = new(OpenOut)
open_out.Fh = 1
out = open_out
was = false
case FUSE_READDIR:
if was {
break
}
in := new(ReadIn)
err = binary.Read(r, binary.LittleEndian, in)
if err != nil {
break
}
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)
}
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:
errors <- os.NewError(fmt.Sprintf("Unsupported OpCode: %d", h.Opcode))
......
......@@ -223,7 +223,7 @@ type Kstatfs struct {
Files uint64
Ffree uint64
Bsize uint32
Namelen uint32
NameLen uint32
Frsize uint32
Padding uint32
Spare [6]uint32
......@@ -244,7 +244,7 @@ type EntryOut struct {
AttrValid uint64 /* Cache timeout for the attributes */
EntryValidNsec uint32
AttrValidNsec uint32
Attr Attr
Attr
}
type ForgetIn struct {
......@@ -508,7 +508,7 @@ type OutHeader struct {
type Dirent struct {
Ino uint64
Off uint64
Namelen uint32
NameLen uint32
Typ uint32
// name []byte // char name[0] -- looks like the name is right after this struct.
}
......@@ -521,6 +521,6 @@ type NotifyInvalInodeOut struct {
type NotifyInvalEntryOut struct {
Parent uint64
Namelen uint32
NameLen 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