Lines 784-789
Link Here
|
784 |
echo "${result# *}" |
784 |
echo "${result# *}" |
785 |
} |
785 |
} |
786 |
|
786 |
|
|
|
787 |
# bool is_clean(dir) |
788 |
# |
789 |
# Returns 0 if given directory has no files or has only dot-prefixed files. |
790 |
# |
791 |
# EXAMPLE: if is_clean /proc; then ... |
792 |
is_clean() { |
793 |
local f |
794 |
|
795 |
for f in $1/*; do |
796 |
[[ -e $f || -L $f ]] && return 1 |
797 |
done |
798 |
|
799 |
return 0 |
800 |
} |
801 |
|
802 |
# bool is_mounted(mount point, device) |
803 |
# |
804 |
# 'device' is optional. |
805 |
# |
806 |
# If no 'device' is specified, returns 0 if 'mount point' is really a mount |
807 |
# point or 1 if it's not. |
808 |
# |
809 |
# If 'device' is specified returns 0 if the exact 'device' is mounted under |
810 |
# 'mount point'. The check is done in /proc/mounts (for /proc there's check |
811 |
# for existence of /proc/mounts). Otherwise returns 2. |
812 |
# |
813 |
# EXAMPLE: if is_mounted /dev/pts devpts; then ... |
814 |
is_mounted() { |
815 |
local mnt_point="$1" dev="$2" |
816 |
|
817 |
mountpoint -q "${mnt_point}" || return 1 |
818 |
|
819 |
# Check if under $mnt_point really $dev is mounted |
820 |
if [[ ${dev} ]]; then |
821 |
if [[ ${dev} =~ ^/?proc$ ]]; then |
822 |
[[ -f /proc/mounts ]] || { |
823 |
eerror "Something else than 'procfs' is mounted under '/proc'!" |
824 |
return 2 |
825 |
} |
826 |
else |
827 |
[[ -f /proc/mounts ]] || eerror "No '/proc/mounts'. '/proc' have to be mounted!" |
828 |
[[ $(</proc/mounts) =~ /?${dev}\ .*${mnt_point}\ ]] && return 0 |
829 |
eerror "Another device is mounted under '${mnt_point}' where '${dev}' was expected!" |
830 |
return 2 |
831 |
fi |
832 |
fi |
833 |
} |
834 |
|
787 |
############################################################################## |
835 |
############################################################################## |
788 |
# # |
836 |
# # |
789 |
# This should be the last code in here, please add all functions above!! # |
837 |
# This should be the last code in here, please add all functions above!! # |