ab224c
#!/bin/bash --norc
ab224c
# New mkdumprd
ab224c
#
ab224c
# Copyright 2011 Red Hat, Inc.
ab224c
#
ab224c
# Written by Cong Wang <amwang@redhat.com>
ab224c
#
ab224c
ab224c
. /lib/kdump/kdump-lib.sh
ab224c
export IN_KDUMP=1
ab224c
ab224c
conf_file="/etc/kdump.conf"
ab224c
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
ab224c
SAVE_PATH=$(grep ^path $conf_file| cut -d' '  -f2)
1b417c
[ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH
ab224c
extra_modules=""
1b417c
dracut_args=("--hostonly" "--hostonly-cmdline" "-o" "plymouth dash resume")
ab224c
OVERRIDE_RESETTABLE=0
ab224c
ab224c
perror_exit() {
ab224c
    echo $@ >&2
ab224c
    exit 1
ab224c
}
ab224c
ab224c
perror() {
ab224c
    echo $@ >&2
ab224c
}
ab224c
ab224c
get_persistent_dev() {
ab224c
    local i _tmp _dev
ab224c
ab224c
    _dev=$(udevadm info --query=name --name="$1" 2>/dev/null)
ab224c
    [ -z "$_dev" ] && {
ab224c
        perror_exit "Kernel dev name of $1 is not found."
ab224c
    }
ab224c
ab224c
    for i in /dev/mapper/* /dev/disk/by-uuid/* /dev/disk/by-id/*; do
ab224c
        _tmp=$(udevadm info --query=name --name="$i" 2>/dev/null)
ab224c
        if [ "$_tmp" = "$_dev" ]; then
ab224c
            echo $i
ab224c
            return
ab224c
        fi
ab224c
    done
ab224c
ab224c
    perror "WARNING: Persistent device name of $1 not found. Using $1 as dump target name"
ab224c
    echo $1
ab224c
}
ab224c
ab224c
add_dracut_arg() {
ab224c
    local arg qarg is_quoted=0
ab224c
    while [ $# -gt 0 ];
ab224c
    do
ab224c
        arg="${1//\'/\"}"
ab224c
        #Handle quoted substring properly for passing it to dracut_args array.
ab224c
        if [ $is_quoted -eq 0 ]; then
ab224c
            if [[ "$arg" == "\"" ]] || [[ $arg != ${arg#\"} ]]; then
ab224c
                is_quoted=1
ab224c
                arg=${arg#\"}
ab224c
            fi
ab224c
        fi
ab224c
        if [ $is_quoted -eq 1 ]; then
ab224c
            qarg="$qarg $arg"
ab224c
            if [[ "$arg" == "\"" ]] || [[ $arg != ${arg%\"} ]]; then
ab224c
                is_quoted=0
ab224c
                arg=${qarg%\"}
ab224c
                qarg=""
ab224c
            else
ab224c
                shift
ab224c
                continue
ab224c
            fi
ab224c
        fi
ab224c
        dracut_args+=("$arg")
ab224c
        shift
ab224c
    done
ab224c
}
ab224c
ab224c
add_dracut_module() {
ab224c
    add_dracut_arg "--add" "$1"
ab224c
}
ab224c
ab224c
add_dracut_mount() {
ab224c
    add_dracut_arg "--mount" "$1"
ab224c
}
ab224c
ab224c
add_dracut_sshkey() {
ab224c
    add_dracut_arg "--sshkey" "$1"
ab224c
}
ab224c
ab224c
# Generic substring function.  If $2 is in $1, return 0.
ab224c
strstr() { [[ $1 =~ $2 ]]; }
ab224c
ab224c
target_is_root() {
ab224c
    local _t
ab224c
    _t=$(findmnt -k -n -r -o TARGET $1|sort|head -1)
ab224c
    [ "$_t" = "/" ]
ab224c
}
ab224c
ab224c
# caller should ensure $1 is valid and mounted in 1st kernel
ab224c
to_mount() {
1b417c
    local _dev=$1 _source _target _fstype _options _mntopts _pdev
1b417c
1b417c
    _source=$(findmnt -k -f -n -r -o SOURCE $_dev)
1b417c
    _target=$(findmnt -k -f -n -r -o TARGET $_dev)
1b417c
    # mount under /sysroot if dump to root disk or mount under
1b417c
    #/kdumproot/$_target in other cases in 2nd kernel. systemd
1b417c
    #will be in charge to umount it.
1b417c
1b417c
    if [ "$_target" = "/" ];then
1b417c
        _target="/sysroot"
1b417c
    else
1b417c
        _target="/kdumproot/$_target"
1b417c
    fi
1b417c
1b417c
    _fstype=$(findmnt -k -f -n -r -o FSTYPE $_dev)
1b417c
    _options=$(findmnt --fstab -f -n -r -o OPTIONS $_dev)
1b417c
    [ -z "$_options" ] && _options=$(findmnt -k -f -n -r -o OPTIONS $_dev)
1b417c
    _options=${_options/#ro/rw} #mount fs target as rw in 2nd kernel
1b417c
    # "x-initrd.mount" mount failure will trigger isolate emergency service
1b417c
    # W/o this, systemd won't isolate, thus we won't get to emergency.
1b417c
    # This is not applicable to remote fs mount, because if we use
1b417c
    # "x-initrd.mount", remote mount will become required by
1b417c
    # "initrd-root-fs.target", instead of "remote-fs.target". That's how it is
1b417c
    # handled within systemd internal. We need remote mount to be required
1b417c
    # "remote-fs.target", because we need to bring up network before any remote
1b417c
    # mount and "remote-fs.target" can be a checkpoint of that.
1b417c
    # If remote mount fails, dracut-initqueue will still start and once
1b417c
    # dracut-initqueue finishes, kdump service will start. Because remote mount
1b417c
    # failed, kdump service will fail and it will lead to kdump error handler.
1b417c
    if ! is_nfs_dump_target; then
1b417c
       _options="$_options,x-initrd.mount"
1b417c
    fi
1b417c
    _mntopts="$_target $_fstype $_options"
ab224c
    #for non-nfs _dev converting to use udev persistent name
1b417c
    if [ -b "$_source" ]; then
1b417c
        _pdev="$(get_persistent_dev $_source)"
ab224c
        if [ $? -ne 0 ]; then
ab224c
            return 1
ab224c
        fi
ab224c
ab224c
    else
ab224c
        _pdev=$_dev
ab224c
    fi
ab224c
ab224c
    echo "$_pdev $_mntopts"
ab224c
}
ab224c
ab224c
to_mount_point() {
ab224c
    echo $(findmnt -k -f -n -r -o TARGET $1)
ab224c
}
ab224c
ab224c
is_readonly_mount() {
ab224c
    local _mnt
ab224c
    _mnt=$(findmnt -k -f -n -r -o OPTIONS $1)
ab224c
ab224c
    #fs/proc_namespace.c: show_mountinfo():
ab224c
    #seq_puts(m, mnt->mnt_flags & MNT_READONLY ? " ro" : " rw");
ab224c
    [[ "$_mnt" =~ ^ro ]]
ab224c
}
ab224c
ab224c
#Function: get_ssh_size
ab224c
#$1=dump target
765b01
#called from while loop and shouldn't read from stdin, so we're using "ssh -n"
ab224c
get_ssh_size() {
ab224c
    local _opt _out _size
ab224c
    _opt="-i $SSH_KEY_LOCATION -o BatchMode=yes -o StrictHostKeyChecking=yes"
ab224c
    _out=$(ssh -q -n $_opt $1 "df -P $SAVE_PATH")
ab224c
    [ $? -ne 0 ] && {
ab224c
        perror_exit "checking remote ssh server available size failed."
ab224c
    }
765b01
765b01
    #ssh output removed the line break, so print field NF-2
765b01
    _size=$(echo -n $_out| awk '{avail=NF-2; print $avail}')
ab224c
    echo -n $_size
ab224c
}
ab224c
ab224c
#mkdir if save path does not exist on ssh dump target
ab224c
#$1=ssh dump target
ab224c
#caller should ensure write permission on $DUMP_TARGET:$SAVE_PATH
765b01
#called from while loop and shouldn't read from stdin, so we're using "ssh -n"
ab224c
mkdir_save_path_ssh()
ab224c
{
ab224c
    local _opt _dir
ab224c
    _opt="-i $SSH_KEY_LOCATION -o BatchMode=yes -o StrictHostKeyChecking=yes"
765b01
    ssh -qn $_opt $1 mkdir -p $SAVE_PATH 2>&1 > /dev/null
ab224c
    _ret=$?
ab224c
    if [ $_ret -ne 0 ]; then
ab224c
        perror_exit "mkdir failed on $DUMP_TARGET:$SAVE_PATH"
ab224c
    fi
ab224c
ab224c
    #check whether user has write permission on $SAVE_PATH/$DUMP_TARGET
ab224c
    _dir=$(ssh -qn $_opt $1 mktemp -dqp $SAVE_PATH 2>/dev/null)
ab224c
    _ret=$?
ab224c
    if [ $_ret -ne 0 ]; then
ab224c
        perror_exit "Could not create temporary directory on $DUMP_TARGET:$SAVE_PATH. Make sure user has write permission on destination"
ab224c
    fi
765b01
    ssh -qn $_opt $1 rmdir $_dir
ab224c
ab224c
    return 0
ab224c
}
ab224c
ab224c
#Function: get_fs_size
ab224c
#$1=dump target
ab224c
get_fs_size() {
ab224c
    local _mnt=$(to_mount_point $1)
ab224c
    echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}')
ab224c
}
ab224c
ab224c
#Function: get_raw_size
ab224c
#$1=dump target
ab224c
get_raw_size() {
ab224c
        echo -n $(fdisk -s "$1")
ab224c
}
ab224c
ab224c
#Function: check_size
ab224c
#$1: dump type string ('raw', 'fs', 'ssh')
ab224c
#$2: dump target
ab224c
check_size() {
ab224c
    local avail memtotal
ab224c
ab224c
    memtotal=$(awk '/MemTotal/{print $2}' /proc/meminfo)
ab224c
    case "$1" in
ab224c
        raw)
ab224c
            avail=$(get_raw_size "$2")
ab224c
            ;;
ab224c
        ssh)
ab224c
            avail=$(get_ssh_size "$2")
ab224c
            ;;
ab224c
        fs)
ab224c
            avail=$(get_fs_size "$2")
ab224c
            ;;
ab224c
        *)
ab224c
            return
ab224c
    esac
ab224c
ab224c
    if [ $? -ne 0 ]; then
ab224c
            perror_exit "Check dump target size failed"
ab224c
    fi
ab224c
ab224c
    if [ $avail -lt $memtotal ]; then
ab224c
        echo "Warning: There might not be enough space to save a vmcore."
ab224c
        echo "         The size of $2 should be greater than $memtotal kilo bytes."
ab224c
    fi
ab224c
}
ab224c
ab224c
# $1: core_collector config value
ab224c
verify_core_collector() {
ab224c
    if grep -q "^raw" $conf_file && [ "${1%% *}" != "makedumpfile" ]; then
ab224c
        echo "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually."
ab224c
    fi
ab224c
    if is_ssh_dump_target || is_raw_dump_target; then
ab224c
        if [ "${1%% *}" = "makedumpfile" ]; then
ab224c
            ! strstr "$1" "-F" && {
ab224c
                perror_exit "The specified dump target needs makedumpfile \"-F\" option."
ab224c
            }
ab224c
        fi
ab224c
    fi
ab224c
}
ab224c
ab224c
add_mount() {
ab224c
    if ! target_is_root "$1"; then
ab224c
        local _mnt=$(to_mount "$1")
ab224c
        if [ $? -ne 0 ]; then
ab224c
            exit 1
ab224c
        fi
ab224c
        add_dracut_mount "$_mnt"
ab224c
    fi
ab224c
}
ab224c
ab224c
# get_maj_min <device>
ab224c
# Prints the major and minor of a device node.
ab224c
# Example:
ab224c
# $ get_maj_min /dev/sda2
ab224c
# 8:2
ab224c
get_maj_min() {
ab224c
    local _dev
ab224c
    _dev=$(stat -L -c '$((0x%t)):$((0x%T))' "$1" 2>/dev/null)
ab224c
    _dev=$(eval "echo $_dev")
ab224c
    echo $_dev
ab224c
}
ab224c
ab224c
# ugly workaround for the lvm design
ab224c
# There is no volume group device,
ab224c
# so, there are no slave devices for volume groups.
ab224c
# Logical volumes only have the slave devices they really live on,
ab224c
# but you cannot create the logical volume without the volume group.
ab224c
# And the volume group might be bigger than the devices the LV needs.
ab224c
check_vol_slaves() {
ab224c
    local _lv _vg _pv
ab224c
    for i in /dev/mapper/*; do
ab224c
        _lv=$(get_maj_min $i)
ab224c
        if [[ $_lv = $2 ]]; then
ab224c
            _vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null)
ab224c
            # strip space
ab224c
            _vg=$(echo $_vg)
ab224c
            if [[ $_vg ]]; then
ab224c
                for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
ab224c
                do
ab224c
                    check_block_and_slaves $1 $(get_maj_min $_pv) && return 0
ab224c
                done
ab224c
            fi
ab224c
        fi
ab224c
    done
ab224c
    return 1
ab224c
}
ab224c
ab224c
# Walk all the slave relationships for a given block device.
ab224c
# Stop when our helper function returns success
ab224c
# $1 = function to call on every found block device
ab224c
# $2 = block device in major:minor format
ab224c
check_block_and_slaves() {
ab224c
    local _x
ab224c
    [[ -b /dev/block/$2 ]] || return 1 # Not a block device? So sorry.
ab224c
    "$1" $2 && return
ab224c
    check_vol_slaves "$@" && return 0
ab224c
    if [[ -f /sys/dev/block/$2/../dev ]]; then
ab224c
        check_block_and_slaves $1 $(cat "/sys/dev/block/$2/../dev") && return 0
ab224c
    fi
ab224c
    [[ -d /sys/dev/block/$2/slaves ]] || return 1
ab224c
    for _x in /sys/dev/block/$2/slaves/*/dev; do
ab224c
        [[ -f $_x ]] || continue
ab224c
        check_block_and_slaves $1 $(cat "$_x") && return 0
ab224c
    done
ab224c
    return 1
ab224c
}
ab224c
ab224c
to_dev_name() {
ab224c
    local dev="${1//\"/}"
ab224c
ab224c
    case "$dev" in
ab224c
    UUID=*)
ab224c
        dev=`blkid -U "${dev#UUID=}"`
ab224c
        ;;
ab224c
    LABEL=*)
