Commit ccdeeb8c authored by Ivan Krasin's avatar Ivan Krasin

fuse.go formatted

parent 340517c2
......@@ -53,7 +53,7 @@ func loop(f *os.File, fs FileSystem, errors chan os.Error) {
}
}
func dispatch(fs FileSystem, in_data []byte, toW chan[][]byte, errors chan os.Error) {
func dispatch(fs FileSystem, in_data []byte, toW chan [][]byte, errors chan os.Error) {
fmt.Printf("in_data: %v\n", in_data)
r := bytes.NewBuffer(in_data)
h := new(InHeader)
......@@ -68,14 +68,22 @@ func dispatch(fs FileSystem, in_data []byte, toW chan[][]byte, errors chan os.Er
var out [][]byte
fmt.Printf("Opcode: %v, NodeId: %v, h: %v\n", h.Opcode, h.NodeId, h)
switch h.Opcode {
case FUSE_INIT: out, err = initFuse(fs, h, r)
case FUSE_FORGET: return
case FUSE_GETATTR: out, err = getAttr(fs, h, r)
case FUSE_GETXATTR: out, err = getXAttr(h, r)
case FUSE_OPENDIR: out, err = openDir(h, r)
case FUSE_READDIR: out, err = readDir(h, r)
case FUSE_LOOKUP: out, err = lookup(h, r)
case FUSE_RELEASEDIR: out, err = releaseDir(h, r)
case FUSE_INIT:
out, err = initFuse(fs, h, r)
case FUSE_FORGET:
return
case FUSE_GETATTR:
out, err = getAttr(fs, h, r)
case FUSE_GETXATTR:
out, err = getXAttr(h, r)
case FUSE_OPENDIR:
out, err = openDir(h, r)
case FUSE_READDIR:
out, err = readDir(h, r)
case FUSE_LOOKUP:
out, err = lookup(h, r)
case FUSE_RELEASEDIR:
out, err = releaseDir(h, r)
default:
errors <- os.NewError(fmt.Sprintf("Unsupported OpCode: %d", h.Opcode))
out, err = serialize(h, EIO, nil)
......@@ -118,7 +126,7 @@ func serialize(h *InHeader, res Error, out interface{}) (data [][]byte, err os.E
return
}
_, _ = b.Write(out_data)
data = [][]byte { b.Bytes() }
data = [][]byte{b.Bytes()}
return
}
......@@ -191,7 +199,7 @@ func readDir(h *InHeader, r io.Reader) (data [][]byte, err os.Error) {
dirent.Off = 1
dirent.Ino = h.NodeId
dirent.NameLen = 7
dirent.Typ = (S_IFDIR & 0170000) >> 12;
dirent.Typ = (S_IFDIR & 0170000) >> 12
buf := new(bytes.Buffer)
err = binary.Write(buf, binary.LittleEndian, dirent)
if err != nil {
......@@ -234,4 +242,3 @@ func writer(f *os.File, in chan [][]byte, errors chan os.Error) {
fmt.Printf("writer: OK\n")
}
}
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