Пример #1
0
func getAttr(fs pathfs.FileSystem, name string) *attrResponse {
	a, code := fs.GetAttr(name, nil)
	return &attrResponse{
		Attr:   a,
		Status: code,
	}
}
Пример #2
0
func assertAttr(s *fuseTestSuite, fs pathfs.FileSystem, path string, mode uint32, size uint64) {
	attr, code := fs.GetAttr(path, nil)
	assert.Equal(s.T(), fuse.OK, code)
	if code == fuse.OK {
		assert.Equal(s.T(), mode, attr.Mode)
		assert.Equal(s.T(), size, attr.Size)
	}
}
Пример #3
0
func findDir(fs pathfs.FileSystem, path string, delimiter string) []string {
	ents, _ := fs.OpenDir(path, nil)
	ret := make([]string, 0)
	for _, ent := range ents {
		child := path + delimiter + ent.Name
		attr, _ := fs.GetAttr(child, nil)
		if attr.Mode&fuse.S_IFDIR != 0 {
			ret = append(ret, child+"/")
			ret = append(ret, findDir(fs, child, "/")...)
		} else {
			ret = append(ret, child)
		}
	}

	return ret
}
Пример #4
0
// NewMemUnionFs instantiates a new union file system.  Calling this
// will access the root of the supplied R/O filesystem.
func NewMemUnionFs(backingStore string, roFs pathfs.FileSystem) (*MemUnionFs, error) {
	me := &MemUnionFs{
		deleted:      make(map[string]bool),
		backingStore: backingStore,
		readonly:     roFs,
	}

	me.root = me.newNode(true)
	fi, code := roFs.GetAttr("", nil)
	if !code.Ok() {
		return nil, fmt.Errorf("GetAttr(\"\") for R/O returned %v", code)
	}

	me.root.info = *fi
	me.cond = sync.NewCond(&me.mutex)

	return me, nil
}