本文整理汇总了Golang中github.com/jacobsa/fuse/fuseops.SetInodeAttributesOp.Attributes方法的典型用法代码示例。如果您正苦于以下问题:Golang SetInodeAttributesOp.Attributes方法的具体用法?Golang SetInodeAttributesOp.Attributes怎么用?Golang SetInodeAttributesOp.Attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jacobsa/fuse/fuseops.SetInodeAttributesOp
的用法示例。
在下文中一共展示了SetInodeAttributesOp.Attributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SetInodeAttributes
// SetInodeAttributes sets specified attributes to file or directory.
//
// Required for fuse.FileSystem.
func (k *KodingNetworkFS) SetInodeAttributes(ctx context.Context, op *fuseops.SetInodeAttributesOp) error {
entry, err := k.getEntry(ctx, op.Inode)
if err != nil {
return err
}
attrs := entry.GetAttrs()
// optionally update attrs
if op.Mode != nil {
attrs.Mode = *op.Mode
}
if op.Atime != nil {
attrs.Atime = *op.Atime
}
// optionally update attrs only if entry is a file
if file, isFile := entry.(*File); isFile {
if op.Mtime != nil {
attrs.Mtime = *op.Mtime
}
if op.Size != nil {
if err := file.TruncateTo(*op.Size); err != nil {
return err
}
attrs.Size = *op.Size
}
}
entry.SetAttrs(attrs)
op.Attributes = *attrs
return nil
}
示例2: SetInodeAttributes
func (fs *Goofys) SetInodeAttributes(
ctx context.Context,
op *fuseops.SetInodeAttributesOp) (err error) {
fs.mu.Lock()
inode := fs.getInodeOrDie(op.Inode)
fs.mu.Unlock()
attr, err := inode.GetAttributes(fs)
op.Attributes = *attr
op.AttributesExpiration = time.Now().Add(365 * 24 * time.Hour)
return
}
示例3: SetInodeAttributes
func (fs *memFS) SetInodeAttributes(
op *fuseops.SetInodeAttributesOp) (err error) {
fs.mu.Lock()
defer fs.mu.Unlock()
// Grab the inode.
inode := fs.getInodeOrDie(op.Inode)
// Handle the request.
inode.SetAttributes(op.Size, op.Mode, op.Mtime)
// Fill in the response.
op.Attributes = inode.attrs
// We don't spontaneously mutate, so the kernel can cache as long as it wants
// (since it also handles invalidation).
op.AttributesExpiration = fs.clock.Now().Add(365 * 24 * time.Hour)
return
}