Commit 1ee2df8c authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Move Xattr/lock/writeout types.

parent 7dd16a5e
...@@ -272,7 +272,7 @@ type RawFileSystem interface { ...@@ -272,7 +272,7 @@ type RawFileSystem interface {
GetXAttrSize(header *InHeader, attr string) (sz int, code Status) GetXAttrSize(header *InHeader, attr string) (sz int, code Status)
GetXAttrData(header *InHeader, attr string) (data []byte, code Status) GetXAttrData(header *InHeader, attr string) (data []byte, code Status)
ListXAttr(header *InHeader) (attributes []byte, code Status) ListXAttr(header *InHeader) (attributes []byte, code Status)
SetXAttr(header *InHeader, input *SetXAttrIn, attr string, data []byte) Status SetXAttr(header *InHeader, input *raw.SetXAttrIn, attr string, data []byte) Status
RemoveXAttr(header *InHeader, attr string) (code Status) RemoveXAttr(header *InHeader, attr string) (code Status)
// File handling. // File handling.
......
...@@ -70,7 +70,7 @@ func (me *DefaultRawFileSystem) GetXAttrData(header *InHeader, attr string) (dat ...@@ -70,7 +70,7 @@ func (me *DefaultRawFileSystem) GetXAttrData(header *InHeader, attr string) (dat
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultRawFileSystem) SetXAttr(header *InHeader, input *SetXAttrIn, attr string, data []byte) Status { func (me *DefaultRawFileSystem) SetXAttr(header *InHeader, input *raw.SetXAttrIn, attr string, data []byte) Status {
return ENOSYS return ENOSYS
} }
......
...@@ -307,7 +307,7 @@ func (me *FileSystemConnector) RemoveXAttr(header *InHeader, attr string) Status ...@@ -307,7 +307,7 @@ func (me *FileSystemConnector) RemoveXAttr(header *InHeader, attr string) Status
return node.fsInode.RemoveXAttr(attr, &header.Context) return node.fsInode.RemoveXAttr(attr, &header.Context)
} }
func (me *FileSystemConnector) SetXAttr(header *InHeader, input *SetXAttrIn, attr string, data []byte) Status { func (me *FileSystemConnector) SetXAttr(header *InHeader, input *raw.SetXAttrIn, attr string, data []byte) Status {
node := me.toInode(header.NodeId) node := me.toInode(header.NodeId)
return node.fsInode.SetXAttr(attr, data, int(input.Flags), &header.Context) return node.fsInode.SetXAttr(attr, data, int(input.Flags), &header.Context)
} }
......
...@@ -225,7 +225,7 @@ func (me *LockingRawFileSystem) Link(header *InHeader, input *raw.LinkIn, name s ...@@ -225,7 +225,7 @@ func (me *LockingRawFileSystem) Link(header *InHeader, input *raw.LinkIn, name s
return me.RawFileSystem.Link(header, input, name) return me.RawFileSystem.Link(header, input, name)
} }
func (me *LockingRawFileSystem) SetXAttr(header *InHeader, input *SetXAttrIn, attr string, data []byte) Status { func (me *LockingRawFileSystem) SetXAttr(header *InHeader, input *raw.SetXAttrIn, attr string, data []byte) Status {
defer me.locked()() defer me.locked()()
return me.RawFileSystem.SetXAttr(header, input, attr, data) return me.RawFileSystem.SetXAttr(header, input, attr, data)
} }
......
...@@ -160,7 +160,7 @@ func doSetattr(state *MountState, req *request) { ...@@ -160,7 +160,7 @@ func doSetattr(state *MountState, req *request) {
func doWrite(state *MountState, req *request) { func doWrite(state *MountState, req *request) {
n, status := state.fileSystem.Write(req.inHeader, (*WriteIn)(req.inData), req.arg) n, status := state.fileSystem.Write(req.inHeader, (*WriteIn)(req.inData), req.arg)
o := &WriteOut{ o := &raw.WriteOut{
Size: n, Size: n,
} }
req.outData = unsafe.Pointer(o) req.outData = unsafe.Pointer(o)
...@@ -181,13 +181,13 @@ func doGetXAttr(state *MountState, req *request) { ...@@ -181,13 +181,13 @@ func doGetXAttr(state *MountState, req *request) {
} }
} }
input := (*GetXAttrIn)(req.inData) input := (*raw.GetXAttrIn)(req.inData)
var data []byte var data []byte
switch { switch {
case req.inHeader.opcode == _OP_GETXATTR && input.Size == 0: case req.inHeader.opcode == _OP_GETXATTR && input.Size == 0:
sz, code := state.fileSystem.GetXAttrSize(req.inHeader, req.filenames[0]) sz, code := state.fileSystem.GetXAttrSize(req.inHeader, req.filenames[0])
if code.Ok() { if code.Ok() {
out := &GetXAttrOut{ out := &raw.GetXAttrOut{
Size: uint32(sz), Size: uint32(sz),
} }
req.outData = unsafe.Pointer(out) req.outData = unsafe.Pointer(out)
...@@ -301,7 +301,7 @@ func doFsyncDir(state *MountState, req *request) { ...@@ -301,7 +301,7 @@ func doFsyncDir(state *MountState, req *request) {
func doSetXAttr(state *MountState, req *request) { func doSetXAttr(state *MountState, req *request) {
splits := bytes.SplitN(req.arg, []byte{0}, 2) splits := bytes.SplitN(req.arg, []byte{0}, 2)
req.status = state.fileSystem.SetXAttr(req.inHeader, (*SetXAttrIn)(req.inData), string(splits[0]), splits[1]) req.status = state.fileSystem.SetXAttr(req.inHeader, (*raw.SetXAttrIn)(req.inData), string(splits[0]), splits[1])
} }
func doRemoveXAttr(state *MountState, req *request) { func doRemoveXAttr(state *MountState, req *request) {
...@@ -401,9 +401,9 @@ func init() { ...@@ -401,9 +401,9 @@ func init() {
_OP_WRITE: unsafe.Sizeof(WriteIn{}), _OP_WRITE: unsafe.Sizeof(WriteIn{}),
_OP_RELEASE: unsafe.Sizeof(raw.ReleaseIn{}), _OP_RELEASE: unsafe.Sizeof(raw.ReleaseIn{}),
_OP_FSYNC: unsafe.Sizeof(FsyncIn{}), _OP_FSYNC: unsafe.Sizeof(FsyncIn{}),
_OP_SETXATTR: unsafe.Sizeof(SetXAttrIn{}), _OP_SETXATTR: unsafe.Sizeof(raw.SetXAttrIn{}),
_OP_GETXATTR: unsafe.Sizeof(GetXAttrIn{}), _OP_GETXATTR: unsafe.Sizeof(raw.GetXAttrIn{}),
_OP_LISTXATTR: unsafe.Sizeof(GetXAttrIn{}), _OP_LISTXATTR: unsafe.Sizeof(raw.GetXAttrIn{}),
_OP_FLUSH: unsafe.Sizeof(FlushIn{}), _OP_FLUSH: unsafe.Sizeof(FlushIn{}),
_OP_INIT: unsafe.Sizeof(raw.InitIn{}), _OP_INIT: unsafe.Sizeof(raw.InitIn{}),
_OP_OPENDIR: unsafe.Sizeof(raw.OpenIn{}), _OP_OPENDIR: unsafe.Sizeof(raw.OpenIn{}),
...@@ -429,10 +429,10 @@ func init() { ...@@ -429,10 +429,10 @@ func init() {
_OP_MKDIR: unsafe.Sizeof(EntryOut{}), _OP_MKDIR: unsafe.Sizeof(EntryOut{}),
_OP_LINK: unsafe.Sizeof(EntryOut{}), _OP_LINK: unsafe.Sizeof(EntryOut{}),
_OP_OPEN: unsafe.Sizeof(raw.OpenOut{}), _OP_OPEN: unsafe.Sizeof(raw.OpenOut{}),
_OP_WRITE: unsafe.Sizeof(WriteOut{}), _OP_WRITE: unsafe.Sizeof(raw.WriteOut{}),
_OP_STATFS: unsafe.Sizeof(StatfsOut{}), _OP_STATFS: unsafe.Sizeof(StatfsOut{}),
_OP_GETXATTR: unsafe.Sizeof(GetXAttrOut{}), _OP_GETXATTR: unsafe.Sizeof(raw.GetXAttrOut{}),
_OP_LISTXATTR: unsafe.Sizeof(GetXAttrOut{}), _OP_LISTXATTR: unsafe.Sizeof(raw.GetXAttrOut{}),
_OP_INIT: unsafe.Sizeof(raw.InitOut{}), _OP_INIT: unsafe.Sizeof(raw.InitOut{}),
_OP_OPENDIR: unsafe.Sizeof(raw.OpenOut{}), _OP_OPENDIR: unsafe.Sizeof(raw.OpenOut{}),
_OP_CREATE: unsafe.Sizeof(CreateOut{}), _OP_CREATE: unsafe.Sizeof(CreateOut{}),
......
...@@ -79,18 +79,6 @@ func (me *AccessIn) String() string { ...@@ -79,18 +79,6 @@ func (me *AccessIn) String() string {
return fmt.Sprintf("{%s}", raw.FlagString(accessFlagName, int(me.Mask), "")) return fmt.Sprintf("{%s}", raw.FlagString(accessFlagName, int(me.Mask), ""))
} }
func (me *SetXAttrIn) String() string {
return fmt.Sprintf("{sz %d f%o}", me.Size, me.Flags)
}
func (me *GetXAttrIn) String() string {
return fmt.Sprintf("{sz %d}", me.Size)
}
func (me *GetXAttrOut) String() string {
return fmt.Sprintf("{sz %d}", me.Size)
}
func (me *Kstatfs) String() string { func (me *Kstatfs) String() string {
return fmt.Sprintf( return fmt.Sprintf(
"{b%d f%d fs%d ff%d bs%d nl%d frs%d}", "{b%d f%d fs%d ff%d bs%d nl%d frs%d}",
......
...@@ -107,13 +107,6 @@ type Kstatfs struct { ...@@ -107,13 +107,6 @@ type Kstatfs struct {
Spare [6]uint32 Spare [6]uint32
} }
type FileLock struct {
Start uint64
End uint64
Typ uint32
Pid uint32
}
type EntryOut struct { type EntryOut struct {
NodeId uint64 NodeId uint64
Generation uint64 Generation uint64
...@@ -179,11 +172,6 @@ type WriteIn struct { ...@@ -179,11 +172,6 @@ type WriteIn struct {
Padding uint32 Padding uint32
} }
type WriteOut struct {
Size uint32
Padding uint32
}
type StatfsOut struct { type StatfsOut struct {
Kstatfs Kstatfs
} }
...@@ -194,32 +182,6 @@ type FsyncIn struct { ...@@ -194,32 +182,6 @@ type FsyncIn struct {
Padding uint32 Padding uint32
} }
type SetXAttrIn struct {
Size uint32
Flags uint32
}
type GetXAttrIn struct {
Size uint32
Padding uint32
}
type GetXAttrOut struct {
Size uint32
Padding uint32
}
type LkIn struct {
Fh uint64
Owner uint64
Lk FileLock
LkFlags uint32
Padding uint32
}
type LkOut struct {
Lk FileLock
}
// For AccessIn.Mask. // For AccessIn.Mask.
const ( const (
......
...@@ -147,3 +147,15 @@ func (me *InitOut) String() string { ...@@ -147,3 +147,15 @@ func (me *InitOut) String() string {
FlagString(initFlagNames, int(me.Flags), ""), FlagString(initFlagNames, int(me.Flags), ""),
me.CongestionThreshold, me.MaxBackground, me.MaxWrite) me.CongestionThreshold, me.MaxBackground, me.MaxWrite)
} }
func (me *SetXAttrIn) String() string {
return fmt.Sprintf("{sz %d f%o}", me.Size, me.Flags)
}
func (me *GetXAttrIn) String() string {
return fmt.Sprintf("{sz %d}", me.Size)
}
func (me *GetXAttrOut) String() string {
return fmt.Sprintf("{sz %d}", me.Size)
}
...@@ -212,3 +212,42 @@ type PollOut struct { ...@@ -212,3 +212,42 @@ type PollOut struct {
type NotifyPollWakeupOut struct { type NotifyPollWakeupOut struct {
Kh uint64 Kh uint64
} }
type WriteOut struct {
Size uint32
Padding uint32
}
type SetXAttrIn struct {
Size uint32
Flags uint32
}
type GetXAttrIn struct {
Size uint32
Padding uint32
}
type GetXAttrOut struct {
Size uint32
Padding uint32
}
type FileLock struct {
Start uint64
End uint64
Typ uint32
Pid uint32
}
type LkIn struct {
Fh uint64
Owner uint64
Lk FileLock
LkFlags uint32
Padding uint32
}
type LkOut struct {
Lk FileLock
}
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