[PATCH] Fix incorrect zone count

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all. It seems that the zone map, inodes, inode maps and superblock
aren't included in the zone map. At least it's the impression I've got from:
        Super3.s_zmap_blocks = UPPER(BLOCKS -
(1+get_nimaps()+inode_blocks()),
                         BITS_PER_BLOCK+1);
However, in another place the assumption is opposite and this leads to
an attempt to write outside the allocated buffer. Attached patch fixes it.

-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko

diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c
index 051cd5f..fd68fc9 100644
--- a/disk-utils/mkfs.minix.c
+++ b/disk-utils/mkfs.minix.c
@@ -421,13 +432,13 @@ static void super_set_nzones(void)
 {
 	switch (fs_version) {
 	case 3:
-		Super3.s_zones = BLOCKS;
+		Super3.s_zones = BLOCKS - Super3.s_zmap_blocks - (1+get_nimaps()+inode_blocks());
 		break;
 	case 2:
-		Super.s_zones = BLOCKS;
+		Super.s_zones = BLOCKS - Super.s_zmap_blocks - (1+get_nimaps()+inode_blocks());
 		break;
 	default: /* v1 */
-		Super.s_nzones = BLOCKS;
+		Super.s_nzones = BLOCKS - Super.s_zmap_blocks - (1+get_nimaps()+inode_blocks());
 		break;
 	}
 }
@@ -497,8 +508,6 @@ static void setup_tables(void) {
 	}
 
 	super_init_maxsize();
-	super_set_nzones();
-	zones = get_nzones();
 
 	/* some magic nrs: 1 inode / 3 blocks */
 	if ( req_nr_inodes == 0 ) 
@@ -522,6 +531,9 @@ static void setup_tables(void) {
 	}
 
 	super_set_map_blocks(inodes);
+	super_set_nzones();
+
+	zones = get_nzones();
 	imaps = get_nimaps();
 	zmaps = get_nzmaps();
 

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux