From c47a7642fbbab2c00ee8ddbd48d59b7fa9eeee09 Mon Sep 17 00:00:00 2001 From: Michel Machado Date: Fri, 9 Oct 2015 19:29:10 -0400 Subject: [PATCH] f3brew: handle lack of access right When a non-root user called f3brew on a device, f3brew would issue the following error message: Your username doesn't have access to device `/dev/sdc'. Try to run this program as root: sudo f3probe /dev/sdc In case you don't have access to root, use f3write/f3read. f3brew: f3brew.c:484: main: Assertion `dev' failed. Aborted (core dumped) This patch avoids the assert(). --- f3brew.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/f3brew.c b/f3brew.c index dacd690..7f48b97 100644 --- a/f3brew.c +++ b/f3brew.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -481,7 +482,10 @@ int main(int argc, char **argv) args.fake_size_byte, args.wrap, args.block_order, args.keep_file) : create_block_device(args.filename, args.reset_type); - assert(dev); + if (!dev) { + fprintf(stderr, "\nApplication cannot continue, finishing...\n"); + exit(1); + } printf("Physical block size: 2^%i Bytes\n\n", dev_get_block_order(dev));