Example #1
0
// 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
}
Example #2
0
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
}