fix ext2fs on arm

. the memory allocated with STATICINIT is flaky on arm

Change-Id: Ib559ccbc2b890f22eea8ee602a37f8055d6fe4bd
This commit is contained in:
Ben Gras 2014-08-26 00:26:26 +02:00
parent d26b52b7cf
commit 0cec32da3e
2 changed files with 7 additions and 13 deletions

View File

@ -5,6 +5,7 @@
#include "fs.h"
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <minix/com.h>
#include <sys/stat.h>
#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);

View File

@ -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.