diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index 389527e..9813f8b 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -380,6 +380,15 @@ func (s *Receiver) Receive(ctx context.Context, req *pdu.ReceiveReq, receive zfs } if !ph.FSExists { + if s.rootWithoutClientComponent.HasPrefix(v.Path) { + if v.Path.Length() == 1 { + visitErr = fmt.Errorf("pool %q not imported", v.Path.ToString()) + } else { + visitErr = fmt.Errorf("root_fs %q does not exist", s.rootWithoutClientComponent.ToString()) + } + getLogger(ctx).WithError(visitErr).Error("placeholders are only created automatically below root_fs") + return false + } l := getLogger(ctx).WithField("placeholder_fs", v.Path) l.Debug("create placeholder filesystem") err := zfs.ZFSCreatePlaceholderFilesystem(v.Path) diff --git a/zfs/placeholder.go b/zfs/placeholder.go index 10caa17..1fc95f1 100644 --- a/zfs/placeholder.go +++ b/zfs/placeholder.go @@ -78,6 +78,9 @@ func ZFSGetFilesystemPlaceholderState(p *DatasetPath) (state *FilesystemPlacehol } func ZFSCreatePlaceholderFilesystem(p *DatasetPath) (err error) { + if p.Length() == 1 { + return fmt.Errorf("cannot create %q: pools cannot be created with zfs create", p.ToString()) + } cmd := exec.Command(ZFS_BINARY, "create", "-o", fmt.Sprintf("%s=%s", PlaceholderPropertyName, placeholderPropertyOn), "-o", "mountpoint=none",