forked from len0rd/rockbox
Some code rearrangement and function renaming to help incorporation into rbutil without clashing with ipodpatcher.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12797 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
1860e9ad47
commit
be2971646f
3 changed files with 45 additions and 47 deletions
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "sansapatcher.h"
|
||||
#include "sansaio.h"
|
||||
#include "parttypes.h"
|
||||
|
||||
#define VERSION "0.1"
|
||||
|
||||
|
|
@ -83,6 +84,26 @@ void print_usage(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
char* get_parttype(int pt)
|
||||
{
|
||||
int i;
|
||||
static char unknown[]="Unknown";
|
||||
|
||||
if (pt == -1) {
|
||||
return "HFS/HFS+";
|
||||
}
|
||||
|
||||
i=0;
|
||||
while (parttypes[i].name != NULL) {
|
||||
if (parttypes[i].type == pt) {
|
||||
return (parttypes[i].name);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return unknown;
|
||||
}
|
||||
|
||||
void display_partinfo(struct sansa_t* sansa)
|
||||
{
|
||||
int i;
|
||||
|
|
@ -214,7 +235,7 @@ int main(int argc, char* argv[])
|
|||
fprintf(stderr,"[INFO] Reading partition table from %s\n",sansa.diskname);
|
||||
fprintf(stderr,"[INFO] Sector size is %d bytes\n",sansa.sector_size);
|
||||
|
||||
if (read_partinfo(&sansa,0) < 0) {
|
||||
if (sansa_read_partinfo(&sansa,0) < 0) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
@ -237,7 +258,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
if (action==LIST_IMAGES) {
|
||||
list_images(&sansa);
|
||||
sansa_list_images(&sansa);
|
||||
} else if (action==INTERACTIVE) {
|
||||
|
||||
printf("Enter i to install the Rockbox bootloader, u to uninstall\n or c to cancel and do nothing (i/u/c) :");
|
||||
|
|
@ -248,7 +269,7 @@ int main(int argc, char* argv[])
|
|||
return 5;
|
||||
}
|
||||
|
||||
if (add_bootloader(&sansa, NULL, FILETYPE_INTERNAL)==0) {
|
||||
if (sansa_add_bootloader(&sansa, NULL, FILETYPE_INTERNAL)==0) {
|
||||
fprintf(stderr,"[INFO] Bootloader installed successfully.\n");
|
||||
} else {
|
||||
fprintf(stderr,"[ERR] --install failed.\n");
|
||||
|
|
@ -258,7 +279,7 @@ int main(int argc, char* argv[])
|
|||
return 5;
|
||||
}
|
||||
|
||||
if (delete_bootloader(&sansa)==0) {
|
||||
if (sansa_delete_bootloader(&sansa)==0) {
|
||||
fprintf(stderr,"[INFO] Bootloader removed.\n");
|
||||
} else {
|
||||
fprintf(stderr,"[ERR] Bootloader removal failed.\n");
|
||||
|
|
@ -266,7 +287,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
}
|
||||
} else if (action==READ_FIRMWARE) {
|
||||
if (read_firmware(&sansa, filename)==0) {
|
||||
if (sansa_read_firmware(&sansa, filename)==0) {
|
||||
fprintf(stderr,"[INFO] Firmware read to file %s.\n",filename);
|
||||
} else {
|
||||
fprintf(stderr,"[ERR] --read-firmware failed.\n");
|
||||
|
|
@ -276,7 +297,7 @@ int main(int argc, char* argv[])
|
|||
return 5;
|
||||
}
|
||||
|
||||
if (add_bootloader(&sansa, NULL, FILETYPE_INTERNAL)==0) {
|
||||
if (sansa_add_bootloader(&sansa, NULL, FILETYPE_INTERNAL)==0) {
|
||||
fprintf(stderr,"[INFO] Bootloader installed successfully.\n");
|
||||
} else {
|
||||
fprintf(stderr,"[ERR] --install failed.\n");
|
||||
|
|
@ -286,7 +307,7 @@ int main(int argc, char* argv[])
|
|||
return 5;
|
||||
}
|
||||
|
||||
if (add_bootloader(&sansa, filename, type)==0) {
|
||||
if (sansa_add_bootloader(&sansa, filename, type)==0) {
|
||||
fprintf(stderr,"[INFO] Bootloader %s written to device.\n",filename);
|
||||
} else {
|
||||
fprintf(stderr,"[ERR] --add-bootloader failed.\n");
|
||||
|
|
@ -296,7 +317,7 @@ int main(int argc, char* argv[])
|
|||
return 5;
|
||||
}
|
||||
|
||||
if (delete_bootloader(&sansa)==0) {
|
||||
if (sansa_delete_bootloader(&sansa)==0) {
|
||||
fprintf(stderr,"[INFO] Bootloader removed successfully.\n");
|
||||
} else {
|
||||
fprintf(stderr,"[ERR] --delete-bootloader failed.\n");
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "parttypes.h"
|
||||
#include "sansaio.h"
|
||||
#include "sansapatcher.h"
|
||||
#include "bootimg.h"
|
||||
|
|
@ -43,27 +42,7 @@ extern int verbose;
|
|||
|
||||
unsigned char* sectorbuf;
|
||||
|
||||
char* get_parttype(int pt)
|
||||
{
|
||||
int i;
|
||||
static char unknown[]="Unknown";
|
||||
|
||||
if (pt == -1) {
|
||||
return "HFS/HFS+";
|
||||
}
|
||||
|
||||
i=0;
|
||||
while (parttypes[i].name != NULL) {
|
||||
if (parttypes[i].type == pt) {
|
||||
return (parttypes[i].name);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return unknown;
|
||||
}
|
||||
|
||||
off_t filesize(int fd) {
|
||||
static off_t filesize(int fd) {
|
||||
struct stat buf;
|
||||
|
||||
if (fstat(fd,&buf) < 0) {
|
||||
|
|
@ -134,7 +113,7 @@ void int2be(unsigned int val, unsigned char* addr)
|
|||
((long)array[pos] | ((long)array[pos+1] << 8 ) |\
|
||||
((long)array[pos+2] << 16 ) | ((long)array[pos+3] << 24 ))
|
||||
|
||||
int read_partinfo(struct sansa_t* sansa, int silent)
|
||||
int sansa_read_partinfo(struct sansa_t* sansa, int silent)
|
||||
{
|
||||
int i;
|
||||
unsigned long count;
|
||||
|
|
@ -340,7 +319,7 @@ static int set_mi4header(unsigned char* buf,struct mi4header_t* mi4header)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int sansa_seek_and_read(struct sansa_t* sansa, loff_t pos, unsigned char* buf, int nbytes)
|
||||
static int sansa_seek_and_read(struct sansa_t* sansa, loff_t pos, unsigned char* buf, int nbytes)
|
||||
{
|
||||
int n;
|
||||
|
||||
|
|
@ -450,7 +429,7 @@ int sansa_scan(struct sansa_t* sansa)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (read_partinfo(sansa,1) < 0) {
|
||||
if (sansa_read_partinfo(sansa,1) < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -475,7 +454,7 @@ int sansa_scan(struct sansa_t* sansa)
|
|||
return n;
|
||||
}
|
||||
|
||||
int load_original_firmware(struct sansa_t* sansa, unsigned char* buf, struct mi4header_t* mi4header)
|
||||
static int load_original_firmware(struct sansa_t* sansa, unsigned char* buf, struct mi4header_t* mi4header)
|
||||
{
|
||||
int ppmi_length;
|
||||
int n;
|
||||
|
|
@ -564,7 +543,7 @@ int load_original_firmware(struct sansa_t* sansa, unsigned char* buf, struct mi4
|
|||
return 0;
|
||||
}
|
||||
|
||||
int read_firmware(struct sansa_t* sansa, char* filename)
|
||||
int sansa_read_firmware(struct sansa_t* sansa, char* filename)
|
||||
{
|
||||
int res;
|
||||
int outfile;
|
||||
|
|
@ -587,7 +566,7 @@ int read_firmware(struct sansa_t* sansa, char* filename)
|
|||
}
|
||||
|
||||
|
||||
int add_bootloader(struct sansa_t* sansa, char* filename, int type)
|
||||
int sansa_add_bootloader(struct sansa_t* sansa, char* filename, int type)
|
||||
{
|
||||
int res;
|
||||
int infile;
|
||||
|
|
@ -656,7 +635,7 @@ int add_bootloader(struct sansa_t* sansa, char* filename, int type)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int delete_bootloader(struct sansa_t* sansa)
|
||||
int sansa_delete_bootloader(struct sansa_t* sansa)
|
||||
{
|
||||
int res;
|
||||
struct mi4header_t mi4header;
|
||||
|
|
@ -693,7 +672,7 @@ int delete_bootloader(struct sansa_t* sansa)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void list_images(struct sansa_t* sansa)
|
||||
void sansa_list_images(struct sansa_t* sansa)
|
||||
{
|
||||
struct mi4header_t mi4header;
|
||||
loff_t ppmi_length;
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _IPODPATCHER_H
|
||||
#define _IPODPATCHER_H
|
||||
#ifndef _SANSAPATCHER_H
|
||||
#define _SANSAPATCHER_H
|
||||
|
||||
#include "sansaio.h"
|
||||
|
||||
|
|
@ -30,14 +30,12 @@ extern unsigned char* sectorbuf;
|
|||
#define FILETYPE_MI4 0
|
||||
#define FILETYPE_INTERNAL 1
|
||||
|
||||
char* get_parttype(int pt);
|
||||
int read_partinfo(struct sansa_t* sansa, int silent);
|
||||
off_t filesize(int fd);
|
||||
int sansa_read_partinfo(struct sansa_t* sansa, int silent);
|
||||
int is_e200(struct sansa_t* sansa);
|
||||
int sansa_scan(struct sansa_t* sansa);
|
||||
int read_firmware(struct sansa_t* sansa, char* filename);
|
||||
int add_bootloader(struct sansa_t* sansa, char* filename, int type);
|
||||
int delete_bootloader(struct sansa_t* sansa);
|
||||
void list_images(struct sansa_t* sansa);
|
||||
int sansa_read_firmware(struct sansa_t* sansa, char* filename);
|
||||
int sansa_add_bootloader(struct sansa_t* sansa, char* filename, int type);
|
||||
int sansa_delete_bootloader(struct sansa_t* sansa);
|
||||
void sansa_list_images(struct sansa_t* sansa);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue