function IMMUTABLE_ATTRIBUTE_MISSING {
	local FS=$1
	chattr +i $FS
}

function INODES_HIDDEN_BY_OVERLAY_MOUNT {
	local FS=$1
	
	declare -r FIND_OPTIONS='-xdev -depth -mindepth 1 -maxdepth 3'
	
	PARENT_FS="${FS%/*}/"
	if [[ ! -d $FS || ! -d $PARENT_FS ]]; then
		return 1
	fi

	TMP_DIR=$(mktemp --directory)
	mount --bind $PARENT_FS $TMP_DIR &&

	chattr -i $TMP_DIR/$FS &&

	find $TMP_DIR/$FS $FIND_OPTIONS \( -type f -o -type p \) -print0|
		xargs --null --no-run-if-empty rm --verbose &&

	find $TMP_DIR/$FS $FIND_OPTIONS -type d -print0|
		xargs --null --no-run-if-empty rmdir --verbose &&

	chattr +i $TMP_DIR/$FS &&
	umount $TMP_DIR
}

function VAR_TMP_FILES_FOUND {
	local DIR=$1

	find $DIR -xdev -mindepth 1 -type f -mtime +100 -print0 |
		xargs --null --no-run-if-empty rm --verbose
}

function EXT_RESUID {
	local FS_SPEC=$1
	local res_uid=0

	tune2fs -u $res_uid $FS_SPEC
	mount -o remount,resuid=$res_uid $FS_SPEC
}

function EXT_STRIPE {
	local FS_SPEC=$1

	tune2fs -E stride=0 $FS_SPEC
	tune2fs -E stripe_width=0 $FS_SPEC
	mount -o remount,stripe=0 $FS_SPEC
}

function USRMERGE {
	local USRMERGE_PACKAGES='usrmerge libfile-find-rule-perl libnumber-compare-perl libtext-glob-perl'

	chattr -i /
	apt-get install $USRMERGE_PACKAGES
	/usr/lib/convert-etc-shells
	/usr/lib/convert-usrmerge
	dpkg --purge $USRMERGE_PACKAGES
	chattr +i /
}

function LABEL_EXT34 {
	local fs_spec=${1%%:*}
	local label_req=${1##*:}

	e2label $fs_spec $label_req
}

function LABELFSTAB_EXT34 {
	local fstablabel_cur="${1%%:*}"
	local fstablabel_req="${1##*:}"

	sed -i "s/LABEL=${fstablabel_cur}/LABEL=${fstablabel_req}/" /etc/fstab
}
