mirror of
https://github.com/vivier/EMILE.git
synced 2024-10-11 07:23:40 +00:00
Allow to examine a given device
This commit is contained in:
parent
dc17cc55f7
commit
e23b98e394
@ -18,6 +18,7 @@
|
|||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
|
|
||||||
extern void scanbus(void);
|
extern void scanbus(void);
|
||||||
|
extern void diskinfo(char*);
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -57,7 +58,7 @@ static struct option long_options[] =
|
|||||||
|
|
||||||
static void usage(int argc, char** argv)
|
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, "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);
|
fprintf(stderr, "\nbuild: \n%s\n", SIGNATURE);
|
||||||
}
|
}
|
||||||
@ -378,6 +379,14 @@ int main(int argc, char** argv)
|
|||||||
break;
|
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) {
|
||||||
if (action & ~ACTION_SCANBUS) {
|
if (action & ~ACTION_SCANBUS) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@ -393,9 +402,6 @@ int main(int argc, char** argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind < argc)
|
|
||||||
dev_name = argv[optind];
|
|
||||||
|
|
||||||
if (dev_name == NULL)
|
if (dev_name == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "ERROR: you must specify a device\n");
|
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;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
void scanbus(void)
|
void diskinfo(char* device)
|
||||||
{
|
{
|
||||||
emile_map_t* map;
|
emile_map_t* map;
|
||||||
device_name_t devices[EMILE_MAX_DISK];
|
|
||||||
int count;
|
|
||||||
int i;
|
|
||||||
int j;
|
int j;
|
||||||
int boottype;
|
int boottype;
|
||||||
char bootblock[BOOTBLOCK_SIZE];
|
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 block_size, block_count;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
printf("%s:", devices[i]);
|
printf("%s:", device);
|
||||||
map = emile_map_open(devices[i], O_RDONLY);
|
map = emile_map_open(device, O_RDONLY);
|
||||||
|
|
||||||
ret = emile_map_geometry(map, &block_size, &block_count);
|
ret = emile_map_geometry(map, &block_size, &block_count);
|
||||||
if ((ret != -1) && verbose)
|
if ((ret != -1) && verbose)
|
||||||
@ -127,12 +110,12 @@ void scanbus(void)
|
|||||||
if (map == NULL)
|
if (map == NULL)
|
||||||
{
|
{
|
||||||
printf("\t<No information available>\n");
|
printf("\t<No information available>\n");
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
if (!emile_map_is_valid(map))
|
if (!emile_map_is_valid(map))
|
||||||
{
|
{
|
||||||
printf("\t<No valid partition map found>\n");
|
printf("\t<No valid partition map found>\n");
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
if (emile_map_get_driver_number(map) > 0)
|
if (emile_map_get_driver_number(map) > 0)
|
||||||
printf(" Drivers\n");
|
printf(" Drivers\n");
|
||||||
@ -165,7 +148,7 @@ void scanbus(void)
|
|||||||
printf(" --> ");
|
printf(" --> ");
|
||||||
else
|
else
|
||||||
printf(" ");
|
printf(" ");
|
||||||
printf("%s%-2d: ", devices[i], j + 1);
|
printf("%d: ", j + 1);
|
||||||
printf("%16s [%-16s] ",
|
printf("%16s [%-16s] ",
|
||||||
emile_map_get_partition_name(map),
|
emile_map_get_partition_name(map),
|
||||||
emile_map_get_partition_type(map));
|
emile_map_get_partition_type(map));
|
||||||
@ -226,4 +209,24 @@ void scanbus(void)
|
|||||||
}
|
}
|
||||||
emile_map_close(map);
|
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