aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgermeier <germeier>2004-04-23 19:21:07 +0000
committergermeier <germeier>2004-04-23 19:21:07 +0000
commit70c554eb583caaedeebc94c8af44168831ce8167 (patch)
treecb0e5ef6201b98860b7b539c1d34a0691ff21634
parentbac753b8405c719efd4b922c81983fd75e5486fe (diff)
downloadmpiosh-70c554eb583caaedeebc94c8af44168831ce8167.tar.gz
mpiosh-70c554eb583caaedeebc94c8af44168831ce8167.tar.bz2
mpiosh-70c554eb583caaedeebc94c8af44168831ce8167.zip
don't dump core if internal memory is not available
-rw-r--r--ChangeLog1
-rw-r--r--libmpio/defs.h3
-rw-r--r--libmpio/src/directory.c4
-rw-r--r--libmpio/src/mpio.c28
-rw-r--r--mpiosh/callback.c9
5 files changed, 38 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index f34b9c0..8862316 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
2004-04-23 Markus Germeier <mager@tzi.de>
* libmpio/src/mpio.c (mpio_close):
- fixed a stupid bug while closing the device
+ * don't dump core if internal memory is not available
2004-04-23 Markus Germeier <mager@tzi.de>
* remove all files from CVS which can be automagically
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);
diff --git a/mpiosh/callback.c b/mpiosh/callback.c
index e7d2865..20d8112 100644
--- a/mpiosh/callback.c
+++ b/mpiosh/callback.c
@@ -2,7 +2,7 @@
*
* Author: Andreas Bsching <crunchy@tzi.de>
*
- * $Id: callback.c,v 1.47 2003/10/19 21:06:35 germeier Exp $
+ * $Id: callback.c,v 1.48 2004/04/23 19:21:08 germeier Exp $
*
* Copyright (C) 2001 Andreas Bsching <crunchy@tzi.de>
*
@@ -834,13 +834,16 @@ void
mpiosh_cmd_health(char *args[])
{
mpio_health_t health;
- int i, lost;
+ int i, lost, r;
UNUSED(args);
MPIOSH_CHECK_CONNECTION_CLOSED;
- mpio_health(mpiosh.dev, mpiosh.card, &health);
+ if ((r=mpio_health(mpiosh.dev, mpiosh.card, &health)) != MPIO_OK) {
+ printf("error: %s\n", mpio_strerror(r));
+ return;
+ }
if (mpiosh.card == MPIO_INTERNAL_MEM) {
lost=0;