当前位置: 首页>>代码示例>>Golang>>正文


Golang CreateFileOp.Header方法代码示例

本文整理汇总了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
}
开发者ID:BanzaiMan,项目名称:gcsfuse,代码行数:49,代码来源:memfs.go


注:本文中的github.com/jacobsa/fuse/fuseops.CreateFileOp.Header方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。