From e8cfe71a180602c0eeb4fbacb925e32e3613f197 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Tue, 26 Aug 2014 00:26:26 +0200 Subject: [PATCH] fix ext2fs on arm . the memory allocated with STATICINIT is flaky on arm Change-Id: Ib559ccbc2b890f22eea8ee602a37f8055d6fe4bd --- minix/fs/ext2/mount.c | 5 +++-- minix/fs/ext2/super.c | 15 ++++----------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/minix/fs/ext2/mount.c b/minix/fs/ext2/mount.c index 5904e832f..3dca64bd9 100644 --- a/minix/fs/ext2/mount.c +++ b/minix/fs/ext2/mount.c @@ -5,6 +5,7 @@ #include "fs.h" #include #include +#include #include #include #include "buf.h" @@ -60,9 +61,9 @@ int fs_readsuper() } /* Fill in the super block. */ - STATICINIT(superblock, 1); - if (!superblock) + if(!(superblock = malloc(sizeof(*superblock)))) panic("Can't allocate memory for superblock."); + superblock->s_dev = fs_dev; /* read_super() needs to know which dev */ r = read_super(superblock); diff --git a/minix/fs/ext2/super.c b/minix/fs/ext2/super.c index 67dc2cea0..15976a064 100644 --- a/minix/fs/ext2/super.c +++ b/minix/fs/ext2/super.c @@ -73,7 +73,6 @@ register struct super_block *sp; /* pointer to a superblock */ int r; /* group descriptors, sp->s_group_desc points to this. */ static struct group_desc *group_descs; - char *buf; block_t gd_size; /* group descriptors table size in blocks */ int gdt_position; static char superblock_buf[1024]; @@ -149,16 +148,10 @@ register struct super_block *sp; /* pointer to a superblock */ gd_size = sp->s_gdb_count * sp->s_block_size; - buf = 0; - STATICINIT(buf, gd_size); - group_descs = (struct group_desc *) buf; - - buf = 0; - STATICINIT(buf, gd_size); - ondisk_group_descs = (struct group_desc *) buf; - - if (!group_descs || !ondisk_group_descs) - panic("can't allocate memory for gdt buffer"); + if(!(group_descs = malloc(gd_size * sizeof(struct group_desc)))) + panic("can't allocate group desc array"); + if(!(ondisk_group_descs = malloc(gd_size * sizeof(struct group_desc)))) + panic("can't allocate group desc array"); /* s_first_data_block (block number, where superblock is stored) * is 1 for 1Kb blocks and 0 for larger blocks.