From bb585b9c106e8e81a445b2b864d673bc9f5991cd Mon Sep 17 00:00:00 2001 From: John Howard Date: Wed, 14 Sep 2016 11:35:31 -0700 Subject: [PATCH] Windows: Move to fstab options as per OCI Signed-off-by: John Howard --- daemon/oci_windows.go | 9 ++++++--- libcontainerd/client_windows.go | 8 +++++++- libcontainerd/windowsoci/oci_windows.go | 8 ++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/daemon/oci_windows.go b/daemon/oci_windows.go index c93afcf3a4c6932c77eb8448fa9ea5a9f6e30191..6ccc3f7e956675e166292f3847a1ab698c6125f3 100644 --- a/daemon/oci_windows.go +++ b/daemon/oci_windows.go @@ -46,11 +46,14 @@ func (daemon *Daemon) createSpec(c *container.Container) (*libcontainerd.Spec, e return nil, err } for _, mount := range mounts { - s.Mounts = append(s.Mounts, windowsoci.Mount{ + m := windowsoci.Mount{ Source: mount.Source, Destination: mount.Destination, - Readonly: !mount.Writable, - }) + } + if !mount.Writable { + m.Options = append(m.Options, "ro") + } + s.Mounts = append(s.Mounts, m) } // In s.Process diff --git a/libcontainerd/client_windows.go b/libcontainerd/client_windows.go index 0e0d1a78c813217c42ee20c069e3fad9ba511565..d37b3a07fff519ab6c402807a86ad4553b9b5e50 100644 --- a/libcontainerd/client_windows.go +++ b/libcontainerd/client_windows.go @@ -126,7 +126,13 @@ func (clnt *client) Create(containerID string, checkpoint string, checkpointDir mds[i] = hcsshim.MappedDir{ HostPath: mount.Source, ContainerPath: mount.Destination, - ReadOnly: mount.Readonly} + ReadOnly: false, + } + for _, o := range mount.Options { + if strings.ToLower(o) == "ro" { + mds[i].ReadOnly = true + } + } } configuration.MappedDirectories = mds diff --git a/libcontainerd/windowsoci/oci_windows.go b/libcontainerd/windowsoci/oci_windows.go index f38dcd33c01d5a8a5735f42e86160da73199f4fa..49a4b7e22097b8f55653115a4e1c2dd753445278 100644 --- a/libcontainerd/windowsoci/oci_windows.go +++ b/libcontainerd/windowsoci/oci_windows.go @@ -96,11 +96,11 @@ type Mount struct { Destination string `json:"destination"` // Type specifies the mount kind. Type string `json:"type"` - // Source specifies the source path of the mount. In the case of bind mounts - // this would be the file on the host. + // Source specifies the source path of the mount. In the case of bind mounts on + // Linux based systems this would be the file on the host. Source string `json:"source"` - // Readonly specifies if the mount should be read-only - Readonly bool `json:"readonly"` + // Options are fstab style mount options. + Options []string `json:"options,omitempty"` } // HvRuntime contains settings specific to Hyper-V containers