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 _begin_fstest other auto quick clone realtime
14 # get standard environment
16 # real QA test starts here
18 _require_command "$INDENT_PROG" indent
20 # filter out known changes to xfs type sizes
23 # lazy SB adds __be32 agf_btreeblks - pv960372
24 if [ "$($MKFS_XFS_PROG 2>&1 | grep -c lazy-count )" == "0" ]; then
26 s/sizeof\( xfs_agf_t \) = 60/sizeof( xfs_agf_t ) = <SIZE>/;
30 s/sizeof\( xfs_agf_t \) = 64/sizeof( xfs_agf_t ) = <SIZE>/;
35 # filter out known changes to xfs type names
38 sed -e 's/xfs_bmbt_rec_64_t/xfs_bmbt_rec_t/'
43 sed -e 's/__attribute__ *[(][(]packed[)][)]//' \
47 cprog=$tmp.get_structs.c
48 oprog=$tmp.get_structs
56 # Certain headers must be included in a certain order...
57 for hdr in xfs.h xfs_types.h xfs_fs.h xfs_arch.h xfs_format.h; do
58 test -e "/usr/include/xfs/$hdr" && echo "#include <xfs/$hdr>" >> $cprog
60 # ...but be sure to pull in any new headers that might show up.
61 for hdr in /usr/include/xfs/xfs*.h; do
62 echo "#include <$(echo "$hdr" | sed -e 's|/usr/include/||g')>" >> $cprog
68 cat >$tmp.ignore <<EOF
101 xfs_inode_log_format_t
107 xfs_attr_list_context_t
116 xfs_buf_log_format_v1_t
125 xfs_dir2_data_entry_t
126 xfs_dir2_data_union_t
142 struct xfs_fsop_bulkreq
146 xfs_inobt_rec_incore_t
151 xfs_fsop_setdm_handlereq_t
152 xfs_fsop_attrlist_handlereq_t
154 xfs_fsop_attrmulti_handlereq_t
169 xfs_fsop_getparents_handlereq_t
171 struct xfs_iext_cursor
172 struct xfs_ino_geometry
174 struct xfs_attrlist_ent
175 struct xfs_legacy_ictimestamp
178 echo 'int main(int argc, char *argv[]) {' >>$cprog
181 # Printfs of typedef sizes
183 cat /usr/include/xfs/xfs*.h | indent |\
185 egrep '(} *xfs_.*_t|^struct xfs_[a-z0-9_]*$)' |\
186 egrep -v -f $tmp.ignore |\
187 sed -e 's/^.*}[[:space:]]*//g' -e 's/;.*$//g' -e 's/_t, /_t\n/g' |\
189 awk '{printf("printf(\"sizeof(%s) = \\%zu\\n\", sizeof(%s));\n", $0, $0);}' |\
193 # Look at offsets of key ones which differ in lengths
197 cat /usr/include/xfs/xfs*.h | indent |\
199 /typedef struct xfs_sb/ { structon = 1; next }
200 structon && $2 ~ /^sb_/ { sub(/[;,]/,"",$2)
201 sub(/XFSLABEL_MAX/,"12",$2)
202 printf("printf(\"offsetof(xfs_sb_t, %s) = \\%zu\\n\", offsetof(xfs_sb_t, %s));", $2, $2); next}
203 structon && /}/ { structon = 0; next}
206 echo 'return 0; }' >>$cprog
208 # create and run program
209 cc -o $oprog $cprog >> $seqres.full 2>&1 || \
210 _notrun "Could not compile test program (see end of $seqres.full)"
211 $oprog | _type_size_filter | _type_name_filter > $progout
213 # Find all the items that only exist in the golden output
214 comm -23 <(grep '=' $0.out | sed -e 's/ =.*$//g' | LC_COLLATE=POSIX sort) \
215 <(sed -e 's/ =.*$//g' < $progout | LC_COLLATE=POSIX sort) > $keyfile
217 # Copy those items to the program output
218 grep -F -f $keyfile $0.out >> $progout
220 LC_COLLATE=POSIX sort $progout