summaryrefslogtreecommitdiffstats
path: root/rbutil/ipodpatcher/ipodpatcher.c
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2007-04-13 23:28:20 +0000
committerDave Chapman <dave@dchapman.com>2007-04-13 23:28:20 +0000
commit427fff4320df478cc0d7a6fa5d68e08d70a844b8 (patch)
tree225a8c24ed7304c9fe23ffa16698cca152985801 /rbutil/ipodpatcher/ipodpatcher.c
parent266707f81856e4a8310f6d8dacfc7b9a7033106c (diff)
downloadrockbox-427fff4320df478cc0d7a6fa5d68e08d70a844b8.tar.gz
rockbox-427fff4320df478cc0d7a6fa5d68e08d70a844b8.zip
Add -rfb option for reading the main firmware (OSOS image) as a binary file.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13148 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/ipodpatcher/ipodpatcher.c')
-rw-r--r--rbutil/ipodpatcher/ipodpatcher.c25
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)
return 0;
}
-int read_firmware(struct ipod_t* ipod, char* filename)
+int read_firmware(struct ipod_t* ipod, char* filename, int type)
{
int length;
int i;
@@ -921,22 +921,25 @@ int read_firmware(struct ipod_t* ipod, char* filename)
return -1;
}
- chksum = ipod->modelnum;
- for (i = 0; i < length; i++) {
- /* add 8 unsigned bits but keep a 32 bit sum */
- chksum += sectorbuf[i];
- }
-
- int2be(chksum,header);
- memcpy(header+4, ipod->modelname,4);
-
outfile = open(filename,O_CREAT|O_TRUNC|O_WRONLY|O_BINARY,0666);
if (outfile < 0) {
fprintf(stderr,"[ERR] Couldn't open file %s\n",filename);
return -1;
}
- write(outfile,header,8);
+ if (type == FILETYPE_DOT_IPOD) {
+ chksum = ipod->modelnum;
+ for (i = 0; i < length; i++) {
+ /* add 8 unsigned bits but keep a 32 bit sum */
+ chksum += sectorbuf[i];
+ }
+
+ int2be(chksum,header);
+ memcpy(header+4, ipod->modelname,4);
+
+ write(outfile,header,8);
+ }
+
write(outfile,sectorbuf,length);
close(outfile);