#! /bin/bash # SPDX-License-Identifier: GPL-2.0 # Copyright (c) 2006 Silicon Graphics, Inc. All Rights Reserved. # # FS QA Test No. 122 # # pv#952498 # Keep an eye on some of the xfs type sizes # Motivation from differing ondisk types for 32 and 64 bit word versions. # seq=`basename $0` seqres=$RESULT_DIR/$seq echo "QA output created by $seq" here=`pwd` tmp=/tmp/$$ status=1 # failure is the default! trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15 # get standard environment . ./common/rc # real QA test starts here _supported_fs xfs _require_command "$INDENT_PROG" indent rm -f $seqres.full # filter out known changes to xfs type sizes _type_size_filter() { # lazy SB adds __be32 agf_btreeblks - pv960372 if [ "$($MKFS_XFS_PROG 2>&1 | grep -c lazy-count )" == "0" ]; then perl -ne ' s/sizeof\( xfs_agf_t \) = 60/sizeof( xfs_agf_t ) = /; print;' else perl -ne ' s/sizeof\( xfs_agf_t \) = 64/sizeof( xfs_agf_t ) = /; print;' fi } # filter out known changes to xfs type names _type_name_filter() { sed -e 's/xfs_bmbt_rec_64_t/xfs_bmbt_rec_t/' } _attribute_filter() { sed -e 's/__attribute__ *[(][(]packed[)][)]//' \ -e 's/__arch_pack//' } cprog=$tmp.get_structs.c oprog=$tmp.get_structs progout=$tmp.output keyfile=$tmp.keys cat >$cprog < EOF # Certain headers must be included in a certain order... for hdr in xfs.h xfs_types.h xfs_fs.h xfs_arch.h xfs_format.h; do test -e "/usr/include/xfs/$hdr" && echo "#include " >> $cprog done # ...but be sure to pull in any new headers that might show up. for hdr in /usr/include/xfs/xfs*.h; do echo "#include <$(echo "$hdr" | sed -e 's|/usr/include/||g')>" >> $cprog done # missing: # xfs_trans_header_t cat >$tmp.ignore <>$cprog # # Printfs of typedef sizes # cat /usr/include/xfs/xfs*.h | indent |\ _attribute_filter |\ egrep '(} *xfs_.*_t|^struct xfs_[a-z0-9_]*$)' |\ egrep -v -f $tmp.ignore |\ sed -e 's/^.*}[[:space:]]*//g' -e 's/;.*$//g' -e 's/_t, /_t\n/g' |\ sort | uniq |\ awk '{printf("printf(\"sizeof(%s) = \\%zu\\n\", sizeof(%s));\n", $0, $0);}' |\ cat >> $cprog # # Look at offsets of key ones which differ in lengths # # xfs_sb_t cat /usr/include/xfs/xfs*.h | indent |\ awk ' /typedef struct xfs_sb/ { structon = 1; next } structon && $2 ~ /^sb_/ { sub(/[;,]/,"",$2) sub(/XFSLABEL_MAX/,"12",$2) printf("printf(\"offsetof(xfs_sb_t, %s) = \\%zu\\n\", offsetof(xfs_sb_t, %s));", $2, $2); next} structon && /}/ { structon = 0; next} '>>$cprog echo 'return 0; }' >>$cprog # create and run program cc -o $oprog $cprog >> $seqres.full 2>&1 || \ _notrun "Could not compile test program (see end of $seqres.full)" $oprog | _type_size_filter | _type_name_filter > $progout # Find all the items that only exist in the golden output comm -23 <(grep '=' $0.out | sed -e 's/ =.*$//g' | LC_COLLATE=POSIX sort) \ <(sed -e 's/ =.*$//g' < $progout | LC_COLLATE=POSIX sort) > $keyfile # Copy those items to the program output grep -F -f $keyfile $0.out >> $progout LC_COLLATE=POSIX sort $progout status=0