2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2006 Silicon Graphics, Inc. All Rights Reserved.
8 # Keep an eye on some of the xfs type sizes
9 # Motivation from differing ondisk types for 32 and 64 bit word versions.
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
20 # get standard environment
23 # real QA test starts here
26 _require_command "$INDENT_PROG" indent
30 # filter out known changes to xfs type sizes
33 # lazy SB adds __be32 agf_btreeblks - pv960372
34 if [ "$($MKFS_XFS_PROG 2>&1 | grep -c lazy-count )" == "0" ]; then
36 s/sizeof\( xfs_agf_t \) = 60/sizeof( xfs_agf_t ) = <SIZE>/;
40 s/sizeof\( xfs_agf_t \) = 64/sizeof( xfs_agf_t ) = <SIZE>/;
45 # filter out known changes to xfs type names
48 sed -e 's/xfs_bmbt_rec_64_t/xfs_bmbt_rec_t/'
53 sed -e 's/__attribute__ *[(][(]packed[)][)]//' \
57 cprog=$tmp.get_structs.c
58 oprog=$tmp.get_structs
66 # Certain headers must be included in a certain order...
67 for hdr in xfs.h xfs_types.h xfs_fs.h xfs_arch.h xfs_format.h; do
68 test -e "/usr/include/xfs/$hdr" && echo "#include <xfs/$hdr>" >> $cprog
70 # ...but be sure to pull in any new headers that might show up.
71 for hdr in /usr/include/xfs/xfs*.h; do
72 echo "#include <$(echo "$hdr" | sed -e 's|/usr/include/||g')>" >> $cprog
76 # xfs_attr_shortform_t
79 cat >$tmp.ignore <<EOF
112 xfs_inode_log_format_t
118 xfs_attr_list_context_t
127 xfs_buf_log_format_v1_t
136 xfs_dir2_data_entry_t
137 xfs_dir2_data_union_t
153 struct xfs_fsop_bulkreq
157 xfs_inobt_rec_incore_t
162 xfs_fsop_setdm_handlereq_t
163 xfs_fsop_attrlist_handlereq_t
165 xfs_fsop_attrmulti_handlereq_t
180 xfs_fsop_getparents_handlereq_t
182 struct xfs_iext_cursor
183 struct xfs_ino_geometry
185 struct xfs_attrlist_ent
188 echo 'int main(int argc, char *argv[]) {' >>$cprog
191 # Printfs of typedef sizes
193 cat /usr/include/xfs/xfs*.h | indent |\
195 egrep '(} *xfs_.*_t|^struct xfs_[a-z0-9_]*$)' |\
196 egrep -v -f $tmp.ignore |\
197 sed -e 's/^.*}[[:space:]]*//g' -e 's/;.*$//g' -e 's/_t, /_t\n/g' |\
199 awk '{printf("printf(\"sizeof(%s) = \\%zu\\n\", sizeof(%s));\n", $0, $0);}' |\
203 # Look at offsets of key ones which differ in lengths
207 cat /usr/include/xfs/xfs*.h | indent |\
209 /typedef struct xfs_sb/ { structon = 1; next }
210 structon && $2 ~ /^sb_/ { sub(/[;,]/,"",$2)
211 sub(/XFSLABEL_MAX/,"12",$2)
212 printf("printf(\"offsetof(xfs_sb_t, %s) = \\%zu\\n\", offsetof(xfs_sb_t, %s));", $2, $2); next}
213 structon && /}/ { structon = 0; next}
216 echo 'return 0; }' >>$cprog
218 # create and run program
219 cc -o $oprog $cprog >> $seqres.full 2>&1 || \
220 _notrun "Could not compile test program (see end of $seqres.full)"
221 $oprog | _type_size_filter | _type_name_filter > $progout
223 # Find all the items that only exist in the golden output
224 comm -23 <(grep '=' $0.out | sed -e 's/ =.*$//g' | LC_COLLATE=POSIX sort) \
225 <(sed -e 's/ =.*$//g' < $progout | LC_COLLATE=POSIX sort) > $keyfile
227 # Copy those items to the program output
228 grep -F -f $keyfile $0.out >> $progout
230 LC_COLLATE=POSIX sort $progout