int xfs_agf_good_version(unsigned v) { return XFS_AGF_GOOD_VERSION(v); }
static int verify_set_agf(xfs_mount_t *mp, xfs_agf_t *agf, xfs_agnumber_t i) { xfs_drfsbno_t agblocks; int retval = 0; /* check common fields */ if (be32_to_cpu(agf->agf_magicnum) != XFS_AGF_MAGIC) { retval = XR_AG_AGF; do_warn(_("bad magic # 0x%x for agf %d\n"), be32_to_cpu(agf->agf_magicnum), i); if (!no_modify) agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC); } if (!XFS_AGF_GOOD_VERSION(be32_to_cpu(agf->agf_versionnum))) { retval = XR_AG_AGF; do_warn(_("bad version # %d for agf %d\n"), be32_to_cpu(agf->agf_versionnum), i); if (!no_modify) agf->agf_versionnum = cpu_to_be32(XFS_AGF_VERSION); } if (be32_to_cpu(agf->agf_seqno) != i) { retval = XR_AG_AGF; do_warn(_("bad sequence # %d for agf %d\n"), be32_to_cpu(agf->agf_seqno), i); if (!no_modify) agf->agf_seqno = cpu_to_be32(i); } if (be32_to_cpu(agf->agf_length) != mp->m_sb.sb_agblocks) { if (i != mp->m_sb.sb_agcount - 1) { retval = XR_AG_AGF; do_warn(_("bad length %d for agf %d, should be %d\n"), be32_to_cpu(agf->agf_length), i, mp->m_sb.sb_agblocks); if (!no_modify) agf->agf_length = cpu_to_be32(mp->m_sb.sb_agblocks); } else { agblocks = mp->m_sb.sb_dblocks - (xfs_drfsbno_t) mp->m_sb.sb_agblocks * i; if (be32_to_cpu(agf->agf_length) != agblocks) { retval = XR_AG_AGF; do_warn( _("bad length %d for agf %d, should be %" PRIu64 "\n"), be32_to_cpu(agf->agf_length), i, agblocks); if (!no_modify) agf->agf_length = cpu_to_be32(agblocks); } } } /* * check first/last AGF fields. if need be, lose the free * space in the AGFL, we'll reclaim it later. */ if (be32_to_cpu(agf->agf_flfirst) >= XFS_AGFL_SIZE(mp)) { do_warn(_("flfirst %d in agf %d too large (max = %zu)\n"), be32_to_cpu(agf->agf_flfirst), i, XFS_AGFL_SIZE(mp)); if (!no_modify) agf->agf_flfirst = cpu_to_be32(0); } if (be32_to_cpu(agf->agf_fllast) >= XFS_AGFL_SIZE(mp)) { do_warn(_("fllast %d in agf %d too large (max = %zu)\n"), be32_to_cpu(agf->agf_fllast), i, XFS_AGFL_SIZE(mp)); if (!no_modify) agf->agf_fllast = cpu_to_be32(0); } /* don't check freespace btrees -- will be checked by caller */ return(retval); }