mirror of
https://github.com/docker/cli.git
synced 2026-09-24 07:25:07 -05:00
Devmapper: Mount images readonly when calculating changes
There is no need to have this be writable, and there is a chance that e.g. atime updates will cause writes to the image which is bad for disk use wrt sharing between all containers. Upstream-commit: a14496ce891f1f09b10f0459550e8fe095b477b5 Component: engine
This commit is contained in:
@@ -650,7 +650,7 @@ func (devices *DeviceSetDM) Shutdown() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (devices *DeviceSetDM) MountDevice(hash, path string) error {
|
||||
func (devices *DeviceSetDM) MountDevice(hash, path string, readOnly bool) error {
|
||||
devices.Lock()
|
||||
defer devices.Unlock()
|
||||
|
||||
@@ -666,9 +666,15 @@ func (devices *DeviceSetDM) MountDevice(hash, path string) error {
|
||||
|
||||
info := devices.Devices[hash]
|
||||
|
||||
err := syscall.Mount(info.DevName(), path, "ext4", syscall.MS_MGC_VAL, "discard")
|
||||
var flags uintptr = syscall.MS_MGC_VAL
|
||||
|
||||
if readOnly {
|
||||
flags = flags | syscall.MS_RDONLY
|
||||
}
|
||||
|
||||
err := syscall.Mount(info.DevName(), path, "ext4", flags, "discard")
|
||||
if err != nil && err == syscall.EINVAL {
|
||||
err = syscall.Mount(info.DevName(), path, "ext4", syscall.MS_MGC_VAL, "")
|
||||
err = syscall.Mount(info.DevName(), path, "ext4", flags, "")
|
||||
}
|
||||
if err != nil {
|
||||
utils.Debugf("\n--->Err: %s\n", err)
|
||||
|
||||
Reference in New Issue
Block a user