[PATCH-2.6-test-BK] Fix a bug in the NTFS driver.

From: Anton Altaparmakov
Date: Thu Nov 13 2003 - 08:54:12 EST


Linus, please do a

bk pull http://linux-ntfs.bkbits.net/ntfs-2.6

This fixes a bug in ntfs that has been reported by at least two people so
far which renders some fragmented files generated by Windows XP
inaccessible from Linux. This patch has been verified to work correctly
on examples of these files.

Thanks!

Best regards,

Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/, http://www-stu.christs.cam.ac.uk/~aia21/

===================================================================

This will update the following files:

Documentation/filesystems/ntfs.txt | 4 ++++
fs/ntfs/ChangeLog | 8 ++++++++
fs/ntfs/Makefile | 2 +-
fs/ntfs/attrib.c | 33 +++++++++++++++------------------
fs/ntfs/attrib.h | 2 +-
5 files changed, 29 insertions(+), 20 deletions(-)

through these ChangeSets:

<aia21@xxxxxxxxxx> (03/11/11 1.1422.3.1)
NTFS: Minor bug fix in attribute list attribute handling that fixes the
I/O errors on "ls" of certain fragmented files found by at least two
people running Windows XP.


diff -Nru a/Documentation/filesystems/ntfs.txt b/Documentation/filesystems/ntfs.txt
--- a/Documentation/filesystems/ntfs.txt Thu Nov 13 13:42:28 2003
+++ b/Documentation/filesystems/ntfs.txt Thu Nov 13 13:42:28 2003
@@ -272,6 +272,10 @@

Note, a technical ChangeLog aimed at kernel hackers is in fs/ntfs/ChangeLog.

+2.1.5:
+ - Minor bug fix in attribute list attribute handling that fixes the
+ I/O errors on "ls" of certain fragmented files found by at least two
+ people running Windows XP.
2.1.4:
- Minor update allowing compilation with all gcc versions (well, the
ones the kernel can be compiled with anyway).
diff -Nru a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog
--- a/fs/ntfs/ChangeLog Thu Nov 13 13:42:28 2003
+++ b/fs/ntfs/ChangeLog Thu Nov 13 13:42:28 2003
@@ -20,6 +20,14 @@
sufficient for synchronisation here. We then just need to make sure
ntfs_readpage/writepage/truncate interoperate properly with us.

+2.1.5 - Fix minor bug in attribute list attribute handling.
+
+ - Fix bug in attribute list handling. Actually it is not as much a bug
+ as too much protection in that we were not allowing attribute lists
+ which waste space on disk while Windows XP clearly allows it and in
+ fact creates such attribute lists so our driver was failing.
+ - Update NTFS documentation ready for 2.6 kernel release.
+
2.1.4 - Reduce compiler requirements.

- Remove all uses of unnamed structs and unions in the driver to make
diff -Nru a/fs/ntfs/Makefile b/fs/ntfs/Makefile
--- a/fs/ntfs/Makefile Thu Nov 13 13:42:28 2003
+++ b/fs/ntfs/Makefile Thu Nov 13 13:42:28 2003
@@ -5,7 +5,7 @@
ntfs-objs := aops.o attrib.o compress.o debug.o dir.o file.o inode.o mft.o \
mst.o namei.o super.o sysctl.o time.o unistr.o upcase.o

-EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.4\"
+EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.5\"

