Skip to content

Commit

Permalink
drivers: inform Mount of the mappings used by the container
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Jul 26, 2018
1 parent 140e0b6 commit 1897396
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 57 deletions.
2 changes: 1 addition & 1 deletion drivers/aufs/aufs.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ func atomicRemove(source string) error {

// Get returns the rootfs path for the id.
// This will mount the dir at its given path
func (a *Driver) Get(id, mountLabel string) (string, error) {
func (a *Driver) Get(id, mountLabel string, uidMaps, gidMaps []idtools.IDMap) (string, error) {
a.locker.Lock(id)
defer a.locker.Unlock(id)
parents, err := a.getParentLayerPaths(id)
Expand Down
12 changes: 6 additions & 6 deletions drivers/aufs/aufs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func testInit(dir string, t testing.TB) graphdriver.Driver {
}

func driverGet(d *Driver, id string, mntLabel string) (string, error) {
return d.Get(id, mntLabel)
return d.Get(id, mntLabel, nil, nil)
}

func newDriver(t testing.TB) *Driver {
Expand Down Expand Up @@ -171,7 +171,7 @@ func TestGetWithoutParent(t *testing.T) {
t.Fatal(err)
}

diffPath, err := d.Get("1", "")
diffPath, err := d.Get("1", "", nil, nil)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -224,7 +224,7 @@ func TestMountedTrueResponse(t *testing.T) {
err = d.Create("2", "1", nil)
require.NoError(t, err)

_, err = d.Get("2", "")
_, err = d.Get("2", "", nil, nil)
require.NoError(t, err)

response, err := d.mounted(d.pathCache["2"])
Expand All @@ -249,7 +249,7 @@ func TestMountWithParent(t *testing.T) {
}
}()

mntPath, err := d.Get("2", "")
mntPath, err := d.Get("2", "", nil, nil)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -280,7 +280,7 @@ func TestRemoveMountedDir(t *testing.T) {
}
}()

mntPath, err := d.Get("2", "")
mntPath, err := d.Get("2", "", nil, nil)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -760,7 +760,7 @@ func BenchmarkConcurrentAccess(b *testing.B) {
for i := 0; i < b.N; i++ {
innerGroup.Add(1)
go func() {
d.Get(id, "")
d.Get(id, "", nil, nil)
d.Put(id)
innerGroup.Done()
}()
Expand Down
2 changes: 1 addition & 1 deletion drivers/btrfs/btrfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ func (d *Driver) Remove(id string) error {
}

// Get the requested filesystem id.
func (d *Driver) Get(id, mountLabel string) (string, error) {
func (d *Driver) Get(id, mountLabel string, uidMaps, gidMaps []idtools.IDMap) (string, error) {
dir := d.subvolumesDirID(id)
st, err := os.Stat(dir)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion drivers/btrfs/btrfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestBtrfsSubvolDelete(t *testing.T) {
}
defer graphtest.PutDriver(t)

dir, err := d.Get("test", "")
dir, err := d.Get("test", "", nil, nil)
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/chown.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func NewNaiveLayerIDMapUpdater(driver ProtoDriver) LayerIDMapUpdater {
// same "container" IDs.
func (n *naiveLayerIDMapUpdater) UpdateLayerIDMap(id string, toContainer, toHost *idtools.IDMappings, mountLabel string) error {
driver := n.ProtoDriver
layerFs, err := driver.Get(id, mountLabel)
layerFs, err := driver.Get(id, mountLabel, nil, nil)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/devmapper/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (d *Driver) Remove(id string) error {
}

// Get mounts a device with given id into the root filesystem
func (d *Driver) Get(id, mountLabel string) (string, error) {
func (d *Driver) Get(id, mountLabel string, uidMaps, gidMaps []idtools.IDMap) (string, error) {
d.locker.Lock(id)
defer d.locker.Unlock(id)
mp := path.Join(d.home, "mnt", id)
Expand Down
3 changes: 2 additions & 1 deletion drivers/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ type ProtoDriver interface {
Remove(id string) error
// Get returns the mountpoint for the layered filesystem referred
// to by this id. You can optionally specify a mountLabel or "".
// Optionally it gets the mappings used to create the layer.
// Returns the absolute path to the mounted layered filesystem.
Get(id, mountLabel string) (dir string, err error)
Get(id, mountLabel string, uidMaps, gidMaps []idtools.IDMap) (dir string, err error)
// Put releases the system resources for the specified id,
// e.g, unmounting layered filesystem.
Put(id string) error
Expand Down
12 changes: 6 additions & 6 deletions drivers/fsdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (gdw *NaiveDiffDriver) Diff(id string, idMappings *idtools.IDMappings, pare
parentMappings = &idtools.IDMappings{}
}

layerFs, err := driver.Get(id, mountLabel)
layerFs, err := driver.Get(id, mountLabel, nil, nil)
if err != nil {
return nil, err
}
Expand All @@ -78,7 +78,7 @@ func (gdw *NaiveDiffDriver) Diff(id string, idMappings *idtools.IDMappings, pare
}), nil
}

parentFs, err := driver.Get(parent, mountLabel)
parentFs, err := driver.Get(parent, mountLabel, nil, nil)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -119,7 +119,7 @@ func (gdw *NaiveDiffDriver) Changes(id string, idMappings *idtools.IDMappings, p
parentMappings = &idtools.IDMappings{}
}

layerFs, err := driver.Get(id, mountLabel)
layerFs, err := driver.Get(id, mountLabel, nil, nil)
if err != nil {
return nil, err
}
Expand All @@ -128,7 +128,7 @@ func (gdw *NaiveDiffDriver) Changes(id string, idMappings *idtools.IDMappings, p
parentFs := ""

if parent != "" {
parentFs, err = driver.Get(parent, mountLabel)
parentFs, err = driver.Get(parent, mountLabel, nil, nil)
if err != nil {
return nil, err
}
Expand All @@ -149,7 +149,7 @@ func (gdw *NaiveDiffDriver) ApplyDiff(id string, applyMappings *idtools.IDMappin
}

// Mount the root filesystem so we can apply the diff/layer.
layerFs, err := driver.Get(id, mountLabel)
layerFs, err := driver.Get(id, mountLabel, nil, nil)
if err != nil {
return
}
Expand Down Expand Up @@ -189,7 +189,7 @@ func (gdw *NaiveDiffDriver) DiffSize(id string, idMappings *idtools.IDMappings,
return
}

layerFs, err := driver.Get(id, mountLabel)
layerFs, err := driver.Get(id, mountLabel, nil, nil)
if err != nil {
return
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/graphtest/graphbench_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func DriverBenchGetEmpty(b *testing.B, drivername string, driveroptions ...strin

b.ResetTimer()
for i := 0; i < b.N; i++ {
_, err := driver.Get(base, "")
_, err := driver.Get(base, "", nil, nil)
b.StopTimer()
if err != nil {
b.Fatalf("Error getting mount: %s", err)
Expand Down Expand Up @@ -235,7 +235,7 @@ func DriverBenchDeepLayerRead(b *testing.B, layerCount int, drivername string, d
b.Fatal(err)
}

root, err := driver.Get(topLayer, "")
root, err := driver.Get(topLayer, "", nil, nil)
if err != nil {
b.Fatal(err)
}
Expand Down
10 changes: 5 additions & 5 deletions drivers/graphtest/graphtest_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func DriverTestCreateEmpty(t testing.TB, drivername string, driverOptions ...str
t.Fatal("Newly created image doesn't exist")
}

dir, err := driver.Get("empty", "")
dir, err := driver.Get("empty", "", nil, nil)
require.NoError(t, err)

verifyFile(t, dir, 0755|os.ModeDir, 0, 0)
Expand Down Expand Up @@ -327,7 +327,7 @@ func DriverTestSetQuota(t *testing.T, drivername string) {
t.Fatal(err)
}

mountPath, err := driver.Get("zfsTest", "")
mountPath, err := driver.Get("zfsTest", "", nil, nil)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -357,7 +357,7 @@ func DriverTestEcho(t testing.TB, drivername string, driverOptions ...string) {
t.Fatal(err)
}

if root, err = driver.Get(base, ""); err != nil {
if root, err = driver.Get(base, "", nil, nil); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -392,7 +392,7 @@ func DriverTestEcho(t testing.TB, drivername string, driverOptions ...string) {
t.Fatal(err)
}

if root, err = driver.Get(second, ""); err != nil {
if root, err = driver.Get(second, "", nil, nil); err != nil {
t.Fatal(err)
}

Expand All @@ -418,7 +418,7 @@ func DriverTestEcho(t testing.TB, drivername string, driverOptions ...string) {
t.Fatal(err)
}

if root, err = driver.Get(third, ""); err != nil {
if root, err = driver.Get(third, "", nil, nil); err != nil {
t.Fatal(err)
}

Expand Down
22 changes: 11 additions & 11 deletions drivers/graphtest/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func randomContent(size int, seed int64) []byte {
}

func addFiles(drv graphdriver.Driver, layer string, seed int64) error {
root, err := drv.Get(layer, "")
root, err := drv.Get(layer, "", nil, nil)
if err != nil {
return err
}
Expand All @@ -50,7 +50,7 @@ func addFiles(drv graphdriver.Driver, layer string, seed int64) error {
}

func checkFile(drv graphdriver.Driver, layer, filename string, content []byte) error {
root, err := drv.Get(layer, "")
root, err := drv.Get(layer, "", nil, nil)
if err != nil {
return err
}
Expand All @@ -69,7 +69,7 @@ func checkFile(drv graphdriver.Driver, layer, filename string, content []byte) e
}

func addFile(drv graphdriver.Driver, layer, filename string, content []byte) error {
root, err := drv.Get(layer, "")
root, err := drv.Get(layer, "", nil, nil)
if err != nil {
return err
}
Expand All @@ -79,7 +79,7 @@ func addFile(drv graphdriver.Driver, layer, filename string, content []byte) err
}

func addDirectory(drv graphdriver.Driver, layer, dir string) error {
root, err := drv.Get(layer, "")
root, err := drv.Get(layer, "", nil, nil)
if err != nil {
return err
}
Expand All @@ -89,7 +89,7 @@ func addDirectory(drv graphdriver.Driver, layer, dir string) error {
}

func removeAll(drv graphdriver.Driver, layer string, names ...string) error {
root, err := drv.Get(layer, "")
root, err := drv.Get(layer, "", nil, nil)
if err != nil {
return err
}
Expand All @@ -104,7 +104,7 @@ func removeAll(drv graphdriver.Driver, layer string, names ...string) error {
}

func checkFileRemoved(drv graphdriver.Driver, layer, filename string) error {
root, err := drv.Get(layer, "")
root, err := drv.Get(layer, "", nil, nil)
if err != nil {
return err
}
Expand All @@ -120,7 +120,7 @@ func checkFileRemoved(drv graphdriver.Driver, layer, filename string) error {
}

func addManyFiles(drv graphdriver.Driver, layer string, count int, seed int64) error {
root, err := drv.Get(layer, "")
root, err := drv.Get(layer, "", nil, nil)
if err != nil {
return err
}
Expand All @@ -143,7 +143,7 @@ func addManyFiles(drv graphdriver.Driver, layer string, count int, seed int64) e
}

func changeManyFiles(drv graphdriver.Driver, layer string, count int, seed int64) ([]archive.Change, error) {
root, err := drv.Get(layer, "")
root, err := drv.Get(layer, "", nil, nil)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -194,7 +194,7 @@ func changeManyFiles(drv graphdriver.Driver, layer string, count int, seed int64
}

func checkManyFiles(drv graphdriver.Driver, layer string, count int, seed int64) error {
root, err := drv.Get(layer, "")
root, err := drv.Get(layer, "", nil, nil)
if err != nil {
return err
}
Expand Down Expand Up @@ -248,7 +248,7 @@ func checkChanges(expected, actual []archive.Change) error {
}

func addLayerFiles(drv graphdriver.Driver, layer, parent string, i int) error {
root, err := drv.Get(layer, "")
root, err := drv.Get(layer, "", nil, nil)
if err != nil {
return err
}
Expand Down Expand Up @@ -289,7 +289,7 @@ func addManyLayers(drv graphdriver.Driver, baseLayer string, count int) (string,
}

func checkManyLayers(drv graphdriver.Driver, layer string, count int) error {
root, err := drv.Get(layer, "")
root, err := drv.Get(layer, "", nil, nil)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/graphtest/testutil_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func createBase(t testing.TB, driver graphdriver.Driver, name string) {
err := driver.CreateReadWrite(name, "", nil)
require.NoError(t, err)

dir, err := driver.Get(name, "")
dir, err := driver.Get(name, "", nil, nil)
require.NoError(t, err)
defer driver.Put(name)

Expand All @@ -54,7 +54,7 @@ func createBase(t testing.TB, driver graphdriver.Driver, name string) {
}

func verifyBase(t testing.TB, driver graphdriver.Driver, name string) {
dir, err := driver.Get(name, "")
dir, err := driver.Get(name, "", nil, nil)
require.NoError(t, err)
defer driver.Put(name)

Expand Down
Loading

0 comments on commit 1897396

Please sign in to comment.