Skip to content

Commit

Permalink
Replace some of ZFSListMapping -> ZFSListPaths
Browse files Browse the repository at this point in the history
  • Loading branch information
dsh2dsh committed Nov 23, 2024
1 parent 9dd0f4c commit fc61192
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/client/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func doMigratePlaceholder0_1(ctx context.Context, sc *cli.Subcommand, args []str

cfg := sc.Config()

allFSS, err := zfs.ZFSListMapping(ctx, zfs.NoFilter())
allFSS, err := zfs.ZFSListPaths(ctx)
if err != nil {
return fmt.Errorf("cannot list filesystems: %w", err)
}
Expand Down Expand Up @@ -154,7 +154,7 @@ func doMigrateReplicationCursor(ctx context.Context, sc *cli.Subcommand, args []

// scan all filesystems for v1 replication cursors

fss, err := zfs.ZFSListMapping(ctx, zfs.NoFilter())
fss, err := zfs.ZFSListPaths(ctx)
if err != nil {
return fmt.Errorf("list filesystems: %w", err)
}
Expand Down
17 changes: 17 additions & 0 deletions internal/zfs/zfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,23 @@ func ZFSList(ctx context.Context, properties []string, zfsArgs ...string,
return res, nil
}

func ZFSListPaths(ctx context.Context) ([]*DatasetPath, error) {
paths := []*DatasetPath{}
zfsList := ZFSListIter(ctx, []string{"name"}, nil, "-r", "-t",
"filesystem,volume")
for fields, err := range zfsList {
if err != nil {
return nil, err
}
path, err := NewDatasetPath(fields[0])
if err != nil {
return nil, err
}
paths = append(paths, path)
}
return paths, nil
}

// ZFSListIter executes `zfs list` and returns an iterator with the results.
//
// If notExistHint is not nil and zfs exits with an error, the stderr is
Expand Down

0 comments on commit fc61192

Please sign in to comment.