Skip to content

Commit 178e69d

Browse files
committed
Merge remote-tracking branch 'calmh/master' into p1
2 parents 6709706 + fc23d69 commit 178e69d

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

utils.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,13 @@ func parseInodeChanges(lines [][]string) ([]*InodeChange, error) {
266266
return changes, nil
267267
}
268268

269-
func listByType(t, filter string) ([]*Dataset, error) {
270-
args := []string{"get", "-rHp", "-t", t, "all"}
269+
func listByType(t, filter string, depth int) ([]*Dataset, error) {
270+
var args []string
271+
if depth > 0 {
272+
args = []string{"get", fmt.Sprintf("-d%d", depth), "-rHp", "-t", t, "all"}
273+
} else {
274+
args = []string{"get", "-rHp", "-t", t, "all"}
275+
}
271276
if filter != "" {
272277
args = append(args, filter)
273278
}

zfs.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,29 +117,29 @@ func zfs(arg ...string) ([][]string, error) {
117117
// Datasets returns a slice of ZFS datasets, regardless of type.
118118
// A filter argument may be passed to select a dataset with the matching name,
119119
// or empty string ("") may be used to select all datasets.
120-
func Datasets(filter string) ([]*Dataset, error) {
121-
return listByType("all", filter)
120+
func Datasets(filter string, depth int) ([]*Dataset, error) {
121+
return listByType("all", filter, depth)
122122
}
123123

124124
// Snapshots returns a slice of ZFS snapshots.
125125
// A filter argument may be passed to select a snapshot with the matching name,
126126
// or empty string ("") may be used to select all snapshots.
127-
func Snapshots(filter string) ([]*Dataset, error) {
128-
return listByType(DatasetSnapshot, filter)
127+
func Snapshots(filter string, depth int) ([]*Dataset, error) {
128+
return listByType(DatasetSnapshot, filter, depth)
129129
}
130130

131131
// Filesystems returns a slice of ZFS filesystems.
132132
// A filter argument may be passed to select a filesystem with the matching name,
133133
// or empty string ("") may be used to select all filesystems.
134-
func Filesystems(filter string) ([]*Dataset, error) {
135-
return listByType(DatasetFilesystem, filter)
134+
func Filesystems(filter string, depth int) ([]*Dataset, error) {
135+
return listByType(DatasetFilesystem, filter, depth)
136136
}
137137

138138
// Volumes returns a slice of ZFS volumes.
139139
// A filter argument may be passed to select a volume with the matching name,
140140
// or empty string ("") may be used to select all volumes.
141-
func Volumes(filter string) ([]*Dataset, error) {
142-
return listByType(DatasetVolume, filter)
141+
func Volumes(filter string, depth int) ([]*Dataset, error) {
142+
return listByType(DatasetVolume, filter, depth)
143143
}
144144

145145
// GetDataset retrieves a single ZFS dataset by name. This dataset could be
@@ -336,7 +336,7 @@ func (d *Dataset) Rename(name string, createParent bool, recursiveRenameSnapshot
336336

337337
// Snapshots returns a slice of all ZFS snapshots of a given dataset.
338338
func (d *Dataset) Snapshots() ([]*Dataset, error) {
339-
return Snapshots(d.Name)
339+
return Snapshots(d.Name, 1)
340340
}
341341

342342
// CreateFilesystem creates a new ZFS filesystem with the specified name and

zpool.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ func GetZpool(name string) (*Zpool, error) {
4949
}
5050

5151
// Datasets returns a slice of all ZFS datasets in a zpool.
52-
func (z *Zpool) Datasets() ([]*Dataset, error) {
53-
return Datasets(z.Name)
52+
func (z *Zpool) Datasets(depth int) ([]*Dataset, error) {
53+
return Datasets(z.Name, depth)
5454
}
5555

5656
// Snapshots returns a slice of all ZFS snapshots in a zpool.
57-
func (z *Zpool) Snapshots() ([]*Dataset, error) {
58-
return Snapshots(z.Name)
57+
func (z *Zpool) Snapshots(depth int) ([]*Dataset, error) {
58+
return Snapshots(z.Name, depth)
5959
}
6060

6161
// CreateZpool creates a new ZFS zpool with the specified name, properties,

0 commit comments

Comments
 (0)