5 # Keep an eye on some of the xfs type sizes
6 # Motivation from differing ondisk types for 32 and 64 bit word versions.
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2006 Silicon Graphics, Inc. All Rights Reserved.
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #-----------------------------------------------------------------------
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
36 # get standard environment
39 # real QA test starts here
42 _require_command "$INDENT_PROG" indent
46 # filter out known changes to xfs type sizes
49 # lazy SB adds __be32 agf_btreeblks - pv960372
50 if [ "$($MKFS_XFS_PROG 2>&1 | grep -c lazy-count )" == "0" ]; then
52 s/sizeof\( xfs_agf_t \) = 60/sizeof( xfs_agf_t ) = <SIZE>/;
56 s/sizeof\( xfs_agf_t \) = 64/sizeof( xfs_agf_t ) = <SIZE>/;
61 # filter out known changes to xfs type names
64 sed -e 's/xfs_bmbt_rec_64_t/xfs_bmbt_rec_t/'
69 sed -e 's/__attribute__ *[(][(]packed[)][)]//' \
73 cprog=$tmp.get_structs.c
74 oprog=$tmp.get_structs
82 for hdr in /usr/include/xfs/xfs*.h; do
83 echo "#include <$(echo "$hdr" | sed -e 's|/usr/include/||g')>" >> $cprog
87 # xfs_attr_shortform_t
90 cat >$tmp.ignore <<EOF
123 xfs_inode_log_format_t
129 xfs_attr_list_context_t
138 xfs_buf_log_format_v1_t
147 xfs_dir2_data_entry_t
148 xfs_dir2_data_union_t
166 xfs_inobt_rec_incore_t
170 xfs_fsop_setdm_handlereq_t
171 xfs_fsop_attrlist_handlereq_t
173 xfs_fsop_attrmulti_handlereq_t
188 xfs_fsop_getparents_handlereq_t
190 struct xfs_iext_cursor
193 echo 'int main(int argc, char *argv[]) {' >>$cprog
196 # Printfs of typedef sizes
198 cat /usr/include/xfs/xfs*.h | indent |\
200 egrep '(} *xfs_.*_t|^struct xfs_[a-z0-9_]*$)' |\
201 egrep -v -f $tmp.ignore |\
202 sed -e 's/^.*}[[:space:]]*//g' -e 's/;.*$//g' -e 's/_t, /_t\n/g' |\
204 awk '{printf("printf(\"sizeof(%s) = \\%zu\\n\", sizeof(%s));\n", $0, $0);}' |\
208 # Look at offsets of key ones which differ in lengths
212 cat /usr/include/xfs/xfs*.h | indent |\
214 /typedef struct xfs_sb/ { structon = 1; next }
215 structon && $2 ~ /^sb_/ { sub(/[;,]/,"",$2)
216 printf("printf(\"offsetof(xfs_sb_t, %s) = \\%zu\\n\", offsetof(xfs_sb_t, %s));", $2, $2); next}
217 structon && /}/ { structon = 0; next}
220 echo 'return 0; }' >>$cprog
222 # create and run program
223 cc -o $oprog $cprog >> $seqres.full 2>&1 || \
224 _notrun "Could not compile test program (see end of $seqres.full)"
225 $oprog | _type_size_filter | _type_name_filter > $progout
227 # Find all the items that only exist in the golden output
228 comm -23 <(grep '=' $0.out | sed -e 's/ =.*$//g' | LC_COLLATE=POSIX sort) \
229 <(sed -e 's/ =.*$//g' < $progout | LC_COLLATE=POSIX sort) > $keyfile
231 # Copy those items to the program output
232 grep -F -f $keyfile $0.out >> $progout
234 LC_COLLATE=POSIX sort $progout