major : Fixed computation of index block size (Anton Altaparmakov)

When the cluster size is bigger than the index block size, the index
block size unit is 512 (not the sector size) instead of the cluster size.
The partitions formatted by mkntfs and used by ntfs-3g were not
interoperable with Windows when the cluster size is bigger than 4K
and the sector size is not 512.
edge.strict_endians
Jean-Pierre André 2011-11-04 11:01:11 +01:00
parent 4629a7af14
commit b76883dc84
4 changed files with 14 additions and 8 deletions

View File

@ -380,7 +380,7 @@ u64 ntfs_inode_lookup_by_name(ntfs_inode *dir_ni,
if (vol->cluster_size <= index_block_size) {
index_vcn_size_bits = vol->cluster_size_bits;
} else {
index_vcn_size_bits = vol->sector_size_bits;
index_vcn_size_bits = NTFS_BLOCK_SIZE_BITS;
}
/* Get the starting vcn of the index_block holding the child node. */
@ -1131,7 +1131,7 @@ int ntfs_readdir(ntfs_inode *dir_ni, s64 *pos,
if (vol->cluster_size <= index_block_size) {
index_vcn_size_bits = vol->cluster_size_bits;
} else {
index_vcn_size_bits = vol->sector_size_bits;
index_vcn_size_bits = NTFS_BLOCK_SIZE_BITS;
}
/* Are we jumping straight into the index allocation attribute? */
@ -1513,7 +1513,7 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni, le32 securid,
else
ir->clusters_per_index_block =
ni->vol->indx_record_size >>
ni->vol->sector_size_bits;
NTFS_BLOCK_SIZE_BITS;
ir->index.entries_offset = cpu_to_le32(sizeof(INDEX_HEADER));
ir->index.index_length = cpu_to_le32(index_len);
ir->index.allocated_size = cpu_to_le32(index_len);

View File

@ -701,7 +701,7 @@ int ntfs_index_lookup(const void *key, const int key_len, ntfs_index_context *ic
if (ni->vol->cluster_size <= icx->block_size)
icx->vcn_size_bits = ni->vol->cluster_size_bits;
else
icx->vcn_size_bits = ni->vol->sector_size_bits;
icx->vcn_size_bits = NTFS_BLOCK_SIZE_BITS;
/* get the appropriate collation function */
icx->collate = ntfs_get_collate_function(ir->collation_rule);
if (!icx->collate) {

View File

@ -1,7 +1,7 @@
/**
* mkntfs - Part of the Linux-NTFS project.
*
* Copyright (c) 2000-2007 Anton Altaparmakov
* Copyright (c) 2000-2011 Anton Altaparmakov
* Copyright (c) 2001-2005 Richard Russon
* Copyright (c) 2002-2006 Szabolcs Szakacsits
* Copyright (c) 2005 Erik Sornes
@ -2242,8 +2242,8 @@ static int add_attr_index_root(MFT_RECORD *m, const char *name,
free(r);
return -EINVAL;
}
r->clusters_per_index_block = index_block_size /
opts.sector_size;
r->clusters_per_index_block = index_block_size
>> NTFS_BLOCK_SIZE_BITS;
}
memset(&r->reserved, 0, sizeof(r->reserved));
r->index.entries_offset = const_cpu_to_le32(sizeof(INDEX_HEADER));

View File

@ -415,6 +415,7 @@ static void ntfs_dump_volume(ntfs_volume *vol)
printf("\tVolume Version: %u.%u\n", vol->major_ver, vol->minor_ver);
printf("\tSector Size: %hu\n", vol->sector_size);
printf("\tCluster Size: %u\n", (unsigned int)vol->cluster_size);
printf("\tIndex Block Size: %u\n", (unsigned int)vol->indx_record_size);
printf("\tVolume Size in Clusters: %lld\n",
(long long)vol->nr_clusters);
@ -1752,7 +1753,12 @@ static void ntfs_dump_attr_index_root(ATTR_RECORD *attr, ntfs_inode *ni)
printf("\tIndex Block Size:\t %u (0x%x)\n",
(unsigned)le32_to_cpu(index_root->index_block_size),
(unsigned)le32_to_cpu(index_root->index_block_size));
printf("\tClusters Per Block:\t %u (0x%x)\n",
if (le32_to_cpu(index_root->index_block_size) < ni->vol->cluster_size)
printf("\t512-byte Units Per Block:\t %u (0x%x)\n",
(unsigned)index_root->clusters_per_index_block,
(unsigned)index_root->clusters_per_index_block);
else
printf("\tClusters Per Block:\t %u (0x%x)\n",
(unsigned)index_root->clusters_per_index_block,
(unsigned)index_root->clusters_per_index_block);