Skip to content

Commit

Permalink
Config files can now make use of "easy partitions". Version bump.
Browse files Browse the repository at this point in the history
  • Loading branch information
fxb committed Jun 14, 2015
1 parent 6e5353b commit 8fceffc
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 24 deletions.
2 changes: 1 addition & 1 deletion apps/ipod/ipodloader2/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ void config_init(void)
if (!mlc_strncasecmp (value, "rb:", 3)) {
config.image[config.items].path += 3;
config.image[config.items].type = CONFIG_IMAGE_ROCKBOX;
} else if (value[0] != '(') { // no partition specifier -> it's not a path but command
} else if (value[0] != '(' && value[0] != '[') { // no partition specifier -> it's not a path but command
config.image[config.items].type = CONFIG_IMAGE_SPECIAL;
}
config.items++;
Expand Down
1 change: 1 addition & 0 deletions apps/ipod/ipodloader2/ext2.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ void ext2_newfs(uint8 part,uint32 offset) {
myfs.read = ext2_read;
myfs.getinfo = 0;
myfs.partnum = part;
myfs.type = EXT2;

vfs_registerfs(&myfs);
}
15 changes: 8 additions & 7 deletions apps/ipod/ipodloader2/fat32.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,14 +461,15 @@ void fat32_newfs(uint8 part,uint32 offset) {
clusterBuffer = (uint8*)mlc_malloc( fat.bytes_per_cluster );
}

myfs.open = fat32_open;
myfs.close = fat32_close;
myfs.tell = fat32_tell;
myfs.seek = fat32_seek;
myfs.read = fat32_read;
myfs.getinfo= 0;
myfs.fsdata = (void*)&fat;
myfs.open = fat32_open;
myfs.close = fat32_close;
myfs.tell = fat32_tell;
myfs.seek = fat32_seek;
myfs.read = fat32_read;
myfs.getinfo = 0;
myfs.fsdata = (void*)&fat;
myfs.partnum = part;
myfs.type = FAT32;

