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

GetAttr works. GetXAttr fails.

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