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