2004-12-09 22:57:09 +00:00
|
|
|
static __attribute__((used)) char* rcsid = "$CVSHeader$";
|
|
|
|
/*
|
|
|
|
*
|
2013-09-05 12:39:22 +00:00
|
|
|
* (c) 2004 Laurent Vivier <Laurent@Vivier.EU>
|
2004-12-09 22:57:09 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "libemile.h"
|
|
|
|
#include "emile.h"
|
|
|
|
#include "bootblock.h"
|
|
|
|
|
2004-12-10 00:26:10 +00:00
|
|
|
int emile_first_get_param(int fd, int *drive_num, int *second_offset,
|
|
|
|
int *second_size)
|
2004-12-09 22:57:09 +00:00
|
|
|
{
|
|
|
|
eBootBlock_t firstBlock;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = read(fd, &firstBlock, sizeof(firstBlock));
|
|
|
|
if (ret != sizeof(firstBlock))
|
2004-12-12 22:59:38 +00:00
|
|
|
return EEMILE_CANNOT_READ_FIRST;
|
2004-12-09 22:57:09 +00:00
|
|
|
|
2007-02-24 13:35:32 +00:00
|
|
|
if ( strncmp( (char*)firstBlock.boot_block_header.SysName+1,
|
2004-12-09 22:57:09 +00:00
|
|
|
"Mac Bootloader", 14) == 0 )
|
|
|
|
{
|
2007-02-24 13:35:32 +00:00
|
|
|
*drive_num = read_short((u_int16_t*)&firstBlock.second_param_block.ioVRefNum);
|
|
|
|
*second_offset = read_long((u_int32_t*)&firstBlock.second_param_block.ioPosOffset);
|
2004-12-09 22:57:09 +00:00
|
|
|
*second_size = read_long(&firstBlock.second_param_block.ioReqCount);
|
|
|
|
}
|
|
|
|
else
|
2004-12-12 22:59:38 +00:00
|
|
|
return EEMILE_UNKNOWN_FIRST;
|
2004-12-09 22:57:09 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|