Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mount: can't remount,rw #178

Open
Darkness4 opened this issue Nov 9, 2024 · 3 comments
Open

mount: can't remount,rw #178

Darkness4 opened this issue Nov 9, 2024 · 3 comments

Comments

@Darkness4
Copy link

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
}

@kolyshkin
Copy link
Collaborator

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

This implied you've found a regression (IOW your code worked correctly when the docker/docker/pkg/mount was used. It looks like it's not -- I tested with github.com/moby/moby v17.12.0-ce-rc1.0.20190717161051-705d9623b7c1+incompatible and it gives the same result ("remount,rw" is ignored).

Yet it seems the bug is valid, it's just not a regression. Looking...

@kolyshkin
Copy link
Collaborator

My conclusion is, this package did not envision such a use case, but hopefully it can be added without breaking anything else.

Can you give us some more details about your use case?

In the meantime, a workaround for your use case is to specify some text-only option, such as size=....

@Darkness4
Copy link
Author

Hello, I maintaining a fork of k3os. I'm not the original maintainer so I don't really know the original motivation of using the docker/docker/pkg/mount package, but they used the package to remount /k3os/system with rw during upgrades, which is immutable by default (mounted ro).

As proper "workaround", I simply used the syscall package to remount: Darkness4/k3os@2214405#diff-05da710ec6495dd56e5e44533a90c845f5fe090ad706dea8b496b8b9e6dc084dL62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants