Changes by: antona
Update of /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs
In directory usw-pr-cvs1:/tmp/cvs-serv7373/linux/fs/ntfs
Modified Files:
aops.c compress.c inode.c inode.h mft.c
Log Message:
Found bad bug. initialized size is ignored which is plain wrong.
Started on cleaning up the mess...
Index: aops.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/aops.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -U2 -r1.52 -r1.53
--- aops.c 13 Feb 2002 22:00:42 -0000 1.52
+++ aops.c 14 Feb 2002 06:07:14 -0000 1.53
@@ -78,6 +78,9 @@
ofs = ((VCN)blk << vol->sb->s_blocksize_bits) & vol->cluster_size_mask;
+ /* Check for initialized size overflow. */
+ if ((vcn << vol->cluster_size_bits) + ofs >= ni->initialized_size)
+ return 0;
/*
- * Further, we meed to be checking i_size and be just doing the
+ * Further, we need to be checking i_size and be just doing the
* following if it is zero or we are out of bounds:
* bh->b_blocknr = -1UL;
@@ -197,5 +200,5 @@
/* Normal data stream, use generic functionality. */
return block_read_full_page(page, ntfs_file_get_block);
- /* Compressed data stream. Handled in compaops.c. */
+ /* Compressed data stream. Handled in compress.c. */
return ntfs_file_read_compressed_block(page);
}
@@ -286,4 +289,10 @@
bh->b_state &= ~(1UL << BH_Mapped);
bh->b_blocknr = -1;
+ /* Check for initialized size overflow. */
+ if ((vcn << vol->cluster_size_bits) + ofs >=
+ vol->mftbmp_initialized_size) {
+ ntfs_debug("Done.");
+ return 0;
+ }
lcn = vcn_to_lcn(vol->mftbmp_rl, vcn);
ntfs_debug("lcn = 0x%Lx.", (long long)lcn);
Index: compress.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/compress.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -U2 -r1.31 -r1.32
--- compress.c 13 Feb 2002 22:00:42 -0000 1.31
+++ compress.c 14 Feb 2002 06:07:14 -0000 1.32
@@ -558,4 +558,9 @@
BOOL is_retry = FALSE;
retry_remap:
+ /* Make sure we are not overflowing the file limits. */
+ if (vcn << vol->cluster_size_bits >= ni->initialized_size) {
+ /* Overflow, just zero this region. */
+ // TODO: AIA
+ }
/* Find lcn of vcn and convert it into blocks. */
lcn = vcn_to_lcn(ni->run_list, vcn);
@@ -581,4 +586,5 @@
max_block = block + (vol->cluster_size >> block_size_bits);
do {
+ // TODO: Need overflow checks here, too! (AIA)
ntfs_debug("block = 0x%x.", block);
if (unlikely(!(bhs[nr_bhs] = getblk(dev, block,
Index: inode.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/inode.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -U2 -r1.67 -r1.68
--- inode.c 14 Feb 2002 00:52:08 -0000 1.67
+++ inode.c 14 Feb 2002 06:07:14 -0000 1.68
@@ -511,5 +511,5 @@
if (!(ir->index.flags & LARGE_INDEX)) {
/* No index allocation. */
- vi->i_size = 0;
+ vi->i_size = ni->initialized_size = 0;
goto skip_large_dir_stuff;
} /* LARGE_INDEX: Index allocation present. Setup state. */
@@ -539,7 +539,9 @@
goto put_unm_err_out;
}
- if (!sle64_to_cpu(ctx->attr->lowest_vcn))
+ if (!sle64_to_cpu(ctx->attr->lowest_vcn)) {
vi->i_size = sle64_to_cpu(ctx->attr->data_size);
- else
+ ni->initialized_size = sle64_to_cpu(
+ ctx->attr->initialized_size);
+ } else
/*
* Just a rough guess as ->*_size are not defined for
@@ -549,5 +551,6 @@
* very fragmented or sparse.
*/
- vi->i_size = sle64_to_cpu(ctx->attr->highest_vcn)
+ vi->i_size = ni->initialized_size =
+ sle64_to_cpu(ctx->attr->highest_vcn)
<< vol->cluster_size_bits;
/* Setup the run list. */
@@ -604,10 +607,10 @@
ni->bmp_size = le32_to_cpu(ctx->attr->value_length);
/* Consistency check bitmap size vs. index allocation size. */
- if (ni->bmp_size << 3 < vi->i_size >>
+ if (ni->bmp_size << 3 < ni->initialized_size >>
ni->index_block_size_bits) {
ntfs_error(vi->i_sb, "$I30 bitmap too small (0x%Lx) "
"for index allocation (0x%Lx).",
(long long)ni->bmp_size << 3,
- vi->i_size);
+ (long long)ni->initialized_size);
goto put_unm_err_out;
}
@@ -631,5 +634,5 @@
reinit_attr_search_ctx(ctx);
if (!lookup_attr(AT_DATA, NULL, 0, 0, 0, NULL, 0, ctx)) {
- vi->i_size = 0LL;
+ vi->i_size = ni->initialized_size = 0LL;
/*
* FILE_Secure does not have an unnamed $DATA
@@ -725,11 +728,17 @@
* fragmented or compressed or sparse.
*/
- vi->i_size = sle64_to_cpu(
+ vi->i_size = ni->initialized_size =
+ sle64_to_cpu(
ctx->attr->highest_vcn) <<
vol->cluster_size_bits;
- else
+ else {
vi->i_size = sle64_to_cpu(ctx->attr->data_size);
- } else /* Resident attribute. */
+ ni->initialized_size = sle64_to_cpu(
+ ctx->attr->initialized_size);
+ }
+ } else { /* Resident attribute. */
vi->i_size = le32_to_cpu(ctx->attr->value_length);
+ ni->initialized_size = 0LL;
+ }
no_data_attr_special_case:
/* Everyone gets read permissions. */
@@ -1046,4 +1055,6 @@
/* Fill in the inode size. */
vi->i_size = sle64_to_cpu(attr->data_size);
+ ni->initialized_size =
+ sle64_to_cpu(attr->initialized_size);
/* Set the number of mft records. */
vol->nr_mft_records = vi->i_size >>
Index: inode.h
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/inode.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -U2 -r1.14 -r1.15
--- inode.h 8 Feb 2002 05:17:11 -0000 1.14
+++ inode.h 14 Feb 2002 06:07:14 -0000 1.15
@@ -35,4 +35,5 @@
*/
struct _ntfs_inode {
+ s64 initialized_size; /* Copy from unnamed $DATA attribute. */
unsigned long state; /* NTFS specific flags describing this inode.
See fs/ntfs/ntfs.h:ntfs_inode_state_bits. */
Index: mft.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/mft.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -U2 -r1.48 -r1.49
--- mft.c 13 Feb 2002 22:00:42 -0000 1.48
+++ mft.c 14 Feb 2002 06:07:14 -0000 1.49
@@ -181,5 +181,5 @@
blocks = PAGE_CACHE_SIZE >> blocksize_bits;
iblock = page->index << (PAGE_CACHE_SHIFT - blocksize_bits);
- lblock = (vi->i_size + blocksize - 1) >> blocksize_bits;
+ lblock = (ni->initialized_size + blocksize - 1) >> blocksize_bits;
bh = head = page->buffers;
|