From: Felipe Sateler <ffsateler@debian.org>
Date: Sat, 23 May 2015 17:00:30 -0300
Subject: Support union mounts with overlay, as in Linux 4.0

Bug: https://github.com/codelibre-net/schroot/issues/1
Signed-off-by: Felipe Sateler <ffsateler@debian.org>
Signed-off-by: Antonio Terceiro <terceiro@debian.org>
---
 etc/setup.d/10mount                 | 3 +++
 man/schroot.conf.5.man              | 4 ++--
 sbuild/sbuild-chroot-facet-union.cc | 1 +
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/etc/setup.d/10mount b/etc/setup.d/10mount
index bbfe118..04757c3 100755
--- a/etc/setup.d/10mount
+++ b/etc/setup.d/10mount
@@ -122,6 +122,9 @@ do_mount_fs_union()
             overlayfs)
                 CHROOT_UNION_MOUNT_OPTIONS="lowerdir=${CHROOT_UNION_UNDERLAY_DIRECTORY},upperdir=${CHROOT_UNION_OVERLAY_DIRECTORY}"
                 ;;
+            overlay)
+                mkdir -p ${CHROOT_UNION_OVERLAY_DIRECTORY}/upper ${CHROOT_UNION_OVERLAY_DIRECTORY}/work
+                CHROOT_UNION_MOUNT_OPTIONS="lowerdir=${CHROOT_UNION_UNDERLAY_DIRECTORY},upperdir=${CHROOT_UNION_OVERLAY_DIRECTORY}/upper,workdir=${CHROOT_UNION_OVERLAY_DIRECTORY}/work"
         esac
     fi
 
diff --git a/man/schroot.conf.5.man b/man/schroot.conf.5.man
index dc2dc5f..a5bf0ed 100644
--- a/man/schroot.conf.5.man
+++ b/man/schroot.conf.5.man
@@ -447,8 +447,8 @@ optional.
 .TP
 \f[CBI]union\-type=\fP\f[CI]type\fP
 Set the union filesystem type.  Currently supported filesystems are
-\[oq]aufs\[cq], \[oq]overlayfs\[cq] and \[oq]unionfs\[cq].  The default is
-\[oq]none\[cq], which disables this feature.
+\[oq]aufs\[cq], \[oq]overlayfs\[cq], \[oq]overlay\[cq] (as of Linux 4.0+) and
+\[oq]unionfs\[cq].  The default is \[oq]none\[cq], which disables this feature.
 .TP
 \f[CBI]union\-mount\-options=\fP\f[CI]options\fP
 Union filesystem mount options (branch configuration), used for mounting the
diff --git a/sbuild/sbuild-chroot-facet-union.cc b/sbuild/sbuild-chroot-facet-union.cc
index b5d8e5e..e1f11b6 100644
--- a/sbuild/sbuild-chroot-facet-union.cc
+++ b/sbuild/sbuild-chroot-facet-union.cc
@@ -136,6 +136,7 @@ void
 chroot_facet_union::set_union_type (std::string const& type)
 {
   if (type == "aufs" ||
+      type == "overlay" ||
       type == "overlayfs" ||
       type == "unionfs" ||
       type == "none")
