Merge pull request #7 from rutsky/verbose-messages
handle errors in verbose user friendly way
This commit is contained in:
commit
5192bb933b
8
buse.c
8
buse.c
|
@ -95,7 +95,13 @@ int buse_main(const char* dev_file, const struct buse_operations *aop, void *use
|
|||
assert(!err);
|
||||
|
||||
nbd = open(dev_file, O_RDWR);
|
||||
assert(nbd != -1);
|
||||
if (nbd == -1) {
|
||||
fprintf(stderr,
|
||||
"Failed to open `%s': %s\n"
|
||||
"Is kernel module `nbd' is loaded and you have permissions "
|
||||
"to access the device?\n", dev_file, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
err = ioctl(nbd, NBD_SET_SIZE, aop->size);
|
||||
assert(err != -1);
|
||||
|
|
11
busexmp.c
11
busexmp.c
|
@ -74,7 +74,16 @@ static struct buse_operations aop = {
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
(void)(argc);
|
||||
if (argc != 2)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage:\n"
|
||||
" %s /dev/nbd0\n"
|
||||
"Don't forget to load nbd kernel module (`modprobe nbd`) and\n"
|
||||
"run example from root.\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
data = malloc(aop.size);
|
||||
|
||||
return buse_main(argv[1], &aop, (void *)&xmpl_debug);
|
||||
|
|
Loading…
Reference in New Issue