vfs_registerfs( &myfs);
}
1 change: 1 addition & 0 deletions apps/ipod/ipodloader2/fwfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ void fwfs_newfs(uint8 part,uint32 offset) {
myfs.getinfo = fwfs_getinfo;
myfs.fsdata = (void*)&fwfs;
myfs.partnum = part;
myfs.type = FWFS;

//mlc_printf("Registering..\n");

Expand Down
2 changes: 1 addition & 1 deletion apps/ipod/ipodloader2/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "config.h"
#include "interrupts.h"

#define LOADERNAME "iPL Loader 2.5 " VERSION // "d" stands for development version, "b" for beta version
#define LOADERNAME "iPL Loader 2.6 " VERSION // "d" stands for development version, "b" for beta version

static uint16 *framebuffer;
static int orig_contrast;
Expand Down
15 changes: 8 additions & 7 deletions apps/ipod/ipodloader2/macpartitions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -672,14 +672,15 @@ static void hfsplus_newfs (uint8 part, uint32 offset) {
mlc_show_critical_error();
return;
}
myfs.open = hfsplus_open;
myfs.close = hfsplus_close;
myfs.tell = hfsplus_tell;
myfs.seek = hfsplus_seek;
myfs.read = hfsplus_read;
myfs.getinfo = 0;
myfs.fsdata = (void*)fsData;
myfs.open = hfsplus_open;
myfs.close = hfsplus_close;
myfs.tell = hfsplus_tell;
myfs.seek = hfsplus_seek;
myfs.read = hfsplus_read;
myfs.getinfo = 0;
myfs.fsdata = (void*)fsData;
myfs.partnum = part;
myfs.type = HFSPLUS;

/* set up the fs data for this partition */
fsData->numHandles = 0;
Expand Down
55 changes: 47 additions & 8 deletions apps/ipod/ipodloader2/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
#include "macpartitions.h"

#define MAX_FILES 10
#define MAX_FS 4

static filesystem *fs[4]; /* Hardlimit of 4 registered filesystems */
static filesystem *fs[MAX_FS]; /* Hardlimit of 4 registered filesystems */
static uint32 fsCnt;

typedef struct {
Expand All @@ -20,20 +21,58 @@ typedef struct {
vfs_handle_t vfs_handle[MAX_FILES]; /* Hardlimit of 10 open files */
uint32 maxHandle;

int vfs_find_part(vfs_type type) {
int i;

for(i = 0; i < MAX_FS; i++){
if(fs[i] && fs[i]->type == type){
return (i);
}
}

return (-1);
}

int vfs_open(char *fname) {
uint8 part;
int i;
int8 part;
int i;

part = -1;

/* FAT32: [dos], [fat], [win], [vfat], [fat32]
EXT2: [ext], [ext2], [linux]
HFS+: [hfs], [hfs+], [linux] */
if( fname[0] == '[' ){
if( !mlc_strncmp(fname,"[dos]",5) || !mlc_strncmp(fname,"[fat]",5) ||
!mlc_strncmp(fname,"[win]",5) || !mlc_strncmp(fname,"[vfat]",6) ||
!mlc_strncmp(fname,"[fat32]",7) ){
part = vfs_find_part(FAT32);
}
if( !mlc_strncmp(fname,"[ext]",5) || !mlc_strncmp(fname,"[ext2]",6) ||
!mlc_strncmp(fname,"[linux]",7) ){
part = vfs_find_part(EXT2);
}
if( !mlc_strncmp(fname,"[hfs]",5) || !mlc_strncmp(fname,"[hfs+]",6) ||
(part == -1 && !mlc_strncmp(fname,"[linux]",7)) ){
part = vfs_find_part(HFSPLUS);
}
/* [xxx]/ == position of ] + 2 chars */
fname = mlc_strchr(fname, ']') + 2;
}
else if( !mlc_strncmp(fname,"(hd0,",5) ){
part = fname[5] - '0'; /* atoi, the old-fashioned way */
/* (hd0,0)/ == 8 chars */
fname = fname + 8;
}

/* (hd0,0)/ == 8 chars */
if( mlc_strncmp(fname,"(hd0,",5) != 0 ) return(-1);
part = fname[5] - '0'; /* atoi, the old-fashioned way */
if( part == -1 ) return(-1);

if (fs[part]) {
i = 0;
while( (vfs_handle[i].fd != -1) && (i<MAX_FILES) ) i++;

vfs_handle[i].fsIdx = part;
vfs_handle[i].fd = fs[part]->open(fs[part]->fsdata,fname+8);
vfs_handle[i].fd = fs[part]->open(fs[part]->fsdata,fname);

if( vfs_handle[i].fd != -1 )
return(i);
Expand Down Expand Up @@ -126,7 +165,7 @@ void vfs_init( void) {
if((logBlkMultiplier < 1) | (logBlkMultiplier > 4)) logBlkMultiplier = 1;

/* Check each primary partition for a supported FS */
for(i=0;i<4;i++) {
for(i=0;i<MAX_FS;i++) {
uint32 offset,validoffset;
uint8 type;

Expand Down
9 changes: 9 additions & 0 deletions apps/ipod/ipodloader2/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
#define VFS_SEEK_SET 1
#define VFS_SEEK_END 2

typedef enum _vfs_type {
FWFS,
EXT2,
FAT32,
HFSPLUS
} vfs_type;

typedef struct {
int (*open)(void *fsdata,char *fname);
void (*close)(void *fsdata, int fd);
Expand All @@ -15,8 +22,10 @@ typedef struct {

void *fsdata;
uint8 partnum;
vfs_type type;
} filesystem;

int vfs_find_part(vfs_type type);
void vfs_init(void);
void vfs_registerfs( filesystem *fs );
int vfs_open(char *fname);
Expand Down

0 comments on commit 8fceffc

Please sign in to comment.