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)
downloadrockbox-a5e77d8f943e602c56036f0f21b60b7f442a3976.tar.gz
rockbox-a5e77d8f943e602c56036f0f21b60b7f442a3976.zip
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 @@
2#include <stdlib.h> 2#include <stdlib.h>
3#include <string.h> 3#include <string.h>
4#include "debug.h" 4#include "debug.h"
5#include "panic.h"
5 6
6#define BLOCK_SIZE 512 7#define BLOCK_SIZE 512
7 8
@@ -9,7 +10,10 @@ static FILE* file;
9 10
10int ata_read_sectors(unsigned long start, unsigned char count, void* buf) 11int ata_read_sectors(unsigned long start, unsigned char count, void* buf)
11{ 12{
12 DEBUGF("[Reading block 0x%lx]\n",start); 13 int i;
14 for (i=0; i<count; i++ )
15 DEBUGF("[Reading block 0x%lx]\n",start+i);
16
13 if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { 17 if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) {
14 perror("fseek"); 18 perror("fseek");
15 return -1; 19 return -1;
@@ -17,6 +21,7 @@ int ata_read_sectors(unsigned long start, unsigned char count, void* buf)
17 if(!fread(buf,BLOCK_SIZE,count,file)) { 21 if(!fread(buf,BLOCK_SIZE,count,file)) {
18 printf("Failed reading %d blocks starting at block 0x%lx\n",count,start); 22 printf("Failed reading %d blocks starting at block 0x%lx\n",count,start);
19 perror("fread"); 23 perror("fread");
24 panicf("Disk error\n");
20 return -2; 25 return -2;
21 } 26 }
22 return 0; 27 return 0;
@@ -24,20 +29,22 @@ int ata_read_sectors(unsigned long start, unsigned char count, void* buf)
24 29
25int ata_write_sectors(unsigned long start, unsigned char count, void* buf) 30int ata_write_sectors(unsigned long start, unsigned char count, void* buf)
26{ 31{
27 DEBUGF("[Writing block 0x%lx]\n",start); 32 int i;
33 for (i=0; i<count; i++ )
34 DEBUGF("[Writing block 0x%lx]\n",start+i);
28 35
29 if (start == 0) { 36 if (start == 0)
30 DEBUGF("Holy crap! You're writing on sector 0!\n"); 37 panicf("Writing on sector 0!\n");
31 exit(0);
32 }
33 38
34 if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) { 39 if(fseek(file,start*BLOCK_SIZE,SEEK_SET)) {
35 perror("fseek"); 40 perror("fseek");
36 return -1; 41 return -1;
42 panicf("Disk error\n");
37 } 43 }
38 if(!fwrite(buf,BLOCK_SIZE,count,file)) { 44 if(!fwrite(buf,BLOCK_SIZE,count,file)) {
39 perror("fwrite"); 45 perror("fwrite");
40 return -2; 46 return -2;
47 panicf("Disk error\n");
41 } 48 }
42 return 0; 49 return 0;
43} 50}