RemoveXattr implementation

geesefs-0-30-9
Ka-Hing Cheung 2015-12-04 12:26:49 -08:00
parent 77e8f7f767
commit 8aade5c71f
4 changed files with 40 additions and 0 deletions

View File

@ -420,6 +420,19 @@ func convertInMessage(
Flags: fusekernel.InitFlags(in.Flags),
}
case fusekernel.OpRemovexattr:
buf := inMsg.ConsumeBytes(inMsg.Len())
n := len(buf)
if n == 0 || buf[n-1] != '\x00' {
err = errors.New("Corrupt OpRemovexattr")
return
}
o = &fuseops.RemoveXattrOp{
Inode: fuseops.InodeID(inMsg.Header().Nodeid),
Name: string(buf[:n-1]),
}
default:
o = &unknownOp{
OpCode: inMsg.Header().Opcode,
@ -623,6 +636,9 @@ func (c *Connection) kernelResponseForOp(
out.St.Bsize = o.IoSize
out.St.Frsize = o.BlockSize
case *fuseops.RemoveXattrOp:
// Empty response
case *initOp:
out := (*fusekernel.InitOut)(m.Grow(int(unsafe.Sizeof(fusekernel.InitOut{}))))

View File

@ -767,3 +767,16 @@ type ReadSymlinkOp struct {
// Set by the file system: the target of the symlink.
Target string
}
////////////////////////////////////////////////////////////////////////
// eXtended attributes
////////////////////////////////////////////////////////////////////////
// Remove an extended attribute
type RemoveXattrOp struct {
// The inode that we are reading
Inode InodeID
// The name of the extended attribute
Name string
}

View File

@ -57,6 +57,7 @@ type FileSystem interface {
FlushFile(context.Context, *fuseops.FlushFileOp) error
ReleaseFileHandle(context.Context, *fuseops.ReleaseFileHandleOp) error
ReadSymlink(context.Context, *fuseops.ReadSymlinkOp) error
RemoveXattr(context.Context, *fuseops.RemoveXattrOp) error
// Regard all inodes (including the root inode) as having their lookup counts
// decremented to zero, and clean up any resources associated with the file
@ -186,6 +187,9 @@ func (s *fileSystemServer) handleOp(
case *fuseops.ReadSymlinkOp:
err = s.fs.ReadSymlink(ctx, typed)
case *fuseops.RemoveXattrOp:
err = s.fs.RemoveXattr(ctx, typed)
}
c.Reply(ctx, err)

View File

@ -183,5 +183,12 @@ func (fs *NotImplementedFileSystem) ReadSymlink(
return
}
func (fs *NotImplementedFileSystem) RemoveXattr(
ctx context.Context,
op *fuseops.RemoveXattrOp) (err error) {
err = fuse.ENOSYS
return
}
func (fs *NotImplementedFileSystem) Destroy() {
}