[syslinux] [PATCH] xfs: Add support for v3 directories
Paulo Alcantara
pcacjr at zytor.com
Mon Jan 18 05:06:44 PST 2016
On Mon, January 18, 2016 10:51 am, Gene Cumm wrote:
> On Mon, Dec 14, 2015 at 7:54 PM, Paulo Alcantara <pcacjr at gmail.com> wrote:
>> Besides supporting newer version of xfs file system, this patch also
>> does some code refactoring and fix completely broken listing and
>> searching on v2-3 node directories.
>>
>> Cc: Gene Cumm <gene.cumm at gmail.com>
>> Cc: H. Peter Anvin <hpa at zytor.com>
>> Cc: Raphael S. Carvalho <raphael.scarv at gmail.com>
>> Cc: Ady <ady-sf at hotmail.com>
>> Signed-off-by: Paulo Alcantara <pcacjr at zytor.com>
>> ---
>> core/fs/xfs/xfs.c | 19 +--
>> core/fs/xfs/xfs.h | 155 +++++++++++++++++++-----
>> core/fs/xfs/xfs_dinode.c | 2 +-
>> core/fs/xfs/xfs_dir2.c | 296
>> +++++++++++++++++++++++++---------------------
>> core/fs/xfs/xfs_dir2.h | 6 +-
>> core/fs/xfs/xfs_readdir.c | 151 ++++++++++++++---------
>> 6 files changed, 399 insertions(+), 230 deletions(-)
>
>> diff --git a/core/fs/xfs/xfs_dir2.c b/core/fs/xfs/xfs_dir2.c
>> index de37ef7..f738a58 100644
>
>> --- a/core/fs/xfs/xfs_dir2.c
>> +++ b/core/fs/xfs/xfs_dir2.c
>
>> @@ -593,110 +628,99 @@ struct inode *xfs_dir2_node_find_entry(const char
>> *dname, struct inode *parent,
>> xfs_dinode_t *core)
>> {
>
>> - uint32_t hash = 0;
>> + uint32_t hash;
>
>> + uint16_t count;
>
>> - int mid = 0;
>> + int mid;
>
>
>> + if (be16_to_cpu(lhdr->info.magic) == XFS_DIR2_LEAFN_MAGIC) {
>> + count = be16_to_cpu(lhdr->count);
>> + ents = (xfs_dir2_leaf_entry_t *)((uint8_t *)lhdr +
>> + sizeof(struct
>> xfs_dir2_leaf_hdr));
>> + } else if (be16_to_cpu(lhdr->info.magic) == XFS_DIR3_LEAFN_MAGIC) {
>> + count = be16_to_cpu(((xfs_dir3_leaf_hdr_t *)lhdr)->count);
>> + ents = (xfs_dir2_leaf_entry_t *)((uint8_t *)lhdr +
>> + sizeof(struct
>> xfs_dir3_leaf_hdr));
>> + } else {
>> + xfs_error("Leaf's magic number does not match (0x%04x)!",
>> + be16_to_cpu(lhdr->info.magic));
>> goto out;
>> }
>>
>> - if (!leaf->hdr.count)
>> - goto out;
>> + if (!count)
>> + goto out;
>>
>> - for (lep = leaf->ents, low = 0, high = be16_to_cpu(leaf->hdr.count)
>> - 1;
>> - low <= high; ) {
>> + lep = ents;
>> + low = 0;
>> + high = count - 1;
>> + while (low <= high) {
>> mid = (low + high) >> 1;
>> -
>> if ((hash = be32_to_cpu(lep[mid].hashval)) == hashwant)
>> break;
>> if (hash < hashwant)
>
> Paulo, the initialization to zero of hash and mid silences the
> compiler's warning about potentially unitialized variables since some
> versions aren't intelligent enough to realize you've checked for the
> case of (count == 0), initialized low to 0 and therefore high must be
> equal to or greater than low.
>
> Other than this, it should be good.
Gene, thanks for pointing it out. Could you fix that for me, please? You
might want to checkout my 'xfs-v3-support' branch to make your life
easier.
Thanks,
Paulo
--
Paulo Alcantara, HP Inc.
Speaking for myself only.
More information about the Syslinux
mailing list