overlay: check if we can mknod() kernel whiteout

When checking if we can use the kernel's overlay filesystem, verify that
we can create whiteouts in the format the kernel expects (character
devices with major and minor of 0), and if we fail to do that, don't try
to use the kernel's overlay filesystem.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
Nalin Dahyabhai 2021-07-16 12:50:46 -04:00
parent 99e3f482c4
commit 8690ca73ce
1 changed files with 4 additions and 0 deletions

View File

@ -613,6 +613,10 @@ func supportsOverlay(home string, homeMagic graphdriver.FsMagic, rootUID, rootGI
if unshare.IsRootless() {
flags = fmt.Sprintf("%s,userxattr", flags)
}
if err := syscall.Mknod(filepath.Join(upperDir, "whiteout"), syscall.S_IFCHR|0600, int(unix.Mkdev(0, 0))); err != nil {
logrus.Debugf("unable to create kernel-style whiteout: %v", err)
return supportsDType, errors.Wrapf(err, "unable to create kernel-style whiteout")
}
if len(flags) < unix.Getpagesize() {
err := unix.Mount("overlay", mergedDir, "overlay", 0, flags)