ab224c
        dev=`blkid -L "${dev#LABEL=}"`
ab224c
        ;;
ab224c
    esac
ab224c
    echo $dev
ab224c
}
ab224c
ab224c
get_block_dump_target()
ab224c
{
ab224c
    local _target
ab224c
ab224c
765b01
    _target=$(get_user_configured_dump_disk)
ab224c
    [ -n "$_target" ] && echo $(to_dev_name $_target) && return
ab224c
ab224c
    #get rootfs device name
765b01
    _target=$(get_root_fs_device)
ab224c
    [ -b "$_target" ] && echo $(to_dev_name $_target)
ab224c
}
ab224c
1b417c
#handle the case user does not specify the dump target explicitly
1b417c
handle_default_dump_target()
765b01
{
765b01
    local _target
765b01
    local _mntpoint
1b417c
    local _fstype
765b01
765b01
    is_user_configured_dump_target && return
765b01
1b417c
    check_save_path_fs $SAVE_PATH
1b417c
1b417c
    _mntpoint=$(get_mntpoint_from_path $SAVE_PATH)
1b417c
    _target=$(get_target_from_path $SAVE_PATH)
1b417c
    if [ "$_mntpoint" != "/" ]; then
1b417c
        SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
1b417c
        _fstype=$(get_fs_type_from_target $_target)
1b417c
1b417c
        if $(is_fs_type_nfs $_fstype); then
1b417c
            add_dracut_module "nfs"
765b01
        fi
1b417c
1b417c
        add_mount "$_target"
1b417c
        check_size fs $_target
765b01
    fi
765b01
}
765b01
ab224c
get_default_action_target()
ab224c
{
ab224c
    local _target
ab224c
    local _action=$(grep "^default" /etc/kdump.conf 2>/dev/null | awk '{print $2}')
ab224c
    if [ -n "$_action" ] && [ "$_action" = "dump_to_rootfs" ]; then
ab224c
        #get rootfs device name
ab224c
        _target=$(findmnt -k -f -n -o SOURCE /)
ab224c
        [ -b "$_target" ] && echo $(to_dev_name $_target)
ab224c
    fi
ab224c
    return
ab224c
}
ab224c
ab224c
get_override_resettable()
ab224c
{
ab224c
    local override_resettable
ab224c
ab224c
    override_resettable=$(grep "^override_resettable" $conf_file)
ab224c
    if [ -n "$override_resettable" ]; then
ab224c
        OVERRIDE_RESETTABLE=$(echo $override_resettable | cut -d' '  -f2)
ab224c
        if [ "$OVERRIDE_RESETTABLE" != "0" ] && [ "$OVERRIDE_RESETTABLE" != "1" ];then
ab224c
            perror_exit "override_resettable value $OVERRIDE_RESETTABLE is invalid"
ab224c
        fi
ab224c
    fi
ab224c
}
ab224c
ab224c
ab224c
# $1: function name
ab224c
for_each_block_target()
ab224c
{
ab224c
    local dev majmin
ab224c
ab224c
    #check dump target
ab224c
    dev=$(get_block_dump_target)
ab224c
ab224c
    if [ -n "$dev" ]; then
ab224c
        majmin=$(get_maj_min $dev)
ab224c
        check_block_and_slaves $1 $majmin && return 1
ab224c
    fi
ab224c
ab224c
    #check rootfs when default action dump_to_rootfs is set
ab224c
    dev=$(get_default_action_target)
ab224c
    if [ -n "$dev" ]; then
ab224c
        majmin=$(get_maj_min $dev)
ab224c
        check_block_and_slaves $1 $majmin && return 2
ab224c
    fi
ab224c
ab224c
    return 0
ab224c
}
ab224c
ab224c
ab224c
ab224c
#judge if a specific device with $1 is unresettable
ab224c
#return false if unresettable.
ab224c
is_unresettable()
ab224c
{
ab224c
    local path="/sys/$(udevadm info --query=all --path=/sys/dev/block/$1 | awk '/^P:/ {print $2}' | sed -e 's/\(cciss[0-9]\+\/\).*/\1/g' -e 's/\/block\/.*$//')/resettable"
ab224c
    local resettable=1
ab224c
ab224c
    if [ -f "$path" ]
ab224c
    then
ab224c
        resettable="$(cat $path)"
ab224c
        [ $resettable -eq 0 -a "$OVERRIDE_RESETTABLE" -eq 0 ] && {
ab224c
            local device=$(udevadm info --query=all --path=/sys/dev/block/$1 | awk -F= '/DEVNAME/{print $2}')
ab224c
            echo "Device $device is unresettable"
ab224c
            return 0
ab224c
        }
ab224c
    fi
ab224c
ab224c
    return 1
ab224c
}
ab224c
ab224c
#check if machine is resettable.
ab224c
#return true if resettable
ab224c
check_resettable()
ab224c
{
ab224c
    local _ret _target
ab224c
ab224c
    get_override_resettable
ab224c
ab224c
    for_each_block_target is_unresettable
ab224c
    _ret=$?
ab224c
ab224c
    [ $_ret -eq 0 ] && return
ab224c
ab224c
    if [ $_ret -eq 1 ]; then
ab224c
        _target=$(get_block_dump_target)
ab224c
        perror "Can not save vmcore to target device $_target . This device can not be initialized in kdump kernel as it is not resettable"
ab224c
    elif [ $_ret -eq 2 ]; then
ab224c
        _target=$(get_default_action_target)
ab224c
        perror "Rootfs device $_target is not resettable, can not be used as the default target, please specify a default action"
ab224c
    fi
ab224c
ab224c
    return 1
ab224c
}
ab224c
ab224c
# $1: maj:min
ab224c
is_crypt()
ab224c
{
ab224c
    local majmin=$1 dev line ID_FS_TYPE=""
ab224c
ab224c
    line=$(udevadm info --query=property --path=/sys/dev/block/$majmin \
ab224c
            | grep "^ID_FS_TYPE")
ab224c
    eval "$line"
ab224c
    [[ "$ID_FS_TYPE" = "crypto_LUKS" ]] && {
ab224c
        dev=$(udevadm info --query=all --path=/sys/dev/block/$majmin | awk -F= '/DEVNAME/{print $2}')
765b01
        echo "Device $dev is encrypted."
ab224c
        return 0
ab224c
    }
ab224c
    return 1
ab224c
}
ab224c
ab224c
check_crypt()
ab224c
{
ab224c
    local _ret _target
ab224c
ab224c
    for_each_block_target is_crypt
ab224c
    _ret=$?
ab224c
ab224c
    [ $_ret -eq 0 ] && return
ab224c
ab224c
    return 1
ab224c
}
ab224c
765b01
if ! check_resettable; then
ab224c
    exit 1
