lkml.org 
[lkml]   [2001]   [Jan]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRE: [PTACH] wrong stat of NTFS volume in linux-kernel 2.4.0
Willem,

First of all thanks for tracking down this bug! Keep up the good work.

I have produced a IMHO more elegant solution (see attached patch) which
doesn't require introducing the ugly divide function by using the
asm/bitops.h::ffs() function and then replacing all clusterfactor
arithmetic with shifts by the (new) clusterfactorbits. In fact the
clusterfactor is completely replaced by the clusterfactorbits in the
driver.

The patch has been submitted to Alan for inclusion in the 2.4.0-ac series
as Linus at present only accepts critical patches which this clearly is
not.

btw. Patch is tested and works fine.

Best regards,

Anton Altaparmakov

--
Anton Altaparmakov Phone: +44-(0)1223-333541 (lab)
Christ's College eMail: AntonA@bigfoot.com
Cambridge CB2 3BU WWW: http://www-stu.christs.cam.ac.uk/~aia21/
United Kingdom ICQ: 8561279
--- linux/fs/ntfs/super.old Mon Jan 8 09:08:10 2001
+++ linux/fs/ntfs/super.c Mon Jan 8 02:36:33 2001
@@ -12,6 +12,7 @@
#include "super.h"

#include <linux/errno.h>
+#include <asm/bitops.h>
#include "macros.h"
#include "inode.h"
#include "support.h"
@@ -75,7 +76,7 @@

/* Sector size */
vol->blocksize=NTFS_GETU16(boot+0xB);
- vol->clusterfactor=NTFS_GETU8(boot+0xD);
+ vol->clusterfactorbits = ffs(NTFS_GETU8(boot+0xD)) - 1;
vol->mft_clusters_per_record=NTFS_GETS8(boot+0x40);
vol->index_clusters_per_record=NTFS_GETS8(boot+0x44);

@@ -95,7 +96,7 @@
if(vol->mft_clusters_per_record<0 && vol->mft_clusters_per_record!=-10)
ntfs_error("Unexpected data #4 in boot block\n");

- vol->clustersize=vol->blocksize*vol->clusterfactor;
+ vol->clustersize = vol->blocksize << vol->clusterfactorbits;
if(vol->mft_clusters_per_record>0)
vol->mft_recordsize=
vol->clustersize*vol->mft_clusters_per_record;
@@ -322,7 +323,7 @@
io.do_read=1;
io.size=vol->clustersize;
ntfs_getput_clusters(vol,0,0,&io);
- *vol_size = NTFS_GETU64(cluster0+0x28);
+ *vol_size = NTFS_GETU64(cluster0+0x28) >> vol->clusterfactorbits;
ntfs_free(cluster0);
return 0;
}
--- linux/fs/ntfs/struct.old Mon Jan 8 02:37:18 2001
+++ linux/fs/ntfs/struct.h Mon Jan 8 02:35:15 2001
@@ -54,7 +54,7 @@
ntfs_u32 at_symlink; /* aka SYMBOLIC_LINK or REPARSE_POINT */
/* Data read from the boot file */
int blocksize;
- int clusterfactor;
+ int clusterfactorbits;
int clustersize;
int mft_recordsize;
int mft_clusters_per_record;
--- linux/include/linux/ntfs_fs_sb.old Mon Jan 8 02:37:46 2001
+++ linux/include/linux/ntfs_fs_sb.h Mon Jan 8 02:37:54 2001
@@ -26,7 +26,7 @@
ntfs_u32 at_symlink; /* aka SYMBOLIC_LINK or REPARSE_POINT */
/* Data read from the boot file */
int blocksize;
- int clusterfactor;
+ int clusterfactorbits;
int clustersize;
int mft_recordsize;
int mft_clusters_per_record;
\
 
 \ /
  Last update: 2005-03-22 12:52    [W:0.031 / U:14.208 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site