Index: branches/baselayout-1_12/sbin/functions.sh =================================================================== --- branches/baselayout-1_12/sbin/functions.sh (revision 3174) +++ branches/baselayout-1_12/sbin/functions.sh (working copy) @@ -784,6 +784,54 @@ echo "${result# *}" } +# bool is_clean(dir) +# +# Returns 0 if given directory has no files or has only dot-prefixed files. +# +# EXAMPLE: if is_clean /proc; then ... +is_clean() { + local f + + for f in $1/*; do + [[ -e $f || -L $f ]] && return 1 + done + + return 0 +} + +# bool is_mounted(mount point, device) +# +# 'device' is optional. +# +# If no 'device' is specified, returns 0 if 'mount point' is really a mount +# point or 1 if it's not. +# +# If 'device' is specified returns 0 if the exact 'device' is mounted under +# 'mount point'. The check is done in /proc/mounts (for /proc there's check +# for existence of /proc/mounts). Otherwise returns 2. +# +# EXAMPLE: if is_mounted /dev/pts devpts; then ... +is_mounted() { + local mnt_point="$1" dev="$2" + + mountpoint -q "${mnt_point}" || return 1 + + # Check if under $mnt_point really $dev is mounted + if [[ ${dev} ]]; then + if [[ ${dev} =~ ^/?proc$ ]]; then + [[ -f /proc/mounts ]] || { + eerror "Something else than 'procfs' is mounted under '/proc'!" + return 2 + } + else + [[ -f /proc/mounts ]] || eerror "No '/proc/mounts'. '/proc' have to be mounted!" + [[ $(