overlay2: doesSupportNativeDiff: add fast path for userns

When running in userns, returns error (i.e. "use naive, not native")
immediately.

No substantial change to the logic.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit 67aa418df2)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
Akihiro Suda 2021-03-23 15:17:10 +09:00
parent daae27bfce
commit 22dc1597b9
No known key found for this signature in database
GPG key ID: 49524C6F9F638F1A

View file

@ -10,6 +10,7 @@ import (
"path/filepath"
"syscall"
"github.com/containerd/containerd/sys"
"github.com/docker/docker/pkg/system"
"github.com/pkg/errors"
"golang.org/x/sys/unix"
@ -19,7 +20,14 @@ import (
// which copies up the opaque flag when copying up an opaque
// directory or the kernel enable CONFIG_OVERLAY_FS_REDIRECT_DIR.
// When these exist naive diff should be used.
//
// When running in a user namespace, returns errRunningInUserNS
// immediately.
func doesSupportNativeDiff(d string) error {
if sys.RunningInUserNS() {
return errors.New("running in a user namespace")
}
td, err := ioutil.TempDir(d, "opaque-bug-check")
if err != nil {
return err