ifeq ($(CONFIG_NTFS_DEBUG),y)
EXTRA_CFLAGS += -DDEBUG
diff -Nru a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
--- a/fs/ntfs/attrib.c Thu Nov 13 13:42:28 2003
+++ b/fs/ntfs/attrib.c Thu Nov 13 13:42:28 2003
@@ -1215,7 +1215,7 @@
* load_attribute_list - load an attribute list into memory
* @vol: ntfs volume from which to read
* @run_list: run list of the attribute list
- * @al: destination buffer
+ * @al_start: destination buffer
* @size: size of the destination buffer in bytes
* @initialized_size: initialized size of the attribute list
*
@@ -1227,10 +1227,11 @@
*
* Return 0 on success or -errno on error.
*/
-int load_attribute_list(ntfs_volume *vol, run_list *run_list, u8 *al,
+int load_attribute_list(ntfs_volume *vol, run_list *run_list, u8 *al_start,
const s64 size, const s64 initialized_size)
{
LCN lcn;
+ u8 *al = al_start;
u8 *al_end = al + initialized_size;
run_list_element *rl;
struct buffer_head *bh;
@@ -1284,32 +1285,28 @@
}
if (initialized_size < size) {
initialize:
- memset(al + initialized_size, 0, size - initialized_size);
+ memset(al_start + initialized_size, 0, size - initialized_size);
}
done:
up_read(&run_list->lock);
return err;
do_final:
if (al < al_end) {
- /* Partial block. */
- memcpy(al, bh->b_data, al_end - al);
- brelse(bh);
/*
- * Skip sanity checking if initialized_size < size as it is
- * too much trouble.
+ * Partial block.
+ *
+ * Note: The attribute list can be smaller than its allocation
+ * by multiple clusters. This has been encountered by at least
+ * two people running Windows XP, thus we cannot do any
+ * truncation sanity checking here. (AIA)
*/
+ memcpy(al, bh->b_data, al_end - al);
+ brelse(bh);
if (initialized_size < size)
goto initialize;
- /* If the final lcn is partial all is fine. */
- if (((s64)(block - (lcn << vol->cluster_size_bits >>
- block_size_bits)) << block_size_bits >>
- vol->cluster_size_bits) == rl->length - 1) {
- if (!rl[1].length || (rl[1].lcn == LCN_RL_NOT_MAPPED
- && !rl[2].length))
- goto done;
- }
- } else
- brelse(bh);
+ goto done;
+ }
+ brelse(bh);
/* Real overflow! */
ntfs_error(sb, "Attribute list buffer overflow. Read attribute list "
"is truncated.");
diff -Nru a/fs/ntfs/attrib.h b/fs/ntfs/attrib.h
--- a/fs/ntfs/attrib.h Thu Nov 13 13:42:28 2003
+++ b/fs/ntfs/attrib.h Thu Nov 13 13:42:28 2003
@@ -87,7 +87,7 @@
const IGNORE_CASE_BOOL ic, const VCN lowest_vcn, const u8 *val,
const u32 val_len, attr_search_context *ctx);

-extern int load_attribute_list(ntfs_volume *vol, run_list *rl, u8 *al,
+extern int load_attribute_list(ntfs_volume *vol, run_list *rl, u8 *al_start,
const s64 size, const s64 initialized_size);

static inline s64 attribute_value_length(const ATTR_RECORD *a)

===================================================================

This BitKeeper patch contains the following changesets:
1.1422.3.1
## Wrapped with gzip_uu ##


M'XL( $6*LS\ ^U86V_:2!1^QK_B*'U)4S SOF&SHFK:M-VHMRA)=_M0"8WM
M,;9B/,@S+F7E_>][Q@XD$&@3E'U8=0%A,Y[YSO@[W[F8)_!9\G+881FSJ/$$
M?A=2#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0PR0L4A"5G"ET
MG&PVNFX+I !1E1"7&;;$VB"NR5IBD);/LQB7-HT>Q+?S$2!FO$ ME(!]-5SQ
MLN Y#FI!<,WI[7A=MC<;X?J@YFEWL*XU3[=B53=/;:QBRKM_J%+HT5\[5)NF
M<T>H+LG>(U)/?*#&J?YZ_>7R_'C\ZLW[X[<7,(+>B=;7^(_7YQ>GGSZ.OAXT
MT?SU8$U#RWYU0T,/:X=WBVBM';Z=\(GKMB(*R$-$A,F(^K^TC-H'B1TR6M*]
MCXRH11LE71_A"%ZP?"P5*_&IOQ-SJ;*BS5%AE22\U"MLTJYHCEF!MR%8/%Y1
M-=;,'>J=C;^)'+,<'.&QJ^^LN01'R[,N5#X<+>UU&TP;,3OM,*IY>>TW;=<?
MM':;8Z<SQ>Z-J\/E%'B&_LM4QO+L+QZ/)7YW@71!GV QV[SVM($,'+";HP^6
MA@X"\! ::3A#2)P/82ZB*[,9:R]\Q#(TA,N4;VH%)0LA%I@IU@[,_J@3K%18
M%'0IB1H.6P!T_;3*5::]'>45%J528CV\3+$*IE@R0LX+X$6$.L%+?$TK+0(*
M9K=<NFBYDKHVXH9T98P%UK#%]4J<W^X%)$-&%A"E/+K2""G:,N'P^/3X*3)A
M8R1:+<G1;($D=R%,>\_#,98PUM5^X:CB'IX@xxxxx,5*\L,P;6BU"7J1:!1J
M(;^=SD0H@?LH.,[]VUB;O24MI=O3TOV>37^:E=+-K.31P+>;K(3=S_^E[=XY
MJ7VF_W%.2O?)24&37YIO_AU#0#=\>R29?#.]K/Z=;#0OJ^DHT'\5Q&%B_ -)
'I2S5"14

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/