Gigabeat S bootloader: make it move a rockbox binary back to /.rockbox/ when it finds one in the MTP directory.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17133 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nicolas Pennequin 2008-04-15 23:17:03 +00:00
parent 1423e9c0bc
commit 620e6b4d93

View file

@ -141,10 +141,11 @@ void main(void)
{
char buf[MAX_PATH];
char tarstring[6];
char model[5];
lcd_clear_display();
printf("Hello world!");
printf("Gigabeat S Rockbox Bootloader v.00000004");
printf("Gigabeat S Rockbox Bootloader v.00000005");
system_init();
kernel_init();
printf("kernel init done");
@ -182,6 +183,25 @@ void main(void)
fd = open(buf, O_RDONLY);
if (fd >= 0)
{
/* Check whether the file is a rockbox binary. */
lseek(fd, 4, SEEK_SET);
rc = read(fd, model, 4);
if (rc == 4)
{
model[4] = 0;
if (strcmp(model, "gigs") == 0)
{
printf("Found rockbox binary. Moving...");
close(fd);
remove("/.rockbox/rockbox.gigabeat");
int ret = rename(buf, "/.rockbox/rockbox.gigabeat");
printf("returned %d", ret);
sleep(100);
break;
}
}
/* Check whether the file is a tar file. */
lseek(fd, 257, SEEK_SET);
rc = read(fd, tarstring, 5);
if (rc == 5)