diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2008-06-17 17:52:13 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2008-06-17 17:52:13 +0000 |
commit | d131a312668f2503546d7e1047c4a6be47ca0589 (patch) | |
tree | 9bd6582b61be4fd4af074d39a0b0c347dc8e8b6c /rbutil/sansapatcher/sansapatcher.c | |
parent | 8436e29e7e618db15ae28d9ff4c16c560f18deef (diff) | |
download | rockbox-d131a312668f2503546d7e1047c4a6be47ca0589.tar.gz rockbox-d131a312668f2503546d7e1047c4a6be47ca0589.zip |
Rename variables sectorbuf and verbose to avoid clashes in rbutil. Cleanup exports a bit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17730 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/sansapatcher/sansapatcher.c')
-rw-r--r-- | rbutil/sansapatcher/sansapatcher.c | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/rbutil/sansapatcher/sansapatcher.c b/rbutil/sansapatcher/sansapatcher.c index ee15a16ca9..b251ee5959 100644 --- a/rbutil/sansapatcher/sansapatcher.c +++ b/rbutil/sansapatcher/sansapatcher.c | |||
@@ -38,14 +38,14 @@ | |||
38 | #define NVPARAMS_OFFSET 0x780000 | 38 | #define NVPARAMS_OFFSET 0x780000 |
39 | #define NVPARAMS_SIZE (0x80000-0x200) | 39 | #define NVPARAMS_SIZE (0x80000-0x200) |
40 | 40 | ||
41 | extern int verbose; | 41 | int sansa_verbose = 0; |
42 | 42 | ||
43 | /* Windows requires the buffer for disk I/O to be aligned in memory on a | 43 | /* Windows requires the buffer for disk I/O to be aligned in memory on a |
44 | multiple of the disk volume size - so we use a single global variable | 44 | multiple of the disk volume size - so we use a single global variable |
45 | and initialise it with sansa_alloc_buf() in main(). | 45 | and initialise it with sansa_alloc_buf() in main(). |
46 | */ | 46 | */ |
47 | 47 | ||
48 | extern unsigned char* sectorbuf; | 48 | unsigned char* sansa_sectorbuf; |
49 | 49 | ||
50 | static off_t filesize(int fd) { | 50 | static off_t filesize(int fd) { |
51 | struct stat buf; | 51 | struct stat buf; |
@@ -94,17 +94,17 @@ int sansa_read_partinfo(struct sansa_t* sansa, int silent) | |||
94 | int i; | 94 | int i; |
95 | unsigned long count; | 95 | unsigned long count; |
96 | 96 | ||
97 | count = sansa_read(sansa,sectorbuf, sansa->sector_size); | 97 | count = sansa_read(sansa,sansa_sectorbuf, sansa->sector_size); |
98 | 98 | ||
99 | if (count <= 0) { | 99 | if (count <= 0) { |
100 | print_error(" Error reading from disk: "); | 100 | print_error(" Error reading from disk: "); |
101 | return -1; | 101 | return -1; |
102 | } | 102 | } |
103 | 103 | ||
104 | if ((sectorbuf[510] == 0x55) && (sectorbuf[511] == 0xaa)) { | 104 | if ((sansa_sectorbuf[510] == 0x55) && (sansa_sectorbuf[511] == 0xaa)) { |
105 | /* parse partitions */ | 105 | /* parse partitions */ |
106 | for ( i = 0; i < 4; i++ ) { | 106 | for ( i = 0; i < 4; i++ ) { |
107 | unsigned char* ptr = sectorbuf + 0x1be + 16*i; | 107 | unsigned char* ptr = sansa_sectorbuf + 0x1be + 16*i; |
108 | sansa->pinfo[i].type = ptr[4]; | 108 | sansa->pinfo[i].type = ptr[4]; |
109 | sansa->pinfo[i].start = BYTES2INT32(ptr, 8); | 109 | sansa->pinfo[i].start = BYTES2INT32(ptr, 8); |
110 | sansa->pinfo[i].size = BYTES2INT32(ptr, 12); | 110 | sansa->pinfo[i].size = BYTES2INT32(ptr, 12); |
@@ -114,7 +114,7 @@ int sansa_read_partinfo(struct sansa_t* sansa, int silent) | |||
114 | /* not handled yet */ | 114 | /* not handled yet */ |
115 | } | 115 | } |
116 | } | 116 | } |
117 | } else if ((sectorbuf[0] == 'E') && (sectorbuf[1] == 'R')) { | 117 | } else if ((sansa_sectorbuf[0] == 'E') && (sansa_sectorbuf[1] == 'R')) { |
118 | if (!silent) fprintf(stderr,"[ERR] Bad boot sector signature\n"); | 118 | if (!silent) fprintf(stderr,"[ERR] Bad boot sector signature\n"); |
119 | return -1; | 119 | return -1; |
120 | } | 120 | } |
@@ -405,14 +405,14 @@ int is_sansa(struct sansa_t* sansa) | |||
405 | } | 405 | } |
406 | 406 | ||
407 | /* Check Bootloader header */ | 407 | /* Check Bootloader header */ |
408 | if (sansa_seek_and_read(sansa, sansa->start, sectorbuf, 0x200) < 0) { | 408 | if (sansa_seek_and_read(sansa, sansa->start, sansa_sectorbuf, 0x200) < 0) { |
409 | return -2; | 409 | return -2; |
410 | } | 410 | } |
411 | if (memcmp(sectorbuf,"PPBL",4)!=0) { | 411 | if (memcmp(sansa_sectorbuf,"PPBL",4)!=0) { |
412 | /* No bootloader header, abort */ | 412 | /* No bootloader header, abort */ |
413 | return -4; | 413 | return -4; |
414 | } | 414 | } |
415 | ppbl_length = (le2int(sectorbuf+4) + 0x1ff) & ~0x1ff; | 415 | ppbl_length = (le2int(sansa_sectorbuf+4) + 0x1ff) & ~0x1ff; |
416 | 416 | ||
417 | /* Sanity/safety check - the bootloader can't be larger than PPMI_OFFSET */ | 417 | /* Sanity/safety check - the bootloader can't be larger than PPMI_OFFSET */ |
418 | if (ppbl_length > PPMI_OFFSET) | 418 | if (ppbl_length > PPMI_OFFSET) |
@@ -421,12 +421,12 @@ int is_sansa(struct sansa_t* sansa) | |||
421 | } | 421 | } |
422 | 422 | ||
423 | /* Load Sansa bootloader and check for "Sansa C200" magic string */ | 423 | /* Load Sansa bootloader and check for "Sansa C200" magic string */ |
424 | if (sansa_seek_and_read(sansa, sansa->start + 0x200, sectorbuf, ppbl_length) < 0) { | 424 | if (sansa_seek_and_read(sansa, sansa->start + 0x200, sansa_sectorbuf, ppbl_length) < 0) { |
425 | fprintf(stderr,"[ERR] Seek and read to 0x%08llx in is_sansa failed.\n", | 425 | fprintf(stderr,"[ERR] Seek and read to 0x%08llx in is_sansa failed.\n", |
426 | sansa->start+0x200); | 426 | sansa->start+0x200); |
427 | return -6; | 427 | return -6; |
428 | } | 428 | } |
429 | if (sansa_memmem(sectorbuf, ppbl_length, "Sansa C200", 10) != NULL) { | 429 | if (sansa_memmem(sansa_sectorbuf, ppbl_length, "Sansa C200", 10) != NULL) { |
430 | /* C200 */ | 430 | /* C200 */ |
431 | sansa->targetname="c200"; | 431 | sansa->targetname="c200"; |
432 | } else { | 432 | } else { |
@@ -435,25 +435,25 @@ int is_sansa(struct sansa_t* sansa) | |||
435 | } | 435 | } |
436 | 436 | ||
437 | /* Check Main firmware header */ | 437 | /* Check Main firmware header */ |
438 | if (sansa_seek_and_read(sansa, sansa->start+PPMI_OFFSET, sectorbuf, 0x200) < 0) { | 438 | if (sansa_seek_and_read(sansa, sansa->start+PPMI_OFFSET, sansa_sectorbuf, 0x200) < 0) { |
439 | fprintf(stderr,"[ERR] Seek to 0x%08llx in is_sansa failed.\n", | 439 | fprintf(stderr,"[ERR] Seek to 0x%08llx in is_sansa failed.\n", |
440 | sansa->start+PPMI_OFFSET); | 440 | sansa->start+PPMI_OFFSET); |
441 | return -5; | 441 | return -5; |
442 | } | 442 | } |
443 | if (memcmp(sectorbuf,"PPMI",4)!=0) { | 443 | if (memcmp(sansa_sectorbuf,"PPMI",4)!=0) { |
444 | /* No bootloader header, abort */ | 444 | /* No bootloader header, abort */ |
445 | return -7; | 445 | return -7; |
446 | } | 446 | } |
447 | ppmi_length = le2int(sectorbuf+4); | 447 | ppmi_length = le2int(sansa_sectorbuf+4); |
448 | 448 | ||
449 | /* Check main mi4 file header */ | 449 | /* Check main mi4 file header */ |
450 | if (sansa_seek_and_read(sansa, sansa->start+PPMI_OFFSET+0x200, sectorbuf, 0x200) < 0) { | 450 | if (sansa_seek_and_read(sansa, sansa->start+PPMI_OFFSET+0x200, sansa_sectorbuf, 0x200) < 0) { |
451 | fprintf(stderr,"[ERR] Seek to 0x%08llx in is_sansa failed.\n", | 451 | fprintf(stderr,"[ERR] Seek to 0x%08llx in is_sansa failed.\n", |
452 | sansa->start+PPMI_OFFSET+0x200); | 452 | sansa->start+PPMI_OFFSET+0x200); |
453 | return -5; | 453 | return -5; |
454 | } | 454 | } |
455 | 455 | ||
456 | if (get_mi4header(sectorbuf,&mi4header) < 0) { | 456 | if (get_mi4header(sansa_sectorbuf,&mi4header) < 0) { |
457 | fprintf(stderr,"[ERR] Invalid mi4header\n"); | 457 | fprintf(stderr,"[ERR] Invalid mi4header\n"); |
458 | return -6; | 458 | return -6; |
459 | } | 459 | } |
@@ -465,15 +465,15 @@ int is_sansa(struct sansa_t* sansa) | |||
465 | */ | 465 | */ |
466 | 466 | ||
467 | sansa->hasoldbootloader = 0; | 467 | sansa->hasoldbootloader = 0; |
468 | if (memcmp(sectorbuf+0x1f8,"RBBL",4)==0) { | 468 | if (memcmp(sansa_sectorbuf+0x1f8,"RBBL",4)==0) { |
469 | /* Look for an original firmware after the first image */ | 469 | /* Look for an original firmware after the first image */ |
470 | if (sansa_seek_and_read(sansa, | 470 | if (sansa_seek_and_read(sansa, |
471 | sansa->start + PPMI_OFFSET + 0x200 + ppmi_length, | 471 | sansa->start + PPMI_OFFSET + 0x200 + ppmi_length, |
472 | sectorbuf, 512) < 0) { | 472 | sansa_sectorbuf, 512) < 0) { |
473 | return -7; | 473 | return -7; |
474 | } | 474 | } |
475 | 475 | ||
476 | if (get_mi4header(sectorbuf,&mi4header)!=0) { | 476 | if (get_mi4header(sansa_sectorbuf,&mi4header)!=0) { |
477 | fprintf(stderr,"[ERR] No original firmware found\n"); | 477 | fprintf(stderr,"[ERR] No original firmware found\n"); |
478 | sansa->hasoldbootloader = 1; | 478 | sansa->hasoldbootloader = 1; |
479 | } | 479 | } |
@@ -654,7 +654,7 @@ int sansa_read_firmware(struct sansa_t* sansa, char* filename) | |||
654 | int outfile; | 654 | int outfile; |
655 | struct mi4header_t mi4header; | 655 | struct mi4header_t mi4header; |
656 | 656 | ||
657 | res = load_original_firmware(sansa,sectorbuf,&mi4header); | 657 | res = load_original_firmware(sansa,sansa_sectorbuf,&mi4header); |
658 | if (res < 0) | 658 | if (res < 0) |
659 | return res; | 659 | return res; |
660 | 660 | ||
@@ -664,7 +664,7 @@ int sansa_read_firmware(struct sansa_t* sansa, char* filename) | |||
664 | return -1; | 664 | return -1; |
665 | } | 665 | } |
666 | 666 | ||
667 | res = write(outfile,sectorbuf,mi4header.mi4size); | 667 | res = write(outfile,sansa_sectorbuf,mi4header.mi4size); |
668 | if (res != (int)mi4header.mi4size) { | 668 | if (res != (int)mi4header.mi4size) { |
669 | fprintf(stderr,"[ERR] Write error - %d\n", res); | 669 | fprintf(stderr,"[ERR] Write error - %d\n", res); |
670 | return -1; | 670 | return -1; |
@@ -704,14 +704,14 @@ int sansa_add_bootloader(struct sansa_t* sansa, char* filename, int type) | |||
704 | } | 704 | } |
705 | 705 | ||
706 | /* Create PPMI header */ | 706 | /* Create PPMI header */ |
707 | memset(sectorbuf,0,0x200); | 707 | memset(sansa_sectorbuf,0,0x200); |
708 | memcpy(sectorbuf,"PPMI",4); | 708 | memcpy(sansa_sectorbuf,"PPMI",4); |
709 | int2le(bl_length, sectorbuf+4); | 709 | int2le(bl_length, sansa_sectorbuf+4); |
710 | int2le(0x00020000, sectorbuf+8); | 710 | int2le(0x00020000, sansa_sectorbuf+8); |
711 | 711 | ||
712 | if (type==FILETYPE_MI4) { | 712 | if (type==FILETYPE_MI4) { |
713 | /* Read bootloader into sectorbuf+0x200 */ | 713 | /* Read bootloader into sansa_sectorbuf+0x200 */ |
714 | n = read(infile,sectorbuf+0x200,bl_length); | 714 | n = read(infile,sansa_sectorbuf+0x200,bl_length); |
715 | close(infile); | 715 | close(infile); |
716 | if (n < bl_length) { | 716 | if (n < bl_length) { |
717 | fprintf(stderr,"[ERR] Short read - requested %d bytes, received %d\n" | 717 | fprintf(stderr,"[ERR] Short read - requested %d bytes, received %d\n" |
@@ -719,7 +719,7 @@ int sansa_add_bootloader(struct sansa_t* sansa, char* filename, int type) | |||
719 | return -1; | 719 | return -1; |
720 | } | 720 | } |
721 | 721 | ||
722 | if (memcmp(sectorbuf+0x200+0x1f8,"RBBL",4)!=0) { | 722 | if (memcmp(sansa_sectorbuf+0x200+0x1f8,"RBBL",4)!=0) { |
723 | fprintf(stderr,"[ERR] %s is not a Rockbox bootloader, aborting.\n", | 723 | fprintf(stderr,"[ERR] %s is not a Rockbox bootloader, aborting.\n", |
724 | filename); | 724 | filename); |
725 | return -1; | 725 | return -1; |
@@ -727,15 +727,15 @@ int sansa_add_bootloader(struct sansa_t* sansa, char* filename, int type) | |||
727 | } else { | 727 | } else { |
728 | #ifndef RBUTIL | 728 | #ifndef RBUTIL |
729 | if (strcmp(sansa->targetname,"c200") == 0) { | 729 | if (strcmp(sansa->targetname,"c200") == 0) { |
730 | memcpy(sectorbuf+0x200,bootimg_c200,LEN_bootimg_c200); | 730 | memcpy(sansa_sectorbuf+0x200,bootimg_c200,LEN_bootimg_c200); |
731 | } else { | 731 | } else { |
732 | memcpy(sectorbuf+0x200,bootimg_e200,LEN_bootimg_e200); | 732 | memcpy(sansa_sectorbuf+0x200,bootimg_e200,LEN_bootimg_e200); |
733 | } | 733 | } |
734 | #endif | 734 | #endif |
735 | } | 735 | } |
736 | 736 | ||
737 | /* Load original firmware from Sansa to the space after the bootloader */ | 737 | /* Load original firmware from Sansa to the space after the bootloader */ |
738 | res = load_original_firmware(sansa,sectorbuf+0x200+bl_length,&mi4header); | 738 | res = load_original_firmware(sansa,sansa_sectorbuf+0x200+bl_length,&mi4header); |
739 | if (res < 0) | 739 | if (res < 0) |
740 | return res; | 740 | return res; |
741 | 741 | ||
@@ -749,7 +749,7 @@ int sansa_add_bootloader(struct sansa_t* sansa, char* filename, int type) | |||
749 | 749 | ||
750 | length = 0x200 + bl_length + mi4header.mi4size; | 750 | length = 0x200 + bl_length + mi4header.mi4size; |
751 | 751 | ||
752 | n=sansa_write(sansa, sectorbuf, length); | 752 | n=sansa_write(sansa, sansa_sectorbuf, length); |
753 | if (n < length) { | 753 | if (n < length) { |
754 | fprintf(stderr,"[ERR] Short write in add_bootloader\n"); | 754 | fprintf(stderr,"[ERR] Short write in add_bootloader\n"); |
755 | return -6; | 755 | return -6; |
@@ -765,16 +765,16 @@ int sansa_delete_bootloader(struct sansa_t* sansa) | |||
765 | int n; | 765 | int n; |
766 | int length; | 766 | int length; |
767 | 767 | ||
768 | /* Load original firmware from Sansa to sectorbuf+0x200 */ | 768 | /* Load original firmware from Sansa to sansa_sectorbuf+0x200 */ |
769 | res = load_original_firmware(sansa,sectorbuf+0x200,&mi4header); | 769 | res = load_original_firmware(sansa,sansa_sectorbuf+0x200,&mi4header); |
770 | if (res < 0) | 770 | if (res < 0) |
771 | return res; | 771 | return res; |
772 | 772 | ||
773 | /* Create PPMI header */ | 773 | /* Create PPMI header */ |
774 | memset(sectorbuf,0,0x200); | 774 | memset(sansa_sectorbuf,0,0x200); |
775 | memcpy(sectorbuf,"PPMI",4); | 775 | memcpy(sansa_sectorbuf,"PPMI",4); |
776 | int2le(mi4header.mi4size, sectorbuf+4); | 776 | int2le(mi4header.mi4size, sansa_sectorbuf+4); |
777 | int2le(0x00020000, sectorbuf+8); | 777 | int2le(0x00020000, sansa_sectorbuf+8); |
778 | 778 | ||
779 | /* Now write the whole thing back to the Sansa */ | 779 | /* Now write the whole thing back to the Sansa */ |
780 | 780 | ||
@@ -786,7 +786,7 @@ int sansa_delete_bootloader(struct sansa_t* sansa) | |||
786 | 786 | ||
787 | length = 0x200 + mi4header.mi4size; | 787 | length = 0x200 + mi4header.mi4size; |
788 | 788 | ||
789 | n=sansa_write(sansa, sectorbuf, length); | 789 | n=sansa_write(sansa, sansa_sectorbuf, length); |
790 | if (n < length) { | 790 | if (n < length) { |
791 | fprintf(stderr,"[ERR] Short write in delete_bootloader\n"); | 791 | fprintf(stderr,"[ERR] Short write in delete_bootloader\n"); |
792 | return -6; | 792 | return -6; |
@@ -801,20 +801,20 @@ void sansa_list_images(struct sansa_t* sansa) | |||
801 | loff_t ppmi_length; | 801 | loff_t ppmi_length; |
802 | 802 | ||
803 | /* Check Main firmware header */ | 803 | /* Check Main firmware header */ |
804 | if (sansa_seek_and_read(sansa, sansa->start+PPMI_OFFSET, sectorbuf, 0x200) < 0) { | 804 | if (sansa_seek_and_read(sansa, sansa->start+PPMI_OFFSET, sansa_sectorbuf, 0x200) < 0) { |
805 | return; | 805 | return; |
806 | } | 806 | } |
807 | 807 | ||
808 | ppmi_length = le2int(sectorbuf+4); | 808 | ppmi_length = le2int(sansa_sectorbuf+4); |
809 | 809 | ||
810 | printf("[INFO] Image 1 - %llu bytes\n",ppmi_length); | 810 | printf("[INFO] Image 1 - %llu bytes\n",ppmi_length); |
811 | 811 | ||
812 | /* Look for an original firmware after the first image */ | 812 | /* Look for an original firmware after the first image */ |
813 | if (sansa_seek_and_read(sansa, sansa->start + PPMI_OFFSET + 0x200 + ppmi_length, sectorbuf, 512) < 0) { | 813 | if (sansa_seek_and_read(sansa, sansa->start + PPMI_OFFSET + 0x200 + ppmi_length, sansa_sectorbuf, 512) < 0) { |
814 | return; | 814 | return; |
815 | } | 815 | } |
816 | 816 | ||
817 | if (get_mi4header(sectorbuf,&mi4header)==0) { | 817 | if (get_mi4header(sansa_sectorbuf,&mi4header)==0) { |
818 | printf("[INFO] Image 2 - %d bytes\n",mi4header.mi4size); | 818 | printf("[INFO] Image 2 - %d bytes\n",mi4header.mi4size); |
819 | } | 819 | } |
820 | } | 820 | } |
@@ -864,8 +864,8 @@ int sansa_update_of(struct sansa_t* sansa, char* filename) | |||
864 | of_length = filesize(infile); | 864 | of_length = filesize(infile); |
865 | 865 | ||
866 | /* Load original firmware from file */ | 866 | /* Load original firmware from file */ |
867 | memset(sectorbuf,0,0x200); | 867 | memset(sansa_sectorbuf,0,0x200); |
868 | n = read(infile,sectorbuf,of_length); | 868 | n = read(infile,sansa_sectorbuf,of_length); |
869 | close(infile); | 869 | close(infile); |
870 | if (n < of_length) { | 870 | if (n < of_length) { |
871 | fprintf(stderr,"[ERR] Short read - requested %d bytes, received %d\n" | 871 | fprintf(stderr,"[ERR] Short read - requested %d bytes, received %d\n" |
@@ -874,13 +874,13 @@ int sansa_update_of(struct sansa_t* sansa, char* filename) | |||
874 | } | 874 | } |
875 | 875 | ||
876 | /* Check we have a valid MI4 file. */ | 876 | /* Check we have a valid MI4 file. */ |
877 | if (get_mi4header(sectorbuf,&mi4header)!=0) { | 877 | if (get_mi4header(sansa_sectorbuf,&mi4header)!=0) { |
878 | fprintf(stderr,"[ERR] %s is not a valid mi4 file\n",filename); | 878 | fprintf(stderr,"[ERR] %s is not a valid mi4 file\n",filename); |
879 | return -1; | 879 | return -1; |
880 | } | 880 | } |
881 | 881 | ||
882 | /* Decrypt and build the header */ | 882 | /* Decrypt and build the header */ |
883 | if(prepare_original_firmware(sectorbuf, &mi4header)!=0){ | 883 | if(prepare_original_firmware(sansa_sectorbuf, &mi4header)!=0){ |
884 | fprintf(stderr,"[ERR] Unable to build decrypted mi4 from %s\n" | 884 | fprintf(stderr,"[ERR] Unable to build decrypted mi4 from %s\n" |
885 | ,filename); | 885 | ,filename); |
886 | return -1; | 886 | return -1; |
@@ -893,7 +893,7 @@ int sansa_update_of(struct sansa_t* sansa, char* filename) | |||
893 | return -1; | 893 | return -1; |
894 | } | 894 | } |
895 | 895 | ||
896 | n=sansa_write(sansa, sectorbuf, of_length); | 896 | n=sansa_write(sansa, sansa_sectorbuf, of_length); |
897 | if (n < of_length) { | 897 | if (n < of_length) { |
898 | fprintf(stderr,"[ERR] Short write in sansa_update_of\n"); | 898 | fprintf(stderr,"[ERR] Short write in sansa_update_of\n"); |
899 | return -1; | 899 | return -1; |
@@ -910,8 +910,8 @@ int sansa_update_of(struct sansa_t* sansa, char* filename) | |||
910 | return -1; | 910 | return -1; |
911 | } | 911 | } |
912 | 912 | ||
913 | memset(sectorbuf,0,NVPARAMS_SIZE); | 913 | memset(sansa_sectorbuf,0,NVPARAMS_SIZE); |
914 | n=sansa_write(sansa, sectorbuf, NVPARAMS_SIZE); | 914 | n=sansa_write(sansa, sansa_sectorbuf, NVPARAMS_SIZE); |
915 | if (n < NVPARAMS_SIZE) { | 915 | if (n < NVPARAMS_SIZE) { |
916 | fprintf(stderr,"[ERR] Short write in sansa_update_of\n"); | 916 | fprintf(stderr,"[ERR] Short write in sansa_update_of\n"); |
917 | return -1; | 917 | return -1; |
@@ -937,7 +937,7 @@ int sansa_update_ppbl(struct sansa_t* sansa, char* filename) | |||
937 | 937 | ||
938 | ppbl_length = filesize(infile); | 938 | ppbl_length = filesize(infile); |
939 | 939 | ||
940 | n = read(infile,sectorbuf+0x200,ppbl_length); | 940 | n = read(infile,sansa_sectorbuf+0x200,ppbl_length); |
941 | close(infile); | 941 | close(infile); |
942 | if (n < ppbl_length) { | 942 | if (n < ppbl_length) { |
943 | fprintf(stderr,"[ERR] Short read - requested %d bytes, received %d\n", ppbl_length, n); | 943 | fprintf(stderr,"[ERR] Short read - requested %d bytes, received %d\n", ppbl_length, n); |
@@ -945,10 +945,10 @@ int sansa_update_ppbl(struct sansa_t* sansa, char* filename) | |||
945 | } | 945 | } |
946 | 946 | ||
947 | /* Step 2 - Build the header */ | 947 | /* Step 2 - Build the header */ |
948 | memset(sectorbuf,0,0x200); | 948 | memset(sansa_sectorbuf,0,0x200); |
949 | memcpy(sectorbuf,"PPBL",4); | 949 | memcpy(sansa_sectorbuf,"PPBL",4); |
950 | int2le(ppbl_length, sectorbuf+4); | 950 | int2le(ppbl_length, sansa_sectorbuf+4); |
951 | int2le(0x00010000, sectorbuf+8); | 951 | int2le(0x00010000, sansa_sectorbuf+8); |
952 | 952 | ||
953 | /* Step 3 - write the bootloader to the Sansa */ | 953 | /* Step 3 - write the bootloader to the Sansa */ |
954 | if (sansa_seek(sansa, sansa->start) < 0) { | 954 | if (sansa_seek(sansa, sansa->start) < 0) { |
@@ -956,7 +956,7 @@ int sansa_update_ppbl(struct sansa_t* sansa, char* filename) | |||
956 | return -1; | 956 | return -1; |
957 | } | 957 | } |
958 | 958 | ||
959 | n=sansa_write(sansa, sectorbuf, ppbl_length + 0x200); | 959 | n=sansa_write(sansa, sansa_sectorbuf, ppbl_length + 0x200); |
960 | if (n < (ppbl_length+0x200)) { | 960 | if (n < (ppbl_length+0x200)) { |
961 | fprintf(stderr,"[ERR] Short write in sansa_update_ppbl\n"); | 961 | fprintf(stderr,"[ERR] Short write in sansa_update_ppbl\n"); |
962 | return -1; | 962 | return -1; |