ab224c
fi
ab224c
765b01
if ! check_crypt; then
765b01
    echo "Warning: Encrypted device is in dump path. User will prompted for password during second kernel boot."
765b01
fi
765b01
ab224c
# firstly get right SSH_KEY_LOCATION
ab224c
keyfile=$(awk '/^sshkey/ {print $2}' $conf_file)
ab224c
if [ -f "$keyfile" ]; then
ab224c
    # canonicalize the path
ab224c
    SSH_KEY_LOCATION=$(/usr/bin/readlink -m $keyfile)
ab224c
fi
ab224c
ab224c
if [ "$(uname -m)" = "s390x" ]; then
ab224c
    add_dracut_module "znet"
ab224c
fi
ab224c
ab224c
while read config_opt config_val;
ab224c
do
ab224c
    # remove inline comments after the end of a directive.
ab224c
    config_val=$(strip_comments $config_val)
ab224c
    case "$config_opt" in
ab224c
    extra_modules)
ab224c
        extra_modules="$extra_modules $config_val"
ab224c
        ;;
ab224c
    ext[234]|xfs|btrfs|minix|nfs)
ab224c
        if ! findmnt $config_val >/dev/null; then
ab224c
            perror_exit "Dump target $config_val is probably not mounted."
ab224c
        fi
