aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_dir2_block.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_dir2_block.c')
-rw-r--r--fs/xfs/xfs_dir2_block.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c
index e8a7aca5fe23..98588491cb0e 100644
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -643,6 +643,7 @@ xfs_dir2_block_lookup_int(
643 int mid; /* binary search current idx */ 643 int mid; /* binary search current idx */
644 xfs_mount_t *mp; /* filesystem mount point */ 644 xfs_mount_t *mp; /* filesystem mount point */
645 xfs_trans_t *tp; /* transaction pointer */ 645 xfs_trans_t *tp; /* transaction pointer */
646 enum xfs_dacmp cmp; /* comparison result */
646 647
647 dp = args->dp; 648 dp = args->dp;
648 tp = args->trans; 649 tp = args->trans;
@@ -697,20 +698,31 @@ xfs_dir2_block_lookup_int(
697 dep = (xfs_dir2_data_entry_t *) 698 dep = (xfs_dir2_data_entry_t *)
698 ((char *)block + xfs_dir2_dataptr_to_off(mp, addr)); 699 ((char *)block + xfs_dir2_dataptr_to_off(mp, addr));
699 /* 700 /*
700 * Compare, if it's right give back buffer & entry number. 701 * Compare name and if it's an exact match, return the index
702 * and buffer. If it's the first case-insensitive match, store
703 * the index and buffer and continue looking for an exact match.
701 */ 704 */
702 if (dep->namelen == args->namelen && 705 cmp = mp->m_dirnameops->compname(args, dep->name, dep->namelen);
703 dep->name[0] == args->name[0] && 706 if (cmp != XFS_CMP_DIFFERENT && cmp != args->cmpresult) {
704 memcmp(dep->name, args->name, args->namelen) == 0) { 707 args->cmpresult = cmp;
705 *bpp = bp; 708 *bpp = bp;
706 *entno = mid; 709 *entno = mid;
707 return 0; 710 if (cmp == XFS_CMP_EXACT)
711 return 0;
708 } 712 }
709 } while (++mid < be32_to_cpu(btp->count) && be32_to_cpu(blp[mid].hashval) == hash); 713 } while (++mid < be32_to_cpu(btp->count) &&
714 be32_to_cpu(blp[mid].hashval) == hash);
715
716 ASSERT(args->oknoent);
717 /*
718 * Here, we can only be doing a lookup (not a rename or replace).
719 * If a case-insensitive match was found earlier, return success.
720 */
721 if (args->cmpresult == XFS_CMP_CASE)
722 return 0;
710 /* 723 /*
711 * No match, release the buffer and return ENOENT. 724 * No match, release the buffer and return ENOENT.
712 */ 725 */
713 ASSERT(args->oknoent);
714 xfs_da_brelse(tp, bp); 726 xfs_da_brelse(tp, bp);
715 return XFS_ERROR(ENOENT); 727 return XFS_ERROR(ENOENT);
716} 728}
@@ -1033,6 +1045,7 @@ xfs_dir2_sf_to_block(
1033 xfs_dir2_sf_t *sfp; /* shortform structure */ 1045 xfs_dir2_sf_t *sfp; /* shortform structure */
1034 __be16 *tagp; /* end of data entry */ 1046 __be16 *tagp; /* end of data entry */
1035 xfs_trans_t *tp; /* transaction pointer */ 1047 xfs_trans_t *tp; /* transaction pointer */
1048 struct xfs_name name;
1036 1049
1037 xfs_dir2_trace_args("sf_to_block", args); 1050 xfs_dir2_trace_args("sf_to_block", args);
1038 dp = args->dp; 1051 dp = args->dp;
@@ -1187,8 +1200,10 @@ xfs_dir2_sf_to_block(
1187 tagp = xfs_dir2_data_entry_tag_p(dep); 1200 tagp = xfs_dir2_data_entry_tag_p(dep);
1188 *tagp = cpu_to_be16((char *)dep - (char *)block); 1201 *tagp = cpu_to_be16((char *)dep - (char *)block);
1189 xfs_dir2_data_log_entry(tp, bp, dep); 1202 xfs_dir2_data_log_entry(tp, bp, dep);
1190 blp[2 + i].hashval = cpu_to_be32(xfs_da_hashname( 1203 name.name = sfep->name;
1191 (char *)sfep->name, sfep->namelen)); 1204 name.len = sfep->namelen;
1205 blp[2 + i].hashval = cpu_to_be32(mp->m_dirnameops->
1206 hashname(&name));
1192 blp[2 + i].address = cpu_to_be32(xfs_dir2_byte_to_dataptr(mp, 1207 blp[2 + i].address = cpu_to_be32(xfs_dir2_byte_to_dataptr(mp,
1193 (char *)dep - (char *)block)); 1208 (char *)dep - (char *)block));
1194 offset = (int)((char *)(tagp + 1) - (char *)block); 1209 offset = (int)((char *)(tagp + 1) - (char *)block);