2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2010 IBM Corporation. All Rights Reserved.
7 # Check if fallocate respects RLIMIT_FSIZE
10 _begin_fstest rw auto prealloc quick
12 # Override the default cleanup function.
17 sysctl -w kernel.core_pattern="$core_pattern" &>/dev/null
22 core_pattern=`sysctl -n kernel.core_pattern`
24 _register_cleanup "_cleanup" 25
26 # Import common functions.
28 # real QA test starts here
29 # generic, but xfs_io's fallocate must work
31 # only Linux supports fallocate
34 [ -n "$XFS_IO_PROG" ] || _notrun "xfs_io executable not found"
36 # Sanity check to see if fallocate works
37 _require_xfs_io_command "falloc"
39 # Check if we have good enough space available
40 avail=`df -P $TEST_DIR | awk 'END {print $4}'`
41 [ "$avail" -ge 104000 ] || _notrun "Test device is too small ($avail KiB)"
43 # Suppress core dumped messages
44 sysctl -w kernel.core_pattern=core &>/dev/null
47 # Set the FSIZE ulimit to 100MB and check
50 [ "$flim" != "unlimited" ] || _notrun "Unable to set FSIZE ulimit"
51 [ "$flim" -eq 102400 ] || _notrun "FSIZE ulimit is not correct (100 MB)"
53 echo "File size limit is now set to 100 MB."
54 echo "Let us try to preallocate 101 MB. This should fail."
55 $XFS_IO_PROG -f -c 'falloc 0 101m' $TEST_DIR/ouch
58 echo "Let us now try to preallocate 50 MB. This should succeed."
59 $XFS_IO_PROG -f -c 'falloc 0 50m' $TEST_DIR/ouch