summaryrefslogtreecommitdiff
path: root/firmware/test/fat/ata-sim.c
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-10-31 16:09:28 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-10-31 16:09:28 +0000
commita5e77d8f943e602c56036f0f21b60b7f442a3976 (patch)
tree324101cf4060f4f06bd522bd49d4f57469a6dad3 /firmware/test/fat/ata-sim.c
parent3bf2f7858188c222abde85643ce980963dc7e4c9 (diff)
Fat writing update. File creation now works, though still only short filenames.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2790 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/test/fat/ata-sim.c')
-rw-r--r--firmware/test/fat/ata-sim.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/firmware/test/fat/ata-sim.c b/firmware/test/fat/ata-sim.c
index a64e0a4d4d..661cc79a1f 100644
--- a/firmware/test/fat/ata-sim.c
+++ b/firmware/test/fat/ata-sim.c
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include "debug.h"
+#include "panic.h"
#define BLOCK_SIZE 512
@@ -9,7 +10,10 @@ static FILE* file;
int ata_read_sectors(unsigned long start, unsigned char count, void* buf)
{
- DEBUGF("[Reading block 0x%lx]\n",start);
+ int i;
+ for (i=0; i<count; i++ )
+ DEBUGF("[Reading block 0x%lx]\n",start+i);
+
if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) {
perror("fseek");
return -1;
@@ -17,6 +21,7 @@ int ata_read_sectors(unsigned long start, unsigned char count, void* buf)
if(!fread(buf,BLOCK_SIZE,count,file)) {
printf("Failed reading %d blocks starting at block 0x%lx\n",count,start);
perror("fread");
+ panicf("Disk error\n");
return -2;
}
return 0;
@@ -24,20 +29,22 @@ int ata_read_sectors(unsigned long start, unsigned char count, void* buf)
int ata_write_sectors(unsigned long start, unsigned char count, void* buf)
{
- DEBUGF("[Writing block 0x%lx]\n",start);
+ int i;
+ for (i=0; i<count; i++ )
+ DEBUGF("[Writing block 0x%lx]\n",start+i);
- if (start == 0) {
- DEBUGF("Holy crap! You're writing on sector 0!\n");
- exit(0);
- }
+ if (start == 0)
+ panicf("Writing on sector 0!\n");
if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) {
perror("fseek");
return -1;
+ panicf("Disk error\n");
}
if(!fwrite(buf,BLOCK_SIZE,count,file)) {
perror("fwrite");
return -2;
+ panicf("Disk error\n");
}
return 0;
}