mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Rename mount.IsBind to mount.MakeBindOpts
This commit is contained in:
parent
bcb464db7b
commit
ef855c7c08
@ -201,11 +201,11 @@ func IsNotMountPoint(mounter Interface, file string) (bool, error) {
|
||||
return notMnt, nil
|
||||
}
|
||||
|
||||
// IsBind detects whether a bind mount is being requested and makes the remount options to
|
||||
// MakeBindOpts detects whether a bind mount is being requested and makes the remount options to
|
||||
// use in case of bind mount, due to the fact that bind mount doesn't respect mount options.
|
||||
// The list equals:
|
||||
// options - 'bind' + 'remount' (no duplicate)
|
||||
func IsBind(options []string) (bool, []string, []string) {
|
||||
func MakeBindOpts(options []string) (bool, []string, []string) {
|
||||
// Because we have an FD opened on the subpath bind mount, the "bind" option
|
||||
// needs to be included, otherwise the mount target will error as busy if you
|
||||
// remount as readonly.
|
||||
|
@ -73,7 +73,7 @@ func (mounter *Mounter) Mount(source string, target string, fstype string, optio
|
||||
// Path to mounter binary if containerized mounter is needed. Otherwise, it is set to empty.
|
||||
// All Linux distros are expected to be shipped with a mount utility that a support bind mounts.
|
||||
mounterPath := ""
|
||||
bind, bindOpts, bindRemountOpts := IsBind(options)
|
||||
bind, bindOpts, bindRemountOpts := MakeBindOpts(options)
|
||||
if bind {
|
||||
err := mounter.doMount(mounterPath, defaultMountCommand, source, target, fstype, bindOpts)
|
||||
if err != nil {
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIsBind(t *testing.T) {
|
||||
func TestMakeBindOpts(t *testing.T) {
|
||||
tests := []struct {
|
||||
mountOption []string
|
||||
isBind bool
|
||||
@ -43,7 +43,7 @@ func TestIsBind(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
bind, bindOpts, bindRemountOpts := IsBind(test.mountOption)
|
||||
bind, bindOpts, bindRemountOpts := MakeBindOpts(test.mountOption)
|
||||
if bind != test.isBind {
|
||||
t.Errorf("Expected bind to be %v but got %v", test.isBind, bind)
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ func (mounter *Mounter) Mount(source string, target string, fstype string, optio
|
||||
bindSource := source
|
||||
|
||||
// tell it's going to mount azure disk or azure file according to options
|
||||
if bind, _, _ := IsBind(options); bind {
|
||||
if bind, _, _ := MakeBindOpts(options); bind {
|
||||
// mount azure disk
|
||||
bindSource = NormalizeWindowsPath(source)
|
||||
} else {
|
||||
|
@ -47,7 +47,7 @@ var _ mount.Interface = &execMounter{}
|
||||
|
||||
// Mount runs mount(8) using given exec interface.
|
||||
func (m *execMounter) Mount(source string, target string, fstype string, options []string) error {
|
||||
bind, bindOpts, bindRemountOpts := mount.IsBind(options)
|
||||
bind, bindOpts, bindRemountOpts := mount.MakeBindOpts(options)
|
||||
|
||||
if bind {
|
||||
err := m.doExecMount(source, target, fstype, bindOpts)
|
||||
|
Loading…
Reference in New Issue
Block a user