2004-12-09 22:57:09 +00:00
|
|
|
static __attribute__((used)) char* rcsid = "$CVSHeader$";
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* (c) 2004 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "libemile.h"
|
|
|
|
#include "emile.h"
|
|
|
|
#include "bootblock.h"
|
|
|
|
|
|
|
|
int emile_first_set_param(int fd, unsigned short tune_mask, int drive_num,
|
2004-12-10 00:26:10 +00:00
|
|
|
int second_offset, int second_size)
|
2004-12-09 22:57:09 +00:00
|
|
|
{
|
|
|
|
eBootBlock_t firstBlock;
|
|
|
|
int ret;
|
|
|
|
off_t location;
|
|
|
|
|
|
|
|
location = lseek(fd, 0, SEEK_CUR);
|
|
|
|
if (location == -1)
|
2004-12-12 22:59:38 +00:00
|
|
|
return EEMILE_CANNOT_READ_FIRST;
|
2004-12-09 22:57:09 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
if ( strncmp( firstBlock.boot_block_header.SysName+1,
|
|
|
|
"Mac Bootloader", 14) == 0 )
|
|
|
|
{
|
|
|
|
if (tune_mask & EMILE_FIRST_TUNE_DRIVE)
|
|
|
|
write_short(&firstBlock.second_param_block.ioVRefNum,
|
|
|
|
drive_num);
|
|
|
|
|
|
|
|
if (tune_mask & EMILE_FIRST_TUNE_OFFSET)
|
|
|
|
write_long(&firstBlock.second_param_block.ioPosOffset,
|
|
|
|
second_offset);
|
|
|
|
|
|
|
|
if (tune_mask & EMILE_FIRST_TUNE_SIZE)
|
|
|
|
write_long(&firstBlock.second_param_block.ioReqCount,
|
|
|
|
second_size);
|
|
|
|
|
|
|
|
ret = lseek(fd, location, SEEK_SET);
|
|
|
|
if (ret != 0)
|
2004-12-12 22:59:38 +00:00
|
|
|
return EEMILE_CANNOT_WRITE_FIRST;
|
2004-12-09 22:57:09 +00:00
|
|
|
|
|
|
|
ret = write(fd, &firstBlock, sizeof(firstBlock));
|
|
|
|
if (ret != sizeof(firstBlock))
|
2004-12-12 22:59:38 +00:00
|
|
|
return EEMILE_CANNOT_WRITE_FIRST;
|
2004-12-09 22:57:09 +00:00
|
|
|
}
|
|
|
|
else
|
2004-12-12 22:59:38 +00:00
|
|
|
return EEMILE_UNKNOWN_FIRST;
|
2004-12-09 22:57:09 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|