예제 #1
0
파일: zpool.go 프로젝트: iavael/go-libzfs
// Re-read ZFS pool properties and features, refresh Pool.Properties and
// Pool.Features map
func (pool *Pool) ReloadProperties() (err error) {
	propList := C.read_zpool_properties(pool.list.zph)
	if propList == nil {
		err = LastError()
		return
	}

	pool.Properties = make([]Property, PoolNumProps+1)
	next := propList
	for next != nil {
		pool.Properties[next.property] = Property{Value: C.GoString(&(next.value[0])), Source: C.GoString(&(next.source[0]))}
		next = C.next_property(next)
	}
	C.free_properties(propList)

	// read features
	pool.Features = map[string]string{
		"async_destroy": "disabled",
		"empty_bpobj":   "disabled",
		"lz4_compress":  "disabled"}
	for name, _ := range pool.Features {
		pool.GetFeature(name)
	}
	return
}
예제 #2
0
파일: zfs.go 프로젝트: iavael/go-libzfs
// Reload and return single specified property. This also reloads requested
// property in Properties map.
func (d *Dataset) GetProperty(p ZFSProp) (prop Property, err error) {
	if d.list == nil {
		err = errors.New(msgDatasetIsNil)
		return
	}
	var plist *C.property_list_t
	plist = C.new_property_list()
	defer C.free_properties(plist)
	errcode := C.read_dataset_property(d.list.zh, plist, C.int(p))
	if errcode != 0 {
		err = LastError()
		return
	}
	prop = Property{Value: C.GoString(&(*plist).value[0]),
		Source: C.GoString(&(*plist).source[0])}
	d.Properties[p] = prop
	return
}
예제 #3
0
파일: zfs.go 프로젝트: iavael/go-libzfs
func (d *Dataset) ReloadProperties() (err error) {
	if d.list == nil {
		err = errors.New(msgDatasetIsNil)
		return
	}
	var plist *C.property_list_t
	plist = C.new_property_list()
	defer C.free_properties(plist)
	d.Properties = make(map[ZFSProp]Property)
	for prop := ZFSPropType; prop < ZFSNumProps; prop++ {
		errcode := C.read_dataset_property(d.list.zh, plist, C.int(prop))
		if errcode != 0 {
			continue
		}
		d.Properties[prop] = Property{Value: C.GoString(&(*plist).value[0]),
			Source: C.GoString(&(*plist).source[0])}
	}
	return
}