introduce several basic utility function

These utility function will be shared by several files, they are all
operation related to mount stuff.

Meantime define DEFAULT_PATH="/var/crash".

v5-> v6:
    Since in rhel7 nfs4 becomes default nfs version, and its fstype is
nfs4. So change the implementation of get_fs_type_from_target(),
whatever fstype returned from findmount, just echo nfs as fstype for all
nfs version.

v6->v7:
    Introduce is_fs_type_nfs to check if fstype is nfs or nfs4 per Vivek's
idea.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
Baoquan He 2014-04-11 20:26:59 +08:00 committed by WANG Chao
parent ed12e00218
commit b9185c78ee
2 changed files with 29 additions and 1 deletions

View File

@ -3,6 +3,7 @@
# Kdump common variables and functions
#
DEFAULT_PATH="/var/crash/"
FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump"
FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send"
@ -21,6 +22,13 @@ is_raw_dump_target()
grep -q "^raw" /etc/kdump.conf
}
is_fs_type_nfs()
{
local _fstype=$1
[ $_fstype = "nfs" ] || [ $_fstype = "nfs4" ] && return 0
return 1
}
strip_comments()
{
echo $@ | sed -e 's/\(.*\)#.*/\1/'
@ -82,6 +90,26 @@ get_root_fs_device()
return
}
get_mntpoint_from_path()
{
echo $(df $1 | tail -1 | awk '{print $NF}')
}
get_target_from_path()
{
echo $(df $1 | tail -1 | awk '{print $1}')
}
get_fs_type_from_target()
{
echo $(findmnt -k -f -n -r -o FSTYPE $1)
}
get_mntpoint_from_target()
{
echo $(findmnt -k -f -n -r -o TARGET $1)
}
# get_option_value <option_name>
# retrieves value of option defined in kdump.conf
get_option_value() {

View File

@ -12,7 +12,7 @@ export IN_KDUMP=1
conf_file="/etc/kdump.conf"
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2)
[ -z "$SAVE_PATH" ] && SAVE_PATH="/var/crash"
[ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH
extra_modules=""
dracut_args=("--hostonly" "-o" "plymouth dash resume")
OVERRIDE_RESETTABLE=0