#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2017 Intel Corporation.  All Rights Reserved.
#
# FS QA Test 452
#
# This is a regression test for kernel patch:
#   commit fd96b8da68d3 ("ext4: fix fault handling when mounted with -o dax,ro")
# created by Ross Zwisler <ross.zwisler@linux.intel.com>
#
. ./common/preamble
_begin_fstest auto quick dax

# Import common functions.
. ./common/filter

# Modify as appropriate.
_require_scratch

# we need to be able to execute binaries on scratch
_exclude_scratch_mount_option "noexec"

# format and mount
_scratch_mkfs > $seqres.full 2>&1
_scratch_mount >> $seqres.full 2>&1

# Resolve full absolute path to the ls binary. This is necessary for multi-call
# binaries. In multi-call binary setup "ls" is just a symlink to a binary (e.g.
# coreutils) which behaves as "ls" based on the executable name (first arg $0).
LS="$(realpath $(type -P ls))"
SCRATCH_LS=$SCRATCH_MNT/ls
cp $LS $SCRATCH_LS

$SCRATCH_LS $SCRATCH_LS | _filter_scratch

_scratch_remount ro

$SCRATCH_LS $SCRATCH_LS | _filter_scratch

# success, all done
status=0
exit
