Merge pull request #2190 from stevvooe/vendor-update-btrfs

vendor: update btrfs dependency
This commit is contained in:
Michael Crosby 2018-03-06 16:32:48 -05:00 committed by GitHub
commit db1630d0bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 108 additions and 12 deletions

View File

@ -18,7 +18,7 @@ github.com/golang/protobuf 1643683e1b54a9e88ad26d98f81400c8c9d9f4f9
github.com/opencontainers/runtime-spec v1.0.1
github.com/opencontainers/runc a618ab5a0186905949ee463dbb762c3d23e12a80
github.com/sirupsen/logrus v1.0.0
github.com/containerd/btrfs cc52c4dea2ce11a44e6639e561bb5c2af9ada9e3
github.com/containerd/btrfs 2e1aa0ddf94f91fa282b6ed87c23bf0d64911244
github.com/pmezard/go-difflib v1.0.0
github.com/containerd/fifo fbfb6a11ec671efbe94ad1c12c2e98773f19e1e6
github.com/urfave/cli 7bc6a0acffa589f415f88aca16cc1de5ffd66f9c

View File

@ -16,3 +16,23 @@ is missing, please don't hesitate to submit a PR.
Note that due to struct alignment issues, this isn't yet fully native.
Preferrably, this could be resolved, so contributions in this direction are
greatly appreciated.
## Applying License Header to New Files
If you submit a contribution that adds a new file, please add the license
header. You can do so manually or use the `ltag` tool:
```console
$ go get github.com/kunalkushwaha/ltag
$ ltag -t ./license-templates
```
The above will add the appropriate licenses to Go files. New templates will
need to be added if other kinds of files are added. Please consult the
documentation at https://github.com/
# License
The copyright to this repository is held by the The containerd Authors and the
codebase is released under the [Apache 2.0 license](LICENSE).

View File

@ -1,3 +1,18 @@
/*
Copyright The containerd Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package btrfs
import "sort"
@ -7,10 +22,6 @@ import "sort"
#include <btrfs/ioctl.h>
#include "btrfs.h"
// Required because Go has struct casting rules for negative numbers
const __u64 u64_BTRFS_LAST_FREE_OBJECTID = (__u64)BTRFS_LAST_FREE_OBJECTID;
const __u64 negative_one = (__u64)-1;
static char* get_name_btrfs_ioctl_vol_args_v2(struct btrfs_ioctl_vol_args_v2* btrfs_struct) {
return btrfs_struct->name;
}
@ -81,13 +92,13 @@ func SubvolInfo(path string) (info Info, err error) {
}
if info, ok := subvolsByID[id]; ok {
return info, nil
return *info, nil
}
return info, errors.Errorf("%q not found", path)
}
func subvolMap(path string) (map[uint64]Info, error) {
func subvolMap(path string) (map[uint64]*Info, error) {
fp, err := openSubvolDir(path)
if err != nil {
return nil, err
@ -100,11 +111,11 @@ func subvolMap(path string) (map[uint64]Info, error) {
args.key.min_type = C.BTRFS_ROOT_ITEM_KEY
args.key.max_type = C.BTRFS_ROOT_BACKREF_KEY
args.key.min_objectid = C.BTRFS_FS_TREE_OBJECTID
args.key.max_objectid = C.u64_BTRFS_LAST_FREE_OBJECTID
args.key.max_offset = C.negative_one
args.key.max_transid = C.negative_one
args.key.max_objectid = C.BTRFS_LAST_FREE_OBJECTID
args.key.max_offset = ^C.__u64(0)
args.key.max_transid = ^C.__u64(0)
subvolsByID := map[uint64]Info{}
subvolsByID := make(map[uint64]*Info)
for {
args.key.nr_items = 4096
@ -127,6 +138,9 @@ func subvolMap(path string) (map[uint64]Info, error) {
buf = buf[shSize:]
info := subvolsByID[uint64(sh.objectid)]
if info == nil {
info = &Info{}
}
info.ID = uint64(sh.objectid)
if sh._type == C.BTRFS_ROOT_BACKREF_KEY {
@ -233,7 +247,7 @@ func SubvolList(path string) ([]Info, error) {
subvols := make([]Info, 0, len(subvolsByID))
for _, sv := range subvolsByID {
subvols = append(subvols, sv)
subvols = append(subvols, *sv)
}
sort.Sort(infosByID(subvols))

17
vendor/github.com/containerd/btrfs/doc.go generated vendored Normal file
View File

@ -0,0 +1,17 @@
/*
Copyright The containerd Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package btrfs provides bindings for working with btrfs partitions from Go.
package btrfs

View File

@ -1,3 +1,18 @@
/*
Copyright The containerd Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package btrfs
/*

View File

@ -1,3 +1,18 @@
/*
Copyright The containerd Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package btrfs
// Info describes metadata about a btrfs subvolume.

View File

@ -1,3 +1,18 @@
/*
Copyright The containerd Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package btrfs
import "syscall"