本文整理汇总了Golang中github.com/jacobsa/fuse/fuseops.CreateFileOp.Header方法的典型用法代码示例。如果您正苦于以下问题:Golang CreateFileOp.Header方法的具体用法?Golang CreateFileOp.Header怎么用?Golang CreateFileOp.Header使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jacobsa/fuse/fuseops.CreateFileOp
的用法示例。
在下文中一共展示了CreateFileOp.Header方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CreateFile
func (fs *memFS) CreateFile(
op *fuseops.CreateFileOp) (err error) {
fs.mu.Lock()
defer fs.mu.Unlock()
// Grab the parent, which we will update shortly.
parent := fs.getInodeOrDie(op.Parent)
// Ensure that the name doesn't already exist, so we don't wind up with a
// duplicate.
_, _, exists := parent.LookUpChild(op.Name)
if exists {
err = fuse.EEXIST
return
}
// Set up attributes from the child, using the credentials of the calling
// process as owner (matching inode_init_owner, cf. http://goo.gl/5qavg8).
now := fs.clock.Now()
childAttrs := fuseops.InodeAttributes{
Nlink: 1,
Mode: op.Mode,
Atime: now,
Mtime: now,
Ctime: now,
Crtime: now,
Uid: op.Header().Uid,
Gid: op.Header().Gid,
}
// Allocate a child.
childID, child := fs.allocateInode(childAttrs)
// Add an entry in the parent.
parent.AddChild(childID, op.Name, fuseutil.DT_File)
// Fill in the response entry.
op.Entry.Child = childID
op.Entry.Attributes = child.attrs
// We don't spontaneously mutate, so the kernel can cache as long as it wants
// (since it also handles invalidation).
op.Entry.AttributesExpiration = fs.clock.Now().Add(365 * 24 * time.Hour)
op.Entry.EntryExpiration = op.Entry.EntryExpiration
// We have nothing interesting to put in the Handle field.
return
}