diff options
Diffstat (limited to 'firmware/test/fat')
-rw-r--r-- | firmware/test/fat/main.c | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/firmware/test/fat/main.c b/firmware/test/fat/main.c index 5490fa9777..6d05dbe600 100644 --- a/firmware/test/fat/main.c +++ b/firmware/test/fat/main.c | |||
@@ -129,6 +129,59 @@ void dbg_type(char* name) | |||
129 | close(fd); | 129 | close(fd); |
130 | } | 130 | } |
131 | 131 | ||
132 | void dbg_tail(char* name) | ||
133 | { | ||
134 | unsigned char buf[SECTOR_SIZE*5]; | ||
135 | int fd,rc; | ||
136 | |||
137 | fd = open(name,O_RDONLY); | ||
138 | if (fd<0) | ||
139 | return; | ||
140 | DEBUGF("Got file descriptor %d\n",fd); | ||
141 | |||
142 | rc = lseek(fd,512,SEEK_SET); | ||
143 | if ( rc >= 0 ) { | ||
144 | rc = read(fd, buf, SECTOR_SIZE); | ||
145 | if( rc > 0 ) | ||
146 | { | ||
147 | buf[rc]=0; | ||
148 | printf("%d: %s\n", strlen(buf), buf); | ||
149 | } | ||
150 | else if ( rc == 0 ) { | ||
151 | DEBUGF("EOF\n"); | ||
152 | } | ||
153 | else | ||
154 | { | ||
155 | DEBUGF("Failed reading file: %d\n",rc); | ||
156 | } | ||
157 | } | ||
158 | else { | ||
159 | perror("lseek"); | ||
160 | } | ||
161 | |||
162 | rc = lseek(fd,-100,SEEK_CUR); | ||
163 | if ( rc >= 0 ) { | ||
164 | rc = read(fd, buf, SECTOR_SIZE); | ||
165 | if( rc > 0 ) | ||
166 | { | ||
167 | buf[rc]=0; | ||
168 | printf("%d: %s\n", strlen(buf), buf); | ||
169 | } | ||
170 | else if ( rc == 0 ) { | ||
171 | DEBUGF("EOF\n"); | ||
172 | } | ||
173 | else | ||
174 | { | ||
175 | DEBUGF("Failed reading file: %d\n",rc); | ||
176 | } | ||
177 | } | ||
178 | else { | ||
179 | perror("lseek"); | ||
180 | } | ||
181 | |||
182 | close(fd); | ||
183 | } | ||
184 | |||
132 | char current_directory[256] = "\\"; | 185 | char current_directory[256] = "\\"; |
133 | int last_secnum = 0; | 186 | int last_secnum = 0; |
134 | 187 | ||
@@ -221,7 +274,8 @@ int main(int argc, char *argv[]) | |||
221 | DEBUGF("*** Failed mounting fat\n"); | 274 | DEBUGF("*** Failed mounting fat\n"); |
222 | } | 275 | } |
223 | 276 | ||
224 | dbg_console(); | 277 | //dbg_console(); |
278 | dbg_tail("/fat.h"); | ||
225 | 279 | ||
226 | return 0; | 280 | return 0; |
227 | } | 281 | } |