1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

pkg/containerfs: drop Driver abstraction

The Driver abstraction was needed for Linux Containers on Windows,
support for which has since been removed.

There is no direct equivalent to Lchmod() in the standard library so
continue to use the containerd/continuity version.

Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
Cory Snider 2022-09-22 20:59:58 -04:00
parent 7014c0d65d
commit be4f4644a8
14 changed files with 64 additions and 69 deletions

View file

@ -20,7 +20,7 @@ type archiveContext struct {
} }
func (c *archiveContext) Close() error { func (c *archiveContext) Close() error {
return c.root.RemoveAll(c.root.Path()) return os.RemoveAll(c.root.Path())
} }
func convertPathError(err error, cleanpath string) error { func convertPathError(err error, cleanpath string) error {
@ -91,7 +91,7 @@ func (c *archiveContext) Remove(path string) error {
if err != nil { if err != nil {
return err return err
} }
return c.root.RemoveAll(fullpath) return os.RemoveAll(fullpath)
} }
func (c *archiveContext) Hash(path string) (string, error) { func (c *archiveContext) Hash(path string) (string, error) {

View file

@ -162,7 +162,7 @@ func openAt(remote builder.Source, path string) (driver.File, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
return remote.Root().Open(fullPath) return os.Open(fullPath)
} }
// StatAt is a helper for calling Stat on a path from a source // StatAt is a helper for calling Stat on a path from a source
@ -171,7 +171,7 @@ func StatAt(remote builder.Source, path string) (os.FileInfo, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
return remote.Root().Stat(fullPath) return os.Stat(fullPath)
} }
// FullPath is a helper for getting a full path for a path from a source // FullPath is a helper for getting a full path for a path from a source

View file

@ -119,5 +119,5 @@ func (r *stubRemote) Close() error {
return errors.New("not implemented") return errors.New("not implemented")
} }
func (r *stubRemote) Remove(p string) error { func (r *stubRemote) Remove(p string) error {
return r.root.Remove(filepath.Join(r.root.Path(), p)) return os.Remove(filepath.Join(r.root.Path(), p))
} }

View file

