From 70c554eb583caaedeebc94c8af44168831ce8167 Mon Sep 17 00:00:00 2001 From: germeier Date: Fri, 23 Apr 2004 19:21:07 +0000 Subject: don't dump core if internal memory is not available --- libmpio/defs.h | 3 ++- libmpio/src/directory.c | 4 +++- libmpio/src/mpio.c | 28 ++++++++++++++++++++++++++-- 3 files changed, 31 insertions(+), 4 deletions(-) (limited to 'libmpio') diff --git a/libmpio/defs.h b/libmpio/defs.h index 780c46e..c7880c0 100644 --- a/libmpio/defs.h +++ b/libmpio/defs.h @@ -1,5 +1,5 @@ /* - * $Id: defs.h,v 1.33 2004/04/19 12:19:20 germeier Exp $ + * $Id: defs.h,v 1.34 2004/04/23 19:21:07 germeier Exp $ * * libmpio - a library for accessing Digit@lways MPIO players * Copyright (C) 2002, 2003 Markus Germeier @@ -166,6 +166,7 @@ typedef struct { #define MPIO_ERR_DIR_RECURSION -16 #define MPIO_ERR_FILE_IS_A_DIR -17 #define MPIO_ERR_USER_CANCEL -18 +#define MPIO_ERR_MEMORY_NOT_AVAIL -19 /* internal errors, occur when UI has errors! */ #define MPIO_ERR_INT_STRING_INVALID -101 diff --git a/libmpio/src/directory.c b/libmpio/src/directory.c index e0065bd..4827ae3 100644 --- a/libmpio/src/directory.c +++ b/libmpio/src/directory.c @@ -1,5 +1,5 @@ /* - * $Id: directory.c,v 1.12 2003/10/19 21:06:35 germeier Exp $ + * $Id: directory.c,v 1.13 2004/04/23 19:21:07 germeier Exp $ * * libmpio - a library for accessing Digit@lways MPIO players * Copyright (C) 2002, 2003 Markus Germeier @@ -231,6 +231,8 @@ mpio_directory_open(mpio_t *m, mpio_mem_t mem) return NULL; } } else { + if (!m->internal.size) + return NULL; out = m->internal.cdir->dir; } diff --git a/libmpio/src/mpio.c b/libmpio/src/mpio.c index 1d66578..d5667d1 100644 --- a/libmpio/src/mpio.c +++ b/libmpio/src/mpio.c @@ -1,5 +1,5 @@ /* - * $Id: mpio.c,v 1.13 2004/04/23 18:17:56 germeier Exp $ + * $Id: mpio.c,v 1.14 2004/04/23 19:21:07 germeier Exp $ * * libmpio - a library for accessing Digit@lways MPIO players * Copyright (C) 2002-2004 Markus Germeier @@ -108,6 +108,8 @@ static mpio_error_t mpio_errors[] = { "Requested file is a directory!" }, { MPIO_ERR_USER_CANCEL , "Operation canceled by user!" }, + { MPIO_ERR_MEMORY_NOT_AVAIL , + "Selected memory is not available!" }, { MPIO_ERR_INT_STRING_INVALID, "Internal Error: Supported is invalid!" } }; @@ -590,6 +592,9 @@ mpio_file_get_real(mpio_t *m, mpio_mem_t mem, mpio_filename_t filename, if (mem == MPIO_INTERNAL_MEM) sm = &m->internal; if (mem == MPIO_EXTERNAL_MEM) sm = &m->external; + if (!sm->size) + MPIO_ERR_RETURN(MPIO_ERR_MEMORY_NOT_AVAIL); + block_size = mpio_block_get_blocksize(m, mem); if(as==NULL) { @@ -732,6 +737,9 @@ mpio_file_put_real(mpio_t *m, mpio_mem_t mem, mpio_filename_t i_filename, if (mem==MPIO_INTERNAL_MEM) sm=&m->internal; if (mem==MPIO_EXTERNAL_MEM) sm=&m->external; + if (!sm->size) + MPIO_ERR_RETURN(MPIO_ERR_MEMORY_NOT_AVAIL); + block_size = mpio_block_get_blocksize(m, mem); if (memory) @@ -1047,6 +1055,9 @@ mpio_memory_format(mpio_t *m, mpio_mem_t mem, data_offset = 0x02; } + if (!sm->size) + MPIO_ERR_RETURN(MPIO_ERR_MEMORY_NOT_AVAIL); + clusters = sm->size*128; @@ -1167,6 +1178,9 @@ mpio_file_del(mpio_t *m, mpio_mem_t mem, mpio_filename_t filename, if (mem == MPIO_INTERNAL_MEM) sm = &m->internal; if (mem == MPIO_EXTERNAL_MEM) sm = &m->external; + if (!sm->size) + MPIO_ERR_RETURN(MPIO_ERR_MEMORY_NOT_AVAIL); + block_size = mpio_block_get_blocksize(m, mem); if ((strcmp(filename, "..") == 0) || @@ -1286,6 +1300,8 @@ mpio_health(mpio_t *m, mpio_mem_t mem, mpio_health_t *r) { sm = &m->internal; r->num = sm->chips; + if (!sm->size) + return MPIO_ERR_MEMORY_NOT_AVAIL; r->block_size = mpio_block_get_blocksize(m, mem) / 1024; @@ -1313,7 +1329,9 @@ mpio_health(mpio_t *m, mpio_mem_t mem, mpio_health_t *r) if (mem == MPIO_EXTERNAL_MEM) { - sm = &m->external; + sm = &m->external; + if (!sm->size) + return MPIO_ERR_MEMORY_NOT_AVAIL; zones = sm->max_cluster / MPIO_ZONE_LBLOCKS + 1; r->num = zones; @@ -1350,6 +1368,9 @@ mpio_memory_dump(mpio_t *m, mpio_mem_t mem) if (mem == MPIO_INTERNAL_MEM) { + if (!m->internal.size) + return 0; + hexdump(m->internal.fat, m->internal.max_blocks*0x10); hexdump(m->internal.root->dir, DIR_SIZE); if (m->internal.version) { @@ -1371,6 +1392,9 @@ mpio_memory_dump(mpio_t *m, mpio_mem_t mem) if (mem == MPIO_EXTERNAL_MEM) { + if (!m->external.size) + return 0; + hexdump(m->external.spare, m->external.max_blocks*0x10); hexdump(m->external.fat, m->external.fat_size*SECTOR_SIZE); hexdump(m->external.root->dir, DIR_SIZE); -- cgit v1.2.3