From 0f8f050563803de89c7104df31ed1df3a905e43a Mon Sep 17 00:00:00 2001 From: Faruk Kasumovic Date: Fri, 17 Jan 2020 09:57:13 +0100 Subject: [PATCH 1/5] Remove SendOne since it does not make sense in context of this lib --- sendrecv.go | 43 ------------------------------------------- 1 file changed, 43 deletions(-) diff --git a/sendrecv.go b/sendrecv.go index 579142f..e4bcc34 100644 --- a/sendrecv.go +++ b/sendrecv.go @@ -12,7 +12,6 @@ import ( "fmt" "io/ioutil" "os" - "path" "regexp" "strconv" "strings" @@ -128,48 +127,6 @@ func (d *Dataset) send(FromName string, outf *os.File, flags *SendFlags) (err er return } -func (d *Dataset) SendOne(FromName string, outf *os.File, flags *SendFlags) (err error) { - var cfromname, ctoname *C.char - var dpath string - var lzc_send_flags C.struct_sendflags - - if d.Type == DatasetTypeSnapshot || (len(FromName) > 0 && !strings.Contains(FromName, "#")) { - err = fmt.Errorf( - "Unsupported with snapshot. Use func Send() for that purpose.") - return - } - if flags.Replicate || flags.DoAll || flags.Props || flags.Dedup || flags.DryRun { - err = fmt.Errorf("Unsupported flag with filesystem or bookmark.") - return - } - - if flags.LargeBlock { - lzc_send_flags.largeblock = booleanT(true) - } - if flags.EmbedData { - lzc_send_flags.embed_data = booleanT(true) - } - // if (flags.Compress) - // lzc_send_flags |= LZC_SEND_FLAG_COMPRESS; - if dpath, err = d.Path(); err != nil { - return - } - if len(FromName) > 0 { - if FromName[0] == '#' || FromName[0] == '@' { - FromName = dpath + FromName - } - cfromname = C.CString(FromName) - defer C.free(unsafe.Pointer(cfromname)) - } - ctoname = C.CString(path.Base(dpath)) - defer C.free(unsafe.Pointer(ctoname)) - cerr := C.zfs_send_one(d.list.zh, cfromname, C.int(outf.Fd()), &lzc_send_flags, nil) - if cerr != 0 { - err = LastError() - } - return -} - func (d *Dataset) SendResume(outf *os.File, flags *SendFlags, receiveResumeToken string) (err error) { if d.Type != DatasetTypeSnapshot { err = fmt.Errorf("Unsupported method on filesystem or bookmark. Use func SendOne() for that purpose.") From ac0486e24f966077e7453a54d7bea03857419a84 Mon Sep 17 00:00:00 2001 From: Asmir Selimovic <40600512+aslmvc@users.noreply.github.com> Date: Fri, 18 Oct 2019 14:46:24 +0200 Subject: [PATCH 2/5] - Return after failing in SetProperty (#21) --- zfs.go | 1 + 1 file changed, 1 insertion(+) diff --git a/zfs.go b/zfs.go index 0dfc44c..af3f32d 100644 --- a/zfs.go +++ b/zfs.go @@ -385,6 +385,7 @@ func (d *Dataset) SetProperty(p Prop, value string) (err error) { C.free(unsafe.Pointer(csValue)) if errcode != 0 { err = LastError() + return } // Update Properties member with change made if _, err = d.GetProperty(p); err != nil { From c346b62190c59a4dbb5d0390c3eb7f9c04b6f6da Mon Sep 17 00:00:00 2001 From: Asmir Selimovic Date: Tue, 10 Dec 2019 15:37:02 +0100 Subject: [PATCH 3/5] - Option to resume interrupted send --- sendrecv.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/sendrecv.go b/sendrecv.go index e4bcc34..13d0000 100644 --- a/sendrecv.go +++ b/sendrecv.go @@ -160,6 +160,40 @@ func (d *Dataset) SendResume(outf *os.File, flags *SendFlags, receiveResumeToken return } +func (d *Dataset) SendResume(outf *os.File, flags *SendFlags, receiveResumeToken string) (err error) { + if d.Type != DatasetTypeSnapshot { + err = fmt.Errorf("Unsupported method on filesystem or bookmark. Use func SendOne() for that purpose.") + return + } + + var dpath string + var pd Dataset + + cflags := to_sendflags_t(flags) + defer C.free(unsafe.Pointer(cflags)) + if dpath, err = d.Path(); err != nil { + return + } + sendparams := strings.Split(dpath, "@") + parent := sendparams[0] + + if pd, err = DatasetOpen(parent); err != nil { + return + } + defer pd.Close() + + cReceiveResumeToken := C.CString(receiveResumeToken) + defer C.free(unsafe.Pointer(cReceiveResumeToken)) + + clerr := C.zfs_send_resume(C.libzfsHandle, cflags, C.int(outf.Fd()), cReceiveResumeToken) + if clerr != 0 { + err = LastError() + fmt.Println(err.Error()) + } + + return +} + func (d *Dataset) Send(outf *os.File, flags SendFlags) (err error) { if flags.Replicate { flags.DoAll = true From ed6aa6ccd01c0ce62602023e94ad27c42b574452 Mon Sep 17 00:00:00 2001 From: Faruk Kasumovic Date: Wed, 15 Jan 2020 15:40:16 +0100 Subject: [PATCH 4/5] Remove fmt.Println call from SendResume --- sendrecv.go | 1 - 1 file changed, 1 deletion(-) diff --git a/sendrecv.go b/sendrecv.go index 13d0000..afff3ba 100644 --- a/sendrecv.go +++ b/sendrecv.go @@ -188,7 +188,6 @@ func (d *Dataset) SendResume(outf *os.File, flags *SendFlags, receiveResumeToken clerr := C.zfs_send_resume(C.libzfsHandle, cflags, C.int(outf.Fd()), cReceiveResumeToken) if clerr != 0 { err = LastError() - fmt.Println(err.Error()) } return From 5ffd9a792408e5d4346112251a05ece025aa9228 Mon Sep 17 00:00:00 2001 From: Faruk Kasumovic Date: Fri, 17 Jan 2020 09:57:13 +0100 Subject: [PATCH 5/5] Remove SendOne since it does not make sense in context of this lib --- sendrecv.go | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/sendrecv.go b/sendrecv.go index afff3ba..e4bcc34 100644 --- a/sendrecv.go +++ b/sendrecv.go @@ -160,39 +160,6 @@ func (d *Dataset) SendResume(outf *os.File, flags *SendFlags, receiveResumeToken return } -func (d *Dataset) SendResume(outf *os.File, flags *SendFlags, receiveResumeToken string) (err error) { - if d.Type != DatasetTypeSnapshot { - err = fmt.Errorf("Unsupported method on filesystem or bookmark. Use func SendOne() for that purpose.") - return - } - - var dpath string - var pd Dataset - - cflags := to_sendflags_t(flags) - defer C.free(unsafe.Pointer(cflags)) - if dpath, err = d.Path(); err != nil { - return - } - sendparams := strings.Split(dpath, "@") - parent := sendparams[0] - - if pd, err = DatasetOpen(parent); err != nil { - return - } - defer pd.Close() - - cReceiveResumeToken := C.CString(receiveResumeToken) - defer C.free(unsafe.Pointer(cReceiveResumeToken)) - - clerr := C.zfs_send_resume(C.libzfsHandle, cflags, C.int(outf.Fd()), cReceiveResumeToken) - if clerr != 0 { - err = LastError() - } - - return -} - func (d *Dataset) Send(outf *os.File, flags SendFlags) (err error) { if flags.Replicate { flags.DoAll = true