Skip to content

mount: can't remount,rw #178

Open
Open
@Darkness4

Description

@Darkness4

Hello, I've migrated from docker/docker/pkg/mount to moby/sys/mount, and I've run in a small issue.

I'm running this test:

package main

import (
	"os"

	"github.com/moby/sys/mount"
)

func main() {
	_ = os.Mkdir("/tmp/test", 0755)
	err := mount.Mount("tmpfs", "/tmp/test", "tmpfs", "ro")
	if err != nil {
		panic(err)
	}

	err = mount.Mount("", "/tmp/test", "none", "remount,rw")
	if err != nil {
		panic(err)
	}
}

And "remount,rw" doesn't get executed. Not sure if this is expected behavior.

It doesn't enter any case in this function:

func mount(device, target, mType string, flags uintptr, data string) error {
oflags := flags &^ ptypes
if !isremount(device, flags) || data != "" {
// Initial call applying all non-propagation flags for mount
// or remount with changed data
if err := unix.Mount(device, target, mType, oflags, data); err != nil {
return &mountError{
op: "mount",
source: device,
target: target,
flags: oflags,
data: data,
err: err,
}
}
}
if flags&ptypes != 0 {
// Change the propagation type.
if err := unix.Mount("", target, "", flags&pflags, ""); err != nil {
return &mountError{
op: "remount",
target: target,
flags: flags & pflags,
err: err,
}
}
}
if oflags&broflags == broflags {
// Remount the bind to apply read only.
if err := unix.Mount("", target, "", oflags|unix.MS_REMOUNT, ""); err != nil {
return &mountError{
op: "remount-ro",
target: target,
flags: oflags | unix.MS_REMOUNT,
err: err,
}
}
}
return nil
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions