diff options
-rw-r--r-- | firmware/test/fat/debug.c | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/firmware/test/fat/debug.c b/firmware/test/fat/debug.c index c24314fc22..fa7ff8651a 100644 --- a/firmware/test/fat/debug.c +++ b/firmware/test/fat/debug.c | |||
@@ -82,7 +82,7 @@ void dbg_dir(struct bpb *bpb, int currdir) | |||
82 | { | 82 | { |
83 | while(fat_getnext(bpb, &dent, &de) >= 0) | 83 | while(fat_getnext(bpb, &dent, &de) >= 0) |
84 | { | 84 | { |
85 | printf("%s\n", de.name); | 85 | printf("%s (%d)\n", de.name,de.firstcluster); |
86 | } | 86 | } |
87 | } | 87 | } |
88 | else | 88 | else |
@@ -91,6 +91,26 @@ void dbg_dir(struct bpb *bpb, int currdir) | |||
91 | } | 91 | } |
92 | } | 92 | } |
93 | 93 | ||
94 | void dbg_type(struct bpb *bpb, int cluster) | ||
95 | { | ||
96 | unsigned char buf[SECTOR_SIZE*5]; | ||
97 | struct fat_fileent ent; | ||
98 | int i; | ||
99 | |||
100 | fat_open(bpb,cluster,&ent); | ||
101 | |||
102 | for (i=0;i<5;i++) | ||
103 | if(fat_read(bpb, &ent, 1, buf) >= 0) | ||
104 | { | ||
105 | buf[SECTOR_SIZE]=0; | ||
106 | printf("%s\n", buf); | ||
107 | } | ||
108 | else | ||
109 | { | ||
110 | fprintf(stderr, "Could not read file on cluster %d\n", cluster); | ||
111 | } | ||
112 | } | ||
113 | |||
94 | char current_directory[256] = "\\"; | 114 | char current_directory[256] = "\\"; |
95 | int last_secnum = 0; | 115 | int last_secnum = 0; |
96 | 116 | ||
@@ -105,7 +125,6 @@ void dbg_console(struct bpb* bpb) | |||
105 | char last_cmd[32] = ""; | 125 | char last_cmd[32] = ""; |
106 | int quit = 0; | 126 | int quit = 0; |
107 | char *s; | 127 | char *s; |
108 | int secnum; | ||
109 | 128 | ||
110 | while(!quit) | 129 | while(!quit) |
111 | { | 130 | { |
@@ -123,7 +142,7 @@ void dbg_console(struct bpb* bpb) | |||
123 | { | 142 | { |
124 | if(!strcasecmp(s, "dir")) | 143 | if(!strcasecmp(s, "dir")) |
125 | { | 144 | { |
126 | secnum = 0; | 145 | int secnum = 0; |
127 | if((s = strtok(NULL, " \n"))) | 146 | if((s = strtok(NULL, " \n"))) |
128 | { | 147 | { |
129 | secnum = atoi(s); | 148 | secnum = atoi(s); |
@@ -149,6 +168,17 @@ void dbg_console(struct bpb* bpb) | |||
149 | dbg_dump_sector(last_secnum); | 168 | dbg_dump_sector(last_secnum); |
150 | continue; | 169 | continue; |
151 | } | 170 | } |
171 | |||
172 | if(!strcasecmp(s, "type")) | ||
173 | { | ||
174 | int cluster = 0; | ||
175 | if((s = strtok(NULL, " \n"))) | ||
176 | { | ||
177 | cluster = atoi(s); | ||
178 | } | ||
179 | dbg_type(bpb,cluster); | ||
180 | continue; | ||
181 | } | ||
152 | 182 | ||
153 | if(!strcasecmp(s, "exit") || | 183 | if(!strcasecmp(s, "exit") || |
154 | !strcasecmp(s, "x")) | 184 | !strcasecmp(s, "x")) |