mirror of
https://github.com/vivier/EMILE.git
synced 2024-10-12 14:23:40 +00:00
add get_info() function
This commit is contained in:
parent
6e434b9527
commit
aeddb9f7e4
@ -58,69 +58,8 @@ static void usage(int argc, char** argv)
|
|||||||
fprintf(stderr, "\nbuild: \n%s\n", SIGNATURE);
|
fprintf(stderr, "\nbuild: \n%s\n", SIGNATURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
static int get_info(char *image, int verbose)
|
||||||
{
|
{
|
||||||
int verbose = 0;
|
|
||||||
int option_index = 0;
|
|
||||||
char* first_level = NULL;
|
|
||||||
char* second_level = NULL;
|
|
||||||
char* kernel_image = NULL;
|
|
||||||
char* ramdisk = NULL;
|
|
||||||
char* image = NULL;
|
|
||||||
char* config_path = NULL;
|
|
||||||
char *ramdisk_ondisk, *kernel_ondisk;
|
|
||||||
int action_getinfo = 0;
|
|
||||||
int c;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
while(1)
|
|
||||||
{
|
|
||||||
c = getopt_long(argc, argv, "hvf:s:k:r:gc:", long_options,
|
|
||||||
&option_index);
|
|
||||||
if (c == -1)
|
|
||||||
break;
|
|
||||||
switch(c)
|
|
||||||
{
|
|
||||||
case ARG_HELP:
|
|
||||||
usage(argc, argv);
|
|
||||||
return 0;
|
|
||||||
case ARG_VERBOSE:
|
|
||||||
verbose = 1;
|
|
||||||
break;
|
|
||||||
case ARG_FIRST:
|
|
||||||
first_level = optarg;
|
|
||||||
break;
|
|
||||||
case ARG_SECOND:
|
|
||||||
second_level = optarg;
|
|
||||||
break;
|
|
||||||
case ARG_KERNEL:
|
|
||||||
kernel_image = optarg;
|
|
||||||
break;
|
|
||||||
case ARG_RAMDISK:
|
|
||||||
ramdisk = optarg;
|
|
||||||
break;
|
|
||||||
case ARG_GETINFO:
|
|
||||||
action_getinfo = 1;
|
|
||||||
break;
|
|
||||||
case ARG_CONFIG:
|
|
||||||
config_path = optarg;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (optind < argc)
|
|
||||||
image = argv[optind];
|
|
||||||
|
|
||||||
if (image == NULL)
|
|
||||||
{
|
|
||||||
fprintf(stderr,
|
|
||||||
"ERROR: you must provide an image file or a block device.\n");
|
|
||||||
usage(argc, argv);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (action_getinfo)
|
|
||||||
{
|
|
||||||
int fd;
|
int fd;
|
||||||
int drive_num;
|
int drive_num;
|
||||||
int second_offset;
|
int second_offset;
|
||||||
@ -138,6 +77,7 @@ int main(int argc, char** argv)
|
|||||||
int i;
|
int i;
|
||||||
int current;
|
int current;
|
||||||
int res;
|
int res;
|
||||||
|
int ret;
|
||||||
|
|
||||||
fd = open(image, O_RDONLY);
|
fd = open(image, O_RDONLY);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
@ -234,7 +174,71 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
int verbose = 0;
|
||||||
|
int option_index = 0;
|
||||||
|
char* first_level = NULL;
|
||||||
|
char* second_level = NULL;
|
||||||
|
char* kernel_image = NULL;
|
||||||
|
char* ramdisk = NULL;
|
||||||
|
char* image = NULL;
|
||||||
|
char* config_path = NULL;
|
||||||
|
char *ramdisk_ondisk, *kernel_ondisk;
|
||||||
|
int action_getinfo = 0;
|
||||||
|
int c;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
c = getopt_long(argc, argv, "hvf:s:k:r:gc:", long_options,
|
||||||
|
&option_index);
|
||||||
|
if (c == -1)
|
||||||
|
break;
|
||||||
|
switch(c)
|
||||||
|
{
|
||||||
|
case ARG_HELP:
|
||||||
|
usage(argc, argv);
|
||||||
|
return 0;
|
||||||
|
case ARG_VERBOSE:
|
||||||
|
verbose = 1;
|
||||||
|
break;
|
||||||
|
case ARG_FIRST:
|
||||||
|
first_level = optarg;
|
||||||
|
break;
|
||||||
|
case ARG_SECOND:
|
||||||
|
second_level = optarg;
|
||||||
|
break;
|
||||||
|
case ARG_KERNEL:
|
||||||
|
kernel_image = optarg;
|
||||||
|
break;
|
||||||
|
case ARG_RAMDISK:
|
||||||
|
ramdisk = optarg;
|
||||||
|
break;
|
||||||
|
case ARG_GETINFO:
|
||||||
|
action_getinfo = 1;
|
||||||
|
break;
|
||||||
|
case ARG_CONFIG:
|
||||||
|
config_path = optarg;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optind < argc)
|
||||||
|
image = argv[optind];
|
||||||
|
|
||||||
|
if (image == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"ERROR: you must provide an image file or a block device.\n");
|
||||||
|
usage(argc, argv);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (action_getinfo)
|
||||||
|
return get_info(image, verbose);
|
||||||
|
|
||||||
if (config_path != NULL)
|
if (config_path != NULL)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user