Changes by: yura
Update of /cvs/linux-ntfs/ntfsprogs/ntfsprogs
In directory delta357:/tmp/cvs-serv2599/ntfsprogs
Modified Files:
	ntfsmount.c 
Log Message:
Fix free clusters and MFT records calculation
Index: ntfsmount.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/ntfsprogs/ntfsmount.c,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -p -r1.96 -r1.97
--- ntfsmount.c	17 Nov 2006 22:35:21 -0000	1.96
+++ ntfsmount.c	21 Nov 2006 15:31:10 -0000	1.97
@@ -141,10 +141,9 @@ static __inline__ int ntfs_fuse_is_named
 	return 0;
 }
 
-static long ntfs_fuse_get_nr_free_mft_records(ntfs_volume *vol)
+static long ntfs_fuse_get_nr_free_mft_records(ntfs_volume *vol, long nr_free)
 {
 	u8 *buf;
-	long nr_free = 0;
 	s64 br, total = 0;
 
 	if (!(ctx->state & NF_FreeMFTOutdate))
@@ -162,8 +161,8 @@ static long ntfs_fuse_get_nr_free_mft_re
 		total += br;
 		for (i = 0; i < br; i++)
 			for (j = 0; j < 8; j++)
-				if (!((buf[i] >> j) & 1))
-					nr_free++;
+				if ((buf[i] >> j) & 1)
+					nr_free--;
 	}
 	free(buf);
 	if (!total || br < 0)
@@ -176,7 +175,7 @@ static long ntfs_fuse_get_nr_free_mft_re
 static long ntfs_fuse_get_nr_free_clusters(ntfs_volume *vol)
 {
 	u8 *buf;
-	long nr_free = 0;
+	long nr_free = vol->nr_clusters;
 	s64 br, total = 0;
 
 	if (!(ctx->state & NF_FreeClustersOutdate))
@@ -194,8 +193,8 @@ static long ntfs_fuse_get_nr_free_cluste
 		total += br;
 		for (i = 0; i < br; i++)
 			for (j = 0; j < 8; j++)
-				if (!((buf[i] >> j) & 1))
-					nr_free++;
+				if ((buf[i] >> j) & 1)
+					nr_free--;
 	}
 	free(buf);
 	if (!total || br < 0)
@@ -247,9 +246,10 @@ static int ntfs_fuse_statfs(const char *
 	/* Free blocks avail to non-superuser, same as above on NTFS. */
 	sfs->f_bavail = sfs->f_bfree = size;
 	/* Number of inodes in file system (at this point in time). */
-	sfs->f_files = vol->mft_na->data_size >> vol->mft_record_size_bits;
+	size = vol->mft_na->data_size >> vol->mft_record_size_bits;
+	sfs->f_files = size; 
 	/* Free inodes in fs (based on current total count). */
-	size = ntfs_fuse_get_nr_free_mft_records(vol);
+	size = ntfs_fuse_get_nr_free_mft_records(vol, size);
 	if (size < 0)
 		size = 0;
 	sfs->f_ffree = size;
 |