aboutsummaryrefslogtreecommitdiff
path: root/libmpio
diff options
context:
space:
mode:
authorgermeier <germeier>2002-09-24 15:38:03 +0000
committergermeier <germeier>2002-09-24 15:38:03 +0000
commitd9ec7993f9705a100043fc890eaa050bcba05349 (patch)
treeb90d070abdf68018624f459cc602ad354bc7eb6e /libmpio
parent0606ee0c8abd344763d6fa46519e8f6db485538e (diff)
downloadmpiosh-d9ec7993f9705a100043fc890eaa050bcba05349.tar.gz
mpiosh-d9ec7993f9705a100043fc890eaa050bcba05349.tar.bz2
mpiosh-d9ec7993f9705a100043fc890eaa050bcba05349.zip
fixed issues with 8.3 names in directory.c
actually use mpio_filetype_t to tag files during writing of internal memory writing of Config.dat does work now (though it needs some code in mpiosh)
Diffstat (limited to 'libmpio')
-rw-r--r--libmpio/defs.h7
-rw-r--r--libmpio/directory.c35
-rw-r--r--libmpio/fat.c48
-rw-r--r--libmpio/fat.h6
-rw-r--r--libmpio/mpio.c23
-rw-r--r--libmpio/mpio.h5
6 files changed, 73 insertions, 51 deletions
diff --git a/libmpio/defs.h b/libmpio/defs.h
index a6422cd..68a87ca 100644
--- a/libmpio/defs.h
+++ b/libmpio/defs.h
@@ -1,7 +1,7 @@
/* -*- linux-c -*- */
/*
- * $Id: defs.h,v 1.9 2002/09/23 22:38:03 germeier Exp $
+ * $Id: defs.h,v 1.10 2002/09/24 15:38:03 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -59,12 +59,13 @@ typedef enum { GET_VERSION = 0x01,
/* file types on internal memory */
/* found in the code of salmoon, are these needed? -mager */
-typedef enum { FTYPE_CONF = 'C',
+typedef enum { FTYPE_MUSIC = 0x01,
+ FTYPE_CONF = 'C',
FTYPE_FONT = 'F',
FTYPE_OTHER = 'H',
FTYPE_MEMO = 'M',
FTYPE_WAV = 'V',
- FTYPE_ENTRY = 'R' } mpio_file_t;
+ FTYPE_ENTRY = 'R' } mpio_filetype_t;
/* type of callback functions */
typedef BYTE (*mpio_callback_t)(int, int) ;
diff --git a/libmpio/directory.c b/libmpio/directory.c
index 0991cc1..ea51ac3 100644
--- a/libmpio/directory.c
+++ b/libmpio/directory.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: directory.c,v 1.6 2002/09/14 22:54:41 germeier Exp $
+ * $Id: directory.c,v 1.7 2002/09/24 15:38:03 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -414,7 +414,7 @@ mpio_dentry_get_startcluster(mpio_t *m, mpio_mem_t mem, BYTE *p)
if (cluster < 0)
return NULL;
- new = mpio_fatentry_new(m, mem, cluster);
+ new = mpio_fatentry_new(m, mem, cluster, FTYPE_MUSIC);
if (mem == MPIO_INTERNAL_MEM)
{
@@ -515,8 +515,6 @@ mpio_dentry_put(mpio_t *m, mpio_mem_t mem,
/* find uniq 8.3 filename */
memset(f_8_3, 0x20, 12);
- f_8_3[6]='~';
- f_8_3[7]='1';
f_8_3[8]='.';
f_8_3[12]=0x00;
@@ -540,6 +538,12 @@ mpio_dentry_put(mpio_t *m, mpio_mem_t mem,
j++;
}
+ if (mpio_dentry_find_name_8_3(m, mem, f_8_3))
+ {
+ f_8_3[6]='~';
+ f_8_3[7]='1';
+ }
+
while(mpio_dentry_find_name_8_3(m, mem, f_8_3))
f_8_3[7]++;
@@ -597,8 +601,25 @@ mpio_dentry_find_name_8_3(mpio_t *m, BYTE mem, BYTE *filename)
WORD wdummy;
BYTE fname[129];
BYTE fname_8_3[13];
+ BYTE filename_8_3[13];
DWORD ddummy;
BYTE *found = 0;
+ int i, j, len;
+
+ /* format given filename to a "standard" 8.3 filename */
+ memset(filename_8_3, 0x20, 13);
+ filename_8_3[12]=0;
+ len=strlen(filename);
+ i=j=0;
+ while ((i<13) && (j <len))
+ {
+ if (filename[j] == '.')
+ i=8;
+ filename_8_3[i] = filename[j];
+
+ i++;
+ j++;
+ }
p = mpio_directory_open(m, mem);
while ((p) && (!found)) {
@@ -607,9 +628,9 @@ mpio_dentry_find_name_8_3(mpio_t *m, BYTE mem, BYTE *filename)
fname_8_3,
&wdummy, &bdummy, &bdummy,
&bdummy, &bdummy, &ddummy);
-/* debug ("s: %s\n", fname_8_3); */
- if ((strcmp(fname_8_3, filename) == 0) &&
- (strcmp(filename,fname_8_3) == 0)) {
+
+ if ((strcmp(fname_8_3, filename_8_3) == 0) &&
+ (strcmp(filename_8_3,fname_8_3) == 0)) {
found = p;
p = NULL;
}
diff --git a/libmpio/fat.c b/libmpio/fat.c
index a7bec74..1a09f7b 100644
--- a/libmpio/fat.c
+++ b/libmpio/fat.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: fat.c,v 1.13 2002/09/23 22:41:14 germeier Exp $
+ * $Id: fat.c,v 1.14 2002/09/24 15:38:03 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -200,7 +200,7 @@ mpio_bootblocks_read (mpio_t *m, mpio_mem_t mem)
}
mpio_fatentry_t *
-mpio_fatentry_new(mpio_t *m, mpio_mem_t mem, DWORD sector)
+mpio_fatentry_new(mpio_t *m, mpio_mem_t mem, DWORD sector, BYTE ftype)
{
mpio_smartmedia_t *sm;
mpio_fatentry_t *new;
@@ -216,7 +216,7 @@ mpio_fatentry_new(mpio_t *m, mpio_mem_t mem, DWORD sector)
/* init FAT entry */
memset(new->i_fat, 0xff, 0x10);
new->i_fat[0x00] = 0xaa; /* start of file */
- new->i_fat[0x06] = 0x01; /* filetype, hmm ... */
+ new->i_fat[0x06] = ftype;
new->i_fat[0x0b] = 0x00;
new->i_fat[0x0c] = 0x00;
new->i_fat[0x0d] = 0x00;
@@ -341,17 +341,24 @@ mpio_fatentry_read(mpio_t *m, mpio_mem_t mem, mpio_fatentry_t *f )
debug("defective block encountered, abort reading!\n");
return 0xaaaaaaaa;
}
- e += 7;
- if((sm->fat[e+0] == 0xff) &&
- (sm->fat[e+1] == 0xff) &&
- (sm->fat[e+2] == 0xff) &&
- (sm->fat[e+3] == 0xff))
+ /* this is a special system file! */
+ if((sm->fat[e+6] != FTYPE_MUSIC) &&
+ (sm->fat[e+7] == 0xff) &&
+ (sm->fat[e+8] == 0x00) &&
+ (sm->fat[e+9] == 0xff) &&
+ (sm->fat[e+10] == 0xff))
+ return 0xffffffff;
+
+ if((sm->fat[e+7] == 0xff) &&
+ (sm->fat[e+8] == 0xff) &&
+ (sm->fat[e+9] == 0xff) &&
+ (sm->fat[e+10] == 0xff))
return 0xffffffff;
- v = sm->fat[e+0] * 0x1000000 +
- sm->fat[e+1] * 0x10000 +
- sm->fat[e+2] * 0x100 +
- sm->fat[e+3];
+ v = sm->fat[e+7] * 0x1000000 +
+ sm->fat[e+8] * 0x10000 +
+ sm->fat[e+9] * 0x100 +
+ sm->fat[e+10];
return v;
}
@@ -427,7 +434,7 @@ mpio_fat_internal_find_startsector(mpio_t *m, BYTE start)
mpio_smartmedia_t *sm = &m->internal;
int found=-1;
- f = mpio_fatentry_new(m, MPIO_INTERNAL_MEM, 0);
+ f = mpio_fatentry_new(m, MPIO_INTERNAL_MEM, 0, FTYPE_MUSIC);
while(mpio_fatentry_plus_plus(f))
{
@@ -451,7 +458,7 @@ mpio_fat_internal_find_fileindex(mpio_t *m)
memset(index, 1, 256);
- f = mpio_fatentry_new(m, MPIO_INTERNAL_MEM, 0);
+ f = mpio_fatentry_new(m, MPIO_INTERNAL_MEM, 0, FTYPE_MUSIC);
while(mpio_fatentry_plus_plus(f))
{
if (sm->fat[f->entry * 0x10 + 1] != 0xff)
@@ -483,7 +490,7 @@ mpio_fat_free_clusters(mpio_t *m, mpio_mem_t mem)
int e = 0;
int fsize;
- f = mpio_fatentry_new(m, mem, 0);
+ f = mpio_fatentry_new(m, mem, 0, FTYPE_MUSIC);
do
{
@@ -497,11 +504,11 @@ mpio_fat_free_clusters(mpio_t *m, mpio_mem_t mem)
}
mpio_fatentry_t *
-mpio_fatentry_find_free(mpio_t *m, mpio_mem_t mem)
+mpio_fatentry_find_free(mpio_t *m, mpio_mem_t mem, BYTE ftype)
{
mpio_fatentry_t *f;
- f = mpio_fatentry_new(m, mem, 1);
+ f = mpio_fatentry_new(m, mem, 1, ftype);
while(mpio_fatentry_plus_plus(f))
{
@@ -589,7 +596,7 @@ mpio_fat_clear(mpio_t *m, mpio_mem_t mem)
if (mem == MPIO_INTERNAL_MEM) {
sm = &m->internal;
- f = mpio_fatentry_new(m, mem, 1);
+ f = mpio_fatentry_new(m, mem, 1, FTYPE_MUSIC);
do {
mpio_fatentry_set_free(m, mem, f) ;
} while(mpio_fatentry_plus_plus(f));
@@ -627,7 +634,7 @@ mpio_fat_write(mpio_t *m, mpio_mem_t mem)
if (mem == MPIO_INTERNAL_MEM) {
sm = &m->internal;
- f=mpio_fatentry_new(m, mem, 0);
+ f=mpio_fatentry_new(m, mem, 0, FTYPE_MUSIC);
mpio_io_block_delete(m, mem, f);
free(f);
@@ -656,7 +663,8 @@ mpio_fat_write(mpio_t *m, mpio_mem_t mem)
/* yuck */
f=mpio_fatentry_new(m, mem,
((i / 0x20) -
- ((sm->dir_offset + DIR_NUM)/BLOCK_SECTORS - 2 )));
+ ((sm->dir_offset + DIR_NUM)/BLOCK_SECTORS - 2 )),
+ FTYPE_MUSIC);
mpio_io_block_delete(m, mem, f);
free(f);
}
diff --git a/libmpio/fat.h b/libmpio/fat.h
index 84963b5..65e0857 100644
--- a/libmpio/fat.h
+++ b/libmpio/fat.h
@@ -1,6 +1,6 @@
/*
*
- * $Id: fat.h,v 1.7 2002/09/23 22:38:03 germeier Exp $
+ * $Id: fat.h,v 1.8 2002/09/24 15:38:03 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -36,10 +36,10 @@ int mpio_fat_clear(mpio_t *, mpio_mem_t);
int mpio_fat_free_clusters(mpio_t *, mpio_mem_t);
int mpio_fat_free(mpio_t *, mpio_mem_t);
-mpio_fatentry_t *mpio_fatentry_new(mpio_t *, mpio_mem_t, DWORD);
+mpio_fatentry_t *mpio_fatentry_new(mpio_t *, mpio_mem_t, DWORD, BYTE);
int mpio_fatentry_plus_plus(mpio_fatentry_t *);
-mpio_fatentry_t *mpio_fatentry_find_free(mpio_t *, mpio_mem_t);
+mpio_fatentry_t *mpio_fatentry_find_free(mpio_t *, mpio_mem_t, BYTE);
int mpio_fatentry_next_free(mpio_t *, mpio_mem_t,
mpio_fatentry_t *);
int mpio_fatentry_next_entry(mpio_t *, mpio_mem_t,
diff --git a/libmpio/mpio.c b/libmpio/mpio.c
index 97c5884..6e2fd45 100644
--- a/libmpio/mpio.c
+++ b/libmpio/mpio.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: mpio.c,v 1.26 2002/09/23 22:38:03 germeier Exp $
+ * $Id: mpio.c,v 1.27 2002/09/24 15:38:03 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -381,11 +381,6 @@ mpio_file_get(mpio_t *m, mpio_mem_t mem, mpio_filename_t filename,
MPIO_CHECK_FILENAME(filename);
- /* please fix me sometime */
- /* the system entries are kind of special ! */
- if (strncmp("sysdum", filename, 6) == 0)
- MPIO_ERR_RETURN(MPIO_ERR_PERMISSION_DENIED);
-
if (mem == MPIO_INTERNAL_MEM) sm = &m->internal;
if (mem == MPIO_EXTERNAL_MEM) sm = &m->external;
@@ -454,6 +449,7 @@ mpio_file_get(mpio_t *m, mpio_mem_t mem, mpio_filename_t filename,
int
mpio_file_put(mpio_t *m, mpio_mem_t mem, mpio_filename_t filename,
+ mpio_filetype_t filetype,
mpio_callback_t progress_callback)
{
mpio_smartmedia_t *sm;
@@ -497,7 +493,7 @@ mpio_file_put(mpio_t *m, mpio_mem_t mem, mpio_filename_t filename,
}
/* find first free sector */
- f = mpio_fatentry_find_free(m, mem);
+ f = mpio_fatentry_find_free(m, mem, filetype);
if (!f)
{
debug("could not free cluster for file!\n");
@@ -637,8 +633,7 @@ mpio_file_put(mpio_t *m, mpio_mem_t mem, mpio_filename_t filename,
}
int
-mpio_memory_format(mpio_t *m, mpio_mem_t mem,
- BYTE (*progress_callback)(int, int))
+mpio_memory_format(mpio_t *m, mpio_mem_t mem, mpio_callback_t progress_callback)
{
int data_offset;
mpio_smartmedia_t *sm;
@@ -665,7 +660,7 @@ mpio_memory_format(mpio_t *m, mpio_mem_t mem,
*/
mpio_fat_clear(m, mem);
- f = mpio_fatentry_new(m, mem, data_offset);
+ f = mpio_fatentry_new(m, mem, data_offset, FTYPE_MUSIC);
do
{
if (!mpio_io_block_delete(m, mem, f))
@@ -689,7 +684,8 @@ mpio_memory_format(mpio_t *m, mpio_mem_t mem,
if (mem == MPIO_EXTERNAL_MEM) {
/* format CIS area */
f = mpio_fatentry_new(m, mem, /* yuck */
- (1-((sm->dir_offset + DIR_NUM)/BLOCK_SECTORS - 2)));
+ (1-((sm->dir_offset + DIR_NUM)/BLOCK_SECTORS - 2)),
+ FTYPE_MUSIC);
mpio_io_block_delete(m, mem, f);
free(f);
mpio_io_sector_write(m, mem, 0x20, sm->cis);
@@ -719,11 +715,6 @@ mpio_file_del(mpio_t *m, mpio_mem_t mem, mpio_filename_t filename,
MPIO_CHECK_FILENAME(filename);
- /* please fix me sometime */
- /* the system entry are kind of special ! */
- if (strncmp("sysdum", filename, 6)==0)
- MPIO_ERR_RETURN(MPIO_ERR_PERMISSION_DENIED);
-
if (mem == MPIO_INTERNAL_MEM) sm = &m->internal;
if (mem == MPIO_EXTERNAL_MEM) sm = &m->external;
diff --git a/libmpio/mpio.h b/libmpio/mpio.h
index 10272c9..d90591f 100644
--- a/libmpio/mpio.h
+++ b/libmpio/mpio.h
@@ -1,7 +1,7 @@
#/* -*- linux-c -*- */
/*
- * $Id: mpio.h,v 1.8 2002/09/23 22:38:03 germeier Exp $
+ * $Id: mpio.h,v 1.9 2002/09/24 15:38:03 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -75,7 +75,8 @@ int mpio_dentry_get(mpio_t *, mpio_mem_t, BYTE *, BYTE *, int,WORD *,
int mpio_file_get(mpio_t *, mpio_mem_t, mpio_filename_t, mpio_callback_t);
/* context, memory bank, filename, callback */
-int mpio_file_put(mpio_t *, mpio_mem_t, mpio_filename_t, mpio_callback_t);
+int mpio_file_put(mpio_t *, mpio_mem_t, mpio_filename_t, mpio_filetype_t,
+ mpio_callback_t);
/* context, memory bank, filename, callback */
int mpio_file_del(mpio_t *, mpio_mem_t, mpio_filename_t, mpio_callback_t);