#include "attr.h"
#include "io.h"
#include "init.h"
+#include "output.h"
static int attr_leaf_entries_count(void *obj, int startoff);
static int attr_leaf_hdr_count(void *obj, int startoff);
{ NULL }
};
+/*
+ * Special read verifier for attribute buffers. Detect the magic number
+ * appropriately and set the correct verifier and call it.
+ */
+static void
+xfs_attr3_db_read_verify(
+ struct xfs_buf *bp)
+{
+ __be32 magic32;
+ __be16 magic16;
+
+ magic32 = *(__be32 *)bp->b_addr;
+ magic16 = ((struct xfs_da_blkinfo *)bp->b_addr)->magic;
+
+ switch (magic16) {
+ case cpu_to_be16(XFS_ATTR3_LEAF_MAGIC):
+ bp->b_ops = &xfs_attr3_leaf_buf_ops;
+ goto verify;
+ case cpu_to_be16(XFS_DA3_NODE_MAGIC):
+ bp->b_ops = &xfs_da3_node_buf_ops;
+ goto verify;
+ default:
+ break;
+ }
+
+ switch (magic32) {
+ case cpu_to_be32(XFS_ATTR3_RMT_MAGIC):
+ bp->b_ops = &xfs_attr3_rmt_buf_ops;
+ break;
+ default:
+ dbprintf(_("Unknown attribute buffer type!\n"));
+ xfs_buf_ioerror(bp, EFSCORRUPTED);
+ return;
+ }
+verify:
+ bp->b_ops->verify_read(bp);
+}
+
+static void
+xfs_attr3_db_write_verify(
+ struct xfs_buf *bp)
+{
+ dbprintf(_("Writing unknown attribute buffer type!\n"));
+ xfs_buf_ioerror(bp, EFSCORRUPTED);
+}
+
+const struct xfs_buf_ops xfs_attr3_db_buf_ops = {
+ .verify_read = xfs_attr3_db_read_verify,
+ .verify_write = xfs_attr3_db_write_verify,
+};
extern int attr_leaf_name_size(void *obj, int startoff, int idx);
extern int attr_size(void *obj, int startoff, int idx);
+
+extern const struct xfs_buf_ops xfs_attr3_db_buf_ops;
{ TYP_AGF, "agf", handle_struct, agf_hfld, &xfs_agf_buf_ops },
{ TYP_AGFL, "agfl", handle_struct, agfl_crc_hfld, &xfs_agfl_buf_ops },
{ TYP_AGI, "agi", handle_struct, agi_hfld, &xfs_agfl_buf_ops },
- { TYP_ATTR, "attr3", handle_struct, attr3_hfld, NULL },
+ { TYP_ATTR, "attr3", handle_struct, attr3_hfld,
+ &xfs_attr3_db_buf_ops },
{ TYP_BMAPBTA, "bmapbta", handle_struct, bmapbta_crc_hfld,
&xfs_bmbt_buf_ops },
{ TYP_BMAPBTD, "bmapbtd", handle_struct, bmapbtd_crc_hfld,