Commit 374671a4 authored by Ivan Krasin's avatar Ivan Krasin

GetAttr works. GetXAttr fails.

parent 8bfe84d5
......@@ -19,6 +19,7 @@ const (
type FileSystem interface {
Init(in *InitIn) (out *InitOut, code Error)
GetAttr(h *InHeader, in *GetAttrIn) (out *AttrOut, code Error)
}
type MountPoint struct {
......@@ -124,6 +125,21 @@ func handle(fs FileSystem, in_data []byte, toW chan [][]byte, errors chan os.Err
case FUSE_FORGET:
return
case FUSE_GETATTR:
in := new(GetAttrIn)
err = binary.Read(r, binary.LittleEndian, in)
if err != nil {
break
}
fmt.Printf("FUSE_GETATTR: %v\n", in)
var attr_out *AttrOut
attr_out, result = fs.GetAttr(h, in)
if attr_out != nil {
out = attr_out
}
case FUSE_GETXATTR:
result = ENODATA
default:
errors <- os.NewError(fmt.Sprintf("Unsupported OpCode: %d", h.Opcode))
result = EIO
......
......@@ -32,6 +32,13 @@ func (fs *testFuse) Init(in *InitIn) (out *InitOut, code Error) {
return
}
func (fs *testFuse) GetAttr(h *InHeader, in *GetAttrIn) (out *AttrOut, code Error) {
out = new(AttrOut)
out.Ino = h.NodeId
out.Mode = S_IFDIR
return
}
func errorHandler(errors chan os.Error) {
for err := range errors {
log.Stderr("MountPoint.errorHandler: ", err)
......
......@@ -67,7 +67,7 @@ const (
FUSE_RELEASE_FLUSH = (1 << 0)
/**
* Getattr flags
* GetAttr flags
*/
FUSE_GETATTR_FH = (1 << 0)
......@@ -126,6 +126,8 @@ const (
FUSE_COMPAT_STATFS_SIZE = 48
CUSE_INIT_INFO_MAX = 4096
S_IFDIR = syscall.S_IFDIR
)
type Error int32
......@@ -134,6 +136,7 @@ const (
OK = Error(0)
EIO = Error(syscall.EIO)
ENOSYS = Error(syscall.ENOSYS)
ENODATA = Error(syscall.ENODATA)
)
type Opcode int
......@@ -233,15 +236,14 @@ type FileLock struct {
Pid uint32 /* tgid */
}
type EntryOut struct {
Nodeid uint64 /* Inode ID */
NodeId uint64 /* Inode ID */
Generation uint64 /* Inode generation: nodeid:gen must
be unique for the fs's lifetime */
Entry_valid uint64 /* Cache timeout for the name */
Attr_valid uint64 /* Cache timeout for the attributes */
Entry_valid_nsec uint32
Attr_valid_nsec uint32
EntryValid uint64 /* Cache timeout for the name */
AttrValid uint64 /* Cache timeout for the attributes */
EntryValidNsec uint32
AttrValidNsec uint32
Attr Attr
}
......@@ -249,21 +251,19 @@ type ForgetIn struct {
Nlookup uint64
}
type GetattrIn struct {
Getattr_flags uint32
type GetAttrIn struct {
GetAttrFlags uint32
Dummy uint32
Fh uint64
}
type AttrOut struct {
Attr_valid uint64 /* Cache timeout for the attributes */
Attr_valid_nsec uint32
AttrValid uint64 /* Cache timeout for the attributes */
AttrValidNsec uint32
Dummy uint32
Attr Attr
Attr
}
type MknodIn struct {
Mode uint32
Rdev uint32
......@@ -490,7 +490,7 @@ type InHeader struct {
Length uint32
Opcode uint32
Unique uint64
Nodeid uint64
NodeId uint64
Uid uint32
Gid uint32
Pid 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