@ -47,7 +47,7 @@ func (c *lazySource) Hash(path string) (string, error) {
return "", errors.WithStack(convertPathError(err, cleanPath)) return "", errors.WithStack(convertPathError(err, cleanPath))
} }
fi, err := c.root.Lstat(fullPath) fi, err := os.Lstat(fullPath)
if err != nil { if err != nil {
// Backwards compatibility: a missing file returns a path as hash. // Backwards compatibility: a missing file returns a path as hash.
// This is reached in the case of a broken symlink. // This is reached in the case of a broken symlink.
@ -72,7 +72,7 @@ func (c *lazySource) prepareHash(relPath string, fi os.FileInfo) (string, error)
return "", errors.Wrapf(err, "failed to create hash for %s", relPath) return "", errors.Wrapf(err, "failed to create hash for %s", relPath)
} }
if fi.Mode().IsRegular() && fi.Size() > 0 { if fi.Mode().IsRegular() && fi.Size() > 0 {
f, err := c.root.Open(p) f, err := os.Open(p)
if err != nil { if err != nil {
return "", errors.Wrapf(err, "failed to open %s", relPath) return "", errors.Wrapf(err, "failed to open %s", relPath)
} }

View file

@ -118,7 +118,7 @@ func TestRemoveDirectory(t *testing.T) {
src := makeTestArchiveContext(t, contextDir) src := makeTestArchiveContext(t, contextDir)
_, err = src.Root().Stat(filepath.Join(src.Root().Path(), relativePath)) _, err = os.Stat(filepath.Join(src.Root().Path(), relativePath))
if err != nil { if err != nil {
t.Fatalf("Statting %s shouldn't fail: %+v", relativePath, err) t.Fatalf("Statting %s shouldn't fail: %+v", relativePath, err)
} }
@ -129,7 +129,7 @@ func TestRemoveDirectory(t *testing.T) {
t.Fatalf("Error when executing Remove: %s", err) t.Fatalf("Error when executing Remove: %s", err)
} }
_, err = src.Root().Stat(filepath.Join(src.Root().Path(), relativePath)) _, err = os.Stat(filepath.Join(src.Root().Path(), relativePath))
if !errors.Is(err, os.ErrNotExist) { if !errors.Is(err, os.ErrNotExist) {
t.Fatalf("Directory should not exist at this point: %+v ", err) t.Fatalf("Directory should not exist at this point: %+v ", err)
} }

View file

@ -52,7 +52,7 @@ func (container *Container) StatPath(resolvedPath, absPath string) (stat *types.
} }
driver := container.BaseFS driver := container.BaseFS
lstat, err := driver.Lstat(resolvedPath) lstat, err := os.Lstat(resolvedPath)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -310,7 +310,7 @@ func (daemon *Daemon) containerExtractToDir(container *container.Container, path
return err return err
} }
stat, err := driver.Lstat(resolvedPath) stat, err := os.Lstat(resolvedPath)
if err != nil { if err != nil {
return err return err
} }
@ -421,7 +421,7 @@ func (daemon *Daemon) containerCopy(container *container.Container, resource str
if err != nil { if err != nil {
return nil, err return nil, err
} }
stat, err := driver.Stat(basePath) stat, err := os.Stat(basePath)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -5,10 +5,10 @@ package graphtest // import "github.com/docker/docker/daemon/graphdriver/graphte
import ( import (
"io" "io"
"os"
"path/filepath" "path/filepath"
"testing" "testing"
contdriver "github.com/containerd/continuity/driver"
"github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/stringid"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
) )
@ -250,7 +250,7 @@ func DriverBenchDeepLayerRead(b *testing.B, layerCount int, drivername string, d
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
// Read content // Read content
c, err := contdriver.ReadFile(root, filepath.Join(root.Path(), "testfile.txt")) c, err := os.ReadFile(filepath.Join(root.Path(), "testfile.txt"))
if err != nil { if err != nil {
b.Fatal(err) b.Fatal(err)
} }

View file

@ -99,7 +99,7 @@ func DriverTestCreateEmpty(t testing.TB, drivername string, driverOptions ...str
verifyFile(t, dir.Path(), 0755|os.ModeDir, 0, 0) verifyFile(t, dir.Path(), 0755|os.ModeDir, 0, 0)
// Verify that the directory is empty // Verify that the directory is empty
fis, err := readDir(dir, dir.Path()) fis, err := readDir(dir.Path())
assert.NilError(t, err) assert.NilError(t, err)
assert.Check(t, is.Len(fis, 0)) assert.Check(t, is.Len(fis, 0))

View file

@ -3,12 +3,12 @@ package graphtest // import "github.com/docker/docker/daemon/graphdriver/graphte
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"io/fs"
"math/rand" "math/rand"
"os" "os"
"path/filepath" "path/filepath"
"sort" "sort"
"github.com/containerd/continuity/driver"
"github.com/docker/docker/daemon/graphdriver" "github.com/docker/docker/daemon/graphdriver"
"github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/stringid"
@ -36,17 +36,17 @@ func addFiles(drv graphdriver.Driver, layer string, seed int64) error {
} }
defer drv.Put(layer) defer drv.Put(layer)
if err := driver.WriteFile(root, filepath.Join(root.Path(), "file-a"), randomContent(64, seed), 0755); err != nil { if err := os.WriteFile(filepath.Join(root.Path(), "file-a"), randomContent(64, seed), 0755); err != nil {
return err return err
} }
if err := root.MkdirAll(filepath.Join(root.Path(), "dir-b"), 0755); err != nil { if err := os.MkdirAll(filepath.Join(root.Path(), "dir-b"), 0755); err != nil {
return err return err
} }
if err := driver.WriteFile(root, filepath.Join(root.Path(), "dir-b", "file-b"), randomContent(128, seed+1), 0755); err != nil { if err := os.WriteFile(filepath.Join(root.Path(), "dir-b", "file-b"), randomContent(128, seed+1), 0755); err != nil {
return err return err
} }
return driver.WriteFile(root, filepath.Join(root.Path(), "file-c"), randomContent(128*128, seed+2), 0755) return os.WriteFile(filepath.Join(root.Path(), "file-c"), randomContent(128*128, seed+2), 0755)
} }
func checkFile(drv graphdriver.Driver, layer, filename string, content []byte) error { 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) defer drv.Put(layer)
fileContent, err := driver.ReadFile(root, filepath.Join(root.Path(), filename)) fileContent, err := os.ReadFile(filepath.Join(root.Path(), filename))
if err != nil { if err != nil {
return err return err
} }
@ -75,7 +75,7 @@ func addFile(drv graphdriver.Driver, layer, filename string, content []byte) err
} }
defer drv.Put(layer) defer drv.Put(layer)
return driver.WriteFile(root, filepath.Join(root.Path(), filename), content, 0755) return os.WriteFile(filepath.Join(root.Path(), filename), content, 0755)
} }
func addDirectory(drv graphdriver.Driver, layer, dir string) error { 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) defer drv.Put(layer)
return root.MkdirAll(filepath.Join(root.Path(), dir), 0755) return os.MkdirAll(filepath.Join(root.Path(), dir), 0755)
} }
func removeAll(drv graphdriver.Driver, layer string, names ...string) error { 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) defer drv.Put(layer)
for _, filename := range names { for _, filename := range names {
if err := root.RemoveAll(filepath.Join(root.Path(), filename)); err != nil { if err := os.RemoveAll(filepath.Join(root.Path(), filename)); err != nil {
return err return err
} }
} }
@ -110,7 +110,7 @@ func checkFileRemoved(drv graphdriver.Driver, layer, filename string) error {
} }
defer drv.Put(layer) defer drv.Put(layer)
if _, err := root.Stat(filepath.Join(root.Path(), filename)); err == nil { if _, err := os.Stat(filepath.Join(root.Path(), filename)); err == nil {
return fmt.Errorf("file still exists: %s", filepath.Join(root.Path(), filename)) return fmt.Errorf("file still exists: %s", filepath.Join(root.Path(), filename))
} else if !os.IsNotExist(err) { } else if !os.IsNotExist(err) {
return err return err
@ -128,12 +128,12 @@ func addManyFiles(drv graphdriver.Driver, layer string, count int, seed int64) e
for i := 0; i < count; i += 100 { for i := 0; i < count; i += 100 {
dir := filepath.Join(root.Path(), fmt.Sprintf("directory-%d", i)) dir := filepath.Join(root.Path(), fmt.Sprintf("directory-%d", i))
if err := root.MkdirAll(dir, 0755); err != nil { if err := os.MkdirAll(dir, 0755); err != nil {
return err return err
} }
for j := 0; i+j < count && j < 100; j++ { for j := 0; i+j < count && j < 100; j++ {
file := filepath.Join(dir, fmt.Sprintf("file-%d", i+j)) file := filepath.Join(dir, fmt.Sprintf("file-%d", i+j))
if err := driver.WriteFile(root, file, randomContent(64, seed+int64(i+j)), 0755); err != nil { if err := os.WriteFile(file, randomContent(64, seed+int64(i+j)), 0755); err != nil {
return err return err
} }
} }
@ -152,7 +152,7 @@ func changeManyFiles(drv graphdriver.Driver, layer string, count int, seed int64
var changes []archive.Change var changes []archive.Change
for i := 0; i < count; i += 100 { for i := 0; i < count; i += 100 {
archiveRoot := fmt.Sprintf("/directory-%d", i) archiveRoot := fmt.Sprintf("/directory-%d", i)
if err := root.MkdirAll(filepath.Join(root.Path(), archiveRoot), 0755); err != nil { if err := os.MkdirAll(filepath.Join(root.Path(), archiveRoot), 0755); err != nil {
return nil, err return nil, err
} }
for j := 0; i+j < count && j < 100; j++ { 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: case 0:
change.Path = filepath.Join(archiveRoot, fmt.Sprintf("file-%d", i+j)) change.Path = filepath.Join(archiveRoot, fmt.Sprintf("file-%d", i+j))
change.Kind = archive.ChangeModify change.Kind = archive.ChangeModify
if err := driver.WriteFile(root, filepath.Join(root.Path(), change.Path), randomContent(64, seed+int64(i+j)), 0755); err != nil { if err := os.WriteFile(filepath.Join(root.Path(), change.Path), randomContent(64, seed+int64(i+j)), 0755); err != nil {
return nil, err return nil, err
} }
// Add file // Add file
case 1: case 1:
change.Path = filepath.Join(archiveRoot, fmt.Sprintf("file-%d-%d", seed, i+j)) change.Path = filepath.Join(archiveRoot, fmt.Sprintf("file-%d-%d", seed, i+j))
change.Kind = archive.ChangeAdd change.Kind = archive.ChangeAdd
if err := driver.WriteFile(root, filepath.Join(root.Path(), change.Path), randomContent(64, seed+int64(i+j)), 0755); err != nil { if err := os.WriteFile(filepath.Join(root.Path(), change.Path), randomContent(64, seed+int64(i+j)), 0755); err != nil {
return nil, err return nil, err
} }
// Remove file // Remove file
case 2: case 2:
change.Path = filepath.Join(archiveRoot, fmt.Sprintf("file-%d", i+j)) change.Path = filepath.Join(archiveRoot, fmt.Sprintf("file-%d", i+j))
change.Kind = archive.ChangeDelete change.Kind = archive.ChangeDelete
if err := root.Remove(filepath.Join(root.Path(), change.Path)); err != nil { if err := os.Remove(filepath.Join(root.Path(), change.Path)); err != nil {
return nil, err return nil, err
} }
} }
@ -204,7 +204,7 @@ func checkManyFiles(drv graphdriver.Driver, layer string, count int, seed int64)
dir := filepath.Join(root.Path(), fmt.Sprintf("directory-%d", i)) dir := filepath.Join(root.Path(), fmt.Sprintf("directory-%d", i))
for j := 0; i+j < count && j < 100; j++ { for j := 0; i+j < count && j < 100; j++ {
file := filepath.Join(dir, fmt.Sprintf("file-%d", i+j)) file := filepath.Join(dir, fmt.Sprintf("file-%d", i+j))
fileContent, err := driver.ReadFile(root, file) fileContent, err := os.ReadFile(file)
if err != nil { if err != nil {
return err return err
} }
@ -254,17 +254,17 @@ func addLayerFiles(drv graphdriver.Driver, layer, parent string, i int) error {
} }
defer drv.Put(layer) defer drv.Put(layer)
if err := driver.WriteFile(root, filepath.Join(root.Path(), "top-id"), []byte(layer), 0755); err != nil { if err := os.WriteFile(filepath.Join(root.Path(), "top-id"), []byte(layer), 0755); err != nil {
return err return err
} }
layerDir := filepath.Join(root.Path(), fmt.Sprintf("layer-%d", i)) layerDir := filepath.Join(root.Path(), fmt.Sprintf("layer-%d", i))
if err := root.MkdirAll(layerDir, 0755); err != nil { if err := os.MkdirAll(layerDir, 0755); err != nil {
return err return err
} }
if err := driver.WriteFile(root, filepath.Join(layerDir, "layer-id"), []byte(layer), 0755); err != nil { if err := os.WriteFile(filepath.Join(layerDir, "layer-id"), []byte(layer), 0755); err != nil {
return err return err
} }
return driver.WriteFile(root, filepath.Join(layerDir, "parent-id"), []byte(parent), 0755) return os.WriteFile(filepath.Join(layerDir, "parent-id"), []byte(parent), 0755)
} }
func addManyLayers(drv graphdriver.Driver, baseLayer string, count int) (string, error) { func addManyLayers(drv graphdriver.Driver, baseLayer string, count int) (string, error) {
@ -291,7 +291,7 @@ func checkManyLayers(drv graphdriver.Driver, layer string, count int) error {
} }
defer drv.Put(layer) defer drv.Put(layer)
layerIDBytes, err := driver.ReadFile(root, filepath.Join(root.Path(), "top-id")) layerIDBytes, err := os.ReadFile(filepath.Join(root.Path(), "top-id"))
if err != nil { if err != nil {
return err return err
} }
@ -303,14 +303,14 @@ func checkManyLayers(drv graphdriver.Driver, layer string, count int) error {
for i := count; i > 0; i-- { for i := count; i > 0; i-- {
layerDir := filepath.Join(root.Path(), fmt.Sprintf("layer-%d", i)) layerDir := filepath.Join(root.Path(), fmt.Sprintf("layer-%d", i))
thisLayerIDBytes, err := driver.ReadFile(root, filepath.Join(layerDir, "layer-id")) thisLayerIDBytes, err := os.ReadFile(filepath.Join(layerDir, "layer-id"))
if err != nil { if err != nil {
return err return err
} }
if !bytes.Equal(thisLayerIDBytes, layerIDBytes) { if !bytes.Equal(thisLayerIDBytes, layerIDBytes) {
return fmt.Errorf("mismatched file content %v, expecting %v", thisLayerIDBytes, layerIDBytes) return fmt.Errorf("mismatched file content %v, expecting %v", thisLayerIDBytes, layerIDBytes)
} }
layerIDBytes, err = driver.ReadFile(root, filepath.Join(layerDir, "parent-id")) layerIDBytes, err = os.ReadFile(filepath.Join(layerDir, "parent-id"))
if err != nil { if err != nil {
return err return err
} }
@ -318,11 +318,11 @@ func checkManyLayers(drv graphdriver.Driver, layer string, count int) error {
return nil return nil
} }
// readDir reads a directory just like driver.ReadDir() // readDir reads a directory just like os.ReadDir()
// then hides specific files (currently "lost+found") // then hides specific files (currently "lost+found")
// so the tests don't "see" it // so the tests don't "see" it
func readDir(r driver.Driver, dir string) ([]os.FileInfo, error) { func readDir(dir string) ([]fs.DirEntry, error) {
a, err := driver.ReadDir(r, dir) a, err := os.ReadDir(dir)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -46,11 +46,11 @@ func createBase(t testing.TB, driver graphdriver.Driver, name string) {
defer driver.Put(name) defer driver.Put(name)
subdir := filepath.Join(dirFS.Path(), "a subdir") subdir := filepath.Join(dirFS.Path(), "a subdir")
assert.NilError(t, dirFS.Mkdir(subdir, 0705|os.ModeSticky)) assert.NilError(t, os.Mkdir(subdir, 0705|os.ModeSticky))
assert.NilError(t, dirFS.Lchown(subdir, 1, 2)) assert.NilError(t, contdriver.LocalDriver.Lchown(subdir, 1, 2))
file := filepath.Join(dirFS.Path(), "a file") file := filepath.Join(dirFS.Path(), "a file")
err = contdriver.WriteFile(dirFS, file, []byte("Some data"), 0222|os.ModeSetuid) err = os.WriteFile(file, []byte("Some data"), 0222|os.ModeSetuid)
assert.NilError(t, err) assert.NilError(t, err)
} }
@ -65,7 +65,7 @@ func verifyBase(t testing.TB, driver graphdriver.Driver, name string) {
file := filepath.Join(dirFS.Path(), "a file") file := filepath.Join(dirFS.Path(), "a file")
verifyFile(t, file, 0222|os.ModeSetuid, 0, 0) verifyFile(t, file, 0222|os.ModeSetuid, 0, 0)
files, err := readDir(dirFS, dirFS.Path()) files, err := readDir(dirFS.Path())
assert.NilError(t, err) assert.NilError(t, err)
assert.Check(t, is.Len(files, 2)) assert.Check(t, is.Len(files, 2))
} }

View file

@ -140,16 +140,16 @@ func newTestFile(name string, content []byte, perm os.FileMode) FileApplier {
func (tf *testFile) ApplyFile(root containerfs.ContainerFS) error { func (tf *testFile) ApplyFile(root containerfs.ContainerFS) error {
fullPath := filepath.Join(root.Path(), tf.name) fullPath := filepath.Join(root.Path(), tf.name)
if err := root.MkdirAll(filepath.Dir(fullPath), 0755); err != nil { if err := os.MkdirAll(filepath.Dir(fullPath), 0755); err != nil {
return err return err
} }
// Check if already exists // Check if already exists
if stat, err := root.Stat(fullPath); err == nil && stat.Mode().Perm() != tf.permission { if stat, err := os.Stat(fullPath); err == nil && stat.Mode().Perm() != tf.permission {
if err := root.Lchmod(fullPath, tf.permission); err != nil { if err := driver.LocalDriver.Lchmod(fullPath, tf.permission); err != nil {
return err return err
} }
} }
return driver.WriteFile(root, fullPath, tf.content, tf.permission) return os.WriteFile(fullPath, tf.content, tf.permission)
} }
func initWithFiles(files ...FileApplier) layerInit { func initWithFiles(files ...FileApplier) layerInit {
@ -267,7 +267,7 @@ func TestMountAndRegister(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
b, err := driver.ReadFile(path2, filepath.Join(path2.Path(), "testfile.txt")) b, err := os.ReadFile(filepath.Join(path2.Path(), "testfile.txt"))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -375,7 +375,7 @@ func TestStoreRestore(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
if err := driver.WriteFile(pathFS, filepath.Join(pathFS.Path(), "testfile.txt"), []byte("nothing here"), 0644); err != nil { if err := os.WriteFile(filepath.Join(pathFS.Path(), "testfile.txt"), []byte("nothing here"), 0644); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -422,7 +422,7 @@ func TestStoreRestore(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
b, err := driver.ReadFile(pathFS, filepath.Join(pathFS.Path(), "testfile.txt")) b, err := os.ReadFile(filepath.Join(pathFS.Path(), "testfile.txt"))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View file

@ -2,6 +2,7 @@ package layer // import "github.com/docker/docker/layer"
import ( import (
"io" "io"
"os"
"path/filepath" "path/filepath"
"runtime" "runtime"
"sort" "sort"
@ -46,12 +47,12 @@ func TestMountInit(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
fi, err := pathFS.Stat(filepath.Join(pathFS.Path(), "testfile.txt")) fi, err := os.Stat(filepath.Join(pathFS.Path(), "testfile.txt"))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
f, err := pathFS.Open(filepath.Join(pathFS.Path(), "testfile.txt")) f, err := os.Open(filepath.Join(pathFS.Path(), "testfile.txt"))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -106,7 +107,7 @@ func TestMountSize(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
if err := driver.WriteFile(pathFS, filepath.Join(pathFS.Path(), "file2"), content2, 0755); err != nil { if err := os.WriteFile(filepath.Join(pathFS.Path(), "file2"), content2, 0755); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -158,23 +159,23 @@ func TestMountChanges(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
if err := pathFS.Lchmod(filepath.Join(pathFS.Path(), "testfile1.txt"), 0755); err != nil { if err := driver.LocalDriver.Lchmod(filepath.Join(pathFS.Path(), "testfile1.txt"), 0755); err != nil {
t.Fatal(err) t.Fatal(err)
} }
if err := driver.WriteFile(pathFS, filepath.Join(pathFS.Path(), "testfile1.txt"), []byte("mount data!"), 0755); err != nil { if err := os.WriteFile(filepath.Join(pathFS.Path(), "testfile1.txt"), []byte("mount data!"), 0755); err != nil {
t.Fatal(err) t.Fatal(err)
} }
if err := pathFS.Remove(filepath.Join(pathFS.Path(), "testfile2.txt")); err != nil { if err := os.Remove(filepath.Join(pathFS.Path(), "testfile2.txt")); err != nil {
t.Fatal(err) t.Fatal(err)
} }
if err := pathFS.Lchmod(filepath.Join(pathFS.Path(), "testfile3.txt"), 0755); err != nil { if err := driver.LocalDriver.Lchmod(filepath.Join(pathFS.Path(), "testfile3.txt"), 0755); err != nil {
t.Fatal(err) t.Fatal(err)
} }
if err := driver.WriteFile(pathFS, filepath.Join(pathFS.Path(), "testfile4.txt"), []byte("mount data!"), 0644); err != nil { if err := os.WriteFile(filepath.Join(pathFS.Path(), "testfile4.txt"), []byte("mount data!"), 0644); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -249,7 +250,7 @@ func TestMountApply(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
f, err := pathFS.Open(filepath.Join(pathFS.Path(), "newfile.txt")) f, err := os.Open(filepath.Join(pathFS.Path(), "newfile.txt"))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View file

@ -3,7 +3,6 @@ package containerfs // import "github.com/docker/docker/pkg/containerfs"
import ( import (
"path/filepath" "path/filepath"
"github.com/containerd/continuity/driver"
"github.com/moby/sys/symlink" "github.com/moby/sys/symlink"
) )
@ -12,23 +11,18 @@ type ContainerFS interface {
// Path returns the path to the root. Note that this may not exist // Path returns the path to the root. Note that this may not exist
// on the local system, so the continuity operations must be used // on the local system, so the continuity operations must be used
Path() string Path() string
// Driver provides methods to manipulate files
driver.Driver
} }
// NewLocalContainerFS is a helper function to implement daemon's Mount interface // NewLocalContainerFS is a helper function to implement daemon's Mount interface
// when the graphdriver mount point is a local path on the machine. // when the graphdriver mount point is a local path on the machine.
func NewLocalContainerFS(path string) ContainerFS { func NewLocalContainerFS(path string) ContainerFS {
return &local{ return &local{
path: path, path: path,
Driver: driver.LocalDriver,
} }
} }
type local struct { type local struct {
path string path string
driver.Driver
} }
func (l *local) Path() string { func (l *local) Path() string {