diff options
Diffstat (limited to 'rbutil/sansapatcher/sansapatcher.c')
-rw-r--r-- | rbutil/sansapatcher/sansapatcher.c | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/rbutil/sansapatcher/sansapatcher.c b/rbutil/sansapatcher/sansapatcher.c index aa13df00e5..55f5245bd9 100644 --- a/rbutil/sansapatcher/sansapatcher.c +++ b/rbutil/sansapatcher/sansapatcher.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <sys/types.h> | 26 | #include <sys/types.h> |
27 | #include <sys/stat.h> | 27 | #include <sys/stat.h> |
28 | 28 | ||
29 | #include "parttypes.h" | ||
30 | #include "sansaio.h" | 29 | #include "sansaio.h" |
31 | #include "sansapatcher.h" | 30 | #include "sansapatcher.h" |
32 | #include "bootimg.h" | 31 | #include "bootimg.h" |
@@ -43,27 +42,7 @@ extern int verbose; | |||
43 | 42 | ||
44 | unsigned char* sectorbuf; | 43 | unsigned char* sectorbuf; |
45 | 44 | ||
46 | char* get_parttype(int pt) | 45 | static off_t filesize(int fd) { |
47 | { | ||
48 | int i; | ||
49 | static char unknown[]="Unknown"; | ||
50 | |||
51 | if (pt == -1) { | ||
52 | return "HFS/HFS+"; | ||
53 | } | ||
54 | |||
55 | i=0; | ||
56 | while (parttypes[i].name != NULL) { | ||
57 | if (parttypes[i].type == pt) { | ||
58 | return (parttypes[i].name); | ||
59 | } | ||
60 | i++; | ||
61 | } | ||
62 | |||
63 | return unknown; | ||
64 | } | ||
65 | |||
66 | off_t filesize(int fd) { | ||
67 | struct stat buf; | 46 | struct stat buf; |
68 | 47 | ||
69 | if (fstat(fd,&buf) < 0) { | 48 | if (fstat(fd,&buf) < 0) { |
@@ -134,7 +113,7 @@ void int2be(unsigned int val, unsigned char* addr) | |||
134 | ((long)array[pos] | ((long)array[pos+1] << 8 ) |\ | 113 | ((long)array[pos] | ((long)array[pos+1] << 8 ) |\ |
135 | ((long)array[pos+2] << 16 ) | ((long)array[pos+3] << 24 )) | 114 | ((long)array[pos+2] << 16 ) | ((long)array[pos+3] << 24 )) |
136 | 115 | ||
137 | int read_partinfo(struct sansa_t* sansa, int silent) | 116 | int sansa_read_partinfo(struct sansa_t* sansa, int silent) |
138 | { | 117 | { |
139 | int i; | 118 | int i; |
140 | unsigned long count; | 119 | unsigned long count; |
@@ -340,7 +319,7 @@ static int set_mi4header(unsigned char* buf,struct mi4header_t* mi4header) | |||
340 | return 0; | 319 | return 0; |
341 | } | 320 | } |
342 | 321 | ||
343 | int sansa_seek_and_read(struct sansa_t* sansa, loff_t pos, unsigned char* buf, int nbytes) | 322 | static int sansa_seek_and_read(struct sansa_t* sansa, loff_t pos, unsigned char* buf, int nbytes) |
344 | { | 323 | { |
345 | int n; | 324 | int n; |
346 | 325 | ||
@@ -450,7 +429,7 @@ int sansa_scan(struct sansa_t* sansa) | |||
450 | continue; | 429 | continue; |
451 | } | 430 | } |
452 | 431 | ||
453 | if (read_partinfo(sansa,1) < 0) { | 432 | if (sansa_read_partinfo(sansa,1) < 0) { |
454 | continue; | 433 | continue; |
455 | } | 434 | } |
456 | 435 | ||
@@ -475,7 +454,7 @@ int sansa_scan(struct sansa_t* sansa) | |||
475 | return n; | 454 | return n; |
476 | } | 455 | } |
477 | 456 | ||
478 | int load_original_firmware(struct sansa_t* sansa, unsigned char* buf, struct mi4header_t* mi4header) | 457 | static int load_original_firmware(struct sansa_t* sansa, unsigned char* buf, struct mi4header_t* mi4header) |
479 | { | 458 | { |
480 | int ppmi_length; | 459 | int ppmi_length; |
481 | int n; | 460 | int n; |
@@ -564,7 +543,7 @@ int load_original_firmware(struct sansa_t* sansa, unsigned char* buf, struct mi4 | |||
564 | return 0; | 543 | return 0; |
565 | } | 544 | } |
566 | 545 | ||
567 | int read_firmware(struct sansa_t* sansa, char* filename) | 546 | int sansa_read_firmware(struct sansa_t* sansa, char* filename) |
568 | { | 547 | { |
569 | int res; | 548 | int res; |
570 | int outfile; | 549 | int outfile; |
@@ -587,7 +566,7 @@ int read_firmware(struct sansa_t* sansa, char* filename) | |||
587 | } | 566 | } |
588 | 567 | ||
589 | 568 | ||
590 | int add_bootloader(struct sansa_t* sansa, char* filename, int type) | 569 | int sansa_add_bootloader(struct sansa_t* sansa, char* filename, int type) |
591 | { | 570 | { |
592 | int res; | 571 | int res; |
593 | int infile; | 572 | int infile; |
@@ -656,7 +635,7 @@ int add_bootloader(struct sansa_t* sansa, char* filename, int type) | |||
656 | return 0; | 635 | return 0; |
657 | } | 636 | } |
658 | 637 | ||
659 | int delete_bootloader(struct sansa_t* sansa) | 638 | int sansa_delete_bootloader(struct sansa_t* sansa) |
660 | { | 639 | { |
661 | int res; | 640 | int res; |
662 | struct mi4header_t mi4header; | 641 | struct mi4header_t mi4header; |
@@ -693,7 +672,7 @@ int delete_bootloader(struct sansa_t* sansa) | |||
693 | return 0; | 672 | return 0; |
694 | } | 673 | } |
695 | 674 | ||
696 | void list_images(struct sansa_t* sansa) | 675 | void sansa_list_images(struct sansa_t* sansa) |
697 | { | 676 | { |
698 | struct mi4header_t mi4header; | 677 | struct mi4header_t mi4header; |
699 | loff_t ppmi_length; | 678 | loff_t ppmi_length; |