blob: 038ab0f2c22710d004fbb951ac8a322d3f92912a [file] [log] [blame]
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 RedHat Inc. All Rights Reserved.
#
# FS QA Test 504
#
# Regression test case for kernel patch:
# fs/lock: skip lock owner pid translation in case we are in init_pid_ns
#
# Open new fd by exec shell built-in, then require exclusive lock
# by flock(1) command. Checking /proc/locks for the lock info.
#
. ./common/preamble
_begin_fstest auto quick locks
# Override the default cleanup function.
_cleanup()
{
exec {test_fd}<&-
cd /
rm -f $tmp.*
}
# Import common functions.
. ./common/filter
# real QA test starts here
_supported_fs generic
_require_test
_require_command "$FLOCK_PROG" "flock"
# Create test file and find its inode NO.
testfile=$TEST_DIR/flock_testfile_$seq
touch $testfile
tf_inode=$(stat -c %i $testfile)
echo inode $tf_inode >> $seqres.full
# Create new fd by exec
exec {test_fd}> $testfile
# flock locks the fd then exits, we should see the lock info even the owner is dead
flock -x $test_fd
cat /proc/locks >> $seqres.full
# Checking
grep -q ":$tf_inode " /proc/locks || echo "lock info not found"
# success, all done
status=0
echo "Silence is golden"
exit