From 7ab51fad0d9c7b3538f56805dc8ccf2c9ae4b053 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Fri, 16 Nov 2018 11:12:29 +0100 Subject: [PATCH] zfs: add 'received' property source, handle 'any' source correctly and use 'any' for placeholder FS detection we want was first noticed in zfs 0.8rc1 Upstream doc PR: https://github.com/zfsonlinux/zfs/pull/8134 --- zfs/diff.go | 2 +- zfs/zfs.go | 5 ++++- zfs/zfs_test.go | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/zfs/diff.go b/zfs/diff.go index 31886e3..2b37f6d 100644 --- a/zfs/diff.go +++ b/zfs/diff.go @@ -248,7 +248,7 @@ func IsPlaceholder(p *DatasetPath, placeholderPropertyValue string) (isPlacehold // for nonexistent FS, isPlaceholder == false && err == nil func ZFSIsPlaceholderFilesystem(p *DatasetPath) (isPlaceholder bool, err error) { - props, err := zfsGet(p.ToString(), []string{ZREPL_PLACEHOLDER_PROPERTY_NAME}, sourceLocal) + props, err := zfsGet(p.ToString(), []string{ZREPL_PLACEHOLDER_PROPERTY_NAME}, sourceAny) if err == io.ErrUnexpectedEOF { // interpret this as an early exit of the zfs binary due to the fs not existing return false, nil diff --git a/zfs/zfs.go b/zfs/zfs.go index 40a0ea8..56c9c77 100644 --- a/zfs/zfs.go +++ b/zfs/zfs.go @@ -601,17 +601,20 @@ const ( sourceInherited sourceNone sourceTemporary + sourceReceived sourceAny zfsPropertySource = ^zfsPropertySource(0) ) func (s zfsPropertySource) zfsGetSourceFieldPrefixes() []string { - prefixes := make([]string, 0, 5) + prefixes := make([]string, 0, 7) if s&sourceLocal != 0 {prefixes = append(prefixes, "local")} if s&sourceDefault != 0 {prefixes = append(prefixes, "default")} if s&sourceInherited != 0 {prefixes = append(prefixes, "inherited")} if s&sourceNone != 0 {prefixes = append(prefixes, "-")} if s&sourceTemporary != 0 { prefixes = append(prefixes, "temporary")} + if s&sourceReceived != 0 { prefixes = append(prefixes, "received")} + if s == sourceAny { prefixes = append(prefixes, "") } return prefixes } diff --git a/zfs/zfs_test.go b/zfs/zfs_test.go index cc0f4c6..6ffdfdf 100644 --- a/zfs/zfs_test.go +++ b/zfs/zfs_test.go @@ -39,7 +39,8 @@ func TestZFSPropertySource(t *testing.T) { }{ { in: sourceAny, - exp: []string{"local", "default", "inherited", "-", "temporary"}, + // although empty prefix matches any source + exp: []string{"local", "default", "inherited", "-", "temporary", "received", ""}, }, { in: sourceTemporary,