All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix incorrect zone count
@ 2012-05-09 21:49 Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 0 replies; only message in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2012-05-09 21:49 UTC (permalink / raw)
  To: util-linux


[-- Attachment #1.1: Type: text/plain, Size: 484 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: minix.diff --]
[-- Type: text/x-diff; name="minix.diff", Size: 1081 bytes --]

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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-05-09 21:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-09 21:49 [PATCH] Fix incorrect zone count Vladimir 'φ-coder/phcoder' Serbinenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.