Can change output on second_scsi too

This commit is contained in:
Laurent Vivier 2005-12-05 19:52:48 +00:00
parent 0024ca3de5
commit 65e7d52cd2

View File

@ -107,7 +107,6 @@ static int display_output(char* image)
if (ret == EEMILE_UNKNOWN_FIRST) if (ret == EEMILE_UNKNOWN_FIRST)
{ {
/* should be a second level file */ /* should be a second level file */
ret = lseek(fd, 0, SEEK_SET); ret = lseek(fd, 0, SEEK_SET);
if (ret == -1) if (ret == -1)
{ {
@ -159,10 +158,12 @@ static int set_output(char* image,
unsigned int bitrate1, int datasize1, unsigned int bitrate1, int datasize1,
int parity1, int stopbits1, int gestaltid) int parity1, int stopbits1, int gestaltid)
{ {
int drive, second, size;
int fd; int fd;
int ret; int ret;
char *configuration; char *configuration;
char property[32]; char property[32];
int offset;
fd = open(image, O_RDWR); fd = open(image, O_RDWR);
@ -172,12 +173,19 @@ static int set_output(char* image,
return 2; return 2;
} }
ret = lseek(fd, FIRST_LEVEL_SIZE, SEEK_SET); /* can work on an image or directly on second level file */
if (ret == -1)
ret = emile_first_get_param(fd, &drive, &second, &size);
if (ret == EEMILE_UNKNOWN_FIRST)
{ {
perror("Cannot go to buffer offset"); /* should be a second level file */
close(fd); offset = lseek(fd, 0, SEEK_SET);
return 3; if (offset == -1)
{
perror("Cannot go to buffer offset");
close(fd);
return 3;
}
} }
configuration = emile_second_get_configuration(fd); configuration = emile_second_get_configuration(fd);
@ -216,7 +224,7 @@ static int set_output(char* image,
emile_second_set_property(configuration, "gestaltID", property); emile_second_set_property(configuration, "gestaltID", property);
} }
ret = lseek(fd, FIRST_LEVEL_SIZE, SEEK_SET); ret = lseek(fd, offset, SEEK_SET);
if (ret == -1) if (ret == -1)
{ {
perror("Cannot go to buffer offset"); perror("Cannot go to buffer offset");