aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrunchy <crunchy>2002-09-18 20:32:21 +0000
committercrunchy <crunchy>2002-09-18 20:32:21 +0000
commit4a49120603daab9f9ad280f0ef44e36b0218a302 (patch)
treeb52ecd086c0ffdb03018c7f1cbdfba5634ab923e
parent4b5697d9e49aa865058acf71b9a464ff939e8b1e (diff)
downloadmpiosh-4a49120603daab9f9ad280f0ef44e36b0218a302.tar.gz
mpiosh-4a49120603daab9f9ad280f0ef44e36b0218a302.tar.bz2
mpiosh-4a49120603daab9f9ad280f0ef44e36b0218a302.zip
bug fix for mput; removed compiler warnings; better return values on error
-rw-r--r--ChangeLog15
-rw-r--r--libmpio/defs.h19
-rw-r--r--libmpio/mpio.c35
-rw-r--r--mpiosh/callback.c7
-rw-r--r--mpiosh/mpiosh.c8
5 files changed, 55 insertions, 29 deletions
diff --git a/ChangeLog b/ChangeLog
index 6799dd8..0df39c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2002-09-18 Andreas Buesching <crunchy@tzi.de>
+
+ * libmpio/mpio.c (mpio_file_get, mpio_file_put, mpio_file_del):
+ using new error codes
+
+ * libmpio/defs.h (MPIO_ERR_*): added definitions for possible
+ errors codes
+
+ * libmpio/mpio.c (mpio_model_name): moved model array from def.h;
+ removed some compiler warnings (unused variables, missing return
+ codes)
+
+ * mpiosh/mpiosh.c (mpiosh_command_regex_fix): extented conditions
+ to not replace sequences like ".*" by "\\..*"
+
2002-09-16 Andreas Buesching <crunchy@tzi.de>
* kernel/Makefile.am (install-strip): defined to avoid stripping
diff --git a/libmpio/defs.h b/libmpio/defs.h
index 7f247aa..7e06524 100644
--- a/libmpio/defs.h
+++ b/libmpio/defs.h
@@ -1,7 +1,7 @@
/* -*- linux-c -*- */
/*
- * $Id: defs.h,v 1.5 2002/09/15 23:05:25 salmoon Exp $
+ * $Id: defs.h,v 1.6 2002/09/18 20:32:21 crunchy Exp $
*
* Library for USB MPIO-*
*
@@ -46,14 +46,6 @@ typedef enum { MPIO_MODEL_DME = 0x00,
MPIO_MODEL_DMK = 0x04,
MPIO_MODEL_UNKNOWN = 0x05 } mpio_model_t;
-static BYTE *mpio_model_name[] = {
- "MPIO-DME",
- "MPIO-DMG",
- "MPIO-DMB",
- "MPIO-DMB+",
- "MPIO-DMK",
- "unknown" };
-
/* USB commands */
typedef enum { GET_VERSION = 0x01,
GET_BLOCK = 0x02,
@@ -100,6 +92,15 @@ typedef enum { FTYPE_CONF = 'C',
#define INFO_LINE 81
+/* error codes */
+#define MPIO_ERR_FILE_NOT_FOUND -1
+#define MPIO_ERR_NOT_ENOUGH_SPACE -2
+#define MPIO_ERR_FILE_EXISTS -3
+#define MPIO_ERR_FAT_ERROR -4
+#define MPIO_ERR_READING_FILE -5
+#define MPIO_ERR_PERMISSION_DENIED -6
+#define MPIO_ERR_WRITING_FILE -7
+
/* get formatted information, about the MPIO player */
typedef struct {
diff --git a/libmpio/mpio.c b/libmpio/mpio.c
index 51a2894..35570e7 100644
--- a/libmpio/mpio.c
+++ b/libmpio/mpio.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: mpio.c,v 1.17 2002/09/15 12:03:23 germeier Exp $
+ * $Id: mpio.c,v 1.18 2002/09/18 20:32:22 crunchy Exp $
*
* Library for USB MPIO-*
*
@@ -43,6 +43,14 @@
#define DSTRING 100
+static BYTE *mpio_model_name[] = {
+ "MPIO-DME",
+ "MPIO-DMG",
+ "MPIO-DMB",
+ "MPIO-DMB+",
+ "MPIO-DMK",
+ "unknown" };
+
void mpio_init_internal(mpio_t *);
void mpio_init_external(mpio_t *);
@@ -275,7 +283,6 @@ mpio_file_get(mpio_t *m, mpio_mem_t mem, BYTE *filename,
BYTE (*progress_callback)(int, int))
{
mpio_smartmedia_t *sm;
- BYTE fname[129];
BYTE block[BLOCK_SIZE];
int fd, towrite;
BYTE *p;
@@ -288,7 +295,7 @@ mpio_file_get(mpio_t *m, mpio_mem_t mem, BYTE *filename,
/* please fix me sometime */
/* the system entries are kind of special ! */
if (strncmp("sysdum", filename, 6) == 0)
- return 0;
+ return MPIO_ERR_PERMISSION_DENIED;
if (mem == MPIO_INTERNAL_MEM) sm = &m->internal;
if (mem == MPIO_EXTERNAL_MEM) sm = &m->external;
@@ -323,7 +330,7 @@ mpio_file_get(mpio_t *m, mpio_mem_t mem, BYTE *filename,
debug("error writing file data\n");
close(fd);
free (f);
- return -1;
+ return MPIO_ERR_WRITING_FILE;
}
filesize -= towrite;
@@ -360,7 +367,6 @@ mpio_file_put(mpio_t *m, mpio_mem_t mem, BYTE *filename,
mpio_smartmedia_t *sm;
mpio_fatentry_t *f, current, firstblock, backup;
WORD start;
- int data_offset;
BYTE block[BLOCK_SIZE];
int fd, toread;
struct stat file_stat;
@@ -374,7 +380,7 @@ mpio_file_put(mpio_t *m, mpio_mem_t mem, BYTE *filename,
if (stat((const char *)filename, &file_stat)!=0) {
debug("could not find file: %s\n", filename);
- return 0;
+ return MPIO_ERR_FILE_NOT_FOUND;
}
fsize=filesize=file_stat.st_size;
debugn(2, "filesize: %d\n", fsize);
@@ -383,7 +389,7 @@ mpio_file_put(mpio_t *m, mpio_mem_t mem, BYTE *filename,
mpio_memory_free(m, mem, &free);
if (free*1024<fsize) {
debug("not enough space left (only %d KB)\n", free);
- return 0;
+ return MPIO_ERR_NOT_ENOUGH_SPACE;
}
/* check if filename already exists */
@@ -393,7 +399,7 @@ mpio_file_put(mpio_t *m, mpio_mem_t mem, BYTE *filename,
if (p)
{
debug("filename already exists\n");
- return 0;
+ return MPIO_ERR_FILE_EXISTS;
}
/* find first free sector */
@@ -401,7 +407,7 @@ mpio_file_put(mpio_t *m, mpio_mem_t mem, BYTE *filename,
if (!f)
{
debug("could not free cluster for file!\n");
- return 0;
+ return MPIO_ERR_FAT_ERROR;
} else {
memcpy(&firstblock, f, sizeof(mpio_fatentry_t));
start=f->entry;
@@ -429,7 +435,7 @@ mpio_file_put(mpio_t *m, mpio_mem_t mem, BYTE *filename,
if (fd==-1)
{
debug("could not open file: %s\n", filename);
- return 0;
+ return MPIO_ERR_FILE_NOT_FOUND;
}
while ((filesize>BLOCK_SIZE) && (!abort)) {
@@ -443,7 +449,7 @@ mpio_file_put(mpio_t *m, mpio_mem_t mem, BYTE *filename,
if (read(fd, block, toread)!=toread) {
debug("error reading file data\n");
close(fd);
- return -1;
+ return MPIO_ERR_READING_FILE;
}
filesize -= toread;
@@ -473,7 +479,7 @@ mpio_file_put(mpio_t *m, mpio_mem_t mem, BYTE *filename,
if (read(fd, block, toread)!=toread) {
debug("error reading file data\n");
close(fd);
- return -1;
+ return MPIO_ERR_READING_FILE;
}
filesize -= toread;
@@ -544,7 +550,6 @@ mpio_memory_format(mpio_t *m, mpio_mem_t mem,
mpio_smartmedia_t *sm;
mpio_fatentry_t *f;
DWORD clusters;
- DWORD i;
BYTE abort = 0;
if (mem == MPIO_INTERNAL_MEM)
@@ -621,7 +626,7 @@ mpio_file_del(mpio_t *m, mpio_mem_t mem, BYTE *filename,
/* please fix me sometime */
/* the system entry are kind of special ! */
if (strncmp("sysdum", filename, 6)==0)
- return 0;
+ return MPIO_ERR_PERMISSION_DENIED;
if (mem == MPIO_INTERNAL_MEM) sm = &m->internal;
if (mem == MPIO_EXTERNAL_MEM) sm = &m->external;
@@ -684,7 +689,7 @@ int
mpio_sync(mpio_t *m, mpio_mem_t mem)
{
/* this writes the FAT *and* the root directory */
- mpio_fat_write(m, mem);
+ return mpio_fat_write(m, mem);
}
int
diff --git a/mpiosh/callback.c b/mpiosh/callback.c
index 74a4567..df4a3ab 100644
--- a/mpiosh/callback.c
+++ b/mpiosh/callback.c
@@ -2,7 +2,7 @@
*
* Author: Andreas Büsching <crunchy@tzi.de>
*
- * $Id: callback.c,v 1.8 2002/09/15 20:07:10 crunchy Exp $
+ * $Id: callback.c,v 1.9 2002/09/18 20:32:22 crunchy Exp $
*
* Copyright (C) 2001 Andreas Büsching <crunchy@tzi.de>
*
@@ -340,6 +340,11 @@ mpiosh_cmd_mput(char *args[])
printf("putting '%s' ... \n", (*run)->d_name);
fsize = mpio_file_put(mpiosh.dev, mpiosh.card,
(*run)->d_name, mpiosh_callback_put);
+ if ((fsize < 0) && (fsize == MPIO_ERR_NOT_ENOUGH_SPACE)) {
+ fprintf(stderr, "error: not enough space left on memory card\n");
+ break;
+ }
+
if (mpiosh_cancel) break;
printf("\n");
written=1; /* we did write something, so do mpio_sync afterwards */
diff --git a/mpiosh/mpiosh.c b/mpiosh/mpiosh.c
index 79285d3..10e518e 100644
--- a/mpiosh/mpiosh.c
+++ b/mpiosh/mpiosh.c
@@ -2,7 +2,7 @@
/*
*
- * $Id: mpiosh.c,v 1.12 2002/09/15 14:55:58 crunchy Exp $
+ * $Id: mpiosh.c,v 1.13 2002/09/18 20:32:22 crunchy Exp $
*
* Author: Andreas Büsching <crunchy@tzi.de>
*
@@ -256,13 +256,13 @@ mpiosh_command_regex_fix(char *argv[])
new_pos = buffer;
*new_pos++ = '^';
while (*help != '\0') {
- if (*help == '*') {
+ if (*help == '*' && ((help = *walk) || (*(help - 1) != '.'))) {
*new_pos++ = '.';
*new_pos = *help;
- } else if (*help == '.') {
+ } else if ((*help == '.') && (*help != '*')) {
*new_pos++ = '\\';
*new_pos = *help;
- } else if (*help == '?') {
+ } else if (*help == '?' && ((help = *walk) || (*(help - 1) != '\\'))) {
*new_pos = '.';
} else {
*new_pos = *help;