1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or https://opensource.org/licenses/CDDL-1.0. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22# Portions Copyright 2021 iXsystems, Inc. 23# 24 25. $STF_SUITE/include/libtest.shlib 26 27# 28# DESCRIPTION: 29# 30# Verify crtime is functional with xattr=on|sa 31 32verify_runnable "both" 33 34# 35# The statx system call was first added in the 4.11 Linux kernel. Prior to this 36# change there was no mechanism to obtain birth time on Linux. Therefore, this 37# test is expected to fail on older kernels and is skipped. 38# 39if is_linux; then 40 if [[ $(linux_version) -lt $(linux_version "4.11") ]]; then 41 log_unsupported "Requires statx(2) system call on Linux" 42 fi 43 typeset stat_version=$(stat --version | awk '{ print $NF; exit }') 44 if compare_version_gte "8.30" "${stat_version}"; then 45 log_unsupported "Requires coreutils stat(1) > 8.30 on Linux" 46 fi 47fi 48 49log_assert "Verify crtime is functional." 50 51set -A args "sa" "on" 52typeset TESTFILE=$TESTDIR/testfile 53 54for arg in ${args[*]}; do 55 log_note "Testing with xattr set to $arg" 56 log_must zfs set xattr=$arg $TESTPOOL 57 rm -f $TESTFILE 58 log_must touch $TESTFILE 59 typeset -i crtime=$(stat_crtime $TESTFILE) 60 typeset -i ctime=$(stat_ctime $TESTFILE) 61 if (( crtime != ctime )); then 62 log_fail "Incorrect crtime ($crtime != $ctime)" 63 fi 64 log_must touch $TESTFILE 65 typeset -i crtime1=$(stat_crtime $TESTFILE) 66 if (( crtime1 != crtime )); then 67 log_fail "touch modified crtime ($crtime1 != $crtime)" 68 fi 69done 70 71log_pass "Verified crtime is functional." 72