Esempio n. 1
0
func (d dir) Lookup(name string, intr fs.Intr) (fs.Node, fuse.Error) {
	log.Printf("Lookup %q in Directory: %q\n%v\n", name, d.name, d)
	select {
	case <-intr:
		return nil, fuse.EINTR
	default:
	}
	newNodeID := fuse.NodeID(fs.GenerateDynamicInode(uint64(d.inode), name))

	switch d.contentType {
	default:
		return nil, nil
	case "commit":
		node, CommitErr := d.LookupCommit(name, intr, newNodeID)
		return node, CommitErr
	case "list":
		node, listErr := d.LookupList(name, intr, newNodeID)
		return node, listErr
	case "tag":
		node, tagErr := d.LookupTag(name, intr, newNodeID)
		return node, tagErr
	}

}
Esempio n. 2
0
func generateInode(NodeID fuse.NodeID, name string) fuse.NodeID {
	return fuse.NodeID(fs.GenerateDynamicInode(uint64(NodeID), name))
}
Esempio n. 3
0
func (_fs FS) GenerateInode(parentInode uint64, name string) uint64 {
	inode := fs.GenerateDynamicInode(parentInode, name)
	log.Debug("GenerateInode(%d,%s)=%d", parentInode, name, inode)
	return inode
}
Esempio n. 4
0
// Dynamic returns a dynamic inode. The result is guaranteed to never
// collide with inodes returned from Allocate.
func Dynamic(parent uint64, name string) uint64 {
	inode := fs.GenerateDynamicInode(parent, name)
	inode &^= tokens.InodeKindMask
	inode |= tokens.InodeKindDynamic
	return inode
}
Esempio n. 5
0
func (d dir) ReadDir(intr fs.Intr) ([]fuse.Dirent, fuse.Error) {
	//log.Printf("ReadDir requested:\n\tName:%s", d.name)
	select {
	case <-intr:
		return nil, fuse.EINTR
	default:
	}
	var l objects.List
	var listErr error
	var dirDirs = []fuse.Dirent{}
	switch d.contentType {
	case "tag":
		//if d.content_type == "tag" {
		tags, tagErr := services.GetTags(d.leaf.(objects.HKID))
		if tagErr != nil {
			log.Printf("tag %s:", tagErr)
			return nil, fuse.ENOENT
		}
		for _, tag := range tags {
			name := tag.NameSegment
			enttype := fuse.DT_Dir
			switch tag.TypeString {
			case "blob":
				enttype = fuse.DT_File
				fallthrough

			case "list", "commit", "tag":
				dirDirs = append(dirDirs, fuse.Dirent{
					Inode: fs.GenerateDynamicInode(uint64(d.inode), name),
					Name:  name,
					Type:  enttype,
				})
			default:
			}
		}
		return dirDirs, nil
	case "commit":
		//} else if d.content_type == "commit" {
		c, CommitErr := services.GetCommit(d.leaf.(objects.HKID))
		if CommitErr != nil {
			log.Printf("commit %s:", CommitErr)
			return nil, fuse.ENOENT
		}
		l, listErr = services.GetList(c.ListHash)
		if listErr != nil {
			log.Printf("commit list %s:", listErr)
			return nil, fuse.ENOENT
		}
	case "list":
		l, listErr = services.GetList(d.leaf.(objects.HCID))
		if listErr != nil {
			log.Printf("list %s:", listErr)
			return nil, fuse.ENOENT
		}
	default:
		return nil, fuse.ENOENT
	}

	for name, entry := range l {
		if entry.TypeString == "blob" {
			appendToList := fuse.Dirent{
				Inode: fs.GenerateDynamicInode(uint64(d.inode), name),
				Name:  name,
				Type:  fuse.DT_File,
			}
			dirDirs = append(dirDirs, appendToList)
		} else {
			appendToList := fuse.Dirent{
				Inode: fs.GenerateDynamicInode(uint64(d.inode), name),
				Name:  name,
				Type:  fuse.DT_Dir}
			dirDirs = append(dirDirs, appendToList)
		}
	}

	//loop through openHandles
	for openHandle := range d.openHandles {
		inList := false
		for _, dirEntry := range dirDirs {
			if openHandle == dirEntry.Name {
				inList = true
				break
			}
		}
		if !inList {
			dirDirs = append(
				dirDirs,
				fuse.Dirent{
					Inode: fs.GenerateDynamicInode(uint64(d.inode), openHandle),
					Name:  openHandle,
					Type:  fuse.DT_Dir,
				})
		}
	}
	return dirDirs, nil
}