fix VCN size in index.c
parent
c7a53338c0
commit
d3b82fa6cd
|
@ -36,6 +36,7 @@ xx/xx/2006 - 1.13.1-WIP
|
|||
and ntfs_inode_badclus_bad() functions, and convert all copy-pastes
|
||||
to use them. (Szaka)
|
||||
- Fix all incorrect getopt_long() return value usages. (Szaka)
|
||||
- Fix VCN size in the index.c. (Anton, Yura)
|
||||
|
||||
27/02/2006 - 1.13.0 - Lots and lots and lots of fixes and enhancements.
|
||||
|
||||
|
|
|
@ -32,20 +32,22 @@
|
|||
|
||||
/**
|
||||
* struct ntfs_index_context -
|
||||
* @ni: inode containing the @entry described by this context
|
||||
* @name: name of the index described by this context
|
||||
* @name_len: length of the index name
|
||||
* @entry: index entry (points into @ir or @ia)
|
||||
* @data: index entry data (points into @entry)
|
||||
* @data_len: length in bytes of @data
|
||||
* @is_in_root: TRUE if @entry is in @ir and FALSE if it is in @ia
|
||||
* @ir: index root if @is_in_root and NULL otherwise
|
||||
* @actx: attribute search context if @is_in_root and NULL otherwise
|
||||
* @ia: index block if @is_in_root is FALSE and NULL otherwise
|
||||
* @ia_na: opened INDEX_ALLOCATION attribute
|
||||
* @ia_vcn: VCN from which @ia where read from
|
||||
* @ia_dirty: TRUE if index block was changed
|
||||
* @block_size: index block size
|
||||
* @ni: inode containing the @entry described by this context
|
||||
* @name: name of the index described by this context
|
||||
* @name_len: length of the index name
|
||||
* @entry: index entry (points into @ir or @ia)
|
||||
* @data: index entry data (points into @entry)
|
||||
* @data_len: length in bytes of @data
|
||||
* @is_in_root: TRUE if @entry is in @ir or FALSE if it is in @ia
|
||||
* @ir: index root if @is_in_root or NULL otherwise
|
||||
* @actx: attribute search context if in root or NULL otherwise
|
||||
* @ia: index block if @is_in_root is FALSE or NULL otherwise
|
||||
* @ia_na: opened INDEX_ALLOCATION attribute
|
||||
* @ia_vcn: VCN from which @ia where read from
|
||||
* @ia_dirty: TRUE if index block was changed
|
||||
* @block_size: index block size
|
||||
* @vcn_size: VCN size for this index block
|
||||
* @vcn_size_bits: use instead of @vcn_size to speedup multiplication
|
||||
*
|
||||
* @ni is the inode this context belongs to.
|
||||
*
|
||||
|
@ -87,6 +89,8 @@ typedef struct {
|
|||
VCN ia_vcn;
|
||||
BOOL ia_dirty;
|
||||
u32 block_size;
|
||||
u32 vcn_size;
|
||||
u8 vcn_size_bits;
|
||||
} ntfs_index_context;
|
||||
|
||||
extern ntfs_index_context *ntfs_index_ctx_get(ntfs_inode *ni,
|
||||
|
|
|
@ -90,8 +90,7 @@ void ntfs_index_ctx_put(ntfs_index_context *ictx)
|
|||
if (ictx->ia_dirty) {
|
||||
if (ntfs_attr_mst_pwrite(ictx->ia_na,
|
||||
ictx->ia_vcn <<
|
||||
ictx->ni->vol->
|
||||
cluster_size_bits,
|
||||
ictx->vcn_size_bits,
|
||||
1, ictx->block_size,
|
||||
ictx->ia) != 1)
|
||||
ntfs_log_error("Failed to write out "
|
||||
|
@ -122,8 +121,7 @@ void ntfs_index_ctx_reinit(ntfs_index_context *ictx)
|
|||
if (ictx->ia_dirty) {
|
||||
if (ntfs_attr_mst_pwrite(ictx->ia_na,
|
||||
ictx->ia_vcn <<
|
||||
ictx->ni->vol->
|
||||
cluster_size_bits,
|
||||
ictx->vcn_size_bits,
|
||||
1, ictx->block_size,
|
||||
ictx->ia) != 1)
|
||||
ntfs_log_error("Failed to write out "
|
||||
|
@ -218,6 +216,14 @@ int ntfs_index_lookup(const void *key, const int key_len,
|
|||
index_end = (u8*)&ir->index + le32_to_cpu(ir->index.index_length);
|
||||
/* Save index block size for future use. */
|
||||
ictx->block_size = le32_to_cpu(ir->index_block_size);
|
||||
/* Determine the size of a vcn in the directory index. */
|
||||
if (vol->cluster_size <= ictx->block_size) {
|
||||
ictx->vcn_size = vol->cluster_size;
|
||||
ictx->vcn_size_bits = vol->cluster_size_bits;
|
||||
} else {
|
||||
ictx->vcn_size = vol->sector_size;
|
||||
ictx->vcn_size_bits = vol->sector_size_bits;
|
||||
}
|
||||
/* Get collation rule type and validate it. */
|
||||
cr = ir->collation_rule;
|
||||
if (!ntfs_is_collation_rule_supported(cr)) {
|
||||
|
@ -326,7 +332,7 @@ done:
|
|||
descend_into_child_node:
|
||||
ntfs_log_debug("Descend into node with VCN %lld.\n", vcn);
|
||||
/* Read index allocation block. */
|
||||
if (ntfs_attr_mst_pread(na, vcn << vol->cluster_size_bits, 1,
|
||||
if (ntfs_attr_mst_pread(na, vcn << ictx->vcn_size_bits, 1,
|
||||
ictx->block_size, ia) != 1) {
|
||||
ntfs_log_error("Failed to read index allocation.\n");
|
||||
goto err_out;
|
||||
|
|
Loading…
Reference in New Issue