本文整理汇总了Golang中github.com/jacobsa/fuse/internal/buffer.OutMessage.Grow方法的典型用法代码示例。如果您正苦于以下问题:Golang OutMessage.Grow方法的具体用法?Golang OutMessage.Grow怎么用?Golang OutMessage.Grow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jacobsa/fuse/internal/buffer.OutMessage
的用法示例。
在下文中一共展示了OutMessage.Grow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: kernelResponseForOp
// Like kernelResponse, but assumes the user replied with a nil error to the
// op.
func (c *Connection) kernelResponseForOp(
m *buffer.OutMessage,
op interface{}) {
// Create the appropriate output message
switch o := op.(type) {
case *fuseops.LookUpInodeOp:
size := fusekernel.EntryOutSize(c.protocol)
out := (*fusekernel.EntryOut)(m.Grow(size))
convertChildInodeEntry(&o.Entry, out)
case *fuseops.GetInodeAttributesOp:
size := fusekernel.AttrOutSize(c.protocol)
out := (*fusekernel.AttrOut)(m.Grow(size))
out.AttrValid, out.AttrValidNsec = convertExpirationTime(
o.AttributesExpiration)
convertAttributes(o.Inode, &o.Attributes, &out.Attr)
case *fuseops.SetInodeAttributesOp:
size := fusekernel.AttrOutSize(c.protocol)
out := (*fusekernel.AttrOut)(m.Grow(size))
out.AttrValid, out.AttrValidNsec = convertExpirationTime(
o.AttributesExpiration)
convertAttributes(o.Inode, &o.Attributes, &out.Attr)
case *fuseops.MkDirOp:
size := fusekernel.EntryOutSize(c.protocol)
out := (*fusekernel.EntryOut)(m.Grow(size))
convertChildInodeEntry(&o.Entry, out)
case *fuseops.CreateFileOp:
eSize := fusekernel.EntryOutSize(c.protocol)
e := (*fusekernel.EntryOut)(m.Grow(eSize))
convertChildInodeEntry(&o.Entry, e)
oo := (*fusekernel.OpenOut)(m.Grow(unsafe.Sizeof(fusekernel.OpenOut{})))
oo.Fh = uint64(o.Handle)
case *fuseops.CreateSymlinkOp:
size := fusekernel.EntryOutSize(c.protocol)
out := (*fusekernel.EntryOut)(m.Grow(size))
convertChildInodeEntry(&o.Entry, out)
case *fuseops.RenameOp:
// Empty response
case *fuseops.RmDirOp:
// Empty response
case *fuseops.UnlinkOp:
// Empty response
case *fuseops.OpenDirOp:
out := (*fusekernel.OpenOut)(m.Grow(unsafe.Sizeof(fusekernel.OpenOut{})))
out.Fh = uint64(o.Handle)
case *fuseops.ReadDirOp:
// convertInMessage already set up the destination buffer to be at the end
// of the out message. We need only shrink to the right size based on how
// much the user read.
m.ShrinkTo(buffer.OutMessageInitialSize + uintptr(o.BytesRead))
case *fuseops.ReleaseDirHandleOp:
// Empty response
case *fuseops.OpenFileOp:
out := (*fusekernel.OpenOut)(m.Grow(unsafe.Sizeof(fusekernel.OpenOut{})))
out.Fh = uint64(o.Handle)
if o.KeepPageCache {
out.OpenFlags |= uint32(fusekernel.OpenKeepCache)
}
case *fuseops.ReadFileOp:
// convertInMessage already set up the destination buffer to be at the end
// of the out message. We need only shrink to the right size based on how
// much the user read.
m.ShrinkTo(buffer.OutMessageInitialSize + uintptr(o.BytesRead))
case *fuseops.WriteFileOp:
out := (*fusekernel.WriteOut)(m.Grow(unsafe.Sizeof(fusekernel.WriteOut{})))
out.Size = uint32(len(o.Data))
case *fuseops.SyncFileOp:
// Empty response
case *fuseops.FlushFileOp:
// Empty response
case *fuseops.ReleaseFileHandleOp:
// Empty response
case *fuseops.ReadSymlinkOp:
m.AppendString(o.Target)
case *statFSOp:
m.Grow(unsafe.Sizeof(fusekernel.StatfsOut{}))
//.........这里部分代码省略.........
示例2: kernelResponseForOp
// Like kernelResponse, but assumes the user replied with a nil error to the
// op.
func (c *Connection) kernelResponseForOp(
m *buffer.OutMessage,
op interface{}) {
// Create the appropriate output message
switch o := op.(type) {
case *fuseops.LookUpInodeOp:
size := fusekernel.EntryOutSize(c.protocol)
out := (*fusekernel.EntryOut)(m.Grow(size))
convertChildInodeEntry(&o.Entry, out)
case *fuseops.GetInodeAttributesOp:
size := fusekernel.AttrOutSize(c.protocol)
out := (*fusekernel.AttrOut)(m.Grow(size))
out.AttrValid, out.AttrValidNsec = convertExpirationTime(
o.AttributesExpiration)
convertAttributes(o.Inode, &o.Attributes, &out.Attr)
case *fuseops.SetInodeAttributesOp:
size := fusekernel.AttrOutSize(c.protocol)
out := (*fusekernel.AttrOut)(m.Grow(size))
out.AttrValid, out.AttrValidNsec = convertExpirationTime(
o.AttributesExpiration)
convertAttributes(o.Inode, &o.Attributes, &out.Attr)
case *fuseops.MkDirOp:
size := fusekernel.EntryOutSize(c.protocol)
out := (*fusekernel.EntryOut)(m.Grow(size))
convertChildInodeEntry(&o.Entry, out)
case *fuseops.CreateFileOp:
eSize := fusekernel.EntryOutSize(c.protocol)
e := (*fusekernel.EntryOut)(m.Grow(eSize))
convertChildInodeEntry(&o.Entry, e)
oo := (*fusekernel.OpenOut)(m.Grow(unsafe.Sizeof(fusekernel.OpenOut{})))
oo.Fh = uint64(o.Handle)
case *fuseops.CreateSymlinkOp:
size := fusekernel.EntryOutSize(c.protocol)
out := (*fusekernel.EntryOut)(m.Grow(size))
convertChildInodeEntry(&o.Entry, out)
case *fuseops.RenameOp:
// Empty response
case *fuseops.RmDirOp:
// Empty response
case *fuseops.UnlinkOp:
// Empty response
case *fuseops.OpenDirOp:
out := (*fusekernel.OpenOut)(m.Grow(unsafe.Sizeof(fusekernel.OpenOut{})))
out.Fh = uint64(o.Handle)
case *fuseops.ReadDirOp:
// convertInMessage already set up the destination buffer to be at the end
// of the out message. We need only shrink to the right size based on how
// much the user read.
m.ShrinkTo(buffer.OutMessageInitialSize + uintptr(o.BytesRead))
case *fuseops.ReleaseDirHandleOp:
// Empty response
case *fuseops.OpenFileOp:
out := (*fusekernel.OpenOut)(m.Grow(unsafe.Sizeof(fusekernel.OpenOut{})))
out.Fh = uint64(o.Handle)
if o.KeepPageCache {
out.OpenFlags |= uint32(fusekernel.OpenKeepCache)
}
case *fuseops.ReadFileOp:
// convertInMessage already set up the destination buffer to be at the end
// of the out message. We need only shrink to the right size based on how
// much the user read.
m.ShrinkTo(buffer.OutMessageInitialSize + uintptr(o.BytesRead))
case *fuseops.WriteFileOp:
out := (*fusekernel.WriteOut)(m.Grow(unsafe.Sizeof(fusekernel.WriteOut{})))
out.Size = uint32(len(o.Data))
case *fuseops.SyncFileOp:
// Empty response
case *fuseops.FlushFileOp:
// Empty response
case *fuseops.ReleaseFileHandleOp:
// Empty response
case *fuseops.ReadSymlinkOp:
m.AppendString(o.Target)
case *fuseops.StatFSOp:
out := (*fusekernel.StatfsOut)(m.Grow(unsafe.Sizeof(fusekernel.StatfsOut{})))
out.St.Blocks = o.Blocks
//.........这里部分代码省略.........