Changes by: antona
Update of /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs
In directory usw-pr-cvs1:/tmp/cvs-serv11089/linux/fs/ntfs
Modified Files:
inode.c
Log Message:
mark inode as bad if first extent has lowest vcn != 0.
Index: inode.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/inode.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -U2 -r1.70 -r1.71
--- inode.c 4 Mar 2002 22:56:14 -0000 1.70
+++ inode.c 4 Mar 2002 23:48:05 -0000 1.71
@@ -376,4 +376,11 @@
if (ctx->attr->non_resident) {
ni->state |= 1 << NI_AttrListNonResident;
+ if (ctx->attr->_ANR(lowest_vcn)) {
+ ntfs_error(vi->i_sb, "Attribute list has non "
+ "zero lowest_vcn. Inode is "
+ "corrupt. You should run "
+ "chkdsk.");
+ goto put_unm_err_out;
+ }
/*
* Setup the run list. No need for locking as we have
@@ -403,7 +410,8 @@
}
} else /* if (!ctx.attr->non_resident) */ {
- if ((u8*)ctx->attr +
- le16_to_cpu(ctx->attr->_ARA(value_offset)) +
- le32_to_cpu(ctx->attr->_ARA(value_length)) >
+ if ((u8*)ctx->attr + le16_to_cpu(
+ ctx->attr->_ARA(value_offset)) +
+ le32_to_cpu(
+ ctx->attr->_ARA(value_length)) >
(u8*)ctx->mrec + vol->mft_record_size) {
ntfs_error(vi->i_sb, "Corrupt attribute list "
@@ -412,7 +420,8 @@
}
/* Now copy the attribute list. */
- memcpy(ni->attr_list, (u8*)ctx->attr +
- le16_to_cpu(ctx->attr->_ARA(value_offset)),
- le32_to_cpu(ctx->attr->_ARA(value_length)));
+ memcpy(ni->attr_list, (u8*)ctx->attr + le16_to_cpu(
+ ctx->attr->_ARA(value_offset)),
+ le32_to_cpu(
+ ctx->attr->_ARA(value_length)));
}
}
@@ -485,7 +494,9 @@
}
ni->_IDM(index_block_size) = le32_to_cpu(ir->index_block_size);
- if (ni->_IDM(index_block_size) & (ni->_IDM(index_block_size) - 1)) {
+ if (ni->_IDM(index_block_size) &
+ (ni->_IDM(index_block_size) - 1)) {
ntfs_error(vi->i_sb, "Index block size (%u) is not a "
- "power of two.", ni->_IDM(index_block_size));
+ "power of two.",
+ ni->_IDM(index_block_size));
goto put_unm_err_out;
}
@@ -503,9 +514,11 @@
"NTFS_BLOCK_SIZE (%i) is not "
"supported. Sorry.",
- ni->_IDM(index_block_size), NTFS_BLOCK_SIZE);
+ ni->_IDM(index_block_size),
+ NTFS_BLOCK_SIZE);
err = -EOPNOTSUPP;
goto ec_put_unm_err_out;
}
- ni->_IDM(index_block_size_bits) = ffs(ni->_IDM(index_block_size)) - 1;
+ ni->_IDM(index_block_size_bits) =
+ ffs(ni->_IDM(index_block_size)) - 1;
/* Determine the size of a vcn in the directory index. */
if (vol->cluster_size <= ni->_IDM(index_block_size)) {
@@ -546,8 +559,16 @@
goto put_unm_err_out;
}
+ if (ctx->attr->_ANR(lowest_vcn))
+ ntfs_error(vi->i_sb, "First extent of "
+ "$INDEX_ALLOCATION attribute has non "
+ "zero lowest_vcn. Inode is corrupt. "
+ "You should run chkdsk.");
+ goto put_unm_err_out;
+ }
vi->i_size = sle64_to_cpu(ctx->attr->_ANR(data_size));
ni->initialized_size = sle64_to_cpu(
ctx->attr->_ANR(initialized_size));
- ni->allocated_size = sle64_to_cpu(ctx->attr->_ANR(allocated_size));
+ ni->allocated_size = sle64_to_cpu(
+ ctx->attr->_ANR(allocated_size));
/*
* Setup the run list. No need for locking as we have exclusive
@@ -579,4 +600,11 @@
if (ctx->attr->non_resident) {
ni->state |= 1 << NI_BmpNonResident;
+ if (ctx->attr->_ANR(lowest_vcn))
+ ntfs_error(vi->i_sb, "First extent of $BITMAP "
+ "attribute has non zero "
+ "lowest_vcn. Inode is corrupt. "
+ "You should run chkdsk.");
+ goto put_unm_err_out;
+ }
ni->_IDM(bmp_size) = sle64_to_cpu(
ctx->attr->_ANR(data_size));
@@ -589,6 +617,6 @@
* exclusive access to the inode at this time.
*/
- ni->_IDM(bmp_rl).rl = decompress_mapping_pairs(vol, ctx->attr,
- NULL);
+ ni->_IDM(bmp_rl).rl = decompress_mapping_pairs(vol,
+ ctx->attr, NULL);
if (IS_ERR(ni->_IDM(bmp_rl).rl)) {
err = PTR_ERR(ni->_IDM(bmp_rl).rl);
@@ -602,5 +630,6 @@
ni->_IDM(bmp_size) = ni->_IDM(bmp_initialized_size) =
ni->_IDM(bmp_allocated_size) =
- le32_to_cpu(ctx->attr->_ARA(value_length));
+ le32_to_cpu(
+ ctx->attr->_ARA(value_length));
/* Consistency check bitmap size vs. index allocation size. */
if (ni->_IDM(bmp_size) << 3 < vi->i_size >>
@@ -677,5 +706,5 @@
}
ni->_ICF(compression_block_clusters) = 1U <<
- ctx->attr->_ANR(compression_unit);
+ ctx->attr->_ANR(compression_unit);
if (ctx->attr->_ANR(compression_unit) != 4) {
ntfs_error(vi->i_sb, "Found "
@@ -685,11 +714,11 @@
"indicate corruption so you "
"should run chkdsk.",
- ctx->attr->_ANR(compression_unit));
+ ctx->attr->_ANR(compression_unit));
err = -EOPNOTSUPP;
goto ec_put_unm_err_out;
}
- ni->_ICF(compression_block_size) = 1U <<
- (ctx->attr->_ANR(compression_unit) +
- vol->cluster_size_bits);
+ ni->_ICF(compression_block_size) = 1U << (
+ ctx->attr->_ANR(compression_unit)
+ + vol->cluster_size_bits);
ni->_ICF(compression_block_size_bits) = ffs(
ni->_ICF(compression_block_size)) - 1;
@@ -703,4 +732,11 @@
ni->state |= 1 << NI_Encrypted;
}
+ if (ctx->attr->_ANR(lowest_vcn)) {
+ ntfs_error(vi->i_sb, "First extent of $DATA "
+ "attribute has non zero "
+ "lowest_vcn. Inode is corrupt. "
+ "You should run chkdsk.");
+ goto put_unm_err_out;
+ }
/* $MFT is special as we have the run_list already. */
if (likely(vi->i_ino != FILE_MFT)) {
@@ -730,5 +766,5 @@
if (NInoCompressed(ni))
ni->_ICF(compressed_size) = sle64_to_cpu(
- ctx->attr->_ANR(compressed_size));
+ ctx->attr->_ANR(compressed_size));
} else { /* Resident attribute. */
/*
@@ -739,5 +775,5 @@
*/
vi->i_size = ni->initialized_size = ni->allocated_size =
- le32_to_cpu(ctx->attr->_ARA(value_length));
+ le32_to_cpu(ctx->attr->_ARA(value_length));
}
no_data_attr_special_case:
@@ -929,4 +965,10 @@
if (ctx->attr->non_resident) {
ni->state |= 1 << NI_AttrListNonResident;
+ if (ctx->attr->_ANR(lowest_vcn)) {
+ ntfs_error(sb, "Attribute list has non zero "
+ "lowest_vcn. $MFT is corrupt. "
+ "You should run chkdsk.");
+ goto put_err_out;
+ }
/* Setup the run list. */
ni->attr_list_rl.rl = decompress_mapping_pairs(vol,
@@ -949,7 +991,8 @@
}
} else /* if (!ctx.attr->non_resident) */ {
- if ((u8*)ctx->attr +
- le16_to_cpu(ctx->attr->_ARA(value_offset)) +
- le32_to_cpu(ctx->attr->_ARA(value_length)) >
+ if ((u8*)ctx->attr + le16_to_cpu(
+ ctx->attr->_ARA(value_offset)) +
+ le32_to_cpu(
+ ctx->attr->_ARA(value_length)) >
(u8*)ctx->mrec + vol->mft_record_size) {
ntfs_error(sb, "Corrupt attribute list "
@@ -958,7 +1001,8 @@
}
/* Now copy the attribute list. */
- memcpy(ni->attr_list, (u8*)ctx->attr +
- le16_to_cpu(ctx->attr->_ARA(value_offset)),
- le32_to_cpu(ctx->attr->_ARA(value_length)));
+ memcpy(ni->attr_list, (u8*)ctx->attr + le16_to_cpu(
+ ctx->attr->_ARA(value_offset)),
+ le32_to_cpu(
+ ctx->attr->_ARA(value_length)));
}
/* The attribute list is now setup in memory. */
@@ -1065,4 +1109,11 @@
/* Are we in the first extent? */
if (!next_vcn) {
+ if (attr->_ANR(lowest_vcn)) {
+ ntfs_error(sb, "First extent of $DATA "
+ "attribute has non zero "
+ "lowest_vcn. $MFT is corrupt. "
+ "You should run chkdsk.");
+ goto put_err_out;
+ }
/* Get the last vcn in the $DATA attribute. */
last_vcn = sle64_to_cpu(attr->_ANR(allocated_size)) >>
@@ -1070,8 +1121,8 @@
/* Fill in the inode size. */
vi->i_size = sle64_to_cpu(attr->_ANR(data_size));
- ni->initialized_size =
- sle64_to_cpu(attr->_ANR(initialized_size));
- ni->allocated_size =
- sle64_to_cpu(attr->_ANR(allocated_size));
+ ni->initialized_size = sle64_to_cpu(
+ attr->_ANR(initialized_size));
+ ni->allocated_size = sle64_to_cpu(
+ attr->_ANR(allocated_size));
/* Set the number of mft records. */
vol->_VMM(nr_mft_records) = vi->i_size >>
|