Commit 908086b0 authored by Grzegorz Daniluk's avatar Grzegorz Daniluk Committed by Alessandro Rubini

tools: detect when user runs without superuser rights and inform him instead of segfault

parent d69145e6
......@@ -52,8 +52,8 @@ int main(int argc, char **argv)
if(!card)
{
fprintf(stderr, "%s: Can't detect a SPEC card under the given "
"adress.\nMake sure a SPEC card is present in your PC "
"and the driver is loaded.\n", argv[0]);
"adress.\nMake sure a SPEC card is present in your PC, "
"the driver is loaded and you run the program as root.\n", argv[0]);
exit(1);
}
......
......@@ -43,8 +43,8 @@ int main(int argc, char **argv)
if(!card)
{
fprintf(stderr, "Can't detect a SPEC card under the given "
"adress. Make sure a SPEC card is present in your PC "
"and the driver is loaded.\n");
"adress.\nMake sure a SPEC card is present in your PC, "
"the driver is loaded and you run the program as root.\n");
exit(1);
}
......
......@@ -122,8 +122,8 @@ int main(int argc, char **argv)
if(!card)
{
fprintf(stderr, "Can't detect a SPEC card under the given "
"adress. Make sure a SPEC card is present in your PC "
"and the driver is loaded.\n");
"adress.\nMake sure a SPEC card is present in your PC, "
"the driver is loaded and you run the program as root.\n");
exit(1);
}
......
......@@ -104,6 +104,12 @@ void *spec_open(int bus, int dev)
card->bar0 = spec_map_area(bus, dev, BASE_BAR0, 0x100000);
card->bar4 = spec_map_area(bus, dev, BASE_BAR4, 0x1000);
if(!card->bar0 && !card->bar4)
{
free(card);
card = NULL;
}
return card;
}
......
......@@ -78,8 +78,8 @@ int main(int argc, char **argv)
if(!card)
{
fprintf(stderr, "Can't detect a SPEC card under the given "
"adress. Make sure a SPEC card is present in your PC "
"and the driver is loaded.\n");
"adress. Make sure a SPEC card is present in your PC, "
"the driver is loaded and you run the program as root.\n");
exit(1);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment