func (d *Dataset) openChildren() (err error) { var dataset Dataset d.Children = make([]Dataset, 0, 5) errcode := C.dataset_list_children(d.list.zh, &(dataset.list)) for dataset.list != nil { dataset.Type = DatasetType(C.zfs_get_type(dataset.list.zh)) dataset.Properties = make(map[ZFSProp]Property) err = dataset.ReloadProperties() if err != nil { return } d.Children = append(d.Children, dataset) dataset.list = C.dataset_next(dataset.list) } if errcode != 0 { err = LastError() return } for ci, _ := range d.Children { if err = d.Children[ci].openChildren(); err != nil { return } } return }
// Recursive get handles to all available datasets on system // (file-systems, volumes or snapshots). func DatasetOpenAll() (datasets []Dataset, err error) { var dataset Dataset errcode := C.dataset_list_root(libzfs_handle, &dataset.list) for dataset.list != nil { dataset.Type = DatasetType(C.zfs_get_type(dataset.list.zh)) err = dataset.ReloadProperties() if err != nil { return } datasets = append(datasets, dataset) dataset.list = C.dataset_next(dataset.list) } if errcode != 0 { err = LastError() return } for ci, _ := range datasets { if err = datasets[ci].openChildren(); err != nil { return } } return }