Skip to content

Commit

Permalink
Merge pull request #1123 from nalind/ro-for-diff
Browse files Browse the repository at this point in the history
overlay.Get(): default to read-only for layers in additionalStores
  • Loading branch information
rhatdan committed Jan 27, 2022
2 parents a719ec7 + 34afa97 commit fafe869
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions drivers/fsdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func (gdw *NaiveDiffDriver) Changes(id string, idMappings *idtools.IDMappings, p
if parent != "" {
options := MountOpts{
MountLabel: mountLabel,
Options: []string{"ro"},
}
parentFs, err = driver.Get(parent, options)
if err != nil {
Expand Down
13 changes: 9 additions & 4 deletions drivers/overlay/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -1055,17 +1055,22 @@ func (d *Driver) getLower(parent string) (string, error) {
}

func (d *Driver) dir(id string) string {
p, _ := d.dir2(id)
return p
}

func (d *Driver) dir2(id string) (string, bool) {
newpath := path.Join(d.home, id)
if _, err := os.Stat(newpath); err != nil {
for _, p := range d.AdditionalImageStores() {
l := path.Join(p, d.name, id)
_, err = os.Stat(l)
if err == nil {
return l
return l, true
}
}
}
return newpath
return newpath, false
}

func (d *Driver) getLowerDirs(id string) ([]string, error) {
Expand Down Expand Up @@ -1260,11 +1265,11 @@ func (d *Driver) Get(id string, options graphdriver.MountOpts) (_ string, retErr
func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountOpts) (_ string, retErr error) {
d.locker.Lock(id)
defer d.locker.Unlock(id)
dir := d.dir(id)
dir, inAdditionalStore := d.dir2(id)
if _, err := os.Stat(dir); err != nil {
return "", err
}
readWrite := true
readWrite := !inAdditionalStore

if !d.SupportsShifting() || options.DisableShifting {
disableShifting = true
Expand Down

0 comments on commit fafe869

Please sign in to comment.