s4:torture:vfs_fruit: add size checks for resource fork IO
[samba.git] / source4 / torture / vfs / fruit.c
1 /*
2    Unix SMB/CIFS implementation.
3
4    vfs_fruit tests
5
6    Copyright (C) Ralph Boehme 2014
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #include "includes.h"
23 #include "system/filesys.h"
24 #include "libcli/libcli.h"
25 #include "libcli/smb2/smb2.h"
26 #include "libcli/smb2/smb2_calls.h"
27 #include "lib/cmdline/popt_common.h"
28 #include "param/param.h"
29 #include "libcli/resolve/resolve.h"
30 #include "MacExtensions.h"
31
32 #include "torture/torture.h"
33 #include "torture/util.h"
34 #include "torture/smb2/proto.h"
35 #include "torture/vfs/proto.h"
36
37 #define BASEDIR "vfs_fruit_dir"
38
39 #define CHECK_STATUS(status, correct) do { \
40         if (!NT_STATUS_EQUAL(status, correct)) { \
41                 torture_result(tctx, TORTURE_FAIL, \
42                     "(%s) Incorrect status %s - should be %s\n", \
43                     __location__, nt_errstr(status), nt_errstr(correct)); \
44                 ret = false; \
45                 goto done; \
46         }} while (0)
47
48 /*
49  * REVIEW:
50  * This is hokey, but what else can we do?
51  */
52 #if defined(HAVE_ATTROPEN) || defined(FREEBSD)
53 #define AFPINFO_EA_NETATALK "org.netatalk.Metadata"
54 #define AFPRESOURCE_EA_NETATALK "org.netatalk.ResourceFork"
55 #else
56 #define AFPINFO_EA_NETATALK "user.org.netatalk.Metadata"
57 #define AFPRESOURCE_EA_NETATALK "user.org.netatalk.ResourceFork"
58 #endif
59
60 /*
61 The metadata xattr char buf below contains the following attributes:
62
63 -------------------------------------------------------------------------------
64 Entry ID   : 00000008 : File Dates Info
65 Offset     : 00000162 : 354
66 Length     : 00000010 : 16
67
68 -DATE------:          : (GMT)                    : (Local)
69 create     : 1B442169 : Mon Jun 30 13:23:53 2014 : Mon Jun 30 15:23:53 2014
70 modify     : 1B442169 : Mon Jun 30 13:23:53 2014 : Mon Jun 30 15:23:53 2014
71 backup     : 80000000 : Unknown or Initial
72 access     : 1B442169 : Mon Jun 30 13:23:53 2014 : Mon Jun 30 15:23:53 2014
73
74 -RAW DUMP--:  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F : (ASCII)
75 00000000   : 1B 44 21 69 1B 44 21 69 80 00 00 00 1B 44 21 69 : .D!i.D!i.....D!i
76
77 -------------------------------------------------------------------------------
78 Entry ID   : 00000009 : Finder Info
79 Offset     : 0000007A : 122
80 Length     : 00000020 : 32
81
82 -FInfo-----:
83 Type       : 42415252 : BARR
84 Creator    : 464F4F4F : FOOO
85 isAlias    : 0
86 Invisible  : 1
87 hasBundle  : 0
88 nameLocked : 0
89 Stationery : 0
90 CustomIcon : 0
91 Reserved   : 0
92 Inited     : 0
93 NoINITS    : 0
94 Shared     : 0
95 SwitchLaunc: 0
96 Hidden Ext : 0
97 color      : 000      : none
98 isOnDesk   : 0
99 Location v : 0000     : 0
100 Location h : 0000     : 0
101 Fldr       : 0000     : ..
102
103 -FXInfo----:
104 Rsvd|IconID: 0000     : 0
105 Rsvd       : 0000     : ..
106 Rsvd       : 0000     : ..
107 Rsvd       : 0000     : ..
108 AreInvalid : 0
109 unknown bit: 0
110 unknown bit: 0
111 unknown bit: 0
112 unknown bit: 0
113 unknown bit: 0
114 unknown bit: 0
115 CustomBadge: 0
116 ObjctIsBusy: 0
117 unknown bit: 0
118 unknown bit: 0
119 unknown bit: 0
120 unknown bit: 0
121 RoutingInfo: 0
122 unknown bit: 0
123 unknown bit: 0
124 Rsvd|commnt: 0000     : 0
125 PutAway    : 00000000 : 0
126
127 -RAW DUMP--:  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F : (ASCII)
128 00000000   : 42 41 52 52 46 4F 4F 4F 40 00 00 00 00 00 00 00 : BARRFOOO@.......
129 00000010   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
130
131 -------------------------------------------------------------------------------
132 Entry ID   : 0000000E : AFP File Info
133 Offset     : 00000172 : 370
134 Length     : 00000004 : 4
135
136 -RAW DUMP--:  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F : (ASCII)
137 00000000   : 00 00 01 A1                                     : ....
138  */
139
140 char metadata_xattr[] = {
141         0x00, 0x05, 0x16, 0x07, 0x00, 0x02, 0x00, 0x00,
142         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
143         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
144         0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
145         0x00, 0x9a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
146         0x00, 0x08, 0x00, 0x00, 0x01, 0x62, 0x00, 0x00,
147         0x00, 0x10, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
148         0x00, 0x7a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
149         0x00, 0x0e, 0x00, 0x00, 0x01, 0x72, 0x00, 0x00,
150         0x00, 0x04, 0x80, 0x44, 0x45, 0x56, 0x00, 0x00,
151         0x01, 0x76, 0x00, 0x00, 0x00, 0x08, 0x80, 0x49,
152         0x4e, 0x4f, 0x00, 0x00, 0x01, 0x7e, 0x00, 0x00,
153         0x00, 0x08, 0x80, 0x53, 0x59, 0x4e, 0x00, 0x00,
154         0x01, 0x86, 0x00, 0x00, 0x00, 0x08, 0x80, 0x53,
155         0x56, 0x7e, 0x00, 0x00, 0x01, 0x8e, 0x00, 0x00,
156         0x00, 0x04, 0x42, 0x41, 0x52, 0x52, 0x46, 0x4f,
157         0x4f, 0x4f, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
158         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
159         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
160         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
161         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
162         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
163         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
164         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
165         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
166         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
167         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
168         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
169         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
170         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
171         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
172         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
173         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
174         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
175         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
176         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
177         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
178         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
179         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
180         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
181         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
182         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
183         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
184         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
185         0x00, 0x00, 0x1b, 0x44, 0x21, 0x69, 0x1b, 0x44,
186         0x21, 0x69, 0x80, 0x00, 0x00, 0x00, 0x1b, 0x44,
187         0x21, 0x69, 0x00, 0x00, 0x01, 0xa1, 0x00, 0xfd,
188         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x20,
189         0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf1, 0xe3,
190         0x86, 0x53, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x01,
191         0x00, 0x00
192 };
193
194 /*
195 The buf below contains the following AppleDouble encoded data:
196
197 -------------------------------------------------------------------------------
198 MagicNumber: 00051607                                        : AppleDouble
199 Version    : 00020000                                        : Version 2
200 Filler     : 4D 61 63 20 4F 53 20 58 20 20 20 20 20 20 20 20 : Mac OS X
201 Num. of ent: 0002                                            : 2
202
203 -------------------------------------------------------------------------------
204 Entry ID   : 00000009 : Finder Info
205 Offset     : 00000032 : 50
206 Length     : 00000EB0 : 3760
207
208 -FInfo-----:
209 Type       : 54455854 : TEXT
210 Creator    : 21526368 : !Rch
211 ...
212
213 -EA--------:
214 pad        : 0000     : ..
215 magic      : 41545452 : ATTR
216 debug_tag  : 0007F98E : 522638
217 total_size : 00000EE2 : 3810
218 data_start : 00000078 : 120
219 data_length: 00000000 : 0
220 reserved[0]: 00000000 : ....
221 reserved[1]: 00000000 : ....
222 reserved[2]: 00000000 : ....
223 flags      : 0000     : ..
224 num_attrs  : 0000     : 0
225
226 -------------------------------------------------------------------------------
227 Entry ID   : 00000002 : Resource Fork
228 Offset     : 00000EE2 : 3810
229 Length     : 0000011E : 286
230
231 -RAW DUMP--:  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F : (ASCII)
232 00000000   : 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 1E : ................
233 00000010   : 54 68 69 73 20 72 65 73 6F 75 72 63 65 20 66 6F : This resource fo
234 00000020   : 72 6B 20 69 6E 74 65 6E 74 69 6F 6E 61 6C 6C 79 : rk intentionally
235 00000030   : 20 6C 65 66 74 20 62 6C 61 6E 6B 20 20 20 00 00 :  left blank   ..
236 ...
237 00000110   : 00 00 00 00 00 00 00 00 00 1C 00 1E FF FF       : ..............
238 */
239 static char osx_adouble_w_xattr[] = {
240         0x00, 0x05, 0x16, 0x07, 0x00, 0x02, 0x00, 0x00,
241         0x4d, 0x61, 0x63, 0x20, 0x4f, 0x53, 0x20, 0x58,
242         0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
243         0x00, 0x02, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
244         0x00, 0x32, 0x00, 0x00, 0x0e, 0xb0, 0x00, 0x00,
245         0x00, 0x02, 0x00, 0x00, 0x0e, 0xe2, 0x00, 0x00,
246         0x01, 0x1e, 0x54, 0x45, 0x58, 0x54, 0x21, 0x52,
247         0x63, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
248         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
249         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
250         0x00, 0x00, 0x00, 0x00, 0x41, 0x54, 0x54, 0x52,
251         0x00, 0x07, 0xf9, 0x8e, 0x00, 0x00, 0x0e, 0xe2,
252         0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00,
253         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
254         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
255         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
256         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
257         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
258         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
259         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
260         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
261         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
262         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
263         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
264         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
265         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
266         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
267         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
268         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
269         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
270         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
271         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
272         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
273         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
274         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
275         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
276         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
277         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
278         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
279         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
280         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
281         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
282         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
283         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
284         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
285         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
286         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
287         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
288         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
289         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
290         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
291         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
292         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
293         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
294         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
295         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
296         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
297         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
298         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
299         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
300         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
301         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
302         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
303         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
304         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
305         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
306         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
307         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
308         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
309         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
310         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
311         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
312         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
313         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
314         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
315         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
316         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
317         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
318         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
319         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
320         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
321         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
322         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
323         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
324         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
325         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
326         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
327         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
328         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
329         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
330         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
331         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
332         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
333         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
334         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
335         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
336         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
337         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
338         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
339         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
340         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
341         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
342         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
343         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
344         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
345         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
346         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
347         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
348         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
349         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
350         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
351         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
352         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
353         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
354         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
355         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
356         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
357         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
358         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
359         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
360         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
361         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
362         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
363         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
364         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
365         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
366         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
367         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
368         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
369         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
370         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
371         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
372         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
373         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
374         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
375         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
376         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
377         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
378         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
379         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
380         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
381         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
382         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
383         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
384         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
385         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
386         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
387         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
388         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
389         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
390         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
391         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
392         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
393         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
394         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
395         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
396         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
397         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
398         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
399         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
400         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
401         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
402         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
403         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
404         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
405         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
406         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
407         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
408         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
409         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
410         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
411         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
412         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
413         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
414         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
415         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
416         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
417         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
418         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
419         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
420         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
421         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
422         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
423         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
424         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
425         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
426         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
427         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
428         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
429         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
430         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
431         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
432         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
433         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
434         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
435         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
436         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
437         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
438         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
439         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
440         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
441         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
442         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
443         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
444         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
445         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
446         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
447         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
448         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
449         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
450         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
451         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
452         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
453         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
454         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
455         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
456         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
457         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
458         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
459         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
460         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
461         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
462         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
463         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
464         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
465         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
466         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
467         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
468         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
469         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
470         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
471         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
472         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
473         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
474         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
475         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
476         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
477         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
478         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
479         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
480         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
481         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
482         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
483         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
484         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
485         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
486         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
487         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
488         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
489         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
490         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
491         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
492         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
493         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
494         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
495         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
496         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
497         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
498         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
499         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
500         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
501         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
502         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
503         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
504         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
505         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
506         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
507         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
508         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
509         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
510         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
511         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
512         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
513         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
514         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
515         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
516         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
517         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
518         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
519         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
520         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
521         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
522         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
523         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
524         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
525         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
526         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
527         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
528         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
529         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
530         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
531         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
532         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
533         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
534         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
535         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
536         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
537         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
538         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
539         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
540         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
541         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
542         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
543         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
544         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
545         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
546         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
547         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
548         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
549         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
550         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
551         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
552         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
553         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
554         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
555         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
556         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
557         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
558         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
559         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
560         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
561         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
562         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
563         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
564         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
565         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
566         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
567         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
568         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
569         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
570         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
571         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
572         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
573         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
574         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
575         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
576         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
577         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
578         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
579         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
580         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
581         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
582         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
583         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
584         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
585         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
586         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
587         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
588         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
589         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
590         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
591         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
592         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
593         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
594         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
595         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
596         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
597         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
598         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
599         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
600         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
601         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
602         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
603         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
604         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
605         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
606         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
607         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
608         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
609         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
610         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
611         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
612         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
613         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
614         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
615         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
616         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
617         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
618         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
619         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
620         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
621         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
622         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
623         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
624         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
625         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
626         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
627         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
628         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
629         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
630         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
631         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
632         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
633         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
634         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
635         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
636         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
637         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
638         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
639         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
640         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
641         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
642         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
643         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
644         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
645         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
646         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
647         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
648         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
649         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
650         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
651         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
652         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
653         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
654         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
655         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
656         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
657         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
658         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
659         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
660         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
661         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
662         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
663         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
664         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
665         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
666         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
667         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
668         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
669         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
670         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
671         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
672         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
673         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
674         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
675         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
676         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
677         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
678         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
679         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
680         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
681         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
682         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
683         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
684         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
685         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
686         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
687         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
688         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
689         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
690         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
691         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
692         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
693         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
694         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
695         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
696         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
697         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
698         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
699         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
700         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
701         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
702         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
703         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
704         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
705         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
706         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
707         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
708         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
709         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
710         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
711         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
712         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
713         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
714         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
715         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
716         0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
717         0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
718         0x00, 0x1e, 0x54, 0x68, 0x69, 0x73, 0x20, 0x72,
719         0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20,
720         0x66, 0x6f, 0x72, 0x6b, 0x20, 0x69, 0x6e, 0x74,
721         0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c,
722         0x6c, 0x79, 0x20, 0x6c, 0x65, 0x66, 0x74, 0x20,
723         0x62, 0x6c, 0x61, 0x6e, 0x6b, 0x20, 0x20, 0x20,
724         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
725         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
726         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
727         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
728         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
729         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
730         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
731         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
732         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
733         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
734         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
735         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
736         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
737         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
738         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
739         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
740         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
741         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
742         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
743         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
744         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
745         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
746         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
747         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
748         0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
749         0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
750         0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
751         0x00, 0x00, 0x00, 0x1c, 0x00, 0x1e, 0xff, 0xff
752 };
753
754 /**
755  * talloc and intialize an AfpInfo
756  **/
757 static AfpInfo *torture_afpinfo_new(TALLOC_CTX *mem_ctx)
758 {
759         AfpInfo *info;
760
761         info = talloc_zero(mem_ctx, AfpInfo);
762         if (info == NULL) {
763                 return NULL;
764         }
765
766         info->afpi_Signature = AFP_Signature;
767         info->afpi_Version = AFP_Version;
768         info->afpi_BackupTime = AFP_BackupTime;
769
770         return info;
771 }
772
773 /**
774  * Pack AfpInfo into a talloced buffer
775  **/
776 static char *torture_afpinfo_pack(TALLOC_CTX *mem_ctx,
777                                   AfpInfo *info)
778 {
779         char *buf;
780
781         buf = talloc_array(mem_ctx, char, AFP_INFO_SIZE);
782         if (buf == NULL) {
783                 return NULL;
784         }
785
786         RSIVAL(buf, 0, info->afpi_Signature);
787         RSIVAL(buf, 4, info->afpi_Version);
788         RSIVAL(buf, 12, info->afpi_BackupTime);
789         memcpy(buf + 16, info->afpi_FinderInfo, sizeof(info->afpi_FinderInfo));
790
791         return buf;
792 }
793
794 /**
795  * Unpack AfpInfo
796  **/
797 #if 0
798 static void torture_afpinfo_unpack(AfpInfo *info, char *data)
799 {
800         info->afpi_Signature = RIVAL(data, 0);
801         info->afpi_Version = RIVAL(data, 4);
802         info->afpi_BackupTime = RIVAL(data, 12);
803         memcpy(info->afpi_FinderInfo, (const char *)data + 16,
804                sizeof(info->afpi_FinderInfo));
805 }
806 #endif
807
808 static bool torture_write_afpinfo(struct smb2_tree *tree,
809                                   struct torture_context *tctx,
810                                   TALLOC_CTX *mem_ctx,
811                                   const char *fname,
812                                   AfpInfo *info)
813 {
814         struct smb2_handle handle;
815         struct smb2_create io;
816         NTSTATUS status;
817         const char *full_name;
818         char *infobuf;
819         bool ret = true;
820
821         full_name = talloc_asprintf(mem_ctx, "%s%s", fname, AFPINFO_STREAM);
822         if (full_name == NULL) {
823             torture_comment(tctx, "talloc_asprintf error\n");
824             return false;
825         }
826         ZERO_STRUCT(io);
827         io.in.desired_access = SEC_FILE_WRITE_DATA;
828         io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
829         io.in.create_disposition = NTCREATEX_DISP_OVERWRITE_IF;
830         io.in.create_options = 0;
831         io.in.fname = full_name;
832
833         status = smb2_create(tree, mem_ctx, &io);
834         CHECK_STATUS(status, NT_STATUS_OK);
835
836         handle = io.out.file.handle;
837
838         infobuf = torture_afpinfo_pack(mem_ctx, info);
839         if (infobuf == NULL) {
840                 return false;
841         }
842
843         status = smb2_util_write(tree, handle, infobuf, 0, AFP_INFO_SIZE);
844         CHECK_STATUS(status, NT_STATUS_OK);
845
846         smb2_util_close(tree, handle);
847
848 done:
849         return ret;
850 }
851
852 /**
853  * Read 'count' bytes at 'offset' from stream 'fname:sname' and
854  * compare against buffer 'value'
855  **/
856 static bool check_stream(struct smb2_tree *tree,
857                          const char *location,
858                          struct torture_context *tctx,
859                          TALLOC_CTX *mem_ctx,
860                          const char *fname,
861                          const char *sname,
862                          off_t read_offset,
863                          size_t read_count,
864                          off_t comp_offset,
865                          size_t comp_count,
866                          const char *value)
867 {
868         struct smb2_handle handle;
869         struct smb2_create create;
870         struct smb2_read r;
871         NTSTATUS status;
872         const char *full_name;
873
874         full_name = talloc_asprintf(mem_ctx, "%s%s", fname, sname);
875         if (full_name == NULL) {
876             torture_comment(tctx, "talloc_asprintf error\n");
877             return false;
878         }
879         ZERO_STRUCT(create);
880         create.in.desired_access = SEC_FILE_READ_DATA;
881         create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
882         create.in.create_disposition = NTCREATEX_DISP_OPEN;
883         create.in.fname = full_name;
884
885         torture_comment(tctx, "Open stream %s\n", full_name);
886
887         status = smb2_create(tree, mem_ctx, &create);
888         if (!NT_STATUS_IS_OK(status)) {
889                 if (value == NULL) {
890                         return true;
891                 } else {
892                         torture_comment(tctx, "Unable to open stream %s\n",
893                             full_name);
894                         sleep(10000000);
895                         return false;
896                 }
897         }
898
899         handle = create.out.file.handle;
900         if (value == NULL) {
901                 return true;
902         }
903
904
905         ZERO_STRUCT(r);
906         r.in.file.handle = handle;
907         r.in.length      = read_count;
908         r.in.offset      = read_offset;
909
910         status = smb2_read(tree, tree, &r);
911
912         if (!NT_STATUS_IS_OK(status)) {
913                 torture_comment(tctx, "(%s) Failed to read %lu bytes from "
914                     "stream '%s'\n", location, (long)strlen(value), full_name);
915                 return false;
916         }
917
918         if (memcmp(r.out.data.data + comp_offset, value, comp_count) != 0) {
919                 torture_comment(tctx, "(%s) Bad data in stream\n", location);
920                 return false;
921         }
922
923         smb2_util_close(tree, handle);
924         return true;
925 }
926
927 /**
928  * Read 'count' bytes at 'offset' from stream 'fname:sname' and
929  * compare against buffer 'value'
930  **/
931 static bool write_stream(struct smb2_tree *tree,
932                          const char *location,
933                          struct torture_context *tctx,
934                          TALLOC_CTX *mem_ctx,
935                          const char *fname,
936                          const char *sname,
937                          off_t offset,
938                          size_t size,
939                          const char *value)
940 {
941         struct smb2_handle handle;
942         struct smb2_create create;
943         NTSTATUS status;
944         const char *full_name;
945
946         full_name = talloc_asprintf(mem_ctx, "%s%s", fname, sname);
947         if (full_name == NULL) {
948             torture_comment(tctx, "talloc_asprintf error\n");
949             return false;
950         }
951         ZERO_STRUCT(create);
952         create.in.desired_access = SEC_FILE_WRITE_DATA;
953         create.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
954         create.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
955         create.in.fname = full_name;
956
957         status = smb2_create(tree, mem_ctx, &create);
958         if (!NT_STATUS_IS_OK(status)) {
959                 if (value == NULL) {
960                         return true;
961                 } else {
962                         torture_comment(tctx, "Unable to open stream %s\n",
963                             full_name);
964                         sleep(10000000);
965                         return false;
966                 }
967         }
968
969         handle = create.out.file.handle;
970         if (value == NULL) {
971                 return true;
972         }
973
974         status = smb2_util_write(tree, handle, value, offset, size);
975
976         if (!NT_STATUS_IS_OK(status)) {
977                 torture_comment(tctx, "(%s) Failed to write %lu bytes to "
978                     "stream '%s'\n", location, (long)size, full_name);
979                 return false;
980         }
981
982         smb2_util_close(tree, handle);
983         return true;
984 }
985
986 static bool torture_setup_local_xattr(struct torture_context *tctx,
987                                       const char *path_option,
988                                       const char *name,
989                                       const char *metadata,
990                                       size_t size)
991 {
992         int ret = true;
993         int result;
994         const char *spath;
995         char *path;
996
997         spath = torture_setting_string(tctx, path_option, NULL);
998         if (spath == NULL) {
999                 printf("No sharepath for option %s\n", path_option);
1000                 return false;
1001         }
1002
1003         path = talloc_asprintf(tctx, "%s/%s", spath, name);
1004
1005         result = setxattr(path, AFPINFO_EA_NETATALK, metadata, size, 0);
1006         if (result != 0) {
1007                 ret = false;
1008         }
1009
1010         TALLOC_FREE(path);
1011
1012         return ret;
1013 }
1014
1015 static bool torture_setup_local_file(struct torture_context *tctx,
1016                                      const char *path_option,
1017                                      const char *name,
1018                                      const char *buf,
1019                                      size_t size)
1020 {
1021         int fd;
1022         const char *spath;
1023         char *path;
1024         ssize_t rsize;
1025
1026         spath = torture_setting_string(tctx, path_option, NULL);
1027         if (spath == NULL) {
1028                 printf("No sharepath for option %s\n", path_option);
1029                 return false;
1030         }
1031
1032         path = talloc_asprintf(tctx, "%s/%s", spath, name);
1033         if (path == NULL) {
1034                 return false;
1035         }
1036
1037         fd = creat(path, S_IRWXU);
1038         TALLOC_FREE(path);
1039         if (fd == -1) {
1040                 return false;
1041         }
1042
1043         if ((buf == NULL) || (size == 0)) {
1044                 close(fd);
1045                 return true;
1046         }
1047
1048         rsize = write(fd, buf, size);
1049         if (rsize != size) {
1050                 return false;
1051         }
1052
1053         close(fd);
1054
1055         return true;
1056 }
1057
1058 /**
1059  * Create a file or directory
1060  **/
1061 static bool torture_setup_file(TALLOC_CTX *mem_ctx, struct smb2_tree *tree,
1062                                const char *name, bool dir)
1063 {
1064         struct smb2_create io;
1065         NTSTATUS status;
1066
1067         smb2_util_unlink(tree, name);
1068         ZERO_STRUCT(io);
1069         io.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
1070         io.in.file_attributes   = FILE_ATTRIBUTE_NORMAL;
1071         io.in.create_disposition = NTCREATEX_DISP_OVERWRITE_IF;
1072         io.in.share_access =
1073                 NTCREATEX_SHARE_ACCESS_DELETE|
1074                 NTCREATEX_SHARE_ACCESS_READ|
1075                 NTCREATEX_SHARE_ACCESS_WRITE;
1076         io.in.create_options = 0;
1077         io.in.fname = name;
1078         if (dir) {
1079                 io.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
1080                 io.in.share_access &= ~NTCREATEX_SHARE_ACCESS_DELETE;
1081                 io.in.file_attributes   = FILE_ATTRIBUTE_DIRECTORY;
1082                 io.in.create_disposition = NTCREATEX_DISP_CREATE;
1083         }
1084
1085         status = smb2_create(tree, mem_ctx, &io);
1086         if (!NT_STATUS_IS_OK(status)) {
1087                 return false;
1088         }
1089
1090         status = smb2_util_close(tree, io.out.file.handle);
1091         if (!NT_STATUS_IS_OK(status)) {
1092                 return false;
1093         }
1094
1095         return true;
1096 }
1097
1098 static bool test_read_atalk_metadata(struct torture_context *tctx,
1099                                      struct smb2_tree *tree1,
1100                                      struct smb2_tree *tree2)
1101 {
1102         TALLOC_CTX *mem_ctx = talloc_new(tctx);
1103         const char *fname = BASEDIR "\\torture_read_metadata";
1104         NTSTATUS status;
1105         struct smb2_handle testdirh;
1106         bool ret = true;
1107
1108         torture_comment(tctx, "Checking metadata access\n");
1109
1110         smb2_util_unlink(tree1, fname);
1111
1112         status = torture_smb2_testdir(tree1, BASEDIR, &testdirh);
1113         CHECK_STATUS(status, NT_STATUS_OK);
1114         smb2_util_close(tree1, testdirh);
1115
1116         ret = torture_setup_file(mem_ctx, tree1, fname, false);
1117         if (ret == false) {
1118                 goto done;
1119         }
1120
1121         ret = torture_setup_local_xattr(tctx, "localdir",
1122                                         BASEDIR "/torture_read_metadata",
1123                                         metadata_xattr, sizeof(metadata_xattr));
1124         if (ret == false) {
1125                 goto done;
1126         }
1127
1128         ret &= check_stream(tree1, __location__, tctx, mem_ctx, fname, AFPINFO_STREAM,
1129                             0, 60, 0, 4, "AFP");
1130
1131         ret &= check_stream(tree1, __location__, tctx, mem_ctx, fname, AFPINFO_STREAM,
1132                             0, 60, 16, 8, "BARRFOOO");
1133
1134 done:
1135         smb2_deltree(tree1, BASEDIR);
1136         talloc_free(mem_ctx);
1137         return ret;
1138 }
1139
1140 static bool test_write_atalk_metadata(struct torture_context *tctx,
1141                                       struct smb2_tree *tree1,
1142                                       struct smb2_tree *tree2)
1143 {
1144         TALLOC_CTX *mem_ctx = talloc_new(tctx);
1145         const char *fname = BASEDIR "\\torture_write_metadata";
1146         const char *type_creator = "SMB,OLE!";
1147         NTSTATUS status;
1148         struct smb2_handle testdirh;
1149         bool ret = true;
1150         AfpInfo *info;
1151
1152         smb2_util_unlink(tree1, fname);
1153
1154         status = torture_smb2_testdir(tree1, BASEDIR, &testdirh);
1155         CHECK_STATUS(status, NT_STATUS_OK);
1156         smb2_util_close(tree1, testdirh);
1157
1158         ret = torture_setup_file(mem_ctx, tree1, fname, false);
1159         if (ret == false) {
1160                 goto done;
1161         }
1162
1163         info = torture_afpinfo_new(mem_ctx);
1164         if (info == NULL) {
1165                 goto done;
1166         }
1167
1168         memcpy(info->afpi_FinderInfo, type_creator, 8);
1169         ret = torture_write_afpinfo(tree1, tctx, mem_ctx, fname, info);
1170         ret &= check_stream(tree1, __location__, tctx, mem_ctx, fname, AFPINFO_STREAM,
1171                             0, 60, 16, 8, type_creator);
1172
1173 done:
1174         smb2_deltree(tree1, BASEDIR);
1175         talloc_free(mem_ctx);
1176         return ret;
1177 }
1178
1179 static bool test_write_atalk_rfork_io(struct torture_context *tctx,
1180                                       struct smb2_tree *tree1,
1181                                       struct smb2_tree *tree2)
1182 {
1183         TALLOC_CTX *mem_ctx = talloc_new(tctx);
1184         const char *fname = BASEDIR "\\torture_write_rfork_io";
1185         const char *rfork = BASEDIR "\\torture_write_rfork_io" AFPRESOURCE_STREAM;
1186         const char *rfork_content = "1234567890";
1187         NTSTATUS status;
1188         struct smb2_handle testdirh;
1189         bool ret = true;
1190
1191         union smb_open io;
1192         struct smb2_handle filehandle;
1193         union smb_fileinfo finfo;
1194         union smb_setfileinfo sinfo;
1195
1196         smb2_util_unlink(tree1, fname);
1197
1198         status = torture_smb2_testdir(tree1, BASEDIR, &testdirh);
1199         CHECK_STATUS(status, NT_STATUS_OK);
1200         smb2_util_close(tree1, testdirh);
1201
1202         ret = torture_setup_file(mem_ctx, tree1, fname, false);
1203         if (ret == false) {
1204                 goto done;
1205         }
1206
1207         torture_comment(tctx, "(%s) writing to resource fork\n",
1208             __location__);
1209
1210         ret &= write_stream(tree1, __location__, tctx, mem_ctx,
1211                             fname, AFPRESOURCE_STREAM,
1212                             10, 10, rfork_content);
1213
1214         ret &= check_stream(tree1, __location__, tctx, mem_ctx,
1215                             fname, AFPRESOURCE_STREAM,
1216                             0, 20, 10, 10, rfork_content);
1217
1218         /* Check size after write */
1219
1220         ZERO_STRUCT(io);
1221         io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN;
1222         io.smb2.in.desired_access = SEC_FILE_READ_ATTRIBUTE |
1223                 SEC_FILE_WRITE_ATTRIBUTE;
1224         io.smb2.in.fname = rfork;
1225         status = smb2_create(tree1, mem_ctx, &(io.smb2));
1226         CHECK_STATUS(status, NT_STATUS_OK);
1227         filehandle = io.smb2.out.file.handle;
1228
1229         torture_comment(tctx, "(%s) check resource fork size after write\n",
1230             __location__);
1231
1232         ZERO_STRUCT(finfo);
1233         finfo.generic.level = RAW_FILEINFO_ALL_INFORMATION;
1234         finfo.generic.in.file.handle = filehandle;
1235         status = smb2_getinfo_file(tree1, mem_ctx, &finfo);
1236         CHECK_STATUS(status, NT_STATUS_OK);
1237         if (finfo.all_info.out.size != 20) {
1238                 torture_result(tctx, TORTURE_FAIL,
1239                                "(%s) Incorrect resource fork size\n",
1240                                __location__);
1241                 ret = false;
1242                 smb2_util_close(tree1, filehandle);
1243                 goto done;
1244         }
1245         smb2_util_close(tree1, filehandle);
1246
1247         /* Write at large offset */
1248
1249         torture_comment(tctx, "(%s) writing to resource fork at large offset\n",
1250                         __location__);
1251
1252         ret &= write_stream(tree1, __location__, tctx, mem_ctx,
1253                             fname, AFPRESOURCE_STREAM,
1254                             (off_t)1<<32, 10, rfork_content);
1255
1256         ret &= check_stream(tree1, __location__, tctx, mem_ctx,
1257                             fname, AFPRESOURCE_STREAM,
1258                             (off_t)1<<32, 10, 0, 10, rfork_content);
1259
1260         /* Truncate back to size of 1 byte */
1261
1262         torture_comment(tctx, "(%s) truncate resource fork and check size\n",
1263                         __location__);
1264
1265         ZERO_STRUCT(io);
1266         io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN;
1267         io.smb2.in.desired_access = SEC_FILE_READ_ATTRIBUTE |
1268                 SEC_FILE_WRITE_ATTRIBUTE;
1269         io.smb2.in.fname = rfork;
1270         status = smb2_create(tree1, mem_ctx, &(io.smb2));
1271         CHECK_STATUS(status, NT_STATUS_OK);
1272         filehandle = io.smb2.out.file.handle;
1273
1274         ZERO_STRUCT(sinfo);
1275         sinfo.end_of_file_info.level =
1276                 RAW_SFILEINFO_END_OF_FILE_INFORMATION;
1277         sinfo.end_of_file_info.in.file.handle = filehandle;
1278         sinfo.end_of_file_info.in.size = 1;
1279         status = smb2_setinfo_file(tree1, &sinfo);
1280         CHECK_STATUS(status, NT_STATUS_OK);
1281
1282         smb2_util_close(tree1, filehandle);
1283
1284         /* Now check size */
1285         ZERO_STRUCT(io);
1286         io.smb2.in.create_disposition = NTCREATEX_DISP_OPEN;
1287         io.smb2.in.desired_access = SEC_FILE_READ_ATTRIBUTE |
1288                 SEC_FILE_WRITE_ATTRIBUTE;
1289         io.smb2.in.fname = rfork;
1290         status = smb2_create(tree1, mem_ctx, &(io.smb2));
1291         CHECK_STATUS(status, NT_STATUS_OK);
1292         filehandle = io.smb2.out.file.handle;
1293
1294         ZERO_STRUCT(finfo);
1295         finfo.generic.level = RAW_FILEINFO_ALL_INFORMATION;
1296         finfo.generic.in.file.handle = filehandle;
1297         status = smb2_getinfo_file(tree1, mem_ctx, &finfo);
1298         CHECK_STATUS(status, NT_STATUS_OK);
1299         if (finfo.all_info.out.size != 1) {
1300                 torture_result(tctx, TORTURE_FAIL,
1301                                "(%s) Incorrect resource fork size\n",
1302                                __location__);
1303                 ret = false;
1304                 smb2_util_close(tree1, filehandle);
1305                 goto done;
1306         }
1307         smb2_util_close(tree1, filehandle);
1308
1309 done:
1310         smb2_deltree(tree1, BASEDIR);
1311         talloc_free(mem_ctx);
1312         return ret;
1313 }
1314
1315 static bool test_adouble_conversion(struct torture_context *tctx,
1316                                     struct smb2_tree *tree1,
1317                                     struct smb2_tree *tree2)
1318 {
1319         TALLOC_CTX *mem_ctx = talloc_new(tctx);
1320         const char *fname = BASEDIR "\\test_adouble_conversion";
1321         const char *fname_local = BASEDIR "/test_adouble_conversion";
1322         const char *adname_local = BASEDIR "/._test_adouble_conversion";
1323         NTSTATUS status;
1324         struct smb2_handle testdirh;
1325         bool ret = true;
1326         const char *data = "This resource fork intentionally left blank";
1327         size_t datalen = strlen(data);
1328
1329         smb2_util_unlink(tree1, fname);
1330
1331         status = torture_smb2_testdir(tree1, BASEDIR, &testdirh);
1332         CHECK_STATUS(status, NT_STATUS_OK);
1333         smb2_util_close(tree1, testdirh);
1334
1335         ret = torture_setup_local_file(tctx, "localdir", fname_local,
1336                                        NULL, 0);
1337         if (ret == false) {
1338                 goto done;
1339         }
1340
1341         ret = torture_setup_local_file(tctx, "localdir", adname_local,
1342                                        osx_adouble_w_xattr,
1343                                        sizeof(osx_adouble_w_xattr));
1344         if (ret == false) {
1345                 goto done;
1346         }
1347
1348         torture_comment(tctx, "(%s) test OS X AppleDouble conversion\n",
1349             __location__);
1350
1351         ret &= check_stream(tree1, __location__, tctx, mem_ctx,
1352                             fname, AFPRESOURCE_STREAM,
1353                             16, datalen, 0, datalen, data);
1354
1355 done:
1356         smb2_deltree(tree1, BASEDIR);
1357         talloc_free(mem_ctx);
1358         return ret;
1359 }
1360
1361 /*
1362  * Note: This test depends on "vfs objects = catia fruit
1363  * streams_xattr".  Note: To run this test, use
1364  * "--option=torture:share1=<SHARENAME1>
1365  * --option=torture:share2=<SHARENAME2>
1366  * --option=torture:localdir=<SHAREPATH>"
1367  */
1368 struct torture_suite *torture_vfs_fruit(void)
1369 {
1370         struct torture_suite *suite = torture_suite_create(
1371                 talloc_autofree_context(), "fruit");
1372
1373         suite->description = talloc_strdup(suite, "vfs_fruit tests");
1374
1375         torture_suite_add_2ns_smb2_test(suite, "read metadata", test_read_atalk_metadata);
1376         torture_suite_add_2ns_smb2_test(suite, "write metadata", test_write_atalk_metadata);
1377         torture_suite_add_2ns_smb2_test(suite, "resource fork IO", test_write_atalk_rfork_io);
1378         torture_suite_add_2ns_smb2_test(suite, "OS X AppleDouble file conversion", test_adouble_conversion);
1379
1380         return suite;
1381 }