]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/attr.c
xfs_db: identify attr dabtree field types correctly
[thirdparty/xfsprogs-dev.git] / db / attr.c
1 /*
2 * Copyright (c) 2000-2001,2004-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include "libxfs.h"
20 #include "bit.h"
21 #include "type.h"
22 #include "faddr.h"
23 #include "fprint.h"
24 #include "field.h"
25 #include "attr.h"
26 #include "io.h"
27 #include "init.h"
28 #include "output.h"
29
30 static int attr_leaf_entries_count(void *obj, int startoff);
31 static int attr_leaf_hdr_count(void *obj, int startoff);
32 static int attr_leaf_name_local_count(void *obj, int startoff);
33 static int attr_leaf_name_local_name_count(void *obj, int startoff);
34 static int attr_leaf_name_local_value_count(void *obj, int startoff);
35 static int attr_leaf_name_local_value_offset(void *obj, int startoff,
36 int idx);
37 static int attr_leaf_name_remote_count(void *obj, int startoff);
38 static int attr_leaf_name_remote_name_count(void *obj, int startoff);
39 static int attr_leaf_nvlist_count(void *obj, int startoff);
40 static int attr_leaf_nvlist_offset(void *obj, int startoff, int idx);
41 static int attr_node_btree_count(void *obj, int startoff);
42 static int attr_node_hdr_count(void *obj, int startoff);
43
44 const field_t attr_hfld[] = {
45 { "", FLDT_ATTR, OI(0), C1, 0, TYP_NONE },
46 { NULL }
47 };
48
49 #define LOFF(f) bitize(offsetof(xfs_attr_leafblock_t, f))
50 #define NOFF(f) bitize(offsetof(xfs_da_intnode_t, f))
51 const field_t attr_flds[] = {
52 { "hdr", FLDT_ATTR_LEAF_HDR, OI(LOFF(hdr)), attr_leaf_hdr_count,
53 FLD_COUNT, TYP_NONE },
54 { "hdr", FLDT_ATTR_NODE_HDR, OI(NOFF(hdr)), attr_node_hdr_count,
55 FLD_COUNT, TYP_NONE },
56 { "entries", FLDT_ATTR_LEAF_ENTRY, OI(LOFF(entries)),
57 attr_leaf_entries_count, FLD_ARRAY|FLD_COUNT, TYP_NONE },
58 { "btree", FLDT_ATTR_NODE_ENTRY, OI(NOFF(__btree)), attr_node_btree_count,
59 FLD_ARRAY|FLD_COUNT, TYP_NONE },
60 { "nvlist", FLDT_ATTR_LEAF_NAME, attr_leaf_nvlist_offset,
61 attr_leaf_nvlist_count, FLD_ARRAY|FLD_OFFSET|FLD_COUNT, TYP_NONE },
62 { NULL }
63 };
64
65 #define BOFF(f) bitize(offsetof(xfs_da_blkinfo_t, f))
66 const field_t attr_blkinfo_flds[] = {
67 { "forw", FLDT_ATTRBLOCK, OI(BOFF(forw)), C1, 0, TYP_ATTR },
68 { "back", FLDT_ATTRBLOCK, OI(BOFF(back)), C1, 0, TYP_ATTR },
69 { "magic", FLDT_UINT16X, OI(BOFF(magic)), C1, 0, TYP_NONE },
70 { "pad", FLDT_UINT16X, OI(BOFF(pad)), C1, FLD_SKIPALL, TYP_NONE },
71 { NULL }
72 };
73
74 #define LEOFF(f) bitize(offsetof(xfs_attr_leaf_entry_t, f))
75 const field_t attr_leaf_entry_flds[] = {
76 { "hashval", FLDT_UINT32X, OI(LEOFF(hashval)), C1, 0, TYP_NONE },
77 { "nameidx", FLDT_UINT16D, OI(LEOFF(nameidx)), C1, 0, TYP_NONE },
78 { "flags", FLDT_UINT8X, OI(LEOFF(flags)), C1, FLD_SKIPALL, TYP_NONE },
79 { "incomplete", FLDT_UINT1,
80 OI(LEOFF(flags) + bitsz(__uint8_t) - XFS_ATTR_INCOMPLETE_BIT - 1), C1,
81 0, TYP_NONE },
82 { "root", FLDT_UINT1,
83 OI(LEOFF(flags) + bitsz(__uint8_t) - XFS_ATTR_ROOT_BIT - 1), C1, 0,
84 TYP_NONE },
85 { "secure", FLDT_UINT1,
86 OI(LEOFF(flags) + bitsz(__uint8_t) - XFS_ATTR_SECURE_BIT - 1), C1, 0,
87 TYP_NONE },
88 { "local", FLDT_UINT1,
89 OI(LEOFF(flags) + bitsz(__uint8_t) - XFS_ATTR_LOCAL_BIT - 1), C1, 0,
90 TYP_NONE },
91 { "pad2", FLDT_UINT8X, OI(LEOFF(pad2)), C1, FLD_SKIPALL, TYP_NONE },
92 { NULL }
93 };
94
95 #define LHOFF(f) bitize(offsetof(xfs_attr_leaf_hdr_t, f))
96 const field_t attr_leaf_hdr_flds[] = {
97 { "info", FLDT_ATTR_BLKINFO, OI(LHOFF(info)), C1, 0, TYP_NONE },
98 { "count", FLDT_UINT16D, OI(LHOFF(count)), C1, 0, TYP_NONE },
99 { "usedbytes", FLDT_UINT16D, OI(LHOFF(usedbytes)), C1, 0, TYP_NONE },
100 { "firstused", FLDT_UINT16D, OI(LHOFF(firstused)), C1, 0, TYP_NONE },
101 { "holes", FLDT_UINT8D, OI(LHOFF(holes)), C1, 0, TYP_NONE },
102 { "pad1", FLDT_UINT8X, OI(LHOFF(pad1)), C1, FLD_SKIPALL, TYP_NONE },
103 { "freemap", FLDT_ATTR_LEAF_MAP, OI(LHOFF(freemap)),
104 CI(XFS_ATTR_LEAF_MAPSIZE), FLD_ARRAY, TYP_NONE },
105 { NULL }
106 };
107
108 #define LMOFF(f) bitize(offsetof(xfs_attr_leaf_map_t, f))
109 const field_t attr_leaf_map_flds[] = {
110 { "base", FLDT_UINT16D, OI(LMOFF(base)), C1, 0, TYP_NONE },
111 { "size", FLDT_UINT16D, OI(LMOFF(size)), C1, 0, TYP_NONE },
112 { NULL }
113 };
114
115 #define LNOFF(f) bitize(offsetof(xfs_attr_leaf_name_local_t, f))
116 #define LVOFF(f) bitize(offsetof(xfs_attr_leaf_name_remote_t, f))
117 const field_t attr_leaf_name_flds[] = {
118 { "valuelen", FLDT_UINT16D, OI(LNOFF(valuelen)),
119 attr_leaf_name_local_count, FLD_COUNT, TYP_NONE },
120 { "namelen", FLDT_UINT8D, OI(LNOFF(namelen)),
121 attr_leaf_name_local_count, FLD_COUNT, TYP_NONE },
122 { "name", FLDT_CHARNS, OI(LNOFF(nameval)),
123 attr_leaf_name_local_name_count, FLD_COUNT, TYP_NONE },
124 { "value", FLDT_CHARNS, attr_leaf_name_local_value_offset,
125 attr_leaf_name_local_value_count, FLD_COUNT|FLD_OFFSET, TYP_NONE },
126 { "valueblk", FLDT_UINT32X, OI(LVOFF(valueblk)),
127 attr_leaf_name_remote_count, FLD_COUNT, TYP_NONE },
128 { "valuelen", FLDT_UINT32D, OI(LVOFF(valuelen)),
129 attr_leaf_name_remote_count, FLD_COUNT, TYP_NONE },
130 { "namelen", FLDT_UINT8D, OI(LVOFF(namelen)),
131 attr_leaf_name_remote_count, FLD_COUNT, TYP_NONE },
132 { "name", FLDT_CHARNS, OI(LVOFF(name)),
133 attr_leaf_name_remote_name_count, FLD_COUNT, TYP_NONE },
134 { NULL }
135 };
136
137 #define EOFF(f) bitize(offsetof(xfs_da_node_entry_t, f))
138 const field_t attr_node_entry_flds[] = {
139 { "hashval", FLDT_UINT32X, OI(EOFF(hashval)), C1, 0, TYP_NONE },
140 { "before", FLDT_ATTRBLOCK, OI(EOFF(before)), C1, 0, TYP_ATTR },
141 { NULL }
142 };
143
144 #define HOFF(f) bitize(offsetof(xfs_da_node_hdr_t, f))
145 const field_t attr_node_hdr_flds[] = {
146 { "info", FLDT_ATTR_BLKINFO, OI(HOFF(info)), C1, 0, TYP_NONE },
147 { "count", FLDT_UINT16D, OI(HOFF(__count)), C1, 0, TYP_NONE },
148 { "level", FLDT_UINT16D, OI(HOFF(__level)), C1, 0, TYP_NONE },
149 { NULL }
150 };
151
152 static int
153 attr_leaf_entries_count(
154 void *obj,
155 int startoff)
156 {
157 struct xfs_attr_leafblock *leaf = obj;
158
159 ASSERT(startoff == 0);
160 if (be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR_LEAF_MAGIC)
161 return 0;
162 return be16_to_cpu(leaf->hdr.count);
163 }
164
165 static int
166 attr3_leaf_entries_count(
167 void *obj,
168 int startoff)
169 {
170 struct xfs_attr3_leafblock *leaf = obj;
171
172 ASSERT(startoff == 0);
173 if (be16_to_cpu(leaf->hdr.info.hdr.magic) != XFS_ATTR3_LEAF_MAGIC)
174 return 0;
175 return be16_to_cpu(leaf->hdr.count);
176 }
177
178 static int
179 attr_leaf_hdr_count(
180 void *obj,
181 int startoff)
182 {
183 struct xfs_attr_leafblock *leaf = obj;
184
185 ASSERT(startoff == 0);
186 return be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC;
187 }
188
189 static int
190 attr3_leaf_hdr_count(
191 void *obj,
192 int startoff)
193 {
194 struct xfs_attr3_leafblock *leaf = obj;
195
196 ASSERT(startoff == 0);
197 return be16_to_cpu(leaf->hdr.info.hdr.magic) == XFS_ATTR3_LEAF_MAGIC;
198 }
199
200 typedef int (*attr_leaf_entry_walk_f)(struct xfs_attr_leafblock *,
201 struct xfs_attr_leaf_entry *, int);
202 static int
203 attr_leaf_entry_walk(
204 void *obj,
205 int startoff,
206 attr_leaf_entry_walk_f func)
207 {
208 struct xfs_attr_leafblock *leaf = obj;
209 struct xfs_attr3_icleaf_hdr leafhdr;
210 struct xfs_attr_leaf_entry *entries;
211 struct xfs_attr_leaf_entry *e;
212 int i;
213 int off;
214
215 ASSERT(bitoffs(startoff) == 0);
216 if (be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR_LEAF_MAGIC &&
217 be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR3_LEAF_MAGIC)
218 return 0;
219
220 off = byteize(startoff);
221 xfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &leafhdr, leaf);
222 entries = xfs_attr3_leaf_entryp(leaf);
223
224 for (i = 0; i < leafhdr.count; i++) {
225 e = &entries[i];
226 if (be16_to_cpu(e->nameidx) == off)
227 return func(leaf, e, i);
228 }
229 return 0;
230 }
231
232 static int
233 __attr_leaf_name_local_count(
234 struct xfs_attr_leafblock *leaf,
235 struct xfs_attr_leaf_entry *e,
236 int i)
237 {
238 return (e->flags & XFS_ATTR_LOCAL) != 0;
239 }
240
241 static int
242 attr_leaf_name_local_count(
243 void *obj,
244 int startoff)
245 {
246 return attr_leaf_entry_walk(obj, startoff,
247 __attr_leaf_name_local_count);
248 }
249
250 static int
251 __attr_leaf_name_local_name_count(
252 struct xfs_attr_leafblock *leaf,
253 struct xfs_attr_leaf_entry *e,
254 int i)
255 {
256 struct xfs_attr_leaf_name_local *l;
257
258 if (!(e->flags & XFS_ATTR_LOCAL))
259 return 0;
260
261 l = xfs_attr3_leaf_name_local(leaf, i);
262 return l->namelen;
263 }
264
265 static int
266 attr_leaf_name_local_name_count(
267 void *obj,
268 int startoff)
269 {
270 return attr_leaf_entry_walk(obj, startoff,
271 __attr_leaf_name_local_name_count);
272 }
273
274 static int
275 __attr_leaf_name_local_value_count(
276 struct xfs_attr_leafblock *leaf,
277 struct xfs_attr_leaf_entry *e,
278 int i)
279 {
280 struct xfs_attr_leaf_name_local *l;
281
282 if (!(e->flags & XFS_ATTR_LOCAL))
283 return 0;
284
285 l = xfs_attr3_leaf_name_local(leaf, i);
286 return be16_to_cpu(l->valuelen);
287 }
288
289 static int
290 attr_leaf_name_local_value_count(
291 void *obj,
292 int startoff)
293 {
294 return attr_leaf_entry_walk(obj, startoff,
295 __attr_leaf_name_local_value_count);
296 }
297
298 static int
299 __attr_leaf_name_local_value_offset(
300 struct xfs_attr_leafblock *leaf,
301 struct xfs_attr_leaf_entry *e,
302 int i)
303 {
304 struct xfs_attr_leaf_name_local *l;
305 char *vp;
306
307 l = xfs_attr3_leaf_name_local(leaf, i);
308 vp = (char *)&l->nameval[l->namelen];
309
310 return (int)bitize(vp - (char *)l);
311 }
312
313 static int
314 attr_leaf_name_local_value_offset(
315 void *obj,
316 int startoff,
317 int idx)
318 {
319 return attr_leaf_entry_walk(obj, startoff,
320 __attr_leaf_name_local_value_offset);
321 }
322
323 static int
324 __attr_leaf_name_remote_count(
325 struct xfs_attr_leafblock *leaf,
326 struct xfs_attr_leaf_entry *e,
327 int i)
328 {
329 return (e->flags & XFS_ATTR_LOCAL) == 0;
330 }
331
332 static int
333 attr_leaf_name_remote_count(
334 void *obj,
335 int startoff)
336 {
337 return attr_leaf_entry_walk(obj, startoff,
338 __attr_leaf_name_remote_count);
339 }
340
341 static int
342 __attr_leaf_name_remote_name_count(
343 struct xfs_attr_leafblock *leaf,
344 struct xfs_attr_leaf_entry *e,
345 int i)
346 {
347 struct xfs_attr_leaf_name_remote *r;
348
349 if (e->flags & XFS_ATTR_LOCAL)
350 return 0;
351
352 r = xfs_attr3_leaf_name_remote(leaf, i);
353 return r->namelen;
354 }
355
356 static int
357 attr_leaf_name_remote_name_count(
358 void *obj,
359 int startoff)
360 {
361 return attr_leaf_entry_walk(obj, startoff,
362 __attr_leaf_name_remote_name_count);
363 }
364
365 int
366 attr_leaf_name_size(
367 void *obj,
368 int startoff,
369 int idx)
370 {
371 struct xfs_attr_leafblock *leaf = obj;
372 struct xfs_attr_leaf_entry *e;
373 struct xfs_attr_leaf_name_local *l;
374 struct xfs_attr_leaf_name_remote *r;
375
376 ASSERT(startoff == 0);
377 if (be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR_LEAF_MAGIC &&
378 be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR3_LEAF_MAGIC)
379 return 0;
380 e = &xfs_attr3_leaf_entryp(leaf)[idx];
381 if (e->flags & XFS_ATTR_LOCAL) {
382 l = xfs_attr3_leaf_name_local(leaf, idx);
383 return (int)bitize(xfs_attr_leaf_entsize_local(l->namelen,
384 be16_to_cpu(l->valuelen)));
385 } else {
386 r = xfs_attr3_leaf_name_remote(leaf, idx);
387 return (int)bitize(xfs_attr_leaf_entsize_remote(r->namelen));
388 }
389 }
390
391 static int
392 attr_leaf_nvlist_count(
393 void *obj,
394 int startoff)
395 {
396 struct xfs_attr_leafblock *leaf = obj;
397
398 ASSERT(startoff == 0);
399 if (be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR_LEAF_MAGIC)
400 return 0;
401 return be16_to_cpu(leaf->hdr.count);
402 }
403
404 static int
405 attr3_leaf_nvlist_count(
406 void *obj,
407 int startoff)
408 {
409 struct xfs_attr3_leafblock *leaf = obj;
410
411 ASSERT(startoff == 0);
412 if (be16_to_cpu(leaf->hdr.info.hdr.magic) != XFS_ATTR3_LEAF_MAGIC)
413 return 0;
414 return be16_to_cpu(leaf->hdr.count);
415 }
416
417 static int
418 attr_leaf_nvlist_offset(
419 void *obj,
420 int startoff,
421 int idx)
422 {
423 struct xfs_attr_leafblock *leaf = obj;
424 struct xfs_attr_leaf_entry *e;
425
426 ASSERT(startoff == 0);
427 e = &xfs_attr3_leaf_entryp(leaf)[idx];
428 return bitize(be16_to_cpu(e->nameidx));
429 }
430
431 static int
432 attr_node_btree_count(
433 void *obj,
434 int startoff)
435 {
436 struct xfs_da_intnode *node = obj;
437
438 ASSERT(startoff == 0); /* this is a base structure */
439 if (be16_to_cpu(node->hdr.info.magic) != XFS_DA_NODE_MAGIC)
440 return 0;
441 return be16_to_cpu(node->hdr.__count);
442 }
443
444 static int
445 attr3_node_btree_count(
446 void *obj,
447 int startoff)
448 {
449 struct xfs_da3_intnode *node = obj;
450
451 ASSERT(startoff == 0);
452 if (be16_to_cpu(node->hdr.info.hdr.magic) != XFS_DA3_NODE_MAGIC)
453 return 0;
454 return be16_to_cpu(node->hdr.__count);
455 }
456
457
458 static int
459 attr_node_hdr_count(
460 void *obj,
461 int startoff)
462 {
463 struct xfs_da_intnode *node = obj;
464
465 ASSERT(startoff == 0);
466 return be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC;
467 }
468
469 static int
470 attr3_node_hdr_count(
471 void *obj,
472 int startoff)
473 {
474 struct xfs_da3_intnode *node = obj;
475
476 ASSERT(startoff == 0);
477 return be16_to_cpu(node->hdr.info.hdr.magic) == XFS_DA3_NODE_MAGIC;
478 }
479
480 int
481 attr_size(
482 void *obj,
483 int startoff,
484 int idx)
485 {
486 return bitize(mp->m_sb.sb_blocksize);
487 }
488
489 /*
490 * CRC enabled attribute block field definitions
491 */
492 const field_t attr3_hfld[] = {
493 { "", FLDT_ATTR3, OI(0), C1, 0, TYP_NONE },
494 { NULL }
495 };
496
497 #define L3OFF(f) bitize(offsetof(struct xfs_attr3_leafblock, f))
498 #define N3OFF(f) bitize(offsetof(struct xfs_da3_intnode, f))
499 const field_t attr3_flds[] = {
500 { "hdr", FLDT_ATTR3_LEAF_HDR, OI(L3OFF(hdr)), attr3_leaf_hdr_count,
501 FLD_COUNT, TYP_NONE },
502 { "hdr", FLDT_ATTR3_NODE_HDR, OI(N3OFF(hdr)), attr3_node_hdr_count,
503 FLD_COUNT, TYP_NONE },
504 { "entries", FLDT_ATTR_LEAF_ENTRY, OI(L3OFF(entries)),
505 attr3_leaf_entries_count, FLD_ARRAY|FLD_COUNT, TYP_NONE },
506 { "btree", FLDT_ATTR_NODE_ENTRY, OI(N3OFF(__btree)),
507 attr3_node_btree_count, FLD_ARRAY|FLD_COUNT, TYP_NONE },
508 { "nvlist", FLDT_ATTR_LEAF_NAME, attr_leaf_nvlist_offset,
509 attr3_leaf_nvlist_count, FLD_ARRAY|FLD_OFFSET|FLD_COUNT, TYP_NONE },
510 { NULL }
511 };
512
513 #define LH3OFF(f) bitize(offsetof(struct xfs_attr3_leaf_hdr, f))
514 const field_t attr3_leaf_hdr_flds[] = {
515 { "info", FLDT_ATTR3_BLKINFO, OI(LH3OFF(info)), C1, 0, TYP_NONE },
516 { "count", FLDT_UINT16D, OI(LH3OFF(count)), C1, 0, TYP_NONE },
517 { "usedbytes", FLDT_UINT16D, OI(LH3OFF(usedbytes)), C1, 0, TYP_NONE },
518 { "firstused", FLDT_UINT16D, OI(LH3OFF(firstused)), C1, 0, TYP_NONE },
519 { "holes", FLDT_UINT8D, OI(LH3OFF(holes)), C1, 0, TYP_NONE },
520 { "pad1", FLDT_UINT8X, OI(LH3OFF(pad1)), C1, FLD_SKIPALL, TYP_NONE },
521 { "freemap", FLDT_ATTR_LEAF_MAP, OI(LH3OFF(freemap)),
522 CI(XFS_ATTR_LEAF_MAPSIZE), FLD_ARRAY, TYP_NONE },
523 { NULL }
524 };
525
526 #define B3OFF(f) bitize(offsetof(struct xfs_da3_blkinfo, f))
527 const field_t attr3_blkinfo_flds[] = {
528 { "hdr", FLDT_ATTR_BLKINFO, OI(B3OFF(hdr)), C1, 0, TYP_NONE },
529 { "crc", FLDT_CRC, OI(B3OFF(crc)), C1, 0, TYP_NONE },
530 { "bno", FLDT_DFSBNO, OI(B3OFF(blkno)), C1, 0, TYP_BMAPBTD },
531 { "lsn", FLDT_UINT64X, OI(B3OFF(lsn)), C1, 0, TYP_NONE },
532 { "uuid", FLDT_UUID, OI(B3OFF(uuid)), C1, 0, TYP_NONE },
533 { "owner", FLDT_INO, OI(B3OFF(owner)), C1, 0, TYP_NONE },
534 { NULL }
535 };
536
537 #define H3OFF(f) bitize(offsetof(struct xfs_da3_node_hdr, f))
538 const field_t attr3_node_hdr_flds[] = {
539 { "info", FLDT_ATTR3_BLKINFO, OI(H3OFF(info)), C1, 0, TYP_NONE },
540 { "count", FLDT_UINT16D, OI(H3OFF(__count)), C1, 0, TYP_NONE },
541 { "level", FLDT_UINT16D, OI(H3OFF(__level)), C1, 0, TYP_NONE },
542 { "pad", FLDT_UINT32D, OI(H3OFF(__pad32)), C1, 0, TYP_NONE },
543 { NULL }
544 };
545
546 /*
547 * Special read verifier for attribute buffers. Detect the magic number
548 * appropriately and set the correct verifier and call it.
549 */
550 static void
551 xfs_attr3_db_read_verify(
552 struct xfs_buf *bp)
553 {
554 __be32 magic32;
555 __be16 magic16;
556
557 magic32 = *(__be32 *)bp->b_addr;
558 magic16 = ((struct xfs_da_blkinfo *)bp->b_addr)->magic;
559
560 switch (magic16) {
561 case cpu_to_be16(XFS_ATTR3_LEAF_MAGIC):
562 bp->b_ops = &xfs_attr3_leaf_buf_ops;
563 goto verify;
564 case cpu_to_be16(XFS_DA3_NODE_MAGIC):
565 bp->b_ops = &xfs_da3_node_buf_ops;
566 goto verify;
567 default:
568 break;
569 }
570
571 switch (magic32) {
572 case cpu_to_be32(XFS_ATTR3_RMT_MAGIC):
573 bp->b_ops = &xfs_attr3_rmt_buf_ops;
574 break;
575 default:
576 dbprintf(_("Unknown attribute buffer type!\n"));
577 xfs_buf_ioerror(bp, -EFSCORRUPTED);
578 return;
579 }
580 verify:
581 bp->b_ops->verify_read(bp);
582 }
583
584 static void
585 xfs_attr3_db_write_verify(
586 struct xfs_buf *bp)
587 {
588 dbprintf(_("Writing unknown attribute buffer type!\n"));
589 xfs_buf_ioerror(bp, -EFSCORRUPTED);
590 }
591
592 const struct xfs_buf_ops xfs_attr3_db_buf_ops = {
593 .name = "xfs_attr3",
594 .verify_read = xfs_attr3_db_read_verify,
595 .verify_write = xfs_attr3_db_write_verify,
596 };