| 1 | package btrfsscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.12 fmt/" |
| 5 | "ioscip-go gomod github.com/golang/go/src go1.12 io/" |
| 6 | "osscip-go gomod github.com/golang/go/src go1.12 os/" |
| 7 | "path/filepathscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/" |
| 8 | "unsafescip-go gomod github.com/golang/go/src go1.12 unsafe/" |
| 9 | ) |
| 10 | |
| 11 | func Sendscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/Send().(w ioscip-go gomod github.com/golang/go/src go1.12 io/.Writerscip-go gomod github.com/golang/go/src go1.12 io/Writer#, parent string, subvols ...string) error { |
| 12 | if len(subvols) == 0 { |
| 13 | return nil |
| 14 | } |
| 15 | // use first send subvol to determine mount_root |
| 16 | subvol, err := filepathscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/.Absscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/Abs().(subvols[0]) |
| 17 | if err != nil { |
| 18 | return err |
| 19 | } |
| 20 | mountRoot, err := findMountRootscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/findMountRoot().(subvol) |
| 21 | if err == osscip-go gomod github.com/golang/go/src go1.12 os/.ErrNotExistscip-go gomod github.com/golang/go/src go1.12 os/ErrNotExist. { |
| 22 | return fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.12 fmt/Errorf().("cannot find a mountpoint for %s", subvol) |
| 23 | } else if err != nil { |
| 24 | return err |
| 25 | } |
| 26 | var ( |
| 27 | cloneSrc []objectIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/objectID# |
| 28 | parentID objectIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/objectID# |
| 29 | ) |
| 30 | if parent != "" { |
| 31 | parent, err = filepathscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/.Absscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/Abs().(parent) |
| 32 | if err != nil { |
| 33 | return err |
| 34 | } |
| 35 | id, err := getPathRootIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/getPathRootID().(parent) |
| 36 | if err != nil { |
| 37 | return fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.12 fmt/Errorf().("cannot get parent root id: %v", err) |
| 38 | } |
| 39 | parentID = id |
| 40 | cloneSrc = append(cloneSrc, id) |
| 41 | } |
| 42 | // check all subvolumes |
| 43 | paths := make([]string, 0, len(subvols)) |
| 44 | for _, sub := range subvols { |
| 45 | sub, err = filepathscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/.Absscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/Abs().(sub) |
| 46 | if err != nil { |
| 47 | return err |
| 48 | } |
| 49 | paths = append(paths, sub) |
| 50 | mount, err := findMountRootscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/findMountRoot().(sub) |
| 51 | if err != nil { |
| 52 | return fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.12 fmt/Errorf().("cannot find mount root for %v: %v", sub, err) |
| 53 | } else if mount != mountRoot { |
| 54 | return fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.12 fmt/Errorf().("all subvolumes must be from the same filesystem (%s is not)", sub) |
| 55 | } |
| 56 | ok, err := IsReadOnlyscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/IsReadOnly().(sub) |
| 57 | if err != nil { |
| 58 | return err |
| 59 | } else if !ok { |
| 60 | return fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.12 fmt/Errorf().("subvolume %s is not read-only", sub) |
| 61 | } |
| 62 | } |
| 63 | mfs, err := Openscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/Open().(mountRoot, true) |
| 64 | if err != nil { |
| 65 | return err |
| 66 | } |
| 67 | defer mfs.Closescip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/FS#Close().() |
| 68 | full := len(cloneSrc) == 0 |
| 69 | for i, sub := range paths { |
| 70 | var rootID objectIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/objectID# |
| 71 | if !full && parent != "" { |
| 72 | rel, err := filepathscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/.Relscip-go gomod github.com/golang/go/src go1.12 `path/filepath`/Rel().(mountRoot, sub) |
| 73 | if err != nil { |
| 74 | return err |
| 75 | } |
| 76 | si, err := subvolSearchByPathscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/subvolSearchByPath().(mfs.fscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/FS#f., rel) |
| 77 | if err != nil { |
| 78 | return fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.12 fmt/Errorf().("cannot find subvolume %s: %v", rel, err) |
| 79 | } |
| 80 | rootID = objectIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/objectID#(si.RootIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/SubvolInfo#RootID.) |
| 81 | parentID, err = findGoodParentscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/findGoodParent().(mfs.fscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/FS#f., rootID, cloneSrc) |
| 82 | if err != nil { |
| 83 | return fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.12 fmt/Errorf().("cannot find good parent for %v: %v", rel, err) |
| 84 | } |
| 85 | } |
| 86 | fs, err := Openscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/Open().(sub, true) |
| 87 | if err != nil { |
| 88 | return err |
| 89 | } |
| 90 | var flags uint64 |
| 91 | if i != 0 { // not first |
| 92 | flags |= _BTRFS_SEND_FLAG_OMIT_STREAM_HEADERscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/_BTRFS_SEND_FLAG_OMIT_STREAM_HEADER. |
| 93 | } |
| 94 | if i < len(paths)-1 { // not last |
| 95 | flags |= _BTRFS_SEND_FLAG_OMIT_END_CMDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/_BTRFS_SEND_FLAG_OMIT_END_CMD. |
| 96 | } |
| 97 | err = sendscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/send().(w, fs.fscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/FS#f., parentID, cloneSrc, flags) |
| 98 | fs.Closescip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/FS#Close().() |
| 99 | if err != nil { |
| 100 | return fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.12 fmt/Errorf().("error sending %s: %v", sub, err) |
| 101 | } |
| 102 | if !full && parent != "" { |
| 103 | cloneSrc = append(cloneSrc, rootID) |
| 104 | } |
| 105 | } |
| 106 | return nil |
| 107 | } |
| 108 | |
| 109 | func sendscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/send().(w ioscip-go gomod github.com/golang/go/src go1.12 io/.Writerscip-go gomod github.com/golang/go/src go1.12 io/Writer#, subvol *osscip-go gomod github.com/golang/go/src go1.12 os/.Filescip-go gomod github.com/golang/go/src go1.12 os/File#, parent objectIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/objectID#, sources []objectIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/objectID#, flags uint64) error { |
| 110 | pr, pw, err := osscip-go gomod github.com/golang/go/src go1.12 os/.Pipescip-go gomod github.com/golang/go/src go1.12 os/Pipe().() |
| 111 | if err != nil { |
| 112 | return err |
| 113 | } |
| 114 | errc := make(chan error, 1) |
| 115 | go func() { |
| 116 | defer pr.Closescip-go gomod github.com/golang/go/src go1.12 os/File#Close().() |
| 117 | _, err := ioscip-go gomod github.com/golang/go/src go1.12 io/.Copyscip-go gomod github.com/golang/go/src go1.12 io/Copy().(w, pr) |
| 118 | errc <- err |
| 119 | }() |
| 120 | fd := pw.Fdscip-go gomod github.com/golang/go/src go1.12 os/File#Fd().() |
| 121 | wait := func() error { |
| 122 | pw.Closescip-go gomod github.com/golang/go/src go1.12 os/File#Close().() |
| 123 | return <-errc |
| 124 | } |
| 125 | args := &btrfs_ioctl_send_argsscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_send_args#{ |
| 126 | send_fdscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_send_args#send_fd.: int64(fd), |
| 127 | parent_rootscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_send_args#parent_root.: parent, |
| 128 | flagsscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_send_args#flags.: flags, |
| 129 | } |
| 130 | if len(sources) != 0 { |
| 131 | args.clone_sourcesscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_send_args#clone_sources. = &sources[0] |
| 132 | args.clone_sources_countscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_send_args#clone_sources_count. = uint64(len(sources)) |
| 133 | } |
| 134 | if err := iocSendscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/iocSend().(subvol, args); err != nil { |
| 135 | wait() |
| 136 | return err |
| 137 | } |
| 138 | return wait() |
| 139 | } |
| 140 | |
| 141 | // readRootItem reads a root item from the tree. |
| 142 | // |
| 143 | // TODO(dennwc): support older kernels: |
| 144 | // In case we detect a root item smaller then sizeof(root_item), |
| 145 | // we know it's an old version of the root structure and initialize all new fields to zero. |
| 146 | // The same happens if we detect mismatching generation numbers as then we know the root was |
| 147 | // once mounted with an older kernel that was not aware of the root item structure change. |
| 148 | func readRootItemscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/readRootItem().(mnt *osscip-go gomod github.com/golang/go/src go1.12 os/.Filescip-go gomod github.com/golang/go/src go1.12 os/File#, rootID objectIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/objectID#) (*rootItemscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/rootItem#, error) { |
| 149 | sk := btrfs_ioctl_search_keyscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_search_key#{ |
| 150 | tree_idscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_search_key#tree_id.: rootTreeObjectidscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/rootTreeObjectid., |
| 151 | // There may be more than one ROOT_ITEM key if there are |
| 152 | // snapshots pending deletion, we have to loop through them. |
| 153 | min_objectidscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_search_key#min_objectid.: rootID, |
| 154 | max_objectidscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_search_key#max_objectid.: rootID, |
| 155 | min_typescip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_search_key#min_type.: rootItemKeyscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/rootItemKey., |
| 156 | max_typescip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_search_key#max_type.: rootItemKeyscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/rootItemKey., |
| 157 | max_offsetscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_search_key#max_offset.: maxUint64scip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/maxUint64., |
| 158 | max_transidscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_search_key#max_transid.: maxUint64scip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/maxUint64., |
| 159 | nr_itemsscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_search_key#nr_items.: 4096, |
| 160 | } |
| 161 | for ; sk.min_offsetscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_search_key#min_offset. < maxUint64scip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/maxUint64.; sk.min_offsetscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_search_key#min_offset.++ { |
| 162 | results, err := treeSearchRawscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/treeSearchRaw().(mnt, sk) |
| 163 | if err != nil { |
| 164 | return nil, err |
| 165 | } else if len(results) == 0 { |
| 166 | break |
| 167 | } |
| 168 | for _, r := range results { |
| 169 | sk.min_objectidscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_search_key#min_objectid. = r.ObjectIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/searchResult#ObjectID. |
| 170 | sk.min_typescip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_search_key#min_type. = r.Typescip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/searchResult#Type. |
| 171 | sk.min_offsetscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_search_key#min_offset. = r.Offsetscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/searchResult#Offset. |
| 172 | if r.ObjectIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/searchResult#ObjectID. > rootID { |
| 173 | break |
| 174 | } |
| 175 | if r.ObjectIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/searchResult#ObjectID. == rootID && r.Typescip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/searchResult#Type. == rootItemKeyscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/rootItemKey. { |
| 176 | const sz = int(unsafescip-go gomod github.com/golang/go/src go1.12 unsafe/.Sizeof(btrfs_root_item_rawscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_root_item_raw#{})) |
| 177 | if len(r.Datascip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/searchResult#Data.) > sz { |
| 178 | return nil, fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.12 fmt/Errorf().("btrfs_root_item is larger than expected; kernel is newer than the library") |
| 179 | } else if len(r.Datascip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/searchResult#Data.) < sz { // TODO |
| 180 | return nil, fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.12 fmt/Errorf().("btrfs_root_item is smaller then expected; kernel version is too old") |
| 181 | } |
| 182 | p := asRootItemscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/asRootItem().(r.Datascip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/searchResult#Data.).Decodescip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_root_item_raw#Decode().() |
| 183 | return &p, nil |
| 184 | } |
| 185 | } |
| 186 | results = nil |
| 187 | if sk.min_typescip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_search_key#min_type. != rootItemKeyscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/rootItemKey. || sk.min_objectidscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/btrfs_ioctl_search_key#min_objectid. != rootID { |
| 188 | break |
| 189 | } |
| 190 | } |
| 191 | return nil, ErrNotFoundscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/ErrNotFound. |
| 192 | } |
| 193 | |
| 194 | func getParentscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/getParent().(mnt *osscip-go gomod github.com/golang/go/src go1.12 os/.Filescip-go gomod github.com/golang/go/src go1.12 os/File#, rootID objectIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/objectID#) (*SubvolInfoscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/SubvolInfo#, error) { |
| 195 | st, err := subvolSearchByRootIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/subvolSearchByRootID().(mnt, rootID, "") |
| 196 | if err != nil { |
| 197 | return nil, fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.12 fmt/Errorf().("cannot find subvolume %d to determine parent: %v", rootID, err) |
| 198 | } |
| 199 | return subvolSearchByUUIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/subvolSearchByUUID().(mnt, st.ParentUUIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/SubvolInfo#ParentUUID.) |
| 200 | } |
| 201 | |
| 202 | func findGoodParentscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/findGoodParent().(mnt *osscip-go gomod github.com/golang/go/src go1.12 os/.Filescip-go gomod github.com/golang/go/src go1.12 os/File#, rootID objectIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/objectID#, cloneSrc []objectIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/objectID#) (objectIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/objectID#, error) { |
| 203 | parent, err := getParentscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/getParent().(mnt, rootID) |
| 204 | if err != nil { |
| 205 | return 0, fmtscip-go gomod github.com/golang/go/src go1.12 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.12 fmt/Errorf().("get parent failed: %v", err) |
| 206 | } |
| 207 | for _, id := range cloneSrc { |
| 208 | if id == objectIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/objectID#(parent.RootIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/SubvolInfo#RootID.) { |
| 209 | return objectIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/objectID#(parent.RootIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/SubvolInfo#RootID.), nil |
| 210 | } |
| 211 | } |
| 212 | var ( |
| 213 | bestParent *SubvolInfoscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/SubvolInfo# |
| 214 | bestDiff uint64 = maxUint64scip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/maxUint64. |
| 215 | ) |
| 216 | for _, id := range cloneSrc { |
| 217 | parent2, err := getParentscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/getParent().(mnt, id) |
| 218 | if err == ErrNotFoundscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/ErrNotFound. { |
| 219 | continue |
| 220 | } else if err != nil { |
| 221 | return 0, err |
| 222 | } |
| 223 | if parent2.RootIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/SubvolInfo#RootID. != parent.RootIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/SubvolInfo#RootID. { |
| 224 | continue |
| 225 | } |
| 226 | parent2, err = subvolSearchByRootIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/subvolSearchByRootID().(mnt, id, "") |
| 227 | if err != nil { |
| 228 | return 0, err |
| 229 | } |
| 230 | diff := int64(parent2.CTransIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/SubvolInfo#CTransID. - parent.CTransIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/SubvolInfo#CTransID.) |
| 231 | if diff < 0 { |
| 232 | diff = -diff |
| 233 | } |
| 234 | if uint64(diff) < bestDiff { |
| 235 | bestParent, bestDiff = parent2, uint64(diff) |
| 236 | } |
| 237 | } |
| 238 | if bestParent != nil { |
| 239 | return objectIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/objectID#(bestParent.RootIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/SubvolInfo#RootID.), nil |
| 240 | } |
| 241 | if !parent.ParentUUIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/SubvolInfo#ParentUUID..IsZeroscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/UUID#IsZero().() { |
| 242 | return findGoodParentscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/findGoodParent().(mnt, objectIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/objectID#(parent.RootIDscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/SubvolInfo#RootID.), cloneSrc) |
| 243 | } |
| 244 | return 0, ErrNotFoundscip-go gomod github.com/dennwc/btrfs . `github.com/dennwc/btrfs`/ErrNotFound. |
| 245 | } |