Skip to content

Commit 39048cf

Browse files
committed
Really switch to moby/sys/mount*
Switch to moby/sys/mount and mountinfo. Keep the pkg/mount for potential outside users. This commit was generated by the following bash script: ``` set -e -u -o pipefail for file in $(git grep -l 'docker/docker/pkg/mount"' | grep -v ^pkg/mount); do sed -i -e 's#/docker/docker/pkg/mount"#/moby/sys/mount"#' \ -e 's#mount\.\(GetMounts\|Mounted\|Info\|[A-Za-z]*Filter\)#mountinfo.\1#g' \ $file goimports -w $file done ``` Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 59c0495 commit 39048cf

36 files changed

Lines changed: 61 additions & 53 deletions

container/container_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import (
1313
containertypes "github.com/docker/docker/api/types/container"
1414
mounttypes "github.com/docker/docker/api/types/mount"
1515
swarmtypes "github.com/docker/docker/api/types/swarm"
16-
"github.com/docker/docker/pkg/mount"
1716
"github.com/docker/docker/pkg/stringid"
1817
"github.com/docker/docker/volume"
1918
volumemounts "github.com/docker/docker/volume/mounts"
19+
"github.com/moby/sys/mount"
2020
"github.com/opencontainers/selinux/go-selinux/label"
2121
"github.com/pkg/errors"
2222
"github.com/sirupsen/logrus"

daemon/container_operations_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import (
1515
"github.com/docker/docker/daemon/links"
1616
"github.com/docker/docker/errdefs"
1717
"github.com/docker/docker/pkg/idtools"
18-
"github.com/docker/docker/pkg/mount"
1918
"github.com/docker/docker/pkg/stringid"
2019
"github.com/docker/docker/runconfig"
2120
"github.com/docker/libnetwork"
21+
"github.com/moby/sys/mount"
2222
"github.com/opencontainers/selinux/go-selinux/label"
2323
"github.com/pkg/errors"
2424
"github.com/sirupsen/logrus"

daemon/daemon_linux.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import (
99
"strings"
1010

1111
"github.com/docker/docker/daemon/config"
12-
"github.com/docker/docker/pkg/mount"
1312
"github.com/docker/libnetwork/resolvconf"
13+
"github.com/moby/sys/mount"
14+
"github.com/moby/sys/mountinfo"
1415
"github.com/pkg/errors"
1516
"github.com/sirupsen/logrus"
1617
)
@@ -75,7 +76,7 @@ func (daemon *Daemon) cleanupMounts() error {
7576
return err
7677
}
7778

78-
info, err := mount.GetMounts(mount.SingleEntryFilter(daemon.root))
79+
info, err := mountinfo.GetMounts(mountinfo.SingleEntryFilter(daemon.root))
7980
if err != nil {
8081
return errors.Wrap(err, "error reading mount table for cleanup")
8182
}
@@ -122,7 +123,7 @@ func getCleanPatterns(id string) (regexps []*regexp.Regexp) {
122123
return
123124
}
124125

125-
func shouldUnmountRoot(root string, info *mount.Info) bool {
126+
func shouldUnmountRoot(root string, info *mountinfo.Info) bool {
126127
if !strings.HasSuffix(root, info.Root) {
127128
return false
128129
}

daemon/daemon_linux_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import (
1111

1212
containertypes "github.com/docker/docker/api/types/container"
1313
"github.com/docker/docker/daemon/config"
14-
"github.com/docker/docker/pkg/mount"
14+
"github.com/moby/sys/mount"
15+
"github.com/moby/sys/mountinfo"
1516
"gotest.tools/v3/assert"
1617
is "gotest.tools/v3/assert/cmp"
1718
)
@@ -123,25 +124,25 @@ func TestShouldUnmountRoot(t *testing.T) {
123124
for _, test := range []struct {
124125
desc string
125126
root string
126-
info *mount.Info
127+
info *mountinfo.Info
127128
expect bool
128129
}{
129130
{
130131
desc: "root is at /",
131132
root: "/docker",
132-
info: &mount.Info{Root: "/docker", Mountpoint: "/docker"},
133+
info: &mountinfo.Info{Root: "/docker", Mountpoint: "/docker"},
133134
expect: true,
134135
},
135136
{
136137
desc: "root is at in a submount from `/`",
137138
root: "/foo/docker",
138-
info: &mount.Info{Root: "/docker", Mountpoint: "/foo/docker"},
139+
info: &mountinfo.Info{Root: "/docker", Mountpoint: "/foo/docker"},
139140
expect: true,
140141
},
141142
{
142143
desc: "root is mounted in from a parent mount namespace same root dir", // dind is an example of this
143144
root: "/docker",
144-
info: &mount.Info{Root: "/docker/volumes/1234657/_data", Mountpoint: "/docker"},
145+
info: &mountinfo.Info{Root: "/docker/volumes/1234657/_data", Mountpoint: "/docker"},
145146
expect: false,
146147
},
147148
} {
@@ -172,7 +173,7 @@ func TestShouldUnmountRoot(t *testing.T) {
172173

173174
func checkMounted(t *testing.T, p string, expect bool) {
174175
t.Helper()
175-
mounted, err := mount.Mounted(p)
176+
mounted, err := mountinfo.Mounted(p)
176177
assert.Check(t, err)
177178
assert.Check(t, mounted == expect, "expected %v, actual %v", expect, mounted)
178179
}

daemon/daemon_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"github.com/docker/docker/pkg/containerfs"
3030
"github.com/docker/docker/pkg/idtools"
3131
"github.com/docker/docker/pkg/ioutils"
32-
"github.com/docker/docker/pkg/mount"
3332
"github.com/docker/docker/pkg/parsers"
3433
"github.com/docker/docker/pkg/parsers/kernel"
3534
"github.com/docker/docker/pkg/sysinfo"
@@ -42,6 +41,7 @@ import (
4241
"github.com/docker/libnetwork/netutils"
4342
"github.com/docker/libnetwork/options"
4443
lntypes "github.com/docker/libnetwork/types"
44+
"github.com/moby/sys/mount"
4545
"github.com/opencontainers/runc/libcontainer/cgroups"
4646
rsystem "github.com/opencontainers/runc/libcontainer/system"
4747
specs "github.com/opencontainers/runtime-spec/specs-go"

daemon/graphdriver/aufs/aufs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ import (
4242
"github.com/docker/docker/pkg/directory"
4343
"github.com/docker/docker/pkg/idtools"
4444
"github.com/docker/docker/pkg/locker"
45-
"github.com/docker/docker/pkg/mount"
4645
"github.com/docker/docker/pkg/system"
46+
"github.com/moby/sys/mount"
4747
rsystem "github.com/opencontainers/runc/libcontainer/system"
4848
"github.com/opencontainers/selinux/go-selinux/label"
4949
"github.com/pkg/errors"

daemon/graphdriver/aufs/mount.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"syscall"
88
"time"
99

10-
"github.com/docker/docker/pkg/mount"
10+
"github.com/moby/sys/mount"
1111
"github.com/pkg/errors"
1212
"golang.org/x/sys/unix"
1313
)

daemon/graphdriver/btrfs/btrfs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ import (
2929
"github.com/docker/docker/daemon/graphdriver"
3030
"github.com/docker/docker/pkg/containerfs"
3131
"github.com/docker/docker/pkg/idtools"
32-
"github.com/docker/docker/pkg/mount"
3332
"github.com/docker/docker/pkg/parsers"
3433
"github.com/docker/docker/pkg/system"
3534
units "github.com/docker/go-units"
35+
"github.com/moby/sys/mount"
3636
"github.com/opencontainers/selinux/go-selinux/label"
3737
"github.com/pkg/errors"
3838
"github.com/sirupsen/logrus"

daemon/graphdriver/devmapper/deviceset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ import (
2424
"github.com/docker/docker/pkg/dmesg"
2525
"github.com/docker/docker/pkg/idtools"
2626
"github.com/docker/docker/pkg/loopback"
27-
"github.com/docker/docker/pkg/mount"
2827
"github.com/docker/docker/pkg/parsers"
2928
"github.com/docker/docker/pkg/parsers/kernel"
3029
units "github.com/docker/go-units"
30+
"github.com/moby/sys/mount"
3131
"github.com/opencontainers/selinux/go-selinux/label"
3232
"github.com/pkg/errors"
3333
"github.com/sirupsen/logrus"

daemon/graphdriver/devmapper/driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
"github.com/docker/docker/pkg/devicemapper"
1515
"github.com/docker/docker/pkg/idtools"
1616
"github.com/docker/docker/pkg/locker"
17-
"github.com/docker/docker/pkg/mount"
1817
units "github.com/docker/go-units"
18+
"github.com/moby/sys/mount"
1919
"github.com/sirupsen/logrus"
2020
"golang.org/x/sys/unix"
2121
)

0 commit comments

Comments
 (0)