/* ARGSUSED */ static int hash_f( int argc, char **argv) { xfs_dahash_t hashval; hashval = libxfs_da_hashname(argv[1], (int)strlen(argv[1])); dbprintf("0x%x\n", hashval); return 0; }
static int process_leaf_attr_local( struct xfs_mount *mp, xfs_attr_leafblock_t *leaf, int i, xfs_attr_leaf_entry_t *entry, xfs_dahash_t last_hashval, xfs_dablk_t da_bno, xfs_ino_t ino) { xfs_attr_leaf_name_local_t *local; local = xfs_attr3_leaf_name_local(leaf, i); if (local->namelen == 0 || namecheck((char *)&local->nameval[0], local->namelen)) { do_warn( _("attribute entry %d in attr block %u, inode %" PRIu64 " has bad name (namelen = %d)\n"), i, da_bno, ino, local->namelen); return -1; } /* Check on the hash value. Checking order of values * is not necessary, since one wrong clears the whole * fork. If the ordering's wrong, it's caught here or * the kernel code has a bug with transaction logging * or attributes itself. Being paranoid, let's check * ordering anyway in case both the name value and the * hashvalue were wrong but matched. Unlikely, however. */ if (be32_to_cpu(entry->hashval) != libxfs_da_hashname( &local->nameval[0], local->namelen) || be32_to_cpu(entry->hashval) < last_hashval) { do_warn( _("bad hashvalue for attribute entry %d in attr block %u, inode %" PRIu64 "\n"), i, da_bno, ino); return -1; } /* Only check values for root security attributes */ if (entry->flags & XFS_ATTR_ROOT) { if (valuecheck(mp, (char *)&local->nameval[0], NULL, local->namelen, be16_to_cpu(local->valuelen))) { do_warn( _("bad security value for attribute entry %d in attr block %u, inode %" PRIu64 "\n"), i, da_bno, ino); return -1; } } return xfs_attr_leaf_entsize_local(local->namelen, be16_to_cpu(local->valuelen)); }
static int process_leaf_attr_remote( xfs_attr_leafblock_t *leaf, int i, xfs_attr_leaf_entry_t *entry, xfs_dahash_t last_hashval, xfs_dablk_t da_bno, xfs_ino_t ino, xfs_mount_t *mp, blkmap_t *blkmap) { xfs_attr_leaf_name_remote_t *remotep; char* value; remotep = xfs_attr3_leaf_name_remote(leaf, i); if (remotep->namelen == 0 || namecheck((char *)&remotep->name[0], remotep->namelen) || be32_to_cpu(entry->hashval) != libxfs_da_hashname((unsigned char *)&remotep->name[0], remotep->namelen) || be32_to_cpu(entry->hashval) < last_hashval || be32_to_cpu(remotep->valueblk) == 0) { do_warn( _("inconsistent remote attribute entry %d in attr block %u, ino %" PRIu64 "\n"), i, da_bno, ino); return -1; } if (!(entry->flags & XFS_ATTR_ROOT)) goto out; value = malloc(be32_to_cpu(remotep->valuelen)); if (value == NULL) { do_warn( _("cannot malloc enough for remotevalue attribute for inode %" PRIu64 "\n"), ino); do_warn(_("SKIPPING this remote attribute\n")); goto out; } if (rmtval_get(mp, ino, blkmap, be32_to_cpu(remotep->valueblk), be32_to_cpu(remotep->valuelen), value)) { do_warn( _("remote attribute get failed for entry %d, inode %" PRIu64 "\n"), i, ino); goto bad_free_out; } if (valuecheck(mp, (char *)&remotep->name[0], value, remotep->namelen, be32_to_cpu(remotep->valuelen))) { do_warn( _("remote attribute value check failed for entry %d, inode %" PRIu64 "\n"), i, ino); goto bad_free_out; } free(value); out: return xfs_attr_leaf_entsize_remote(remotep->namelen); bad_free_out: free(value); return -1; }