diff options
Diffstat (limited to 'rbutil/ipodpatcher/ipodpatcher.c')
-rw-r--r-- | rbutil/ipodpatcher/ipodpatcher.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/rbutil/ipodpatcher/ipodpatcher.c b/rbutil/ipodpatcher/ipodpatcher.c index 6fcf0c8c27..331c7f0322 100644 --- a/rbutil/ipodpatcher/ipodpatcher.c +++ b/rbutil/ipodpatcher/ipodpatcher.c | |||
@@ -885,7 +885,7 @@ int write_firmware(struct ipod_t* ipod, char* filename, int type) | |||
885 | return 0; | 885 | return 0; |
886 | } | 886 | } |
887 | 887 | ||
888 | int read_firmware(struct ipod_t* ipod, char* filename) | 888 | int read_firmware(struct ipod_t* ipod, char* filename, int type) |
889 | { | 889 | { |
890 | int length; | 890 | int length; |
891 | int i; | 891 | int i; |
@@ -921,22 +921,25 @@ int read_firmware(struct ipod_t* ipod, char* filename) | |||
921 | return -1; | 921 | return -1; |
922 | } | 922 | } |
923 | 923 | ||
924 | chksum = ipod->modelnum; | ||
925 | for (i = 0; i < length; i++) { | ||
926 | /* add 8 unsigned bits but keep a 32 bit sum */ | ||
927 | chksum += sectorbuf[i]; | ||
928 | } | ||
929 | |||
930 | int2be(chksum,header); | ||
931 | memcpy(header+4, ipod->modelname,4); | ||
932 | |||
933 | outfile = open(filename,O_CREAT|O_TRUNC|O_WRONLY|O_BINARY,0666); | 924 | outfile = open(filename,O_CREAT|O_TRUNC|O_WRONLY|O_BINARY,0666); |
934 | if (outfile < 0) { | 925 | if (outfile < 0) { |
935 | fprintf(stderr,"[ERR] Couldn't open file %s\n",filename); | 926 | fprintf(stderr,"[ERR] Couldn't open file %s\n",filename); |
936 | return -1; | 927 | return -1; |
937 | } | 928 | } |
938 | 929 | ||
939 | write(outfile,header,8); | 930 | if (type == FILETYPE_DOT_IPOD) { |
931 | chksum = ipod->modelnum; | ||
932 | for (i = 0; i < length; i++) { | ||
933 | /* add 8 unsigned bits but keep a 32 bit sum */ | ||
934 | chksum += sectorbuf[i]; | ||
935 | } | ||
936 | |||
937 | int2be(chksum,header); | ||
938 | memcpy(header+4, ipod->modelname,4); | ||
939 | |||
940 | write(outfile,header,8); | ||
941 | } | ||
942 | |||
940 | write(outfile,sectorbuf,length); | 943 | write(outfile,sectorbuf,length); |
941 | close(outfile); | 944 | close(outfile); |
942 | 945 | ||