Commit 8aade5c7 authored by Ka-Hing Cheung's avatar Ka-Hing Cheung

RemoveXattr implementation

parent 77e8f7f7
......@@ -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{}))))
......
......@@ -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
}
......@@ -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)
......
......@@ -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() {
}
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