• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang maggiefs.Inode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/jbooth/maggiefs/maggiefs.Inode的典型用法代码示例。如果您正苦于以下问题:Golang Inode类的具体用法?Golang Inode怎么用?Golang Inode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Inode类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: fillEntryOut

func fillEntryOut(out *raw.EntryOut, i *maggiefs.Inode) {
	// fill out
	out.NodeId = i.Inodeid
	out.Generation = i.Generation
	out.EntryValid = uint64(0)
	out.AttrValid = uint64(0)
	out.EntryValidNsec = uint32(100)
	out.AttrValidNsec = uint32(100)
	//Inode
	out.Ino = i.Inodeid
	out.Size = i.Length
	out.Blocks = numBlocks(i.Length, maggiefs.PAGESIZE)
	out.Atime = uint64(0)       // always 0 for atime
	out.Mtime = uint64(i.Mtime) // Mtime is user modifiable and is the last time data changed
	out.Ctime = uint64(i.Ctime) // Ctime is tracked by the FS and changes when attrs or data change
	out.Atimensec = uint32(0)
	out.Mtimensec = uint32(0)
	out.Ctimensec = uint32(0)
	out.Mode = i.FullMode()
	out.Nlink = i.Nlink
	out.Uid = i.Uid
	out.Gid = i.Gid
	out.Rdev = uint32(0) // regular file, not block dvice
	out.Blksize = maggiefs.PAGESIZE
}
开发者ID:jonpugh,项目名称:maggiefs,代码行数:25,代码来源:fuseconnector.go


示例2: SetInode

// seta an inode
func (nd *NameData) SetInode(i *maggiefs.Inode) (err error) {
	nd.inodeStripeLock[i.Inodeid%STRIPE_SIZE].Lock()
	defer nd.inodeStripeLock[i.Inodeid%STRIPE_SIZE].Unlock()
	key := make([]byte, 8)
	binary.LittleEndian.PutUint64(key, i.Inodeid)
	// do the write and send OK
	binsize := i.BinSize()
	b := make([]byte, binsize)
	i.ToBytes(b)

	err = nd.inodb.Put(WriteOpts, key, b)
	return err
}
开发者ID:jonpugh,项目名称:maggiefs,代码行数:14,代码来源:namedata.go


示例3: AddInode

// adds an inode persistent store, setting its inode ID to the generated ID, and returning
// the generated id and error
func (nd *NameData) AddInode(i *maggiefs.Inode) (uint64, error) {
	newNodeId, err := nd.GetIncrCounter(COUNTER_INODE, 1)
	if err != nil {
		return 0, err
	}
	i.Inodeid = newNodeId
	err = nd.SetInode(i)
	return i.Inodeid, err
}
开发者ID:jonpugh,项目名称:maggiefs,代码行数:11,代码来源:namedata.go


示例4: Mkdir

func (m *MaggieFuse) Mkdir(out *raw.EntryOut, header *raw.InHeader, input *raw.MkdirIn, name string) (code fuse.Status) {

	// make new child
	currTime := time.Now().Unix()
	i := maggiefs.Inode{
		0, // id 0 to start, we get id when inserting
		0,
		maggiefs.FTYPE_DIR,
		0,
		07777 & input.Mode,
		currTime,
		currTime,
		0,
		header.Uid,
		header.Gid,
		"",
		make([]maggiefs.Block, 0, 0),
		make(map[string]maggiefs.Dentry),
		make(map[string][]byte),
	}

	// save
	id, err := m.names.AddInode(&i)
	if err != nil {
		return fuse.EROFS
	}
	i.Inodeid = id
	// link parent
	err = m.names.Link(header.NodeId, id, name, false)
	if err != nil {
		// garbage collector will clean up our 0 reference node
		if err == maggiefs.E_EXISTS {
			return fuse.Status(syscall.EEXIST)
		}
		if err == maggiefs.E_NOTDIR {
			return fuse.ENOTDIR
		}
		return fuse.EROFS
	}
	// send entry back to child
	fillEntryOut(out, &i)
	return fuse.OK
}
开发者ID:jonpugh,项目名称:maggiefs,代码行数:43,代码来源:fuseconnector.go


示例5: Mknod

func (m *MaggieFuse) Mknod(out *raw.EntryOut, header *raw.InHeader, input *raw.MknodIn, name string) (code fuse.Status) {

	//build node
	currTime := time.Now().Unix()
	i := maggiefs.Inode{
		0, // id 0 to start
		0, // gen 0
		maggiefs.FTYPE_REG,
		0,
		input.Mode & 07777,
		currTime,
		currTime,
		1,
		header.Uid,
		header.Gid,
		"",
		make([]maggiefs.Block, 0, 0),
		make(map[string]maggiefs.Dentry),
		make(map[string][]byte),
	}

	// save new node
	id, err := m.names.AddInode(&i)
	if err != nil {
		return fuse.EROFS
	}
	i.Inodeid = id

	// link parent
	err = m.names.Link(header.NodeId, i.Inodeid, name, false)
	if err != nil {
		if err == maggiefs.E_EXISTS {
			return fuse.Status(syscall.EEXIST)
		} else {
			return fuse.EROFS
		}
	}
	// output
	fillEntryOut(out, &i)
	return fuse.OK

}
开发者ID:jonpugh,项目名称:maggiefs,代码行数:42,代码来源:fuseconnector.go


