#!/bin/bash

# (c) 2017 Heinlein Support GmbH
#          Robert Sander <r.sander@heinlein-support.de>

# This is free software;  you can redistribute it and/or modify it
# under the  terms of the  GNU General Public License  as published by
# the Free Software Foundation in version 2.  This file is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY;  with-
# out even the implied warranty of  MERCHANTABILITY  or  FITNESS FOR A
# PARTICULAR PURPOSE. See the  GNU General Public License for more de-
# ails.  You should have  received  a copy of the  GNU  General Public
# License along with GNU Make; see the file  COPYING.  If  not,  write
# to the Free Software Foundation, Inc., 51 Franklin St,  Fifth Floor,
# Boston, MA 02110-1301 USA.

awk '/aufs/ { print $2;}' < /proc/mounts | sort -u | while read dir; do
    msg=$(/bin/ls "$dir"/* 2>&1  1> /dev/null)
    res=$?
    if [ -z "$msg" ]; then
        msg="Overlay filesystem OK"
    fi
    echo "$res \"aufs $(echo $dir)\" - $msg"
done
