2004-12-03 00:29:29 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* (c) 2004 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
2004-12-16 23:27:50 +00:00
|
|
|
#include <getopt.h>
|
2004-12-03 00:29:29 +00:00
|
|
|
|
2004-12-10 00:28:35 +00:00
|
|
|
#include "libemile.h"
|
2004-12-07 00:39:39 +00:00
|
|
|
|
2004-12-16 23:27:50 +00:00
|
|
|
int verbose = 0;
|
|
|
|
|
|
|
|
static char *first_path = PREFIX "/boot/emile/first_scsi";
|
|
|
|
static char *second_path = PREFIX "/boot/emile/second_scsi";
|
|
|
|
static char *kernel_path = PREFIX "/boot/vmlinuz";
|
|
|
|
static char *partition = NULL;
|
|
|
|
static int buffer_size = 0;
|
|
|
|
|
|
|
|
static struct option long_options[] =
|
|
|
|
{
|
|
|
|
{"scanbus", 0, NULL, 0},
|
|
|
|
{"backup", 0, NULL, 0},
|
|
|
|
{"restore", 0, NULL, 0},
|
|
|
|
{"verbose", 0, NULL, 'v'},
|
|
|
|
{"first", 1, NULL, 'f'},
|
|
|
|
{"second", 1, NULL, 's'},
|
|
|
|
{"kernel", 1, NULL, 'k'},
|
|
|
|
{"buffer", 1, NULL, 'b'},
|
|
|
|
{"partition", 1, NULL, 'p'},
|
|
|
|
{"help", 0, NULL, 'h'},
|
|
|
|
{NULL,0,NULL,0}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void usage(int argc, char** argv)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "\nbuild: \n%s\n", SIGNATURE);
|
|
|
|
}
|
|
|
|
|
2004-12-13 02:12:27 +00:00
|
|
|
/* first second kernel buffer_size command_line */
|
|
|
|
|
2004-12-07 00:39:39 +00:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2004-12-16 23:27:50 +00:00
|
|
|
int c;
|
|
|
|
int option_index = 0;
|
|
|
|
int action_scanbus = 0;
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
c = getopt_long(argc, argv, "vhf:s:k:b:", long_options, &option_index);
|
|
|
|
if (c == -1)
|
|
|
|
break;
|
|
|
|
switch(c)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (option_index == 0)
|
|
|
|
action_scanbus = 1;
|
|
|
|
break;
|
|
|
|
case 'v':
|
|
|
|
verbose++;
|
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
case '?':
|
|
|
|
usage(argc, argv);
|
|
|
|
return 0;
|
|
|
|
case 'f':
|
|
|
|
first_path = optarg;
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
second_path = optarg;
|
|
|
|
break;
|
|
|
|
case 'k':
|
|
|
|
kernel_path = optarg;
|
|
|
|
break;
|
|
|
|
case 'b':
|
|
|
|
buffer_size = atoi(optarg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action_scanbus) {
|
|
|
|
scanbus();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("first: %s\n", first_path);
|
|
|
|
printf("second: %s\n", second_path);
|
|
|
|
printf("kernel: %s\n", kernel_path);
|
|
|
|
printf("buffer size: %d\n", buffer_size);
|
|
|
|
printf("partition: %s\n", partition);
|
|
|
|
#if 0
|
2004-12-07 00:39:39 +00:00
|
|
|
int fd;
|
|
|
|
int ret;
|
|
|
|
|
2004-12-13 02:12:27 +00:00
|
|
|
/* set kernel info in second level */
|
|
|
|
|
|
|
|
fd = open(argv[2], O_RDWR); /* second */
|
2004-12-07 00:39:39 +00:00
|
|
|
if (fd == -1)
|
|
|
|
{
|
|
|
|
perror("Cannot open second stage");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2004-12-13 02:12:27 +00:00
|
|
|
/* set buffer size */
|
|
|
|
|
|
|
|
printf("Setting buffer size to %d\n", atoi(argv[4]));
|
2004-12-14 21:49:13 +00:00
|
|
|
ret = emile_second_set_buffer_size(fd, atoi(argv[4]));
|
2004-12-13 02:12:27 +00:00
|
|
|
|
|
|
|
/* set cmdline */
|
|
|
|
|
2004-12-07 00:39:39 +00:00
|
|
|
lseek(fd, 0, SEEK_SET);
|
2004-12-13 02:12:27 +00:00
|
|
|
printf("Setting command line to %s\n", argv[5]);
|
|
|
|
ret = emile_second_set_cmdline(fd, argv[5]);
|
|
|
|
|
|
|
|
/* set kernel info */
|
|
|
|
|
|
|
|
lseek(fd, 0, SEEK_SET);
|
|
|
|
ret = emile_second_set_kernel_scsi(fd, argv[3]);
|
2004-12-03 00:29:29 +00:00
|
|
|
|
|
|
|
close(fd);
|
2004-12-13 02:12:27 +00:00
|
|
|
|
|
|
|
/* set second info in first level */
|
|
|
|
|
|
|
|
fd = open(argv[1], O_RDWR);
|
|
|
|
if (fd == -1)
|
|
|
|
{
|
|
|
|
perror("Cannot open first stage");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = emile_first_set_param_scsi(fd, argv[2]);
|
|
|
|
close(fd);
|
2004-12-16 23:27:50 +00:00
|
|
|
#endif
|
2004-12-13 02:12:27 +00:00
|
|
|
|
2004-12-03 00:29:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|