xfs/122: mask wonky ioctls
[xfstests-dev.git] / tests / xfs / 122
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 122
6 #
7 # pv#952498
8 # Keep an eye on some of the xfs type sizes
9 # Motivation from differing ondisk types for 32 and 64 bit word versions.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
19
20 # get standard environment
21 . ./common/rc
22
23 # real QA test starts here
24 _supported_fs xfs
25 _supported_os Linux
26 _require_command "$INDENT_PROG" indent
27
28 rm -f $seqres.full
29
30 # filter out known changes to xfs type sizes
31 _type_size_filter()
32 {
33         # lazy SB adds __be32 agf_btreeblks - pv960372
34         if [ "$($MKFS_XFS_PROG 2>&1 | grep -c lazy-count )" == "0" ]; then
35                 perl -ne '
36 s/sizeof\( xfs_agf_t \) = 60/sizeof( xfs_agf_t ) = <SIZE>/;
37                 print;'
38         else
39                 perl -ne '
40 s/sizeof\( xfs_agf_t \) = 64/sizeof( xfs_agf_t ) = <SIZE>/;
41                 print;'
42         fi
43 }
44
45 # filter out known changes to xfs type names
46 _type_name_filter()
47 {
48         sed -e 's/xfs_bmbt_rec_64_t/xfs_bmbt_rec_t/'
49 }
50
51 _attribute_filter()
52 {
53         sed -e 's/__attribute__ *[(][(]packed[)][)]//' \
54             -e 's/__arch_pack//'
55 }
56
57 cprog=$tmp.get_structs.c
58 oprog=$tmp.get_structs
59 progout=$tmp.output
60 keyfile=$tmp.keys
61
62 cat >$cprog <<EOF
63 #define _GNU_SOURCE
64 #include <stdio.h>
65 EOF
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
69 done
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
73 done
74
75 # missing:
76 # xfs_attr_shortform_t
77 # xfs_trans_header_t
78
79 cat >$tmp.ignore <<EOF
80 xfs_buf_log_format_t
81 xfs_attr3_icleaf_hdr
82 xfs_da3_icnode_hdr
83 xfs_dir3_icfree_hdr
84 xfs_dir3_icleaf_hdr
85 xfs_name
86 xfs_owner_info
87 xfs_refcount_irec
88 xfs_rmap_irec
89 xfs_alloctype_t
90 xfs_buf_cancel_t
91 xfs_bmbt_rec_32_t
92 xfs_swapext_t
93 xfs_dirops_t
94 xfs_efi_log_item_t
95 xfs_efd_log_item_t
96 xfs_iocore_t
97 xfs_ihash_t
98 xfs_chashlist_t
99 xfs_chash_t
100 xfs_iptr_t
101 xfs_dmops_t
102 xfs_qmops_t
103 xfs_ioops_t
104 xfs_mod_sb_t
105 xfs_dqtrx_t
106 xfs_dqtrxops_t
107 xfs_ail_t
108 xfs_ail_entry_t
109 xfs_item_ops_t
110 xfs_log_busy_slot_t
111 xfs_log_busy_chunk_t
112 xfs_inode_log_format_t
113 xfs_efi_log_format_t
114 xfs_efd_log_format_t
115 xfs_perag_busy_t
116 xfs_perag_t
117 xfs_alloc_arg_t
118 xfs_attr_list_context_t
119 xfs_attr_sf_sort_t
120 xfs_bmbt_irec_t
121 xfs_bmbt_rec_host_t
122 xfs_bmap_free_item_t
123 xfs_bmap_free_t
124 xfs_bmalloca_t
125 xfs_btree_cur_t
126 xfs_buf_log_item_t
127 xfs_buf_log_format_v1_t
128 xfs_da_args_t
129 xfs_dabuf_t
130 xfs_da_state_blk_t
131 xfs_da_state_path_t
132 xfs_da_state_t
133 xfs_dinode_t
134 xfs_dircook_t
135 xfs_dir2_block_t
136 xfs_dir2_data_entry_t
137 xfs_dir2_data_union_t
138 xfs_dir2_data_t
139 xfs_dir2_put_args_t
140 xfs_dir_put_args_t
141 xfs_dir_sf_sort_t
142 xfs_extent_t
143 xfs_ext_irec_t
144 xfs_extdelta_t
145 xfs_flock64_t
146 xfs_fsop_geom_v1_t
147 xfs_growfs_data_t
148 xfs_growfs_rt_t
149 xfs_bstime_t
150 xfs_bstat_t
151 struct xfs_bstat
152 xfs_fsop_bulkreq_t
153 struct xfs_fsop_bulkreq
154 xfs_icsb_cnts_t
155 xfs_icdinode_t
156 xfs_ictimestamp_t
157 xfs_inobt_rec_incore_t
158 xfs_inogrp_t
159 struct xfs_inogrp
160 xfs_fid2_t
161 xfs_fsop_handlereq_t
162 xfs_fsop_setdm_handlereq_t
163 xfs_fsop_attrlist_handlereq_t
164 xfs_attr_multiop_t
165 xfs_fsop_attrmulti_handlereq_t
166 xfs_imap_t
167 xfs_ifork_t
168 xfs_inode_t
169 xfs_inode_log_item_t
170 xfs_log_iovec_t
171 xfs_log_callback_t
172 xfs_metablock_t
173 xfs_mount_t
174 xfs_sb_t
175 xfs_log_item_t
176 xfs_log_item_desc_t
177 xfs_log_item_chunk_t
178 xfs_trans_t
179 xfs_dirent_t
180 xfs_fsop_getparents_handlereq_t
181 xfs_dinode_core_t
182 struct xfs_iext_cursor
183 struct xfs_ino_geometry
184 EOF
185
186 echo 'int main(int argc, char *argv[]) {' >>$cprog
187
188 #
189 # Printfs of typedef sizes
190 #
191 cat /usr/include/xfs/xfs*.h | indent |\
192 _attribute_filter |\
193 egrep '(} *xfs_.*_t|^struct xfs_[a-z0-9_]*$)' |\
194 egrep -v -f $tmp.ignore |\
195 sed -e 's/^.*}[[:space:]]*//g' -e 's/;.*$//g' -e 's/_t, /_t\n/g' |\
196 sort | uniq |\
197 awk '{printf("printf(\"sizeof(%s) = \\%zu\\n\", sizeof(%s));\n", $0, $0);}' |\
198 cat >> $cprog
199
200 #
201 # Look at offsets of key ones which differ in lengths
202 #
203
204 # xfs_sb_t
205 cat /usr/include/xfs/xfs*.h | indent |\
206 awk '
207    /typedef struct xfs_sb/ { structon = 1; next }
208    structon && $2 ~ /^sb_/ { sub(/[;,]/,"",$2)
209                              sub(/XFSLABEL_MAX/,"12",$2)
210                              printf("printf(\"offsetof(xfs_sb_t, %s) = \\%zu\\n\", offsetof(xfs_sb_t, %s));", $2, $2); next}
211    structon && /}/ { structon = 0; next}
212 '>>$cprog
213
214 echo 'return 0; }' >>$cprog
215
216 # create and run program
217 cc -o $oprog $cprog >> $seqres.full 2>&1 || \
218   _notrun "Could not compile test program (see end of $seqres.full)"
219 $oprog | _type_size_filter | _type_name_filter > $progout
220
221 # Find all the items that only exist in the golden output
222 comm -23 <(grep '=' $0.out | sed -e 's/ =.*$//g' | LC_COLLATE=POSIX sort) \
223          <(sed -e 's/ =.*$//g' < $progout | LC_COLLATE=POSIX sort) > $keyfile
224
225 # Copy those items to the program output
226 grep -F -f $keyfile $0.out >> $progout
227
228 LC_COLLATE=POSIX sort $progout
229
230 status=0