示例6: addBlocksForFileWrite

// acquires lease, then adds the blocks to the namenode,
// patching up the referenced inode to match
func (w *InodeWriter) addBlocksForFileWrite(inode *maggiefs.Inode, off uint64, length uint32) error {
	//	fmt.Printf("Adding/extending blocks for write at off %d length %d\n", off, length)
	newEndPos := off + uint64(length)
	if newEndPos > inode.Length {
		// if we have a last block and it's less than max length,
		// extend last block to max block length first
		//		fmt.Printf("Adding/extending blocks for file write to inode %+v\n", inode)
		if inode.Blocks != nil && len(inode.Blocks) > 0 {
			idx := int(len(inode.Blocks) - 1)
			lastBlock := inode.Blocks[idx]
			if lastBlock.Length() < BLOCKLENGTH {
				extendLength := BLOCKLENGTH - lastBlock.Length()
				if lastBlock.EndPos+extendLength > off+uint64(length) {
					// only extend as much as we need to
					extendLength = off + uint64(length) - lastBlock.EndPos
				}
				lastBlock.EndPos = lastBlock.EndPos + extendLength
				inode.Blocks[idx] = lastBlock
				inode.Length += extendLength
			}
		}
		// and add new blocks as necessary
		for newEndPos > inode.Length {
			//			fmt.Printf("New end pos %d still greater than inode length %d\n", newEndPos, inode.Length)
			newBlockLength := newEndPos - inode.Length
			if newBlockLength > BLOCKLENGTH {
				newBlockLength = BLOCKLENGTH
			}
			newBlock, err := w.names.AddBlock(inode.Inodeid, uint32(newBlockLength))
			if err != nil {
				return err
			}
			inode.Blocks = append(inode.Blocks, newBlock)
			inode.Length += newBlockLength
		}
	}
	inode.Mtime = time.Now().Unix()
	err := w.names.SetInode(inode)
	return err
}
开发者ID:jonpugh,项目名称:maggiefs,代码行数:42,代码来源:writer.go


示例7: Symlink

func (m *MaggieFuse) Symlink(out *raw.EntryOut, header *raw.InHeader, pointedTo string, linkName string) (code fuse.Status) {
	// new inode type symlink
	currTime := time.Now().Unix()
	i := maggiefs.Inode{
		0, // id 0 to start, we get id when inserting
		0,
		maggiefs.FTYPE_LNK,
		0,
		0777,
		currTime,
		currTime,
		0,
		header.Uid,
		header.Gid,
		pointedTo,
		make([]maggiefs.Block, 0, 0),
		make(map[string]maggiefs.Dentry),
		make(map[string][]byte),
	}
	// save
	id, err := m.names.AddInode(&i)
	if err != nil {
		return fuse.EROFS
	}
	i.Inodeid = id
	// link parent
	err = m.names.Link(header.NodeId, i.Inodeid, linkName, false)
	if err != nil {
		if err == maggiefs.E_EXISTS {
			return fuse.Status(syscall.EEXIST)
		} else if err == maggiefs.E_NOTDIR {
			return fuse.ENOTDIR
		}
		return fuse.EROFS
	}
	// send entry back to child
	fillEntryOut(out, &i)
	return fuse.OK
}
开发者ID:jonpugh,项目名称:maggiefs,代码行数:39,代码来源:fuseconnector.go


示例8: fillAttrOut

func fillAttrOut(out *raw.AttrOut, i *maggiefs.Inode) {
	// raw.Attr
	out.Ino = i.Inodeid
	out.Size = i.Length
	out.Blocks = numBlocks(i.Length, maggiefs.PAGESIZE)
	out.Atime = uint64(0)       // always 0 for atime
	out.Mtime = uint64(i.Mtime) // Mtime is user modifiable and is the last time data changed
	out.Ctime = uint64(i.Ctime) // Ctime is tracked by the FS and changes when attrs or data change
	out.Atimensec = uint32(0)
	out.Mtimensec = uint32(0)
	out.Ctimensec = uint32(0)
	out.Mode = i.FullMode()
	out.Nlink = i.Nlink
	out.Uid = i.Uid
	out.Gid = i.Gid
	out.Rdev = uint32(0) // regular file, not block dvice
	out.Blksize = maggiefs.PAGESIZE
	// raw.AttrOut
	out.AttrValid = uint64(0)
	out.AttrValidNsec = uint32(100)
	fmt.Printf("Filled attrOut %v with inode %v\n", out, i)
}
开发者ID:jonpugh,项目名称:maggiefs,代码行数:22,代码来源:fuseconnector.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang money.Money类代码示例发布时间:2022-05-23
下一篇:
Golang gomdb.Txn类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap