#! /bin/bash # 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. # #----------------------------------------------------------------------- # Copyright (c) 2006 Silicon Graphics, Inc. All Rights Reserved. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation. # # This program is distributed in the hope that it would be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # #----------------------------------------------------------------------- # # creator owner=tes@sgi.com seq=`basename $0` 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 _supported_os Linux _require_command $INDENT_PROG "indent" # 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 } _attribute_filter() { sed -e 's/__attribute__ *[(][(]packed[)][)]//' \ -e 's/__arch_pack//' } cprog=$tmp.get_structs.c oprog=$tmp.get_structs progout=$tmp.output cat >$cprog < #include EOF cat >$tmp.ignore <>$cprog # # Printfs of typedef sizes # cat /usr/include/xfs/xfs*.h | indent |\ _attribute_filter |\ tee $seq.full |\ egrep '} *xfs_.*_t' |\ egrep -v -f $tmp.ignore |\ awk '{sub(/[;,]/,"",$2); print "printf(\"sizeof(", $2, ") = %d\\n\", sizeof(", $2, "));"}' \ >>$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) print "printf(\"offsetof(xfs_sb_t,", $2, ") = %d\\n\", offsetof(xfs_sb_t,", $2, "));"; next} structon && /}/ { structon = 0; next} '>>$cprog echo 'return 0; }' >>$cprog # create and run program cc -o $oprog $cprog >> $seq.full 2>&1 || \ _notrun "Could not compile test program (see end of $seq.full)" $oprog | _type_size_filter > $progout # # add addition sizes and xfs_sb_t fields that don't exist in the version # being tested. # # xfsprogs 2.9.8: sb_bad_features2 in pv 978822 if [ $XFSPROGS_VERSION -lt 20908 ]; then echo 'offsetof(xfs_sb_t, sb_bad_features2 ) = 204' >>$progout fi if [ $XFSPROGS_VERSION -lt 30000 ]; then echo 'sizeof( xfs_dsb_t ) = 208' >>$progout; fi LC_COLLATE=POSIX sort $progout status=0