diff options
| author | Cory Snider <csnider@mirantis.com> | 2022-09-23 14:09:51 -0400 |
|---|---|---|
| committer | Cory Snider <csnider@mirantis.com> | 2022-09-23 16:56:52 -0400 |
| commit | e332c41e9d29954c78f927ae6b4e884fcb683cdd (patch) | |
| tree | 5cdedd2e9fb7bb4d1a141679be054407994a1027 /daemon/graphdriver | |
| parent | 95824f2b5f44cd90096c865b093ed9a68342377a (diff) | |
| download | docker-e332c41e9d29954c78f927ae6b4e884fcb683cdd.tar.gz | |
pkg/containerfs: alias ContainerFS to string
Drop the constructor and redundant string() type-casts.
Signed-off-by: Cory Snider <csnider@mirantis.com>
Diffstat (limited to 'daemon/graphdriver')
| -rw-r--r-- | daemon/graphdriver/aufs/aufs.go | 4 | ||||
| -rw-r--r-- | daemon/graphdriver/aufs/aufs_test.go | 32 | ||||
| -rw-r--r-- | daemon/graphdriver/btrfs/btrfs.go | 2 | ||||
| -rw-r--r-- | daemon/graphdriver/btrfs/btrfs_test.go | 4 | ||||
| -rw-r--r-- | daemon/graphdriver/devmapper/driver.go | 4 | ||||
| -rw-r--r-- | daemon/graphdriver/fsdiff.go | 16 | ||||
| -rw-r--r-- | daemon/graphdriver/fuse-overlayfs/fuseoverlayfs.go | 6 | ||||
| -rw-r--r-- | daemon/graphdriver/graphtest/graphbench_unix.go | 2 | ||||
| -rw-r--r-- | daemon/graphdriver/graphtest/graphtest_unix.go | 12 | ||||
| -rw-r--r-- | daemon/graphdriver/graphtest/testutil.go | 40 | ||||
| -rw-r--r-- | daemon/graphdriver/graphtest/testutil_unix.go | 10 | ||||
| -rw-r--r-- | daemon/graphdriver/overlay/overlay.go | 6 | ||||
| -rw-r--r-- | daemon/graphdriver/overlay2/overlay.go | 6 | ||||
| -rw-r--r-- | daemon/graphdriver/proxy.go | 2 | ||||
| -rw-r--r-- | daemon/graphdriver/vfs/driver.go | 4 | ||||
| -rw-r--r-- | daemon/graphdriver/windows/windows.go | 6 | ||||
| -rw-r--r-- | daemon/graphdriver/zfs/zfs.go | 4 |
17 files changed, 73 insertions, 87 deletions
diff --git a/daemon/graphdriver/aufs/aufs.go b/daemon/graphdriver/aufs/aufs.go index 08ab302bb1..8066549a62 100644 --- a/daemon/graphdriver/aufs/aufs.go +++ b/daemon/graphdriver/aufs/aufs.go @@ -370,7 +370,7 @@ func (a *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) { } } if count := a.ctr.Increment(m); count > 1 { - return containerfs.NewLocalContainerFS(m), nil + return m, nil } // If a dir does not have a parent ( no layers )do not try to mount @@ -384,7 +384,7 @@ func (a *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) { a.pathCacheLock.Lock() a.pathCache[id] = m a.pathCacheLock.Unlock() - return containerfs.NewLocalContainerFS(m), nil + return m, nil } // Put unmounts and updates list of active mounts. diff --git a/daemon/graphdriver/aufs/aufs_test.go b/daemon/graphdriver/aufs/aufs_test.go index 05c2ed778d..26142acfc5 100644 --- a/daemon/graphdriver/aufs/aufs_test.go +++ b/daemon/graphdriver/aufs/aufs_test.go @@ -43,14 +43,6 @@ func testInit(dir string, t testing.TB) graphdriver.Driver { return d } -func driverGet(d *Driver, id string, mntLabel string) (string, error) { - mnt, err := d.Get(id, mntLabel) - if err != nil { - return "", err - } - return string(mnt), nil -} - func newDriver(t testing.TB) *Driver { if err := os.MkdirAll(tmp, 0755); err != nil { t.Fatal(err) @@ -180,7 +172,7 @@ func TestGetWithoutParent(t *testing.T) { t.Fatal(err) } expected := path.Join(tmp, "diff", "1") - if string(diffPath) != expected { + if diffPath != expected { t.Fatalf("Expected path %s got %s", expected, diffPath) } } @@ -262,8 +254,8 @@ func TestMountWithParent(t *testing.T) { } expected := path.Join(tmp, "mnt", "2") - if string(mntPath) != expected { - t.Fatalf("Expected %s got %s", expected, string(mntPath)) + if mntPath != expected { + t.Fatalf("Expected %s got %s", expected, mntPath) } } @@ -323,7 +315,7 @@ func TestGetDiff(t *testing.T) { t.Fatal(err) } - diffPath, err := driverGet(d, "1", "") + diffPath, err := d.Get("1", "") if err != nil { t.Fatal(err) } @@ -367,7 +359,7 @@ func TestChanges(t *testing.T) { } }() - mntPoint, err := driverGet(d, "2", "") + mntPoint, err := d.Get("2", "") if err != nil { t.Fatal(err) } @@ -406,7 +398,7 @@ func TestChanges(t *testing.T) { if err := d.CreateReadWrite("3", "2", nil); err != nil { t.Fatal(err) } - mntPoint, err = driverGet(d, "3", "") + mntPoint, err = d.Get("3", "") if err != nil { t.Fatal(err) } @@ -452,7 +444,7 @@ func TestDiffSize(t *testing.T) { t.Fatal(err) } - diffPath, err := driverGet(d, "1", "") + diffPath, err := d.Get("1", "") if err != nil { t.Fatal(err) } @@ -494,7 +486,7 @@ func TestChildDiffSize(t *testing.T) { t.Fatal(err) } - diffPath, err := driverGet(d, "1", "") + diffPath, err := d.Get("1", "") if err != nil { t.Fatal(err) } @@ -595,7 +587,7 @@ func TestApplyDiff(t *testing.T) { t.Fatal(err) } - diffPath, err := driverGet(d, "1", "") + diffPath, err := d.Get("1", "") if err != nil { t.Fatal(err) } @@ -630,7 +622,7 @@ func TestApplyDiff(t *testing.T) { // Ensure that the file is in the mount point for id 3 - mountPoint, err := driverGet(d, "3", "") + mountPoint, err := d.Get("3", "") if err != nil { t.Fatal(err) } @@ -673,7 +665,7 @@ func testMountMoreThan42Layers(t *testing.T, mountPath string) { err := d.CreateReadWrite(current, parent, nil) assert.NilError(t, err, "current layer %d", i) - point, err := driverGet(d, current, "") + point, err := d.Get(current, "") assert.NilError(t, err, "current layer %d", i) f, err := os.Create(path.Join(point, current)) @@ -689,7 +681,7 @@ func testMountMoreThan42Layers(t *testing.T, mountPath string) { } // Perform the actual mount for the top most image - point, err := driverGet(d, last, "") + point, err := d.Get(last, "") assert.NilError(t, err) files, err := os.ReadDir(point) assert.NilError(t, err) diff --git a/daemon/graphdriver/btrfs/btrfs.go b/daemon/graphdriver/btrfs/btrfs.go index f0bf1ab54d..8373d921a5 100644 --- a/daemon/graphdriver/btrfs/btrfs.go +++ b/daemon/graphdriver/btrfs/btrfs.go @@ -649,7 +649,7 @@ func (d *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) { } } - return containerfs.NewLocalContainerFS(dir), nil + return dir, nil } // Put is not implemented for BTRFS as there is no cleanup required for the id. diff --git a/daemon/graphdriver/btrfs/btrfs_test.go b/daemon/graphdriver/btrfs/btrfs_test.go index 05d0f48e9c..511f29af7d 100644 --- a/daemon/graphdriver/btrfs/btrfs_test.go +++ b/daemon/graphdriver/btrfs/btrfs_test.go @@ -36,14 +36,12 @@ func TestBtrfsSubvolDelete(t *testing.T) { } defer graphtest.PutDriver(t) - dirFS, err := d.Get("test", "") + dir, err := d.Get("test", "") if err != nil { t.Fatal(err) } defer d.Put("test") - dir := string(dirFS) - if err := subvolCreate(dir, "subvoltest"); err != nil { t.Fatal(err) } diff --git a/daemon/graphdriver/devmapper/driver.go b/daemon/graphdriver/devmapper/driver.go index ec8c20d513..894345e468 100644 --- a/daemon/graphdriver/devmapper/driver.go +++ b/daemon/graphdriver/devmapper/driver.go @@ -181,7 +181,7 @@ func (d *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) { mp := path.Join(d.home, "mnt", id) rootFs := path.Join(mp, "rootfs") if count := d.ctr.Increment(mp); count > 1 { - return containerfs.NewLocalContainerFS(rootFs), nil + return rootFs, nil } root := d.idMap.RootPair() @@ -219,7 +219,7 @@ func (d *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) { } } - return containerfs.NewLocalContainerFS(rootFs), nil + return rootFs, nil } // Put unmounts a device and removes it. diff --git a/daemon/graphdriver/fsdiff.go b/daemon/graphdriver/fsdiff.go index 331d60d392..2a201dc2f5 100644 --- a/daemon/graphdriver/fsdiff.go +++ b/daemon/graphdriver/fsdiff.go @@ -50,7 +50,7 @@ func (gdw *NaiveDiffDriver) Diff(id, parent string) (arch io.ReadCloser, err err if err != nil { return nil, err } - layerFs := string(layerRootFs) + layerFs := layerRootFs defer func() { if err != nil { @@ -70,14 +70,12 @@ func (gdw *NaiveDiffDriver) Diff(id, parent string) (arch io.ReadCloser, err err }), nil } - parentRootFs, err := driver.Get(parent, "") + parentFs, err := driver.Get(parent, "") if err != nil { return nil, err } defer driver.Put(parent) - parentFs := string(parentRootFs) - changes, err := archive.ChangesDirs(layerFs, parentFs) if err != nil { return nil, err @@ -106,22 +104,20 @@ func (gdw *NaiveDiffDriver) Diff(id, parent string) (arch io.ReadCloser, err err func (gdw *NaiveDiffDriver) Changes(id, parent string) ([]archive.Change, error) { driver := gdw.ProtoDriver - layerRootFs, err := driver.Get(id, "") + layerFs, err := driver.Get(id, "") if err != nil { return nil, err } defer driver.Put(id) - layerFs := string(layerRootFs) parentFs := "" if parent != "" { - parentRootFs, err := driver.Get(parent, "") + parentFs, err = driver.Get(parent, "") if err != nil { return nil, err } defer driver.Put(parent) - parentFs = string(parentRootFs) } return archive.ChangesDirs(layerFs, parentFs) @@ -140,7 +136,7 @@ func (gdw *NaiveDiffDriver) ApplyDiff(id, parent string, diff io.Reader) (size i } defer driver.Put(id) - layerFs := string(layerRootFs) + layerFs := layerRootFs options := &archive.TarOptions{IDMap: gdw.idMap} start := time.Now().UTC() logrus.WithField("id", id).Debug("Start untar layer") @@ -169,5 +165,5 @@ func (gdw *NaiveDiffDriver) DiffSize(id, parent string) (size int64, err error) } defer driver.Put(id) - return archive.ChangesSize(string(layerFs), changes), nil + return archive.ChangesSize(layerFs, changes), nil } diff --git a/daemon/graphdriver/fuse-overlayfs/fuseoverlayfs.go b/daemon/graphdriver/fuse-overlayfs/fuseoverlayfs.go index a39d58d327..aa7799e1c9 100644 --- a/daemon/graphdriver/fuse-overlayfs/fuseoverlayfs.go +++ b/daemon/graphdriver/fuse-overlayfs/fuseoverlayfs.go @@ -316,14 +316,14 @@ func (d *Driver) Get(id, mountLabel string) (_ containerfs.ContainerFS, retErr e if err != nil { // If no lower, just return diff directory if os.IsNotExist(err) { - return containerfs.NewLocalContainerFS(diffDir), nil + return diffDir, nil } return "", err } mergedDir := path.Join(dir, mergedDirName) if count := d.ctr.Increment(mergedDir); count > 1 { - return containerfs.NewLocalContainerFS(mergedDir), nil + return mergedDir, nil } defer func() { if retErr != nil { @@ -380,7 +380,7 @@ func (d *Driver) Get(id, mountLabel string) (_ containerfs.ContainerFS, retErr e return "", errors.Wrapf(err, "using mount program %s: %s", binary, output) } - return containerfs.NewLocalContainerFS(mergedDir), nil + return mergedDir, nil } // Put unmounts the mount path created for the give id. diff --git a/daemon/graphdriver/graphtest/graphbench_unix.go b/daemon/graphdriver/graphtest/graphbench_unix.go index 88ca80005a..422c3ec23d 100644 --- a/daemon/graphdriver/graphtest/graphbench_unix.go +++ b/daemon/graphdriver/graphtest/graphbench_unix.go @@ -250,7 +250,7 @@ func DriverBenchDeepLayerRead(b *testing.B, layerCount int, drivername string, d for i := 0; i < b.N; i++ { // Read content - c, err := os.ReadFile(filepath.Join(string(root), "testfile.txt")) + c, err := os.ReadFile(filepath.Join(root, "testfile.txt")) if err != nil { b.Fatal(err) } diff --git a/daemon/graphdriver/graphtest/graphtest_unix.go b/daemon/graphdriver/graphtest/graphtest_unix.go index f8fa88dcc6..b0b93d281d 100644 --- a/daemon/graphdriver/graphtest/graphtest_unix.go +++ b/daemon/graphdriver/graphtest/graphtest_unix.go @@ -96,10 +96,10 @@ func DriverTestCreateEmpty(t testing.TB, drivername string, driverOptions ...str dir, err := driver.Get("empty", "") assert.NilError(t, err) - verifyFile(t, string(dir), 0755|os.ModeDir, 0, 0) + verifyFile(t, dir, 0755|os.ModeDir, 0, 0) // Verify that the directory is empty - fis, err := readDir(string(dir)) + fis, err := readDir(dir) assert.NilError(t, err) assert.Check(t, is.Len(fis, 0)) @@ -324,19 +324,19 @@ func DriverTestSetQuota(t *testing.T, drivername string, required bool) { quota := uint64(50 * units.MiB) // Try to write a file smaller than quota, and ensure it works - err = writeRandomFile(path.Join(string(mountPath), "smallfile"), quota/2) + err = writeRandomFile(path.Join(mountPath, "smallfile"), quota/2) if err != nil { t.Fatal(err) } - defer os.Remove(path.Join(string(mountPath), "smallfile")) + defer os.Remove(path.Join(mountPath, "smallfile")) // Try to write a file bigger than quota. We've already filled up half the quota, so hitting the limit should be easy - err = writeRandomFile(path.Join(string(mountPath), "bigfile"), quota) + err = writeRandomFile(path.Join(mountPath, "bigfile"), quota) if err == nil { t.Fatalf("expected write to fail(), instead had success") } if pathError, ok := err.(*os.PathError); ok && pathError.Err != unix.EDQUOT && pathError.Err != unix.ENOSPC { - os.Remove(path.Join(string(mountPath), "bigfile")) + os.Remove(path.Join(mountPath, "bigfile")) t.Fatalf("expect write() to fail with %v or %v, got %v", unix.EDQUOT, unix.ENOSPC, pathError.Err) } } diff --git a/daemon/graphdriver/graphtest/testutil.go b/daemon/graphdriver/graphtest/testutil.go index 6f02c5645b..20a0da8b31 100644 --- a/daemon/graphdriver/graphtest/testutil.go +++ b/daemon/graphdriver/graphtest/testutil.go @@ -36,17 +36,17 @@ func addFiles(drv graphdriver.Driver, layer string, seed int64) error { } defer drv.Put(layer) - if err := os.WriteFile(filepath.Join(string(root), "file-a"), randomContent(64, seed), 0755); err != nil { + if err := os.WriteFile(filepath.Join(root, "file-a"), randomContent(64, seed), 0755); err != nil { return err } - if err := os.MkdirAll(filepath.Join(string(root), "dir-b"), 0755); err != nil { + if err := os.MkdirAll(filepath.Join(root, "dir-b"), 0755); err != nil { return err } - if err := os.WriteFile(filepath.Join(string(root), "dir-b", "file-b"), randomContent(128, seed+1), 0755); err != nil { + if err := os.WriteFile(filepath.Join(root, "dir-b", "file-b"), randomContent(128, seed+1), 0755); err != nil { return err } - return os.WriteFile(filepath.Join(string(root), "file-c"), randomContent(128*128, seed+2), 0755) + return os.WriteFile(filepath.Join(root, "file-c"), randomContent(128*128, seed+2), 0755) } func checkFile(drv graphdriver.Driver, layer, filename string, content []byte) error { @@ -56,7 +56,7 @@ func checkFile(drv graphdriver.Driver, layer, filename string, content []byte) e } defer drv.Put(layer) - fileContent, err := os.ReadFile(filepath.Join(string(root), filename)) + fileContent, err := os.ReadFile(filepath.Join(root, filename)) if err != nil { return err } @@ -75,7 +75,7 @@ func addFile(drv graphdriver.Driver, layer, filename string, content []byte) err } defer drv.Put(layer) - return os.WriteFile(filepath.Join(string(root), filename), content, 0755) + return os.WriteFile(filepath.Join(root, filename), content, 0755) } func addDirectory(drv graphdriver.Driver, layer, dir string) error { @@ -85,7 +85,7 @@ func addDirectory(drv graphdriver.Driver, layer, dir string) error { } defer drv.Put(layer) - return os.MkdirAll(filepath.Join(string(root), dir), 0755) + return os.MkdirAll(filepath.Join(root, dir), 0755) } func removeAll(drv graphdriver.Driver, layer string, names ...string) error { @@ -96,7 +96,7 @@ func removeAll(drv graphdriver.Driver, layer string, names ...string) error { defer drv.Put(layer) for _, filename := range names { - if err := os.RemoveAll(filepath.Join(string(root), filename)); err != nil { + if err := os.RemoveAll(filepath.Join(root, filename)); err != nil { return err } } @@ -110,8 +110,8 @@ func checkFileRemoved(drv graphdriver.Driver, layer, filename string) error { } defer drv.Put(layer) - if _, err := os.Stat(filepath.Join(string(root), filename)); err == nil { - return fmt.Errorf("file still exists: %s", filepath.Join(string(root), filename)) + if _, err := os.Stat(filepath.Join(root, filename)); err == nil { + return fmt.Errorf("file still exists: %s", filepath.Join(root, filename)) } else if !os.IsNotExist(err) { return err } @@ -127,7 +127,7 @@ func addManyFiles(drv graphdriver.Driver, layer string, count int, seed int64) e defer drv.Put(layer) for i := 0; i < count; i += 100 { - dir := filepath.Join(string(root), fmt.Sprintf("directory-%d", i)) + dir := filepath.Join(root, fmt.Sprintf("directory-%d", i)) if err := os.MkdirAll(dir, 0755); err != nil { return err } @@ -152,7 +152,7 @@ func changeManyFiles(drv graphdriver.Driver, layer string, count int, seed int64 var changes []archive.Change for i := 0; i < count; i += 100 { archiveRoot := fmt.Sprintf("/directory-%d", i) - if err := os.MkdirAll(filepath.Join(string(root), archiveRoot), 0755); err != nil { + if err := os.MkdirAll(filepath.Join(root, archiveRoot), 0755); err != nil { return nil, err } for j := 0; i+j < count && j < 100; j++ { @@ -168,21 +168,21 @@ func changeManyFiles(drv graphdriver.Driver, layer string, count int, seed int64 case 0: change.Path = filepath.Join(archiveRoot, fmt.Sprintf("file-%d", i+j)) change.Kind = archive.ChangeModify - if err := os.WriteFile(filepath.Join(string(root), change.Path), randomContent(64, seed+int64(i+j)), 0755); err != nil { + if err := os.WriteFile(filepath.Join(root, change.Path), randomContent(64, seed+int64(i+j)), 0755); err != nil { return nil, err } // Add file case 1: change.Path = filepath.Join(archiveRoot, fmt.Sprintf("file-%d-%d", seed, i+j)) change.Kind = archive.ChangeAdd - if err := os.WriteFile(filepath.Join(string(root), change.Path), randomContent(64, seed+int64(i+j)), 0755); err != nil { + if err := os.WriteFile(filepath.Join(root, change.Path), randomContent(64, seed+int64(i+j)), 0755); err != nil { return nil, err } // Remove file case 2: change.Path = filepath.Join(archiveRoot, fmt.Sprintf("file-%d", i+j)) change.Kind = archive.ChangeDelete - if err := os.Remove(filepath.Join(string(root), change.Path)); err != nil { + if err := os.Remove(filepath.Join(root, change.Path)); err != nil { return nil, err } } @@ -201,7 +201,7 @@ func checkManyFiles(drv graphdriver.Driver, layer string, count int, seed int64) defer drv.Put(layer) for i := 0; i < count; i += 100 { - dir := filepath.Join(string(root), fmt.Sprintf("directory-%d", i)) + dir := filepath.Join(root, fmt.Sprintf("directory-%d", i)) for j := 0; i+j < count && j < 100; j++ { file := filepath.Join(dir, fmt.Sprintf("file-%d", i+j)) fileContent, err := os.ReadFile(file) @@ -254,10 +254,10 @@ func addLayerFiles(drv graphdriver.Driver, layer, parent string, i int) error { } defer drv.Put(layer) - if err := os.WriteFile(filepath.Join(string(root), "top-id"), []byte(layer), 0755); err != nil { + if err := os.WriteFile(filepath.Join(root, "top-id"), []byte(layer), 0755); err != nil { return err } - layerDir := filepath.Join(string(root), fmt.Sprintf("layer-%d", i)) + layerDir := filepath.Join(root, fmt.Sprintf("layer-%d", i)) if err := os.MkdirAll(layerDir, 0755); err != nil { return err } @@ -291,7 +291,7 @@ func checkManyLayers(drv graphdriver.Driver, layer string, count int) error { } defer drv.Put(layer) - layerIDBytes, err := os.ReadFile(filepath.Join(string(root), "top-id")) + layerIDBytes, err := os.ReadFile(filepath.Join(root, "top-id")) if err != nil { return err } @@ -301,7 +301,7 @@ func checkManyLayers(drv graphdriver.Driver, layer string, count int) error { } for i := count; i > 0; i-- { - layerDir := filepath.Join(string(root), fmt.Sprintf("layer-%d", i)) + layerDir := filepath.Join(root, fmt.Sprintf("layer-%d", i)) thisLayerIDBytes, err := os.ReadFile(filepath.Join(layerDir, "layer-id")) if err != nil { diff --git a/daemon/graphdriver/graphtest/testutil_unix.go b/daemon/graphdriver/graphtest/testutil_unix.go index e8b0f8786f..d42682203e 100644 --- a/daemon/graphdriver/graphtest/testutil_unix.go +++ b/daemon/graphdriver/graphtest/testutil_unix.go @@ -45,11 +45,11 @@ func createBase(t testing.TB, driver graphdriver.Driver, name string) { assert.NilError(t, err) defer driver.Put(name) - subdir := filepath.Join(string(dirFS), "a subdir") + subdir := filepath.Join(dirFS, "a subdir") assert.NilError(t, os.Mkdir(subdir, 0705|os.ModeSticky)) assert.NilError(t, contdriver.LocalDriver.Lchown(subdir, 1, 2)) - file := filepath.Join(string(dirFS), "a file") + file := filepath.Join(dirFS, "a file") err = os.WriteFile(file, []byte("Some data"), 0222|os.ModeSetuid) assert.NilError(t, err) } @@ -59,13 +59,13 @@ func verifyBase(t testing.TB, driver graphdriver.Driver, name string) { assert.NilError(t, err) defer driver.Put(name) - subdir := filepath.Join(string(dirFS), "a subdir") + subdir := filepath.Join(dirFS, "a subdir") verifyFile(t, subdir, 0705|os.ModeDir|os.ModeSticky, 1, 2) - file := filepath.Join(string(dirFS), "a file") + file := filepath.Join(dirFS, "a file") verifyFile(t, file, 0222|os.ModeSetuid, 0, 0) - files, err := readDir(string(dirFS)) + files, err := readDir(dirFS) assert.NilError(t, err) assert.Check(t, is.Len(files, 2)) } diff --git a/daemon/graphdriver/overlay/overlay.go b/daemon/graphdriver/overlay/overlay.go index 9c23dc0c15..01d4982e12 100644 --- a/daemon/graphdriver/overlay/overlay.go +++ b/daemon/graphdriver/overlay/overlay.go @@ -349,12 +349,12 @@ func (d *Driver) Get(id, mountLabel string) (_ containerfs.ContainerFS, err erro // If id has a root, just return it rootDir := path.Join(dir, "root") if _, err := os.Stat(rootDir); err == nil { - return containerfs.NewLocalContainerFS(rootDir), nil + return rootDir, nil } mergedDir := path.Join(dir, "merged") if count := d.ctr.Increment(mergedDir); count > 1 { - return containerfs.NewLocalContainerFS(mergedDir), nil + return mergedDir, nil } defer func() { if err != nil { @@ -391,7 +391,7 @@ func (d *Driver) Get(id, mountLabel string) (_ containerfs.ContainerFS, err erro if err := root.Chown(path.Join(workDir, "work")); err != nil { return "", err } - return containerfs.NewLocalContainerFS(mergedDir), nil + return mergedDir, nil } // Put unmounts the mount path created for the give id. diff --git a/daemon/graphdriver/overlay2/overlay.go b/daemon/graphdriver/overlay2/overlay.go index b4b807e796..9140ea089f 100644 --- a/daemon/graphdriver/overlay2/overlay.go +++ b/daemon/graphdriver/overlay2/overlay.go @@ -526,14 +526,14 @@ func (d *Driver) Get(id, mountLabel string) (_ containerfs.ContainerFS, retErr e if err != nil { // If no lower, just return diff directory if os.IsNotExist(err) { - return containerfs.NewLocalContainerFS(diffDir), nil + return diffDir, nil } return "", err } mergedDir := path.Join(dir, mergedDirName) if count := d.ctr.Increment(mergedDir); count > 1 { - return containerfs.NewLocalContainerFS(mergedDir), nil + return mergedDir, nil } defer func() { if retErr != nil { @@ -613,7 +613,7 @@ func (d *Driver) Get(id, mountLabel string) (_ containerfs.ContainerFS, retErr e } } - return containerfs.NewLocalContainerFS(mergedDir), nil + return mergedDir, nil } // Put unmounts the mount path created for the give id. diff --git a/daemon/graphdriver/proxy.go b/daemon/graphdriver/proxy.go index 17abfca6d4..94185131d0 100644 --- a/daemon/graphdriver/proxy.go +++ b/daemon/graphdriver/proxy.go @@ -141,7 +141,7 @@ func (d *graphDriverProxy) Get(id, mountLabel string) (containerfs.ContainerFS, if ret.Err != "" { err = errors.New(ret.Err) } - return containerfs.NewLocalContainerFS(d.p.ScopedPath(ret.Dir)), err + return d.p.ScopedPath(ret.Dir), err } func (d *graphDriverProxy) Put(id string) error { diff --git a/daemon/graphdriver/vfs/driver.go b/daemon/graphdriver/vfs/driver.go index 92e2f115ec..d99b82e833 100644 --- a/daemon/graphdriver/vfs/driver.go +++ b/daemon/graphdriver/vfs/driver.go @@ -172,7 +172,7 @@ func (d *Driver) create(id, parent string, size uint64) error { if err != nil { return fmt.Errorf("%s: %s", parent, err) } - return CopyDir(string(parentDir), dir) + return CopyDir(parentDir, dir) } func (d *Driver) dir(id string) string { @@ -192,7 +192,7 @@ func (d *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) { } else if !st.IsDir() { return "", fmt.Errorf("%s: not a directory", dir) } - return containerfs.NewLocalContainerFS(dir), nil + return dir, nil } // Put is a noop for vfs that return nil for the error, since this driver has no runtime resources to clean up. diff --git a/daemon/graphdriver/windows/windows.go b/daemon/graphdriver/windows/windows.go index 4c89cfe97e..383c3b7473 100644 --- a/daemon/graphdriver/windows/windows.go +++ b/daemon/graphdriver/windows/windows.go @@ -402,7 +402,7 @@ func (d *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) { return "", err } if count := d.ctr.Increment(rID); count > 1 { - return containerfs.NewLocalContainerFS(d.cache[rID]), nil + return d.cache[rID], nil } // Getting the layer paths must be done outside of the lock. @@ -447,7 +447,7 @@ func (d *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) { dir = d.dir(id) } - return containerfs.NewLocalContainerFS(dir), nil + return dir, nil } // Put adds a new layer to the driver. @@ -651,7 +651,7 @@ func (d *Driver) DiffSize(id, parent string) (size int64, err error) { } defer d.Put(id) - return archive.ChangesSize(string(layerFs), changes), nil + return archive.ChangesSize(layerFs, changes), nil } // GetMetadata returns custom driver information. diff --git a/daemon/graphdriver/zfs/zfs.go b/daemon/graphdriver/zfs/zfs.go index aca35e0abd..82f72bf698 100644 --- a/daemon/graphdriver/zfs/zfs.go +++ b/daemon/graphdriver/zfs/zfs.go @@ -368,7 +368,7 @@ func (d *Driver) Get(id, mountLabel string) (_ containerfs.ContainerFS, retErr e defer d.locker.Unlock(id) mountpoint := d.mountPath(id) if count := d.ctr.Increment(mountpoint); count > 1 { - return containerfs.NewLocalContainerFS(mountpoint), nil + return mountpoint, nil } defer func() { if retErr != nil { @@ -404,7 +404,7 @@ func (d *Driver) Get(id, mountLabel string) (_ containerfs.ContainerFS, retErr e return "", fmt.Errorf("error modifying zfs mountpoint (%s) directory ownership: %v", mountpoint, err) } - return containerfs.NewLocalContainerFS(mountpoint), nil + return mountpoint, nil } // Put removes the existing mountpoint for the given id if it exists. |
