vendor: update btrfs dependency

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day
2018-03-06 13:16:56 -08:00
parent d086e56255
commit 23751c9ced
7 changed files with 108 additions and 12 deletions

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"