0
  W   =ˆl–Ðz¾”*C]Še@9pMÜ”Å£�þZqñ,Ü¯8óòŒ.¼ð?Ÿà„ÀqÏå_‡I|¥�+"a–Ãa¾”Ò~êq@?q·î *bÑ¿ä ?÷     =#
# Functions used by several mount* scripts in initscripts package
#
# Sourcer must source /lib/lsb/init-functions.sh

# List available fstab files, including any files in /etc/fstab.d.
# This looks ugly, but we can't use find and it's safer than globbing.
fstab_files()
{
    echo /etc/fstab
    if [ -d /etc/fstab.d ]; then
        ls -1 /etc/fstab.d | grep '\.fstab$' | sed -e 's;^;/etc/fstab.d/;'
    fi
}

# $1: directory
is_empty_dir() {
	for FILE in $1/* $1/.*
	do
		case "$FILE" in
		  "$1/.*") return 0 ;;
		  "$1/*"|"$1/."|"$1/..") continue ;;
		  *) return 1 ;;
		esac
	done
	return 0
}


selinux_enabled () {
	which selinuxenabled >/dev/null 2>&1 && selinuxenabled
}

# Read /etc/fstab, looking for:
# 1) The root filesystem, resolving LABEL=*|UUID=*|PARTUUID=*|PARTLABEL=* entries
#	to the device node,
# 2) Swap that is on a md device or a file that may be on a md
#	device,
_read_fstab () {
	echo "fstabroot=/dev/root"
	echo "rootdev=none"
	echo "roottype=none"
	echo "rootopts=defaults"
	echo "rootmode=rw"
	echo "rootcheck=no"
	echo "swap_on_lv=no"
	echo "swap_on_file=no"

	fstab_files | while read file; do
		if [ -f "$file" ]; then
			while read DEV MTPT FSTYPE OPTS DUMP PASS JUNK; do
				case "$DEV" in
				  ""|\#*)
					continue
					;;
				  /dev/mapper/*)
					[ "$FSTYPE" = "swap" ] && echo swap_on_lv=yes
					;;
				  /dev/*)
					;;
				  LABEL=*|UUID=*|PARTUUID=*|PARTLABEL=*)
					if [ "$MTPT" = "/" ] && [ -x /sbin/findfs ]
					then
						DEV="$(findfs "$DEV")"
					fi
					;;
				  /*)
					[ "$FSTYPE" = "swap" ] && echo swap_on_file=yes
					;;
				  *)
					;;
				esac
				[ "$MTPT" != "/" ] && continue
				echo rootdev=\"$DEV\"
				echo fstabroot=\"$DEV\"
				echo rootopts=\"$OPTS\"
				echo roottype=\"$FSTYPE\"
				( [ "$PASS" != 0 ] && [ "$PASS" != "" ]   ) && echo rootcheck=yes
				( [ "$FSTYPE" = "nfs" ] || [ "$FSTYPE" = "nfs4" ] ) && echo rootcheck=no
				case "$OPTS" in
				  ro|ro,*|*,ro|*,ro,*)
					echo rootmode=ro
					;;
				esac
			done < "$file"
		fi
	done
}

# Parse /etc/fstab and set variables relating to:
# 1) The root filesystem:
#    - rootdev
#    - fstabroot
#    - rootopts
#    - roottype
#    - rootcheck
#    - rootmode
# 2) Swap:
#    - swap_on_file
#    - swap_on_lv

read_fstab () {
	eval "$(_read_fstab)"
}

# Find a specific fstab entry
# $1=mountpoint
# $2=fstype (optional)
_read_fstab_entry () {
	# Not found by default.
	echo "MNT_FSNAME="
	echo "MNT_DIR="
	echo "MNT_TYPE="
	echo "MNT_OPTS="
	echo "MNT_FREQ="
	echo "MNT_PASS="

	fstab_files | while read file; do
		if [ -f "$file" ]; then
			while read MNT_FSNAME MNT_DIR MNT_TYPE MNT_OPTS MNT_FREQ MNT_PASS MNT_JUNK; do
				case "$MNT_FSNAME" in
				  ""|\#*)
					continue;
					;;
				esac
				if [ "$MNT_DIR" = "$1" ]; then
					if [ -n "$2" ]; then
						[ "$MNT_TYPE" = "$2" ] || continue;
					fi
	                                echo "MNT_FSNAME=$MNT_FSNAME"
	                                echo "MNT_DIR=$MNT_DIR"
	                                echo "MNT_TYPE=$MNT_TYPE"
	                                echo "MNT_OPTS=$MNT_OPTS"
	                                echo "MNT_FREQ=$MNT_FREQ"
	                                echo "MNT_PASS=$MNT_PASS"
					break 2
				fi
				MNT_DIR=""
			done < "$file"
		fi
	done
}

# Find a specific fstab entry
# $1=mountpoint
# $2=fstype (optional)
# returns 0 on success, 1 on failure (not found or no fstab)
read_fstab_entry () {
	eval "$(_read_fstab_entry "$1" "$2")"

	# Not found by default.
	found=1
	if [ "$1" = "$MNT_DIR" ]; then
		found=0
	fi

	return $found
}

# Mount kernel and device file systems.
# $1: mount mode (mount, remount)
# $2: file system type
# $3: alternative file system type (or empty string if none)
# $4: mount point
# $5: mount device name
# $6... : extra mount program options
domount () {
	MOUNTMODE="$1"
	PRIFSTYPE="$2"
	ALTFSTYPE="$3"
	MTPT="$4"
	DEVNAME="$5"
	CALLER_OPTS="$6"

	KERNEL="$(uname -s)"
	# Figure out filesystem type from primary and alternative type
	FSTYP