mirror of
https://github.com/vivier/EMILE.git
synced 2024-09-08 19:54:38 +00:00
Allow to examine a given device
This commit is contained in:
parent
dc17cc55f7
commit
e23b98e394
@ -18,6 +18,7 @@
|
||||
int verbose = 0;
|
||||
|
||||
extern void scanbus(void);
|
||||
extern void diskinfo(char*);
|
||||
|
||||
|
||||
enum {
|
||||
@ -57,7 +58,7 @@ static struct option long_options[] =
|
||||
|
||||
static void usage(int argc, char** argv)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [--verbose|-v] --scanbus\n", argv[0]);
|
||||
fprintf(stderr, "Usage: %s [--verbose|-v] [--scanbus|<disk>]\n", argv[0]);
|
||||
fprintf(stderr, "Usage: %s [--startup|--flags FLAGS][--type TYPE][--get-driver|-g FILE][--put-driver|-p FILE] <partition>\n", argv[0]);
|
||||
fprintf(stderr, "\nbuild: \n%s\n", SIGNATURE);
|
||||
}
|
||||
@ -378,6 +379,14 @@ int main(int argc, char** argv)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (optind < argc)
|
||||
dev_name = argv[optind];
|
||||
|
||||
if ( !action && dev_name)
|
||||
{
|
||||
diskinfo(dev_name);
|
||||
return 0;
|
||||
}
|
||||
if (action & ACTION_SCANBUS) {
|
||||
if (action & ~ACTION_SCANBUS) {
|
||||
fprintf(stderr,
|
||||
@ -393,9 +402,6 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
dev_name = argv[optind];
|
||||
|
||||
if (dev_name == NULL)
|
||||
{
|
||||
fprintf(stderr, "ERROR: you must specify a device\n");
|
||||
|
@ -85,34 +85,17 @@ static int emile_scanbus(device_name_t devices[EMILE_MAX_DISK])
|
||||
return j;
|
||||
}
|
||||
|
||||
void scanbus(void)
|
||||
void diskinfo(char* device)
|
||||
{
|
||||
emile_map_t* map;
|
||||
device_name_t devices[EMILE_MAX_DISK];
|
||||
int count;
|
||||
int i;
|
||||
int j;
|
||||
int boottype;
|
||||
char bootblock[BOOTBLOCK_SIZE];
|
||||
|
||||
count = emile_scanbus(devices);
|
||||
if (count == 0)
|
||||
{
|
||||
if (errno == EACCES)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"ERROR: cannot access to devices (you should try as root...)\n");
|
||||
return;
|
||||
}
|
||||
printf("No disk found\n");
|
||||
}
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
int block_size, block_count;
|
||||
int ret;
|
||||
|
||||
printf("%s:", devices[i]);
|
||||
map = emile_map_open(devices[i], O_RDONLY);
|
||||
printf("%s:", device);
|
||||
map = emile_map_open(device, O_RDONLY);
|
||||
|
||||
ret = emile_map_geometry(map, &block_size, &block_count);
|
||||
if ((ret != -1) && verbose)
|
||||
@ -127,12 +110,12 @@ void scanbus(void)
|
||||
if (map == NULL)
|
||||
{
|
||||
printf("\t<No information available>\n");
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
if (!emile_map_is_valid(map))
|
||||
{
|
||||
printf("\t<No valid partition map found>\n");
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
if (emile_map_get_driver_number(map) > 0)
|
||||
printf(" Drivers\n");
|
||||
@ -165,7 +148,7 @@ void scanbus(void)
|
||||
printf(" --> ");
|
||||
else
|
||||
printf(" ");
|
||||
printf("%s%-2d: ", devices[i], j + 1);
|
||||
printf("%d: ", j + 1);
|
||||
printf("%16s [%-16s] ",
|
||||
emile_map_get_partition_name(map),
|
||||
emile_map_get_partition_type(map));
|
||||
@ -226,4 +209,24 @@ void scanbus(void)
|
||||
}
|
||||
emile_map_close(map);
|
||||
}
|
||||
|
||||
void scanbus(void)
|
||||
{
|
||||
device_name_t devices[EMILE_MAX_DISK];
|
||||
int count;
|
||||
int i;
|
||||
|
||||
count = emile_scanbus(devices);
|
||||
if (count == 0)
|
||||
{
|
||||
if (errno == EACCES)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"ERROR: cannot access to devices (you should try as root...)\n");
|
||||
return;
|
||||
}
|
||||
printf("No disk found\n");
|
||||
}
|
||||
for (i = 0; i < count; i++)
|
||||
diskinfo(devices[i]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user