ab224c
ab224c
        if [ "$config_opt" = "nfs" ]; then
ab224c
            add_dracut_module "nfs"
ab224c
        fi
ab224c
        add_mount "$config_val"
1b417c
        check_save_path_fs $(make_absolute_save_path $config_val)
ab224c
        check_size fs $config_val
ab224c
        ;;
ab224c
    raw)
ab224c
        #checking raw disk writable
ab224c
        dd if=$config_val count=1 of=/dev/null > /dev/null 2>&1 || {
ab224c
            perror_exit "Bad raw disk $config_val"
ab224c
        }
ab224c
        _praw=$(get_persistent_dev $config_val)
ab224c
        if [ $? -ne 0 ]; then
ab224c
            exit 1
ab224c
        fi
ab224c
        add_dracut_arg "--device" "$_praw"
ab224c
        check_size raw $config_val
ab224c
        ;;
ab224c
    ssh)
ab224c
        if strstr "$config_val" "@";
ab224c
        then
ab224c
            check_size ssh $config_val
ab224c
            mkdir_save_path_ssh $config_val
ab224c
            add_dracut_module "ssh-client"
ab224c
		add_dracut_sshkey "$SSH_KEY_LOCATION"
ab224c
        else
ab224c
            perror_exit "Bad ssh dump target $config_val"
ab224c
        fi
ab224c
        ;;
ab224c
    core_collector)
ab224c
        verify_core_collector "$config_val"
ab224c
        ;;
ab224c
    dracut_args)
ab224c
        add_dracut_arg $config_val
ab224c
        ;;
ab224c
    *)
ab224c
        if [ -n $(echo $config_opt | grep "^#.*$") ]
ab224c
        then
ab224c
            continue
ab224c
        fi
ab224c
        ;;
ab224c
    esac
ab224c
done < $conf_file
ab224c
1b417c
handle_default_dump_target
1b417c
ab224c
if [ -n "$extra_modules" ]
ab224c
then
ab224c
    add_dracut_arg "--add-drivers" "$extra_modules"
ab224c
fi
ab224c
ab224c
dracut "${dracut_args[@]}" "$@"
ab224c
_rc=$?
ab224c
sync
ab224c
exit $_rc