aboutsummaryrefslogtreecommitdiff
path: root/libmpio/src
diff options
context:
space:
mode:
authorgermeier <germeier>2003-06-16 10:25:02 +0000
committergermeier <germeier>2003-06-16 10:25:02 +0000
commite40c783871c0e81a862a2dc6f899ac9ca06f25d3 (patch)
tree5e3dca5c1b0cb2b13640d7fc2fc5f114bf35de58 /libmpio/src
parentfbf7a7fdb16fe43b297cc787fa9ce8e5aa187900 (diff)
downloadmpiosh-e40c783871c0e81a862a2dc6f899ac9ca06f25d3.tar.gz
mpiosh-e40c783871c0e81a862a2dc6f899ac9ca06f25d3.tar.bz2
mpiosh-e40c783871c0e81a862a2dc6f899ac9ca06f25d3.zip
added/fixed vfat 8.3 checksum to make "real" vfat drivers happy
Diffstat (limited to 'libmpio/src')
-rw-r--r--libmpio/src/directory.c79
1 files changed, 36 insertions, 43 deletions
diff --git a/libmpio/src/directory.c b/libmpio/src/directory.c
index 3fc7496..200d1e9 100644
--- a/libmpio/src/directory.c
+++ b/libmpio/src/directory.c
@@ -1,5 +1,5 @@
/*
- * $Id: directory.c,v 1.4 2003/06/12 08:32:32 germeier Exp $
+ * $Id: directory.c,v 1.5 2003/06/16 10:25:03 germeier Exp $
*
* libmpio - a library for accessing Digit@lways MPIO players
* Copyright (C) 2002, 2003 Markus Germeier
@@ -439,6 +439,7 @@ mpio_dentry_filename_write(mpio_t *m, mpio_mem_t mem, BYTE *p,
int count = 0;
BYTE index;
BYTE f_8_3[13];
+ BYTE alias_check;
mpio_dir_slot_t *slot;
mpio_dir_entry_t *dentry;
DWORD i, j;
@@ -467,32 +468,6 @@ mpio_dentry_filename_write(mpio_t *m, mpio_mem_t mem, BYTE *p,
if (filename_size % 13)
count++;
- slot = (mpio_dir_slot_t *)p;
-
- index = 0x40 + count;
- while (count > 0) {
- mpio_dentry_copy_to_slot(back + ((count - 1) * 26), slot);
- hexdump((char *)back + ((count - 1) * 26), 0x20);
- slot->id = index;
- slot->attr = 0x0f;
- slot->reserved = 0x00;
- slot->start[0] = 0x00;
- slot->start[1] = 0x00;
- /* FIXME: */
- slot->alias_checksum = 0x00; // checksum for 8.3 alias
-
- hexdump((char *)slot, 0x20);
-
- slot++;
- count--;
- index = count;
- }
-
-/* memcpy(p, m->internal.dir+0x220, 0x20); */
-
-/* p+=0x20; */
- dentry = (mpio_dir_entry_t *)slot;
-
/* find uniq 8.3 filename */
memset(f_8_3, 0x20, 12);
f_8_3[8]='.';
@@ -544,31 +519,49 @@ mpio_dentry_filename_write(mpio_t *m, mpio_mem_t mem, BYTE *p,
j++;
}
- /* This seems like a special case to me! */
- if (strcmp(MPIO_MPIO_RECORD, filename)==0)
- {
- f_8_3[6]='~';
- f_8_3[7]='0';
- }
-
- if (mpio_dentry_find_name_8_3(m, mem, f_8_3))
- {
- f_8_3[6]='~';
- f_8_3[7]='1';
- }
+ f_8_3[6]='~';
+ f_8_3[7]='0';
while(mpio_dentry_find_name_8_3(m, mem, f_8_3))
f_8_3[7]++;
-
-/* memcpy(dentry->name,"AAAAAAAA",8); */
-/* memcpy(dentry->ext,"MP3",3); */
+ hexdumpn(5, f_8_3, 13);
+
+ /* calculate checksum for 8.3 alias */
+ alias_check = 0;
+ for (i = 0; i < 12; i++) {
+ if (i!=8) /* yuck */
+ alias_check = (((alias_check & 0x01)<<7)|
+ ((alias_check & 0xfe)>>1)) + f_8_3[i];
+ }
+
+ slot = (mpio_dir_slot_t *)p;
+
+ index = 0x40 + count;
+ while (count > 0) {
+ mpio_dentry_copy_to_slot(back + ((count - 1) * 26), slot);
+ hexdump((char *)back + ((count - 1) * 26), 0x20);
+ slot->id = index;
+ slot->attr = 0x0f;
+ slot->reserved = 0x00;
+ slot->start[0] = 0x00;
+ slot->start[1] = 0x00;
+ slot->alias_checksum = alias_check; // checksum for 8.3 alias
+
+ hexdumpn(5, (char *)slot, 0x20);
+
+ slot++;
+ count--;
+ index = count;
+ }
-/* hexdumpn(0, f_8_3, 13); */
+ dentry = (mpio_dir_entry_t *)slot;
memcpy(dentry->name, f_8_3, 8);
memcpy(dentry->ext, f_8_3+9, 3);
+ hexdumpn(5, (char *)dentry, 0x20);
+
free(unicode);
free(fname);