Merge pull request #37031 from kolyshkin/getmnt
Fix daemon.getSourceMount() for / Upstream-commit: 379845ec20ae651831dcfb0587b95c38a1631a53 Component: engine
This commit is contained in:
@@ -405,13 +405,7 @@ func getSourceMount(source string) (string, string, error) {
|
||||
idx = i
|
||||
}
|
||||
}
|
||||
// and return it unless it's "/"
|
||||
if mi[idx].Mountpoint != "/" {
|
||||
return mi[idx].Mountpoint, mi[idx].Optional, nil
|
||||
}
|
||||
|
||||
// If we are here, we did not find parent mount. Something is wrong.
|
||||
return "", "", fmt.Errorf("Could not find source mount of %s", source)
|
||||
return mi[idx].Mountpoint, mi[idx].Optional, nil
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package daemon // import "github.com/docker/docker/daemon"
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
containertypes "github.com/docker/docker/api/types/container"
|
||||
@@ -86,3 +87,16 @@ func TestIpcPrivateVsReadonly(t *testing.T) {
|
||||
assert.Check(t, is.Equal(false, inSlice(m.Options, "ro")))
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSourceMount(t *testing.T) {
|
||||
// must be able to find source mount for /
|
||||
mnt, _, err := getSourceMount("/")
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, mnt, "/")
|
||||
|
||||
// must be able to find source mount for current directory
|
||||
cwd, err := os.Getwd()
|
||||
assert.NilError(t, err)
|
||||
_, _, err = getSourceMount(cwd)
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user